Android7.0 Notification控制

来源:互联网 发布:淘宝服务能退款吗 编辑:程序博客网 时间:2024/06/07 06:36

frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/Basestatusbar.java


当有通知过来的时候就会走这里,如果想invalid所以通知就在这里做。



@Overridepublic void onNotificationPosted(final StatusBarNotification sbn,        final RankingMap rankingMap) {    if (DEBUG) Log.d(TAG, "onNotificationPosted: " + sbn);    if (sbn != null) {        mHandler.post(new Runnable() {            @Override            public void run() {                processForRemoteInput(sbn.getNotification());                String key = sbn.getKey();                mKeysKeptForRemoteInput.remove(key);                boolean isUpdate = mNotificationData.get(key) != null;                // In case we don't allow child notifications, we ignore children of                // notifications that have a summary, since we're not going to show them                // anyway. This is true also when the summary is canceled,                // because children are automatically canceled by NoMan in that case.                if (!ENABLE_CHILD_NOTIFICATIONS                    && mGroupManager.isChildInGroupWithSummary(sbn)) {                    if (DEBUG) {                        Log.d(TAG, "Ignoring group child due to existing summary: " + sbn);                    }                    // Remove existing notification to avoid stale data.                    if (isUpdate) {                        removeNotification(key, rankingMap);                    } else {                        mNotificationData.updateRanking(rankingMap);                    }                    return;                }                if (isUpdate) {                    updateNotification(sbn, rankingMap);                } else {                    addNotification(sbn, rankingMap, null /* oldEntry */);                }            }        });    }}

原创粉丝点击