summaryrefslogtreecommitdiff
path: root/core/java/android/app/AppOpsManagerInternal.java
diff options
context:
space:
mode:
authorSvet Ganov <svetoslavganov@google.com>2018-06-25 16:39:23 -0700
committerSooraj Sasindran <sasindran@google.com>2019-02-21 19:59:14 +0000
commitc2841ec7feb095cc36d2540844228ee72da3dfca (patch)
treea75b7383d0285ee73db59fbc8f650221ef2b3087 /core/java/android/app/AppOpsManagerInternal.java
parenta6dda25ac90b7ce6a9afa7da6cc86fade59f9ebf (diff)
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
Diffstat (limited to 'core/java/android/app/AppOpsManagerInternal.java')
-rw-r--r--core/java/android/app/AppOpsManagerInternal.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/core/java/android/app/AppOpsManagerInternal.java b/core/java/android/app/AppOpsManagerInternal.java
index 24c5d234c120..f5d5e6e9a950 100644
--- a/core/java/android/app/AppOpsManagerInternal.java
+++ b/core/java/android/app/AppOpsManagerInternal.java
@@ -18,12 +18,55 @@ package android.app;
import android.util.SparseIntArray;
+import com.android.internal.util.function.QuadFunction;
+import com.android.internal.util.function.TriFunction;
+
/**
* App ops service local interface.
*
* @hide Only for use within the system server.
*/
public abstract class AppOpsManagerInternal {
+ /** Interface to override app ops checks via composition */
+ public interface CheckOpsDelegate {
+ /**
+ * Allows overriding check operation behavior.
+ *
+ * @param code The op code to check.
+ * @param uid The UID for which to check.
+ * @param packageName The package for which to check.
+ * @param superImpl The super implementation.
+ * @return The app op check result.
+ */
+ int checkOperation(int code, int uid, String packageName,
+ TriFunction<Integer, Integer, String, Integer> superImpl);
+
+ /**
+ * Allows overriding check audio operation behavior.
+ *
+ * @param code The op code to check.
+ * @param usage The audio op usage.
+ * @param uid The UID for which to check.
+ * @param packageName The package for which to check.
+ * @param superImpl The super implementation.
+ * @return The app op check result.
+ */
+ int checkAudioOperation(int code, int usage, int uid, String packageName,
+ QuadFunction<Integer, Integer, Integer, String, Integer> superImpl);
+
+ /**
+ * Allows overriding note operation behavior.
+ *
+ * @param code The op code to note.
+ * @param uid The UID for which to note.
+ * @param packageName The package for which to note.
+ * @param superImpl The super implementation.
+ * @return The app op note result.
+ */
+ int noteOperation(int code, int uid, String packageName,
+ TriFunction<Integer, Integer, String, Integer> superImpl);
+ }
+
/**
* Set the currently configured device and profile owners. Specifies the package uid (value)
* that has been configured for each user (key) that has one. These will be allowed privileged