diff options
author | Chris Wren <cwren@android.com> | 2014-05-30 20:15:38 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-30 20:15:38 +0000 |
commit | 4f0e39a929f2043c46ada9f34b23654616f93227 (patch) | |
tree | 150088db28725a782460396fc240c9a9e9ad67a4 /packages | |
parent | da44532b615b1a965c94cc43d68eca92fd2ef79d (diff) | |
parent | 333a61c3a5a83fe9c50ebeb5c947317f61385b7b (diff) | |
download | frameworks_base-4f0e39a929f2043c46ada9f34b23654616f93227.zip frameworks_base-4f0e39a929f2043c46ada9f34b23654616f93227.tar.gz frameworks_base-4f0e39a929f2043c46ada9f34b23654616f93227.tar.bz2 |
Merge "Track Zen Mode status in the NotificationRecord" into lmp-preview-dev
Diffstat (limited to 'packages')
4 files changed, 45 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 422d47f..06cc476 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -337,8 +337,7 @@ public abstract class BaseStatusBar extends SystemUI implements mHandler.post(new Runnable() { @Override public void run() { - mNotificationData.updateRanking(currentRanking); - updateNotifications(); + updateRankingInternal(currentRanking); } }); } @@ -1280,6 +1279,8 @@ public abstract class BaseStatusBar extends SystemUI implements public abstract void addNotificationInternal(StatusBarNotification notification, Ranking ranking); + protected abstract void updateRankingInternal(Ranking ranking); + @Override public void removeNotification(String key) { if (!USE_NOTIFICATION_LISTENER) { @@ -1287,7 +1288,7 @@ public abstract class BaseStatusBar extends SystemUI implements } } - protected abstract void removeNotificationInternal(String key, Ranking ranking); + public abstract void removeNotificationInternal(String key, Ranking ranking); public void updateNotification(StatusBarNotification notification) { if (!USE_NOTIFICATION_LISTENER) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java b/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java index 24da5c2..de27119 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java @@ -20,8 +20,10 @@ import android.app.Notification; import android.content.Context; import android.os.Process; import android.provider.Settings; +import android.service.notification.NotificationListenerService.Ranking; import android.service.notification.StatusBarNotification; import android.util.ArrayMap; +import android.util.ArraySet; import android.view.View; import com.android.systemui.R; @@ -30,12 +32,13 @@ import com.android.systemui.statusbar.phone.PhoneStatusBar; public class InterceptedNotifications { private static final String TAG = "InterceptedNotifications"; - private static final String EXTRA_INTERCEPT = "android.intercept"; + private static final String SYNTHETIC_KEY = "InterceptedNotifications.SYNTHETIC_KEY"; private final Context mContext; private final PhoneStatusBar mBar; private final ArrayMap<String, StatusBarNotification> mIntercepted = new ArrayMap<String, StatusBarNotification>(); + private final ArraySet<String> mReleased = new ArraySet<String>(); private String mSynKey; @@ -48,25 +51,45 @@ public class InterceptedNotifications { final int n = mIntercepted.size(); for (int i = 0; i < n; i++) { final StatusBarNotification sbn = mIntercepted.valueAt(i); - sbn.getNotification().extras.putBoolean(EXTRA_INTERCEPT, false); + mReleased.add(sbn.getKey()); mBar.addNotificationInternal(sbn, null); } mIntercepted.clear(); updateSyntheticNotification(); } - public boolean tryIntercept(StatusBarNotification notification) { - if (!notification.getNotification().extras.getBoolean(EXTRA_INTERCEPT)) return false; + public boolean tryIntercept(StatusBarNotification notification, Ranking ranking) { + if (ranking == null) return false; if (shouldDisplayIntercepted()) return false; + if (mReleased.contains(notification.getKey())) return false; + if (!ranking.isInterceptedByDoNotDisturb(notification.getKey())) return false; mIntercepted.put(notification.getKey(), notification); updateSyntheticNotification(); return true; } + public void retryIntercepts(Ranking ranking) { + if (ranking == null) return; + + boolean changed = false; + final int N = mIntercepted.size(); + for (int i = 0; i < N; i++) { + final StatusBarNotification sbn = mIntercepted.valueAt(i); + if (!tryIntercept(sbn, ranking)) { + changed = true; + mBar.addNotificationInternal(sbn, ranking); + } + } + if (changed) { + updateSyntheticNotification(); + } + } + public void remove(String key) { if (mIntercepted.remove(key) != null) { updateSyntheticNotification(); } + mReleased.remove(key); } public boolean isSyntheticEntry(Entry ent) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index dedfff0..f9afcf3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -1050,7 +1050,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, if (shadeEntry == null) { return; } - if (mZenMode != Global.ZEN_MODE_OFF && mIntercepted.tryIntercept(notification)) { + if (mZenMode != Global.ZEN_MODE_OFF && mIntercepted.tryIntercept(notification, ranking)) { // Forward the ranking so we can sort the new notification. mNotificationData.updateRanking(ranking); return; @@ -1114,6 +1114,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } @Override + protected void updateRankingInternal(Ranking ranking) { + mNotificationData.updateRanking(ranking); + mIntercepted.retryIntercepts(ranking); + updateNotifications(); + } + + @Override public void removeNotificationInternal(String key, Ranking ranking) { StatusBarNotification old = removeNotificationViews(key, ranking); if (SPEW) Log.d(TAG, "removeNotification key=" + key + " old=" + old); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java index c2bd1cb..faea8de 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.tv; import android.os.IBinder; +import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.Ranking; import android.service.notification.StatusBarNotification; import android.view.View; @@ -54,11 +55,15 @@ public class TvStatusBar extends BaseStatusBar { } @Override + protected void updateRankingInternal(Ranking ranking) { + } + + @Override public void updateNotification(StatusBarNotification notification) { } @Override - protected void removeNotificationInternal(String key, Ranking ranking) { + public void removeNotificationInternal(String key, Ranking ranking) { } @Override |