public final class AppOpsManagerCompat extends Object
Modifier and Type | Field and Description |
---|---|
static int |
MODE_ALLOWED
Result from
noteOp(android.content.Context, java.lang.String, int, java.lang.String) : the given caller is allowed to
perform the given operation. |
static int |
MODE_DEFAULT
Result from
noteOp(android.content.Context, java.lang.String, int, java.lang.String) : the given caller should use its default
security check. |
static int |
MODE_IGNORED
Result from
noteOp(android.content.Context, java.lang.String, int, java.lang.String) : the given caller is not allowed to perform
the given operation, and this attempt should silently fail (it
should not cause the app to crash). |
Modifier and Type | Method and Description |
---|---|
static int |
noteOp(Context context,
String op,
int uid,
String packageName)
Make note of an application performing an operation.
|
static int |
noteProxyOp(Context context,
String op,
String proxiedPackageName)
Make note of an application performing an operation on behalf of another
application when handling an IPC.
|
static String |
permissionToOp(String permission)
Gets the app op name associated with a given permission.
|
public static final int MODE_ALLOWED
noteOp(android.content.Context, java.lang.String, int, java.lang.String)
: the given caller is allowed to
perform the given operation.public static final int MODE_IGNORED
noteOp(android.content.Context, java.lang.String, int, java.lang.String)
: the given caller is not allowed to perform
the given operation, and this attempt should silently fail (it
should not cause the app to crash).public static final int MODE_DEFAULT
noteOp(android.content.Context, java.lang.String, int, java.lang.String)
: the given caller should use its default
security check. This mode is not normally used; it should only be used
with appop permissions, and callers must explicitly check for it and
deal with it.public static String permissionToOp(@NonNull String permission)
permission
- The permission.public static int noteOp(@NonNull Context context, @NonNull String op, int uid, @NonNull String packageName)
MODE_IGNORED
. If this call
succeeds, the last execution time of the operation for this app will be updated to
the current time.context
- Your context.op
- The operation to note. One of the OPSTR_* constants.uid
- The user id of the application attempting to perform the operation.packageName
- The name of the application attempting to perform the operation.MODE_ALLOWED
if the operation is allowed, or
MODE_IGNORED
if it is not allowed and should be silently ignored (without
causing the app to crash).SecurityException
- If the app has been configured to crash on this op.public static int noteProxyOp(@NonNull Context context, @NonNull String op, @NonNull String proxiedPackageName)
MODE_IGNORED
. If this call
succeeds, the last execution time of the operation for the proxied app and
your app will be updated to the current time.context
- Your context.op
- The operation to note. One of the OPSTR_* constants.proxiedPackageName
- The name of the application calling into the proxy application.MODE_ALLOWED
if the operation is allowed, or
MODE_IGNORED
if it is not allowed and should be silently ignored (without
causing the app to crash).SecurityException
- If the app has been configured to crash on this op.