Merge "Remove notification APIs from StatusBar service"
diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl
index a01e9b7..84bd443 100644
--- a/core/java/com/android/internal/statusbar/IStatusBar.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl
@@ -24,9 +24,6 @@
{
void setIcon(int index, in StatusBarIcon icon);
void removeIcon(int index);
- void addNotification(in StatusBarNotification notification);
- void updateNotification(in StatusBarNotification notification);
- void removeNotification(String key);
void disable(int state);
void animateExpandNotificationsPanel();
void animateExpandSettingsPanel();
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index a3b417f..f3430e7 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -39,8 +39,7 @@
// ---- Methods below are for use by the status bar policy services ----
// You need the STATUS_BAR_SERVICE permission
void registerStatusBar(IStatusBar callbacks, out StatusBarIconList iconList,
- out List<StatusBarNotification> notifications, out int[] switches,
- out List<IBinder> binders);
+ out int[] switches, out List<IBinder> binders);
void onPanelRevealed();
void onPanelHidden();
void onNotificationClick(String key);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 5bc23b5..c621f31 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -94,7 +94,6 @@
public static final String TAG = "StatusBar";
public static final boolean DEBUG = false;
public static final boolean MULTIUSER_DEBUG = false;
- private static final boolean USE_NOTIFICATION_LISTENER = true;
protected static final int MSG_SHOW_RECENT_APPS = 1019;
protected static final int MSG_HIDE_RECENT_APPS = 1020;
@@ -298,7 +297,7 @@
@Override
public void run() {
for (StatusBarNotification sbn : notifications) {
- addNotificationInternal(sbn, currentRanking);
+ addNotification(sbn, currentRanking);
}
}
});
@@ -325,16 +324,16 @@
// wasn't a group child, remove the old instance.
// Otherwise just update the ranking.
if (isUpdate) {
- removeNotificationInternal(sbn.getKey(), rankingMap);
+ removeNotification(sbn.getKey(), rankingMap);
} else {
- updateRankingInternal(rankingMap);
+ updateNotificationRanking(rankingMap);
}
return;
}
if (isUpdate) {
- updateNotificationInternal(sbn, rankingMap);
+ updateNotification(sbn, rankingMap);
} else {
- addNotificationInternal(sbn, rankingMap);
+ addNotification(sbn, rankingMap);
}
}
});
@@ -347,7 +346,7 @@
mHandler.post(new Runnable() {
@Override
public void run() {
- removeNotificationInternal(sbn.getKey(), rankingMap);
+ removeNotification(sbn.getKey(), rankingMap);
}
});
}
@@ -358,7 +357,7 @@
mHandler.post(new Runnable() {
@Override
public void run() {
- updateRankingInternal(rankingMap);
+ updateNotificationRanking(rankingMap);
}
});
}
@@ -414,14 +413,12 @@
// Connect in to the status bar manager service
StatusBarIconList iconList = new StatusBarIconList();
- ArrayList<StatusBarNotification> notifications = new ArrayList<StatusBarNotification>();
mCommandQueue = new CommandQueue(this, iconList);
int[] switches = new int[8];
ArrayList<IBinder> binders = new ArrayList<IBinder>();
try {
- mBarService.registerStatusBar(mCommandQueue, iconList, notifications,
- switches, binders);
+ mBarService.registerStatusBar(mCommandQueue, iconList, switches, binders);
} catch (RemoteException ex) {
// If the system process isn't there we're doomed anyway.
}
@@ -447,19 +444,12 @@
}
// Set up the initial notification state.
- if (USE_NOTIFICATION_LISTENER) {
- try {
- mNotificationListener.registerAsSystemService(
- new ComponentName(mContext.getPackageName(), getClass().getCanonicalName()),
- UserHandle.USER_ALL);
- } catch (RemoteException e) {
- Log.e(TAG, "Unable to register notification listener", e);
- }
- } else {
- N = notifications.size();
- for (int i=0; i<N; i++) {
- addNotification(notifications.get(i));
- }
+ try {
+ mNotificationListener.registerAsSystemService(
+ new ComponentName(mContext.getPackageName(), getClass().getCanonicalName()),
+ UserHandle.USER_ALL);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Unable to register notification listener", e);
}
@@ -1194,7 +1184,7 @@
* WARNING: this will call back into us. Don't hold any locks.
*/
void handleNotificationError(StatusBarNotification n, String message) {
- removeNotification(n.getKey());
+ removeNotification(n.getKey(), null);
try {
mBarService.onNotificationError(n.getPackageName(), n.getTag(), n.getId(), n.getUid(),
n.getInitialPid(), message, n.getUserId());
@@ -1330,34 +1320,11 @@
protected abstract void updateExpandedViewPos(int expandedPosition);
protected abstract boolean shouldDisableNavbarGestures();
- @Override
- public void addNotification(StatusBarNotification notification) {
- if (!USE_NOTIFICATION_LISTENER) {
- addNotificationInternal(notification, null);
- }
- }
-
- public abstract void addNotificationInternal(StatusBarNotification notification,
+ public abstract void addNotification(StatusBarNotification notification,
RankingMap ranking);
-
- protected abstract void updateRankingInternal(RankingMap ranking);
-
- @Override
- public void removeNotification(String key) {
- if (!USE_NOTIFICATION_LISTENER) {
- removeNotificationInternal(key, null);
- }
- }
-
- public abstract void removeNotificationInternal(String key, RankingMap ranking);
-
- public void updateNotification(StatusBarNotification notification) {
- if (!USE_NOTIFICATION_LISTENER) {
- updateNotificationInternal(notification, null);
- }
- }
-
- public void updateNotificationInternal(StatusBarNotification notification, RankingMap ranking) {
+ protected abstract void updateNotificationRanking(RankingMap ranking);
+ public abstract void removeNotification(String key, RankingMap ranking);
+ public void updateNotification(StatusBarNotification notification, RankingMap ranking) {
if (DEBUG) Log.d(TAG, "updateNotification(" + notification + ")");
final String key = notification.getKey();
@@ -1474,7 +1441,7 @@
} else {
if (shouldInterrupt && alertAgain) {
removeNotificationViews(key, ranking);
- addNotificationInternal(notification, ranking); //this will pop the headsup
+ addNotification(notification, ranking); //this will pop the headsup
} else {
updateNotificationViews(oldEntry, notification);
}
@@ -1514,7 +1481,7 @@
if (shouldInterrupt && alertAgain) {
if (DEBUG) Log.d(TAG, "reposting to invoke heads up for key: " + key);
removeNotificationViews(key, ranking);
- addNotificationInternal(notification, ranking); //this will pop the headsup
+ addNotification(notification, ranking); //this will pop the headsup
} else {
if (DEBUG) Log.d(TAG, "rebuilding update in place for key: " + key);
removeNotificationViews(key, ranking);
@@ -1672,12 +1639,10 @@
mWindowManager.removeViewImmediate(mSearchPanelView);
}
mContext.unregisterReceiver(mBroadcastReceiver);
- if (USE_NOTIFICATION_LISTENER) {
- try {
- mNotificationListener.unregisterAsSystemService();
- } catch (RemoteException e) {
- // Ignore.
- }
+ try {
+ mNotificationListener.unregisterAsSystemService();
+ } catch (RemoteException e) {
+ // Ignore.
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index aaeadb6..2b61f09 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -41,23 +41,20 @@
private static final int OP_REMOVE_ICON = 2;
private static final int MSG_ICON = 1 << MSG_SHIFT;
- private static final int MSG_ADD_NOTIFICATION = 2 << MSG_SHIFT;
- private static final int MSG_UPDATE_NOTIFICATION = 3 << MSG_SHIFT;
- private static final int MSG_REMOVE_NOTIFICATION = 4 << MSG_SHIFT;
- private static final int MSG_DISABLE = 5 << MSG_SHIFT;
- private static final int MSG_EXPAND_NOTIFICATIONS = 6 << MSG_SHIFT;
- private static final int MSG_COLLAPSE_PANELS = 7 << MSG_SHIFT;
- private static final int MSG_EXPAND_SETTINGS = 8 << MSG_SHIFT;
- private static final int MSG_SET_SYSTEMUI_VISIBILITY = 9 << MSG_SHIFT;
- private static final int MSG_TOP_APP_WINDOW_CHANGED = 10 << MSG_SHIFT;
- private static final int MSG_SHOW_IME_BUTTON = 11 << MSG_SHIFT;
- private static final int MSG_SET_HARD_KEYBOARD_STATUS = 12 << MSG_SHIFT;
- private static final int MSG_TOGGLE_RECENT_APPS = 13 << MSG_SHIFT;
- private static final int MSG_PRELOAD_RECENT_APPS = 14 << MSG_SHIFT;
- private static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 15 << MSG_SHIFT;
- private static final int MSG_SET_WINDOW_STATE = 16 << MSG_SHIFT;
- private static final int MSG_SHOW_RECENT_APPS = 17 << MSG_SHIFT;
- private static final int MSG_HIDE_RECENT_APPS = 18 << MSG_SHIFT;
+ private static final int MSG_DISABLE = 2 << MSG_SHIFT;
+ private static final int MSG_EXPAND_NOTIFICATIONS = 3 << MSG_SHIFT;
+ private static final int MSG_COLLAPSE_PANELS = 4 << MSG_SHIFT;
+ private static final int MSG_EXPAND_SETTINGS = 5 << MSG_SHIFT;
+ private static final int MSG_SET_SYSTEMUI_VISIBILITY = 6 << MSG_SHIFT;
+ private static final int MSG_TOP_APP_WINDOW_CHANGED = 7 << MSG_SHIFT;
+ private static final int MSG_SHOW_IME_BUTTON = 8 << MSG_SHIFT;
+ private static final int MSG_SET_HARD_KEYBOARD_STATUS = 9 << MSG_SHIFT;
+ private static final int MSG_TOGGLE_RECENT_APPS = 10 << MSG_SHIFT;
+ private static final int MSG_PRELOAD_RECENT_APPS = 11 << MSG_SHIFT;
+ private static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 12 << MSG_SHIFT;
+ private static final int MSG_SET_WINDOW_STATE = 13 << MSG_SHIFT;
+ private static final int MSG_SHOW_RECENT_APPS = 14 << MSG_SHIFT;
+ private static final int MSG_HIDE_RECENT_APPS = 15 << MSG_SHIFT;
public static final int FLAG_EXCLUDE_NONE = 0;
public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -80,9 +77,6 @@
public void updateIcon(String slot, int index, int viewIndex,
StatusBarIcon old, StatusBarIcon icon);
public void removeIcon(String slot, int index, int viewIndex);
- public void addNotification(StatusBarNotification notification);
- public void updateNotification(StatusBarNotification notification);
- public void removeNotification(String key);
public void disable(int state);
public void animateExpandNotificationsPanel();
public void animateCollapsePanels(int flags);
@@ -123,26 +117,6 @@
}
}
- @Override
- public void addNotification(StatusBarNotification notification) {
- synchronized (mList) {
- mHandler.obtainMessage(MSG_ADD_NOTIFICATION, 0, 0, notification).sendToTarget();
- }
- }
-
- @Override
- public void updateNotification(StatusBarNotification notification) {
- synchronized (mList) {
- mHandler.obtainMessage(MSG_UPDATE_NOTIFICATION, 0, 0, notification).sendToTarget();
- }
- }
-
- public void removeNotification(String key) {
- synchronized (mList) {
- mHandler.obtainMessage(MSG_REMOVE_NOTIFICATION, 0, 0, key).sendToTarget();
- }
- }
-
public void disable(int state) {
synchronized (mList) {
mHandler.removeMessages(MSG_DISABLE);
@@ -279,18 +253,6 @@
}
break;
}
- case MSG_ADD_NOTIFICATION: {
- mCallbacks.addNotification((StatusBarNotification) msg.obj);
- break;
- }
- case MSG_UPDATE_NOTIFICATION: {
- mCallbacks.updateNotification((StatusBarNotification) msg.obj);
- break;
- }
- case MSG_REMOVE_NOTIFICATION: {
- mCallbacks.removeNotification((String) msg.obj);
- break;
- }
case MSG_DISABLE:
mCallbacks.disable(msg.arg1);
break;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java b/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java
index bfa74fa..bba49a7f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java
@@ -107,7 +107,7 @@
private void updateSyntheticNotification() {
if (mIntercepted.isEmpty()) {
if (mSynKey != null) {
- mBar.removeNotificationInternal(mSynKey, null);
+ mBar.removeNotification(mSynKey, null);
mSynKey = null;
}
return;
@@ -128,7 +128,7 @@
mSynKey = sbn.getKey();
mBar.displayNotification(sbn, null);
} else {
- mBar.updateNotificationInternal(sbn, null);
+ mBar.updateNotification(sbn, null);
}
final NotificationData.Entry entry = mBar.mNotificationData.findByKey(mSynKey);
entry.row.setOnClickListener(mSynClickListener);
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 7016c0c..2c67aa9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1072,7 +1072,7 @@
}
@Override
- public void addNotificationInternal(StatusBarNotification notification, RankingMap ranking) {
+ public void addNotification(StatusBarNotification notification, RankingMap ranking) {
if (DEBUG) Log.d(TAG, "addNotification key=" + notification.getKey());
if (mZenMode != Global.ZEN_MODE_OFF && mIntercepted.tryIntercept(notification, ranking)) {
// Forward the ranking so we can sort the new notification.
@@ -1165,21 +1165,14 @@
}
@Override
- public void updateNotificationInternal(StatusBarNotification notification, RankingMap ranking) {
- super.updateNotificationInternal(notification, ranking);
- // if we're here, then the notification is already in the shade
- mIntercepted.remove(notification.getKey());
- }
-
- @Override
- protected void updateRankingInternal(RankingMap ranking) {
+ protected void updateNotificationRanking(RankingMap ranking) {
mNotificationData.updateRanking(ranking);
mIntercepted.retryIntercepts(ranking);
updateNotifications();
}
@Override
- public void removeNotificationInternal(String key, RankingMap ranking) {
+ public void removeNotification(String key, RankingMap ranking) {
if (ENABLE_HEADS_UP && mHeadsUpNotificationView.getEntry() != null
&& key.equals(mHeadsUpNotificationView.getEntry().notification.getKey())) {
mHeadsUpNotificationView.clear();
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 9260aac..e354166 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
@@ -47,27 +47,15 @@
}
@Override
- public void addNotification(StatusBarNotification notification) {
+ public void addNotification(StatusBarNotification notification, RankingMap ranking) {
}
@Override
- public void addNotificationInternal(StatusBarNotification notification, RankingMap ranking) {
+ protected void updateNotificationRanking(RankingMap ranking) {
}
@Override
- protected void updateRankingInternal(RankingMap ranking) {
- }
-
- @Override
- public void updateNotification(StatusBarNotification notification) {
- }
-
- @Override
- public void removeNotificationInternal(String key, RankingMap ranking) {
- }
-
- @Override
- public void removeNotification(String key) {
+ public void removeNotification(String key, RankingMap ranking) {
}
@Override
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 825dc84..c7adb68 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1546,41 +1546,11 @@
Collections.sort(mNotificationList, mRankingComparator);
- final int currentUser;
- final long token = Binder.clearCallingIdentity();
- try {
- currentUser = ActivityManager.getCurrentUser();
- } finally {
- Binder.restoreCallingIdentity(token);
- }
-
if (notification.icon != 0) {
- if (old != null && !old.isCanceled) {
- final long identity = Binder.clearCallingIdentity();
- try {
- mStatusBar.updateNotification(n);
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
- } else {
- final long identity = Binder.clearCallingIdentity();
- try {
- mStatusBar.addNotification(n);
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
- }
mListeners.notifyPostedLocked(n);
} else {
Slog.e(TAG, "Not posting notification with icon==0: " + notification);
if (old != null && !old.isCanceled) {
- final long identity = Binder.clearCallingIdentity();
- try {
- mStatusBar.removeNotification(r.getKey());
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
-
mListeners.notifyRemovedLocked(n);
}
// ATTENTION: in a future release we will bail out here
@@ -1992,12 +1962,6 @@
// status bar
if (r.getNotification().icon != 0) {
- final long identity = Binder.clearCallingIdentity();
- try {
- mStatusBar.removeNotification(r.getKey());
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
r.isCanceled = true;
mListeners.notifyRemovedLocked(r.sbn);
}
diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java b/services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java
index 8d905ba..dc44e51 100644
--- a/services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java
+++ b/services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java
@@ -23,7 +23,4 @@
public interface StatusBarManagerInternal {
void setNotificationDelegate(NotificationDelegate delegate);
- void addNotification(StatusBarNotification notification);
- void updateNotification(StatusBarNotification notification);
- void removeNotification(String key);
}
diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
index 55b5e3b..e548fa5 100644
--- a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
+++ b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
@@ -60,8 +60,6 @@
private NotificationDelegate mNotificationDelegate;
private volatile IStatusBar mBar;
private StatusBarIconList mIcons = new StatusBarIconList();
- private HashMap<String,StatusBarNotification> mNotifications
- = new HashMap<String,StatusBarNotification>();
// for disabling the status bar
private final ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>();
@@ -111,56 +109,7 @@
private final StatusBarManagerInternal mInternalService = new StatusBarManagerInternal() {
@Override
public void setNotificationDelegate(NotificationDelegate delegate) {
- synchronized (mNotifications) {
- mNotificationDelegate = delegate;
- }
- }
-
- @Override
- public void addNotification(StatusBarNotification notification) {
- synchronized (mNotifications) {
- mNotifications.put(notification.getKey(), notification);
- if (mBar != null) {
- try {
- mBar.addNotification(notification);
- } catch (RemoteException ex) {
- }
- }
- }
- }
-
- @Override
- public void updateNotification(StatusBarNotification notification) {
- synchronized (mNotifications) {
- String key = notification.getKey();
- if (!mNotifications.containsKey(key)) {
- throw new IllegalArgumentException("updateNotification key not found: " + key);
- }
- mNotifications.put(notification.getKey(), notification);
- if (mBar != null) {
- try {
- mBar.updateNotification(notification);
- } catch (RemoteException ex) {
- }
- }
- }
- }
-
- @Override
- public void removeNotification(String key) {
- synchronized (mNotifications) {
- final StatusBarNotification n = mNotifications.remove(key);
- if (n == null) {
- Slog.e(TAG, "removeNotification key not found: " + key);
- return;
- }
- if (mBar != null) {
- try {
- mBar.removeNotification(key);
- } catch (RemoteException ex) {
- }
- }
- }
+ mNotificationDelegate = delegate;
}
};
@@ -511,7 +460,7 @@
// ================================================================================
@Override
public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList,
- List<StatusBarNotification> notifications, int switches[], List<IBinder> binders) {
+ int switches[], List<IBinder> binders) {
enforceStatusBarService();
Slog.i(TAG, "registerStatusBar bar=" + bar);
@@ -519,11 +468,6 @@
synchronized (mIcons) {
iconList.copyFrom(mIcons);
}
- synchronized (mNotifications) {
- for (StatusBarNotification sbn : mNotifications.values()) {
- notifications.add(sbn);
- }
- }
synchronized (mLock) {
switches[0] = gatherDisableActionsLocked(mCurrentUserId);
switches[1] = mSystemUiVisibility;
@@ -708,15 +652,6 @@
mIcons.dump(pw);
}
- synchronized (mNotifications) {
- int i=0;
- pw.println("Notification list:");
- for (Map.Entry<String,StatusBarNotification> e: mNotifications.entrySet()) {
- pw.printf(" %2d: %s\n", i, e.getValue().toString());
- i++;
- }
- }
-
synchronized (mLock) {
pw.println(" mDisabled=0x" + Integer.toHexString(mDisabled));
final int N = mDisableRecords.size();