summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Sandler <dsandler@android.com>2014-03-19 13:04:00 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-03-19 13:04:01 +0000
commitb78dc69c2be43852dcd7150db2b545f9b4110232 (patch)
tree7d3c131f3238b69f521847a6b99d8926171076fa
parent98a027a506b5acff1a7ab0cc3655399da7d025c7 (diff)
parent4d460833b955fcb669c59d4384bdf7938cc71705 (diff)
downloadframeworks_base-b78dc69c2be43852dcd7150db2b545f9b4110232.zip
frameworks_base-b78dc69c2be43852dcd7150db2b545f9b4110232.tar.gz
frameworks_base-b78dc69c2be43852dcd7150db2b545f9b4110232.tar.bz2
Merge "DO NOT MERGE: Maintain binding to crashed listeners." into klp-dev
-rw-r--r--services/java/com/android/server/NotificationManagerService.java37
1 files changed, 24 insertions, 13 deletions
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index 0438675..dedc9bd 100644
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -260,10 +260,11 @@ public class NotificationManagerService extends INotificationManager.Stub
@Override
public void binderDied() {
- if (connection == null) {
- // This is not a service; it won't be recreated. We can give up this connection.
- unregisterListener(this.listener, this.userid);
- }
+ // Remove the listener, but don't unbind from the service. The system will bring the
+ // service back up, and the onServiceConnected handler will readd the listener with the
+ // new binding. If this isn't a bound service, and is just a registered
+ // INotificationListener, just removing it from the list is all we need to do anyway.
+ removeListenerImpl(this.listener, this.userid);
}
/** convenience method for looking in mEnabledListenersForCurrentUser */
@@ -757,26 +758,36 @@ public class NotificationManagerService extends INotificationManager.Stub
}
/**
- * Remove a listener binder directly
+ * Removes a listener from the list and unbinds from its service.
*/
- @Override
- public void unregisterListener(INotificationListener listener, int userid) {
- // no need to check permissions; if your listener binder is in the list,
- // that's proof that you had permission to add it in the first place
+ public void unregisterListener(final INotificationListener listener, final int userid) {
+ if (listener == null) return;
+
+ NotificationListenerInfo info = removeListenerImpl(listener, userid);
+ if (info != null && info.connection != null) {
+ mContext.unbindService(info.connection);
+ }
+ }
+ /**
+ * Removes a listener from the list but does not unbind from the listener's service.
+ *
+ * @return the removed listener.
+ */
+ NotificationListenerInfo removeListenerImpl(
+ final INotificationListener listener, final int userid) {
+ NotificationListenerInfo listenerInfo = null;
synchronized (mNotificationList) {
final int N = mListeners.size();
for (int i=N-1; i>=0; i--) {
final NotificationListenerInfo info = mListeners.get(i);
if (info.listener.asBinder() == listener.asBinder()
&& info.userid == userid) {
- mListeners.remove(i);
- if (info.connection != null) {
- mContext.unbindService(info.connection);
- }
+ listenerInfo = mListeners.remove(i);
}
}
}
+ return listenerInfo;
}
/**