diff options
| author | 2019-09-10 17:11:56 +0000 | |
|---|---|---|
| committer | 2019-09-10 17:11:56 +0000 | |
| commit | 5ffb16c95fb5024eb65ca2bc9f79cd5cf2d539e4 (patch) | |
| tree | 72f2c5829a6d24c06a35cd012e759ec948e70a48 | |
| parent | 4617a582a7155a1c3e3c30dafb4e3d0314b4e597 (diff) | |
| parent | 9bcc40655e9c0b5e2960e48c97f088bf4c98f7d4 (diff) | |
Merge "Do not call into system server with sLock held"
| -rw-r--r-- | core/java/android/app/AppOpsManager.java | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 1f283eafde0c..bb87d96b742c 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -5845,39 +5845,42 @@ public class AppOpsManager { ActivityThread.currentOpPackageName())) { // This app is noting an app-op for itself. Deliver immediately. sNotedAppOpsCollector.onSelfNoted(new SyncNotedAppOp(code)); - } else if (binderUid != null && binderUid == uid) { - // We are inside of a two-way binder call. Delivered to caller via - // {@link #prefixParcelWithAppOpsIfNeeded} - long[] appOpsNotedInThisBinderTransaction; - - appOpsNotedInThisBinderTransaction = sAppOpsNotedInThisBinderTransaction.get(); - if (appOpsNotedInThisBinderTransaction == null) { - appOpsNotedInThisBinderTransaction = new long[2]; - sAppOpsNotedInThisBinderTransaction.set(appOpsNotedInThisBinderTransaction); - } - if (code < 64) { - appOpsNotedInThisBinderTransaction[0] |= 1L << code; - } else { - appOpsNotedInThisBinderTransaction[1] |= 1L << (code - 64); - } + return; + } + } + + if (binderUid != null && binderUid == uid) { + // If this is inside of a two-way binder call: Delivered to caller via + // {@link #prefixParcelWithAppOpsIfNeeded} + long[] appOpsNotedInThisBinderTransaction; + + appOpsNotedInThisBinderTransaction = sAppOpsNotedInThisBinderTransaction.get(); + if (appOpsNotedInThisBinderTransaction == null) { + appOpsNotedInThisBinderTransaction = new long[2]; + sAppOpsNotedInThisBinderTransaction.set(appOpsNotedInThisBinderTransaction); + } + + if (code < 64) { + appOpsNotedInThisBinderTransaction[0] |= 1L << code; } else { - // We cannot deliver the note synchronous. Hence send it to the system server to - // notify the noted process. - if (message == null) { - // Default message is a stack trace - message = getFormattedStackTrace(); - } + appOpsNotedInThisBinderTransaction[1] |= 1L << (code - 64); + } + } else { + // Cannot deliver the note synchronous: Hence send it to the system server to + // notify the noted process. + if (message == null) { + // Default message is a stack trace + message = getFormattedStackTrace(); + } - long token = Binder.clearCallingIdentity(); - try { - mService.noteAsyncOp(mContext.getOpPackageName(), uid, packageName, code, - message); - } catch (RemoteException e) { - e.rethrowFromSystemServer(); - } finally { - Binder.restoreCallingIdentity(token); - } + long token = Binder.clearCallingIdentity(); + try { + mService.noteAsyncOp(mContext.getOpPackageName(), uid, packageName, code, message); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + } finally { + Binder.restoreCallingIdentity(token); } } } |