summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGriff Hazen <griff@google.com>2014-09-05 21:52:43 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-05 21:52:44 +0000
commit69dd40d08a164d5c357442733cf291719dfe94e8 (patch)
tree723b22baf3d2c69ad6d8f231347e090fb6965179
parentcf2858d363cfde6024752998363ed1cb1436491d (diff)
parent84a00ea9e3df3ff051d3e86945d2befea32072ee (diff)
downloadframeworks_base-69dd40d08a164d5c357442733cf291719dfe94e8.zip
frameworks_base-69dd40d08a164d5c357442733cf291719dfe94e8.tar.gz
frameworks_base-69dd40d08a164d5c357442733cf291719dfe94e8.tar.bz2
Merge "Reduce chance of notification listener dropped messages." into lmp-dev
-rw-r--r--Android.mk1
-rw-r--r--core/java/android/service/notification/INotificationListener.aidl5
-rw-r--r--core/java/android/service/notification/IStatusBarNotificationHolder.aidl24
-rw-r--r--core/java/android/service/notification/NotificationListenerService.java18
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java25
5 files changed, 67 insertions, 6 deletions
diff --git a/Android.mk b/Android.mk
index 03aa762..35d13d7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -204,6 +204,7 @@ LOCAL_SRC_FILES += \
core/java/android/os/IUserManager.aidl \
core/java/android/os/IVibratorService.aidl \
core/java/android/service/notification/INotificationListener.aidl \
+ core/java/android/service/notification/IStatusBarNotificationHolder.aidl \
core/java/android/service/notification/IConditionListener.aidl \
core/java/android/service/notification/IConditionProvider.aidl \
core/java/android/print/ILayoutResultCallback.aidl \
diff --git a/core/java/android/service/notification/INotificationListener.aidl b/core/java/android/service/notification/INotificationListener.aidl
index 8ca9b6c..e6bf6ba 100644
--- a/core/java/android/service/notification/INotificationListener.aidl
+++ b/core/java/android/service/notification/INotificationListener.aidl
@@ -16,6 +16,7 @@
package android.service.notification;
+import android.service.notification.IStatusBarNotificationHolder;
import android.service.notification.StatusBarNotification;
import android.service.notification.NotificationRankingUpdate;
@@ -23,9 +24,9 @@ import android.service.notification.NotificationRankingUpdate;
oneway interface INotificationListener
{
void onListenerConnected(in NotificationRankingUpdate update);
- void onNotificationPosted(in StatusBarNotification notification,
+ void onNotificationPosted(in IStatusBarNotificationHolder notificationHolder,
in NotificationRankingUpdate update);
- void onNotificationRemoved(in StatusBarNotification notification,
+ void onNotificationRemoved(in IStatusBarNotificationHolder notificationHolder,
in NotificationRankingUpdate update);
void onNotificationRankingUpdate(in NotificationRankingUpdate update);
void onListenerHintsChanged(int hints);
diff --git a/core/java/android/service/notification/IStatusBarNotificationHolder.aidl b/core/java/android/service/notification/IStatusBarNotificationHolder.aidl
new file mode 100644
index 0000000..fd6b59e
--- /dev/null
+++ b/core/java/android/service/notification/IStatusBarNotificationHolder.aidl
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2014, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.notification;
+
+import android.service.notification.StatusBarNotification;
+
+/** @hide */
+interface IStatusBarNotificationHolder {
+ StatusBarNotification get();
+}
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index 2ca8098..d744070 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -603,8 +603,15 @@ public abstract class NotificationListenerService extends Service {
private class INotificationListenerWrapper extends INotificationListener.Stub {
@Override
- public void onNotificationPosted(StatusBarNotification sbn,
+ public void onNotificationPosted(IStatusBarNotificationHolder sbnHolder,
NotificationRankingUpdate update) {
+ StatusBarNotification sbn;
+ try {
+ sbn = sbnHolder.get();
+ } catch (RemoteException e) {
+ Log.w(TAG, "onNotificationPosted: Error receiving StatusBarNotification", e);
+ return;
+ }
Notification.Builder.rebuild(getContext(), sbn.getNotification());
// protect subclass from concurrent modifications of (@link mNotificationKeys}.
@@ -618,8 +625,15 @@ public abstract class NotificationListenerService extends Service {
}
}
@Override
- public void onNotificationRemoved(StatusBarNotification sbn,
+ public void onNotificationRemoved(IStatusBarNotificationHolder sbnHolder,
NotificationRankingUpdate update) {
+ StatusBarNotification sbn;
+ try {
+ sbn = sbnHolder.get();
+ } catch (RemoteException e) {
+ Log.w(TAG, "onNotificationRemoved: Error receiving StatusBarNotification", e);
+ return;
+ }
// protect subclass from concurrent modifications of (@link mNotificationKeys}.
synchronized (mWrapper) {
applyUpdate(update);
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index bc538ed..54f043d 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -69,6 +69,7 @@ import android.service.notification.Condition;
import android.service.notification.IConditionListener;
import android.service.notification.IConditionProvider;
import android.service.notification.INotificationListener;
+import android.service.notification.IStatusBarNotificationHolder;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationRankingUpdate;
import android.service.notification.StatusBarNotification;
@@ -2848,8 +2849,9 @@ public class NotificationManagerService extends SystemService {
private void notifyPosted(final ManagedServiceInfo info,
final StatusBarNotification sbn, NotificationRankingUpdate rankingUpdate) {
final INotificationListener listener = (INotificationListener)info.service;
+ StatusBarNotificationHolder sbnHolder = new StatusBarNotificationHolder(sbn);
try {
- listener.onNotificationPosted(sbn, rankingUpdate);
+ listener.onNotificationPosted(sbnHolder, rankingUpdate);
} catch (RemoteException ex) {
Log.e(TAG, "unable to notify listener (posted): " + listener, ex);
}
@@ -2861,8 +2863,9 @@ public class NotificationManagerService extends SystemService {
return;
}
final INotificationListener listener = (INotificationListener) info.service;
+ StatusBarNotificationHolder sbnHolder = new StatusBarNotificationHolder(sbn);
try {
- listener.onNotificationRemoved(sbn, rankingUpdate);
+ listener.onNotificationRemoved(sbnHolder, rankingUpdate);
} catch (RemoteException ex) {
Log.e(TAG, "unable to notify listener (removed): " + listener, ex);
}
@@ -2950,4 +2953,22 @@ public class NotificationManagerService extends SystemService {
return zen ? "zen" : ('\'' + pkgFilter + '\'');
}
}
+
+ /**
+ * Wrapper for a StatusBarNotification object that allows transfer across a oneway
+ * binder without sending large amounts of data over a oneway transaction.
+ */
+ private static final class StatusBarNotificationHolder
+ extends IStatusBarNotificationHolder.Stub {
+ private final StatusBarNotification mValue;
+
+ public StatusBarNotificationHolder(StatusBarNotification value) {
+ mValue = value;
+ }
+
+ @Override
+ public StatusBarNotification get() {
+ return mValue;
+ }
+ }
}