summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2014-05-28 16:40:57 -0400
committerChris Wren <cwren@android.com>2014-05-30 16:09:51 -0400
commit333a61c3a5a83fe9c50ebeb5c947317f61385b7b (patch)
treebbac1a9f9e5bcaf742116ee53c47bbf931e88b12 /packages
parent5c0727ff2debd2ce0b92bf264524480009a36935 (diff)
downloadframeworks_base-333a61c3a5a83fe9c50ebeb5c947317f61385b7b.zip
frameworks_base-333a61c3a5a83fe9c50ebeb5c947317f61385b7b.tar.gz
frameworks_base-333a61c3a5a83fe9c50ebeb5c947317f61385b7b.tar.bz2
Track Zen Mode status in the NotificationRecord
This requires the record to be present in makeRankingUpdateForListener, however, if the ranking object is created before the post to the handler, then no cloning is necessary. Depends-On: I907a1ff28123219db1c08889d723ad1b70b191ab Change-Id: I51fcf689ddbee7715e3387b865f18a715887c943
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java31
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java7
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 21b41c7..944e067 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -332,8 +332,7 @@ public abstract class BaseStatusBar extends SystemUI implements
mHandler.post(new Runnable() {
@Override
public void run() {
- mNotificationData.updateRanking(currentRanking);
- updateNotifications();
+ updateRankingInternal(currentRanking);
}
});
}
@@ -1275,6 +1274,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) {
@@ -1282,7 +1283,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 0e5b7e1..b56af15 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