OSDN Git Service

NoMan: Allow SysUI to register as listener
authorChristoph Studer <chstuder@google.com>
Thu, 22 May 2014 14:48:40 +0000 (16:48 +0200)
committerChristoph Studer <chstuder@google.com>
Thu, 22 May 2014 21:45:07 +0000 (23:45 +0200)
Expand ACL of INotificationManger.registerListener() from
system only to system or SysUI.

Also call onListenerConnected() on listeners connected via
INotificationManger.registerListener().

Bug: 15131411
Change-Id: I8f2ce34325ad72c7740b383de2ebb9fb88dea5d3

services/core/java/com/android/server/notification/ManagedServices.java
services/core/java/com/android/server/notification/NotificationManagerService.java

index 584145f..b94ea62 100644 (file)
@@ -175,7 +175,10 @@ abstract public class ManagedServices {
 
     public void registerService(IInterface service, ComponentName component, int userid) {
         checkNotNull(service);
-        registerServiceImpl(service, component, userid);
+        ManagedServiceInfo info = registerServiceImpl(service, component, userid);
+        if (info != null) {
+            onServiceAdded(info);
+        }
     }
 
     /**
@@ -464,7 +467,7 @@ abstract public class ManagedServices {
         }
     }
 
-    private void registerServiceImpl(final IInterface service,
+    private ManagedServiceInfo registerServiceImpl(final IInterface service,
             final ComponentName component, final int userid) {
         synchronized (mMutex) {
             try {
@@ -472,10 +475,12 @@ abstract public class ManagedServices {
                         true /*isSystem*/, null, Build.VERSION_CODES.L);
                 service.asBinder().linkToDeath(info, 0);
                 mServices.add(info);
+                return info;
             } catch (RemoteException e) {
                 // already dead
             }
         }
+        return null;
     }
 
     /**
index b9a69ab..8641746 100644 (file)
@@ -1264,7 +1264,7 @@ public class NotificationManagerService extends SystemService {
         @Override
         public void registerListener(final INotificationListener listener,
                 final ComponentName component, final int userid) {
-            checkCallerIsSystem();
+            enforceSystemOrSystemUI("INotificationManager.registerListener");
             mListeners.registerService(listener, component, userid);
         }