am e3538083: Merge "Add API to get app op for a permission" into mnc-dev
* commit 'e35380839e582a98477ba9181460ebfee1c74a9f': Add API to get app op for a permission
This commit is contained in:
@@ -3949,6 +3949,7 @@ package android.app {
|
||||
method public void finishOp(java.lang.String, int, java.lang.String);
|
||||
method public int noteOp(java.lang.String, int, java.lang.String);
|
||||
method public int noteOpNoThrow(java.lang.String, int, java.lang.String);
|
||||
method public static java.lang.String permissionToOp(java.lang.String);
|
||||
method public int startOp(java.lang.String, int, java.lang.String);
|
||||
method public int startOpNoThrow(java.lang.String, int, java.lang.String);
|
||||
method public void startWatchingMode(java.lang.String, java.lang.String, android.app.AppOpsManager.OnOpChangedListener);
|
||||
|
||||
@@ -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 {
|
||||
@@ -1065,6 +1075,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_*.
|
||||
|
||||
Reference in New Issue
Block a user