@Implements(value=android.app.AppOpsManager.class) public class ShadowAppOpsManager extends Object
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__(Context context,
com.android.internal.app.IAppOpsService service) |
int |
checkOpNoThrow(int op,
int uid,
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(String op,
int uid,
String packageName)
Deprecated.
|
protected void |
checkPackage(int uid,
String packageName) |
List<AppOpsManager.PackageOps> |
getOpsForPackage(int uid,
String packageName,
int[] ops) |
ShadowAppOpsManager.ModeAndException |
getRestriction(int code,
int usage) |
int |
noteOp(int op,
int uid,
String packageName) |
protected int |
noteOpNoThrow(int op,
int uid,
String packageName) |
protected int |
noteProxyOpNoThrow(int op,
String proxiedPackageName) |
void |
setMode(int op,
int uid,
String packageName,
int mode)
Int version of
setMode(String, int, String, int) . |
void |
setMode(String op,
int uid,
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,
String[] exceptionPackages)
Sets audio restrictions.
|
protected void |
startWatchingMode(int op,
String packageName,
AppOpsManager.OnOpChangedListener callback) |
protected void |
stopWatchingMode(AppOpsManager.OnOpChangedListener callback) |
protected AppOpsManager.OpEntry |
toOpEntry(Integer op) |
int |
unsafeCheckOpNoThrow(String op,
int uid,
String packageName) |
@Implementation(minSdk=19) protected void __constructor__(Context context, com.android.internal.app.IAppOpsService service)
@Implementation(minSdk=28) @HiddenApi public void setMode(String op, int uid, 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, 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=10000) public int unsafeCheckOpNoThrow(String op, int uid, String packageName)
@Implementation(minSdk=28) @Deprecated protected int checkOpNoThrow(String op, int uid, String packageName)
@Implementation(minSdk=19) @HiddenApi public int checkOpNoThrow(int op, int uid, 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, String packageName)
@Implementation(minSdk=19) protected int noteOpNoThrow(int op, int uid, String packageName)
@Implementation(minSdk=23) @HiddenApi protected int noteProxyOpNoThrow(int op, String proxiedPackageName)
@Implementation(minSdk=19) @HiddenApi public List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, int[] ops)
@Implementation(minSdk=19) protected void checkPackage(int uid, String packageName)
@Implementation(minSdk=21) @HiddenApi public void setRestriction(int code, int usage, int mode, 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, String packageName, AppOpsManager.OnOpChangedListener callback)
@Implementation(minSdk=19) protected void stopWatchingMode(AppOpsManager.OnOpChangedListener callback)
protected AppOpsManager.OpEntry toOpEntry(Integer op)