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

1. 应用通知管理

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

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

                                                               图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学习--持续更新中。。。》

长按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;
            }
        });
。。。。。

    原文作者:dido222
    原文地址: https://blog.csdn.net/DIDO222/article/details/50738098
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