diff options
author | Svet Ganov <svetoslavganov@google.com> | 2015-04-28 18:39:06 -0700 |
---|---|---|
committer | Svet Ganov <svetoslavganov@google.com> | 2015-04-29 08:30:48 -0700 |
commit | fbf01f77969c1b46d1ffb517a142381c9a914eb8 (patch) | |
tree | 922ad40f611cbfae5216a9945f45dbd82197e3d0 /core/java/android/app | |
parent | 5af4cc3922e8e1b6e1c89ee438c40c89980583ac (diff) | |
download | frameworks_base-fbf01f77969c1b46d1ffb517a142381c9a914eb8.zip frameworks_base-fbf01f77969c1b46d1ffb517a142381c9a914eb8.tar.gz frameworks_base-fbf01f77969c1b46d1ffb517a142381c9a914eb8.tar.bz2 |
Add API to get app op for a permission
Change-Id: Id75d8fca6654c694fb78d1b4a3564b01e90a4e78
Diffstat (limited to 'core/java/android/app')
-rw-r--r-- | core/java/android/app/AppOpsManager.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 223d528..48e380b 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -726,6 +726,16 @@ public class AppOpsManager { false }; + /** + * This is a mapping from a permission name to public app op name. + */ + private static final ArrayMap<String, String> sPermToOp = new ArrayMap<>(); + static { + sPermToOp.put(Manifest.permission.ACCESS_COARSE_LOCATION, OPSTR_COARSE_LOCATION); + sPermToOp.put(Manifest.permission.ACCESS_FINE_LOCATION, OPSTR_FINE_LOCATION); + sPermToOp.put(Manifest.permission.PACKAGE_USAGE_STATS, OPSTR_GET_USAGE_STATS); + } + private static HashMap<String, Integer> sOpStrToOp = new HashMap<String, Integer>(); static { @@ -1066,6 +1076,21 @@ public class AppOpsManager { } /** + * Gets the app op name associated with a given permission. + * The app op name is one of the public constants defined + * in this class such as {@link #OPSTR_COARSE_LOCATION}. + * + * @param permission The permission. + * @return The app op associated with the permission or null. + * + * @hide + */ + @SystemApi + public static String permissionToOp(String permission) { + return sPermToOp.get(permission); + } + + /** * Monitor for changes to the operating mode for the given op in the given app package. * @param op The operation to monitor, one of OPSTR_*. * @param packageName The name of the application to monitor. |