Class ShadowAppOpsManager
AppOpsManager.- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classClass holding usage mode and exception packages.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected static final intprotected static final longprotected static final Stringprotected static final intprotected static final long
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected void__constructor__(Context context, com.android.internal.app.IAppOpsService service) protected static voidprotected intChecks whether op was previously set usingsetMode(java.lang.String, int, java.lang.String, int)intcheckOpNoThrow(int op, int uid, String packageName) LikeAppOpsManager.checkOp(java.lang.String, int, java.lang.String)but instead of throwing aSecurityExceptionit returnsAppOpsManager.MODE_ERRORED.protected intcheckOpNoThrow(String op, int uid, String packageName) Deprecated.protected voidcheckPackage(int uid, String packageName) protected voidRemoves a fake long-running operation from the set.protected voidRemoves a fake long-running operation from the set.getOpsForPackage(int uid, String packageName, int[] ops) protected List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, String[] ops) protected StringgetOpString(int opCode) protected List<AppOpsManager.PackageOps> getPackagesForOps(int[] ops) Returns app op details for all packages for which one ofsetMode(java.lang.String, int, java.lang.String, int)methods was used to set the value of one of the given app ops (it does return those set to 'default' mode, while the true implementation usually doesn't).protected List<AppOpsManager.PackageOps> getPackagesForOps(String[] ops) Returns app op details for all packages for which one ofsetMode(java.lang.String, int, java.lang.String, int)methods was used to set the value of one of the given app ops (it does return those set to 'default' mode, while the true implementation usually doesn't).getRestriction(int code, int usage) booleanisOpActive(String op, int uid, String packageName) Checks whether the given op is active, i.e.intprotected intprotected intnoteOpNoThrow(int op, int uid, String packageName) protected intnoteOpNoThrow(int op, int uid, String packageName, String attributionTag, String message) protected intnoteProxyOpNoThrow(int op, Object attributionSource, String message, boolean skipProxyOperation) protected intnoteProxyOpNoThrow(int op, String proxiedPackageName) protected intnoteProxyOpNoThrow(int op, String proxiedPackageName, int proxiedUid) protected intnoteProxyOpNoThrow(int op, String proxiedPackageName, int proxiedUid, String proxiedAttributionTag, String message) static voidreset()voidInt version ofsetMode(String, int, String, int).voidChange the operating mode for the given op in the given app package.voidsetRestriction(int code, int usage, int mode, String[] exceptionPackages) Sets audio restrictions.protected voidsetUidMode(int op, int uid, int mode) Int version ofsetUidMode(String, int, int).protected voidsetUidMode(String op, int uid, int mode) Change the operating mode for the given op in the given uid space.protected intStores a fake long-running operation.protected intstartOpNoThrow(int op, int uid, String packageName) Stores a fake long-running operation.protected intstartOpNoThrow(String op, int uid, String packageName, String attributionTag, String message) Stores a fake long-running operation.protected voidstartWatchingMode(int op, String packageName, int flags, AppOpsManager.OnOpChangedListener callback) protected voidstartWatchingMode(int op, String packageName, AppOpsManager.OnOpChangedListener callback) protected voidprotected AppOpsManager.OpEntryintunsafeCheckOpNoThrow(String op, int uid, String packageName) protected intunsafeCheckOpRawNoThrow(int op, int uid, String packageName) intunsafeCheckOpRawNoThrow(String op, int uid, String packageName) LikeunsafeCheckOpNoThrow(String, int, String)but returns the raw mode associated with the op.
- 
Field Details- 
OP_TIMEprotected static final long OP_TIME- See Also:
 
- 
REJECT_TIMEprotected static final long REJECT_TIME- See Also:
 
- 
DURATIONprotected static final int DURATION- See Also:
 
- 
PROXY_UIDprotected static final int PROXY_UID- See Also:
 
- 
PROXY_PACKAGE- See Also:
 
 
- 
- 
Constructor Details- 
ShadowAppOpsManagerpublic ShadowAppOpsManager()
 
- 
- 
Method Details- 
__constructor__@Implementation protected void __constructor__(Context context, com.android.internal.app.IAppOpsService service) 
- 
__staticInitializer__
- 
setMode@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 still be applied.This method is public for testing checkOpNoThrow(java.lang.String, int, java.lang.String). IfcheckOpNoThrow(java.lang.String, int, java.lang.String)is called afterwards with theop,uid, andpackageNameprovided, it will return themodeset here.The mode set by this method takes precedence over the mode set by setMode(String, int, String, int). This may not reflect the true implementation.- Parameters:
- 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.
 
- 
setModeInt version ofsetMode(String, int, String, int).This method is public for testing checkOpNoThrow(java.lang.String, int, java.lang.String). IfcheckOpNoThrow(java.lang.String, int, java.lang.String)is called afterwards with theop,uid, andpackageNameprovided, it will return themodeset here.
- 
setUidModeChange the operating mode for the given op in the given uid space.This method is public for testing checkOpNoThrow(java.lang.String, int, java.lang.String). IfcheckOpNoThrow(java.lang.String, int, java.lang.String)is called afterwards with theopanduidprovided, and anypackageName, it will return themodeset here.The mode set by setMode(String, int, String, int)takes precedence over the mode set by this method. This may not reflect the true implementation.- Parameters:
- op- The operation to modify. One of the OPSTR_* constants.
- uid- The user id of the application whose mode will be changed.
 
