@Implements(value=android.app.AppOpsManager.class) public class ShadowAppOpsManager extends java.lang.Object
Shadow for the AppOpsManager
.
Modifier and Type | Class and Description |
---|---|
static class |
ShadowAppOpsManager.ModeAndException
Class holding usage mode and excpetion packages.
|
Constructor and Description |
---|
ShadowAppOpsManager() |
Modifier and Type | Method and Description |
---|---|
protected void |
__constructor__(android.content.Context context,
com.android.internal.app.IAppOpsService service) |
int |
checkOpNoThrow(int op,
int uid,
java.lang.String packageName)
Like
AppOpsManager.checkOp(java.lang.String, int, java.lang.String) but instead of throwing a SecurityException it returns AppOpsManager.MODE_ERRORED . |
protected int |
checkOpNoThrow(java.lang.String op,
int uid,
java.lang.String packageName)
Deprecated.
|
protected void |
checkPackage(int uid,
java.lang.String packageName) |
java.util.List<android.app.AppOpsManager.PackageOps> |
getOpsForPackage(int uid,
java.lang.String packageName,
int[] ops) |
ShadowAppOpsManager.ModeAndException |
getRestriction(int code,
int usage) |
int |
noteOp(int op,
int uid,
java.lang.String packageName) |
void |
setMode(int op,
int uid,
java.lang.String packageName,
int mode)
Int version of
setMode(String, int, String, int) . |
void |
setMode(java.lang.String op,
int uid,
java.lang.String packageName,
int mode)
Change the operating mode for the given op in the given app package.
|
void |
setRestriction(int code,
int usage,
int mode,
java.lang.String[] exceptionPackages)
Sets audio restrictions.
|
protected void |
startWatchingMode(int op,
java.lang.String packageName,
android.app.AppOpsManager.OnOpChangedListener callback) |
protected void |
stopWatchingMode(android.app.AppOpsManager.OnOpChangedListener callback) |
@Implementation(minSdk=19) protected void __constructor__(android.content.Context context, com.android.internal.app.IAppOpsService service)
@Implementation(minSdk=28) @HiddenApi public void setMode(java.lang.String op, int uid, java.lang.String packageName, int mode)
Change the operating mode for the given op in the given app package. You must pass in both the uid and name of the application whose mode is being modified; if these do not match, the modification will not be applied.
This method is public for testing checkOpNoThrow(java.lang.String, int, java.lang.String)
. If checkOpNoThrow(java.lang.String, int, java.lang.String)
is called afterwards with the op
, ui
, and packageName
provided, it will return the mode
set here.
op
- The operation to modify. One of the OPSTR_* constants.uid
- The user id of the application whose mode will be changed.packageName
- The name of the application package name whose mode will be changed.@Implementation(minSdk=19) @HiddenApi public void setMode(int op, int uid, java.lang.String packageName, int mode)
Int version of setMode(String, int, String, int)
.
This method is public for testing checkOpNoThrow(java.lang.String, int, java.lang.String)
. If checkOpNoThrow(java.lang.String, int, java.lang.String)
is * called afterwards with the op
, ui
, and packageName
provided, it will * return the mode
set here.
@Implementation(minSdk=28) @Deprecated protected int checkOpNoThrow(java.lang.String op, int uid, java.lang.String packageName)
@Implementation(minSdk=19) @HiddenApi public int checkOpNoThrow(int op, int uid, java.lang.String packageName)
Like AppOpsManager.checkOp(java.lang.String, int, java.lang.String)
but instead of throwing a SecurityException
it returns AppOpsManager.MODE_ERRORED
.
Made public for testing setMode(java.lang.String, int, java.lang.String, int)
as the method is .
@Implementation(minSdk=19) public int noteOp(int op, int uid, java.lang.String packageName)
@Implementation(minSdk=19) @HiddenApi public java.util.List<android.app.AppOpsManager.PackageOps> getOpsForPackage(int uid, java.lang.String packageName, int[] ops)
@Implementation(minSdk=19) protected void checkPackage(int uid, java.lang.String packageName)
@Implementation(minSdk=21) @HiddenApi public void setRestriction(int code, int usage, int mode, java.lang.String[] exceptionPackages)
Sets audio restrictions.
This method is public for testing, as the original method is @hide
.
public ShadowAppOpsManager.ModeAndException getRestriction(int code, int usage)
@Implementation(minSdk=19) @HiddenApi protected void startWatchingMode(int op, java.lang.String packageName, android.app.AppOpsManager.OnOpChangedListener callback)
@Implementation(minSdk=19) protected void stopWatchingMode(android.app.AppOpsManager.OnOpChangedListener callback)