OSDN Git Service

Clear binder identity before dispatching ap op mode changes.
authorSvet Ganov <svetoslavganov@google.com>
Tue, 19 May 2015 19:45:52 +0000 (12:45 -0700)
committerSvet Ganov <svetoslavganov@google.com>
Tue, 19 May 2015 19:45:56 +0000 (12:45 -0700)
bug:21078841

Change-Id: I409b739bbda10542142c8aac1522ad49882f5ec5

services/core/java/com/android/server/AppOpsService.java

index 7d427d6..79c66b9 100644 (file)
@@ -408,11 +408,19 @@ public class AppOpsService extends IAppOpsService.Stub {
             }
         }
         if (repCbs != null) {
-            for (int i=0; i<repCbs.size(); i++) {
-                try {
-                    repCbs.get(i).mCallback.opChanged(code, packageName);
-                } catch (RemoteException e) {
+            // There are components watching for mode changes such as window manager
+            // and location manager which are in our process. The callbacks in these
+            // components may require permissions our remote caller does not have.
+            final long identity = Binder.clearCallingIdentity();
+            try {
+                for (int i = 0; i < repCbs.size(); i++) {
+                    try {
+                        repCbs.get(i).mCallback.opChanged(code, packageName);
+                    } catch (RemoteException e) {
+                    }
                 }
+            } finally {
+                Binder.restoreCallingIdentity(identity);
             }
         }
     }