diff options
| author | Philip P. Moltmann <moltmann@google.com> | 2020-09-21 16:21:11 +0000 |
|---|---|---|
| committer | Philip P. Moltmann <moltmann@google.com> | 2020-09-21 22:26:18 +0000 |
| commit | bbeed895f5b9730217f043ebbd5b39f42c64d969 (patch) | |
| tree | 003f373f4ca635a156c0ed80a9cc2085517860ce /core/java/android/app/AppOpsManager.java | |
| parent | fe97984f331c24c3b49cf4cccc2d8f2c3a51defa (diff) | |
Revert "Check cross-user interactions for permissions and app-op..."
Revert "Add dedicated host side tests for permissions and appops"
Revert submission 12439864-PermAppOpsCrossUserCheck-Fixed
Reason for revert: Bug 169044600
Reverted Changes:
I95d015e01:Invalidate package/permission cache if cross-profi...
I2a8a84f57:Check cross-user interactions for permissions and ...
Ie8f0db231:Give all non-package services the power to interac...
I11af434a8:Test package/permission cache invalidation when IN...
Ib6d609a4d:Add dedicated host side tests for permissions and ...
Change-Id: Iea5eeded0ee5caf5383bb0e749133d4fef18d392
Diffstat (limited to 'core/java/android/app/AppOpsManager.java')
| -rw-r--r-- | core/java/android/app/AppOpsManager.java | 84 |
1 files changed, 19 insertions, 65 deletions
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 8ed9b80a1fcd..7087b60d75dd 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -6741,14 +6741,10 @@ public class AppOpsManager { */ @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) public void setUidMode(int code, int uid, @Mode int mode) { - // Clear calling UID to handle calls from inside the system server. See #noteOpNoThrow - long token = Binder.clearCallingIdentity(); try { mService.setUidMode(code, uid, mode); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); - } finally { - Binder.restoreCallingIdentity(token); } } @@ -6766,7 +6762,11 @@ public class AppOpsManager { @TestApi @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) public void setUidMode(@NonNull String appOp, int uid, @Mode int mode) { - setUidMode(AppOpsManager.strOpToOp(appOp), uid, mode); + try { + mService.setUidMode(AppOpsManager.strOpToOp(appOp), uid, mode); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } } /** @hide */ @@ -6795,14 +6795,10 @@ public class AppOpsManager { @TestApi @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) public void setMode(int code, int uid, String packageName, @Mode int mode) { - // Clear calling UID to handle calls from inside the system server. See #noteOpNoThrow - long token = Binder.clearCallingIdentity(); try { mService.setMode(code, uid, packageName, mode); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); - } finally { - Binder.restoreCallingIdentity(token); } } @@ -6822,7 +6818,11 @@ public class AppOpsManager { @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) public void setMode(@NonNull String op, int uid, @Nullable String packageName, @Mode int mode) { - setMode(strOpToOp(op), uid, packageName, mode); + try { + mService.setMode(strOpToOp(op), uid, packageName, mode); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } } /** @@ -7298,14 +7298,10 @@ public class AppOpsManager { * @hide */ public int unsafeCheckOpRawNoThrow(int op, int uid, @NonNull String packageName) { - // Clear calling UID to handle calls from inside the system server. See #noteOpNoThrow - long token = Binder.clearCallingIdentity(); try { return mService.checkOperationRaw(op, uid, packageName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); - } finally { - Binder.restoreCallingIdentity(token); } } @@ -7477,20 +7473,8 @@ public class AppOpsManager { } } - int mode; - // Making the binder call "noteOperation" usually sets Binder.callingUid to the calling - // processes UID. Hence clearing the calling UID is superfluous. - // If the call is inside the system server though "noteOperation" is not a binder all, - // it is only a method call. Hence Binder.callingUid might still be set to the app that - // called the system server. This can lead to problems as not every app can see the - // same appops the system server can see. - long token = Binder.clearCallingIdentity(); - try { - mode = mService.noteOperation(op, uid, packageName, attributionTag, - collectionMode == COLLECT_ASYNC, message, shouldCollectMessage); - } finally { - Binder.restoreCallingIdentity(token); - } + int mode = mService.noteOperation(op, uid, packageName, attributionTag, + collectionMode == COLLECT_ASYNC, message, shouldCollectMessage); if (mode == MODE_ALLOWED) { if (collectionMode == COLLECT_SELF) { @@ -7653,17 +7637,10 @@ public class AppOpsManager { } } - int mode; - // Clear calling UID to handle calls from inside the system server. See #noteOpNoThrow - long token = Binder.clearCallingIdentity(); - try { - mode = mService.noteProxyOperation(op, proxiedUid, proxiedPackageName, - proxiedAttributionTag, myUid, mContext.getOpPackageName(), - mContext.getAttributionTag(), collectionMode == COLLECT_ASYNC, message, - shouldCollectMessage); - } finally { - Binder.restoreCallingIdentity(token); - } + int mode = mService.noteProxyOperation(op, proxiedUid, proxiedPackageName, + proxiedAttributionTag, myUid, mContext.getOpPackageName(), + mContext.getAttributionTag(), collectionMode == COLLECT_ASYNC, message, + shouldCollectMessage); if (mode == MODE_ALLOWED) { if (collectionMode == COLLECT_SELF) { @@ -7713,8 +7690,6 @@ public class AppOpsManager { */ @UnsupportedAppUsage public int checkOp(int op, int uid, String packageName) { - // Clear calling UID to handle calls from inside the system server. See #noteOpNoThrow - long token = Binder.clearCallingIdentity(); try { int mode = mService.checkOperation(op, uid, packageName); if (mode == MODE_ERRORED) { @@ -7723,8 +7698,6 @@ public class AppOpsManager { return mode; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); - } finally { - Binder.restoreCallingIdentity(token); } } @@ -7735,15 +7708,11 @@ public class AppOpsManager { */ @UnsupportedAppUsage public int checkOpNoThrow(int op, int uid, String packageName) { - // Clear calling UID to handle calls from inside the system server. See #noteOpNoThrow - long token = Binder.clearCallingIdentity(); try { int mode = mService.checkOperation(op, uid, packageName); return mode == AppOpsManager.MODE_FOREGROUND ? AppOpsManager.MODE_ALLOWED : mode; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); - } finally { - Binder.restoreCallingIdentity(token); } } @@ -7995,16 +7964,9 @@ public class AppOpsManager { } } - int mode; - // Clear calling UID to handle calls from inside the system server. See #noteOpNoThrow - long token = Binder.clearCallingIdentity(); - try { - mode = mService.startOperation(getClientId(), op, uid, packageName, - attributionTag, startIfModeDefault, collectionMode == COLLECT_ASYNC, - message, shouldCollectMessage); - } finally { - Binder.restoreCallingIdentity(token); - } + int mode = mService.startOperation(getClientId(), op, uid, packageName, + attributionTag, startIfModeDefault, collectionMode == COLLECT_ASYNC, message, + shouldCollectMessage); if (mode == MODE_ALLOWED) { if (collectionMode == COLLECT_SELF) { @@ -8067,14 +8029,10 @@ public class AppOpsManager { */ public void finishOp(int op, int uid, @NonNull String packageName, @Nullable String attributionTag) { - // Clear calling UID to handle calls from inside the system server. See #noteOpNoThrow - long token = Binder.clearCallingIdentity(); try { mService.finishOperation(getClientId(), op, uid, packageName, attributionTag); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); - } finally { - Binder.restoreCallingIdentity(token); } } @@ -8666,14 +8624,10 @@ public class AppOpsManager { // TODO: Uncomment below annotation once b/73559440 is fixed // @RequiresPermission(value=Manifest.permission.WATCH_APPOPS, conditional=true) public boolean isOperationActive(int code, int uid, String packageName) { - // Clear calling UID to handle calls from inside the system server. See #noteOpNoThrow - long token = Binder.clearCallingIdentity(); try { return mService.isOperationActive(code, uid, packageName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); - } finally { - Binder.restoreCallingIdentity(token); } } |
