notification学习--持续更新中。。。

1. 应用通知管理

    settings -> apps -> 选择某个应用 -》 进入应用信息界面,点击“通知” -> 可以看到该应用的通知,如下图:

                                     dialernotification

                                                               图1

该界面对应settings的文件:AppNotificationSettings, 其状态的设置项调用NotificationManagerService的相关方法。

        @Override
        public void setPackagePriority(String pkg, int uid, int priority) {
            checkCallerIsSystem();
            mRankingHelper.setPackagePriority(pkg, uid, priority);
            savePolicyFile();
        }

        @Override
        public int getPackagePriority(String pkg, int uid) {
            checkCallerIsSystem();
            return mRankingHelper.getPackagePriority(pkg, uid);
        }

        @Override
        public void setPackagePeekable(String pkg, int uid, boolean peekable) {
            checkCallerIsSystem();

            mRankingHelper.setPackagePeekable(pkg, uid, peekable);
        }

        @Override
        public boolean getPackagePeekable(String pkg, int uid) {
            checkCallerIsSystem();
            return mRankingHelper.getPackagePeekable(pkg, uid);
        }

       。。。。

并且写入到/data/system/notification_policy.xml中进行保存:

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<notification-policy version="1">
<zen version="2" user="0">
<allow calls="true" repeatCallers="false" messages="false" reminders="true" events="true" callsFrom="1" messagesFrom="1" />
<automatic ruleId="2212c7138aaf49c1b997ce90c01c06c4" enabled="false" snoozing="false" name="周一至周五夜间" zen="3" component="android/com.android.server.notification.ScheduleConditionProvider" conditionId="condition://android/schedule?days=1.2.3.4.5&amp;start=22.0&amp;end=7.0" id="condition://android/schedule?days=1.2.3.4.5&amp;start=22.0&amp;end=7.0" summary="..." line1="..." line2="..." icon="0" state="0" flags="2" />
<automatic ruleId="7315962a6ab7404592e5245ba9781814" enabled="false" snoozing="false" name="周末" zen="3" component="android/com.android.server.notification.ScheduleConditionProvider" conditionId="condition://android/schedule?days=6.7&amp;start=23.30&amp;end=10.0" id="condition://android/schedule?days=6.7&amp;start=23.30&amp;end=10.0" summary="..." line1="..." line2="..." icon="0" state="0" flags="2" />
<automatic ruleId="33b5982469fd47b18a92607638a0458e" enabled="false" snoozing="false" name="活动" zen="3" component="android/com.android.server.notification.EventConditionProvider" conditionId="condition://android/event?userId=-10000&amp;calendar=&amp;reply=1" id="condition://android/event?userId=-10000&amp;calendar=&amp;reply=1" summary="..." line1="..." line2="..." icon="0" state="0" flags="2" />
</zen>
<ranking version="1">
<package name="com.baidu.BaiduMap" priority="2" peekable="true" uid="10090" />
<package name="com.qiyi.video" priority="2" peekable="true" uid="10092" />
<package name="com.tencent.qqpimsecure" uid="10100" />
</ranking>
</notification-policy>


图1中的界面也可以通过下拉通知栏长按某个应用的通知,然后点击感叹号图标进入(手机管家):

                  

长按notification后notification切换到的视图是个viewStub,该viewStub嵌套在布局ExpandableNotificationRow对应的布局status_bar_notification_row中,并且设置setOnInflateListener监听

protected void onFinishInflate() {
        super.onFinishInflate();
        mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
        mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);
        mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub);
        mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() {
            @Override
            public void onInflate(ViewStub stub, View inflated) {
                mGuts = (NotificationGuts) inflated;
                mGuts.setClipTopAmount(getClipTopAmount());
                mGuts.setActualHeight(getActualHeight());
                mGutsStub = null;
            }
        });
。。。。。





  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值