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





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章