- 
setUidModeInt version ofsetUidMode(String, int, int).This method is public for testing checkOpNoThrow(java.lang.String, int, java.lang.String). IfcheckOpNoThrow(java.lang.String, int, java.lang.String)is called afterwards with theop,ui, andpackageNameprovided, it will return themodeset here.
- 
getOpString
- 
getPackagesForOps@Implementation(minSdk=29) @HiddenApi @Nonnull protected List<AppOpsManager.PackageOps> getPackagesForOps(@Nullable String[] ops) Returns app op details for all packages for which one ofsetMode(java.lang.String, int, java.lang.String, int)methods was used to set the value of one of the given app ops (it does return those set to 'default' mode, while the true implementation usually doesn't). Also, we don't enforce any permission checks which might be needed in the true implementation.- Parameters:
- ops- The set of operations you are interested in, or null if you want all of them.
- Returns:
- app ops information about each package, containing only ops that were specified as an argument
 
- 
getPackagesForOpsReturns app op details for all packages for which one ofsetMode(java.lang.String, int, java.lang.String, int)methods was used to set the value of one of the given app ops (it does return those set to 'default' mode, while the true implementation usually doesn't). Also, we don't enforce any permission checks which might be needed in the true implementation.- Parameters:
- ops- The set of operations you are interested in, or null if you want all of them.
- Returns:
- app ops information about each package, containing only ops that were specified as an argument
 
- 
unsafeCheckOpNoThrow
- 
unsafeCheckOpRawNoThrow@Implementation(minSdk=30) protected int unsafeCheckOpRawNoThrow(int op, int uid, String packageName) 
- 
unsafeCheckOpRawNoThrow@Implementation(minSdk=29) public int unsafeCheckOpRawNoThrow(String op, int uid, String packageName) LikeunsafeCheckOpNoThrow(String, int, String)but returns the raw mode associated with the op. Does not throw a security exception, does not translateAppOpsManager.MODE_FOREGROUND.
- 
startOp@Implementation(minSdk=30) protected int startOp(String op, int uid, String packageName, String attributionTag, String message) Stores a fake long-running operation. It does not throw if a wrong uid is passed.
- 
startOpNoThrowStores a fake long-running operation. It does not throw if a wrong uid is passed.
- 
startOpNoThrow@Implementation(minSdk=30) protected int startOpNoThrow(String op, int uid, String packageName, String attributionTag, String message) Stores a fake long-running operation. It does not throw if a wrong uid is passed.
- 
finishOpRemoves a fake long-running operation from the set.
- 
finishOp@Implementation(minSdk=30) protected void finishOp(String op, int uid, String packageName, String attributionTag) Removes a fake long-running operation from the set.
- 
checkOpChecks whether op was previously set usingsetMode(java.lang.String, int, java.lang.String, int)
- 
isOpActiveChecks whether the given op is active, i.e. did someone callstartOp(String, int, String, String, String)withoutfinishOp(String, int, String, String)yet.
- 
checkOpNoThrow@Implementation(minSdk=28) @Deprecated protected int checkOpNoThrow(String op, int uid, String packageName) Deprecated.
- 
checkOpNoThrowLikeAppOpsManager.checkOp(java.lang.String, int, java.lang.String)but instead of throwing aSecurityExceptionit returnsAppOpsManager.MODE_ERRORED.Made public for testing setMode(java.lang.String, int, java.lang.String, int)as the method is@hide.
- 
noteOp
- 
noteOp@Implementation(minSdk=30) protected int noteOp(int op, int uid, String packageName, String attributionTag, String message) 
- 
noteOpNoThrow
- 
noteOpNoThrow@Implementation(minSdk=30) protected int noteOpNoThrow(int op, int uid, @Nullable String packageName, @Nullable String attributionTag, @Nullable String message) 
- 
noteProxyOpNoThrow@Implementation(minSdk=23, maxSdk=29) @HiddenApi protected int noteProxyOpNoThrow(int op, String proxiedPackageName) 
- 
noteProxyOpNoThrow@Implementation(minSdk=29, maxSdk=29) @HiddenApi protected int noteProxyOpNoThrow(int op, String proxiedPackageName, int proxiedUid) 
- 
noteProxyOpNoThrow@Implementation(minSdk=30, maxSdk=30) @HiddenApi protected int noteProxyOpNoThrow(int op, String proxiedPackageName, int proxiedUid, String proxiedAttributionTag, String message) 
- 
noteProxyOpNoThrow@RequiresApi(api=31) @Implementation(minSdk=31) protected int noteProxyOpNoThrow(int op, Object attributionSource, String message, boolean skipProxyOperation) 
- 
getOpsForPackage@Implementation @HiddenApi public List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, int[] ops) 
- 
getOpsForPackage@Implementation(minSdk=29) @HiddenApi protected List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, String[] ops) 
- 
checkPackage
- 
setRestriction@Implementation @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.
- 
getRestriction
- 
startWatchingMode@Implementation protected void startWatchingMode(int op, String packageName, AppOpsManager.OnOpChangedListener callback) 
- 
startWatchingMode@Implementation(minSdk=29) protected void startWatchingMode(int op, String packageName, int flags, AppOpsManager.OnOpChangedListener callback) 
- 
stopWatchingMode
- 
toOpEntry
- 
reset
 
-