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

1. 应用通知管理

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

                                     notification学习--持续更新中。。。_第1张图片

                                                               图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中进行保存:















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

            notification学习--持续更新中。。。_第2张图片      notification学习--持续更新中。。。_第3张图片

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





你可能感兴趣的:(notification学习--持续更新中。。。)