From c2841ec7feb095cc36d2540844228ee72da3dfca Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Mon, 25 Jun 2018 16:39:23 -0700 Subject: Allow UiAutomation to adopt the shell permission indentity For testing we often need to run shell commands. This can be done today via running a shell command from an instrumentation test started from the shell. However, this requires adding shell commands which are not in the API contract, involve boilerplate code, require string parsing, etc. This change allows an instrumentation started from the shell to adopt the shell UID permission state. As a result one can call APIs protected by permissions normal apps cannot get by are granted to the shell. This enables adding dedicated test APIs protected by signatures permissions granted to the shell. Test: cts-tradefed run cts-dev -m CtsUiAutomationTestCases -t android.app.uiautomation.cts.UiAutomationTest#testAdoptShellPermissions bug:80415658 Merged-In: I4bfd4b475225125512abf80ea98cd8fcacb6a1be Change-Id: I4bfd4b475225125512abf80ea98cd8fcacb6a1be --- core/java/android/app/AppOpsManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/java/android/app/AppOpsManager.java') diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index de84281328b2..398b4064d15a 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -2513,7 +2513,7 @@ public class AppOpsManager { */ public int noteProxyOpNoThrow(int op, String proxiedPackageName) { try { - return mService.noteProxyOperation(op, mContext.getOpPackageName(), + return mService.noteProxyOperation(op, Process.myUid(), mContext.getOpPackageName(), Binder.getCallingUid(), proxiedPackageName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); -- cgit v1.2.3