@Implements(android.app.AppOpsManager.class) public class ShadowAppOpsManager extends Object
Modifier and Type | Class | Description |
---|---|---|
static class |
ShadowAppOpsManager.ModeAndException |
Class holding usage mode and excpetion packages.
|
Modifier and Type | Field | Description |
---|---|---|
protected static int |
DURATION |
|
protected static long |
OP_TIME |
|
protected static String |
PROXY_PACKAGE |
|
protected static int |
PROXY_UID |
|
protected static long |
REJECT_TIME |
Constructor | Description |
---|---|
ShadowAppOpsManager() |
Modifier and Type | Method | 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) |
|
protected void |
finishOp(String op,
int uid,
String packageName,
String attributionTag) |
Removes a fake long-running operation from the set.
|
List<AppOpsManager.PackageOps> |
getOpsForPackage(int uid,
String packageName,
int[] ops) |
|
protected List<AppOpsManager.PackageOps> |
getOpsForPackage(int uid,
String packageName,
String[] ops) |
|
ShadowAppOpsManager.ModeAndException |
getRestriction(int code,
int usage) |
|
protected boolean |
isOpActive(String op,
int uid,
String packageName) |
Checks whether the given op is active, i.e.
|
int |
noteOp(int op,
int uid,
String packageName) |
|
protected int |
noteOp(int op,
int uid,
String packageName,
String attributionTag,
String message) |
|
protected int |
noteOpNoThrow(int op,
int uid,
String packageName) |
|
protected int |
noteOpNoThrow(int op,
int uid,
String packageName,
String attributionTag,
String message) |
|
protected int |
noteProxyOpNoThrow(int op,
String proxiedPackageName) |
|
static void |
reset() |
|
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 int |
startOp(String op,
int uid,
String packageName,
String attributionTag,
String message) |
Stores a fake long-running operation.
|
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) |
|
int |
unsafeCheckOpRawNoThrow(String op,
int uid,
String packageName) |
Like
unsafeCheckOpNoThrow(String, int, String) but returns the raw mode
associated with the op. |
protected static final long OP_TIME
protected static final long REJECT_TIME
protected static final int DURATION
protected static final int PROXY_UID
protected static final String PROXY_PACKAGE
@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)
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)
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=29) public int unsafeCheckOpNoThrow(String op, int uid, String packageName)
@Implementation(minSdk=30) protected int startOp(String op, int uid, String packageName, String attributionTag, String message)
@Implementation(minSdk=30) protected void finishOp(String op, int uid, String packageName, String attributionTag)
@Implementation(minSdk=30) protected boolean isOpActive(String op, int uid, String packageName)
startOp(String, int,
String, String, String)
without finishOp(String, int, String, String)
yet.@Implementation(minSdk=29) public int unsafeCheckOpRawNoThrow(String op, int uid, String packageName)
unsafeCheckOpNoThrow(String, int, String)
but returns the raw mode
associated with the op. Does not throw a security exception, does not translate AppOpsManager.MODE_FOREGROUND
.@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)
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=30) protected int noteOp(int op, int uid, String packageName, String attributionTag, String message)
@Implementation(minSdk=19) protected int noteOpNoThrow(int op, int uid, String packageName)
@Implementation(minSdk=30) protected int noteOpNoThrow(int op, int uid, String packageName, String attributionTag, String message)
@Implementation(minSdk=23, maxSdk=29) @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=29) @HiddenApi protected List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, String[] 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)
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)
@Resetter public static void reset()