java.lang.Object | |
↳ | android.app.AppOpsManager |
API for interacting with "application operation" tracking.
This API is not generally intended for third party application developers; most
features are only available to system applications. Obtain an instance of it through
Context.getSystemService
with
Context.APP_OPS_SERVICE
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
AppOpsManager.OnOpChangedListener | Callback for notification of changes to operation state. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | MODE_ALLOWED |
Result from
checkOp(String, int, String)
,
noteOp(String, int, String)
,
startOp(String, int, String)
: the given caller is
allowed to perform the given operation.
|
|||||||||
int | MODE_ERRORED |
Result from
checkOpNoThrow(String, int, String)
,
noteOpNoThrow(String, int, String)
,
startOpNoThrow(String, int, String)
: the
given caller is not allowed to perform the given operation, and this attempt should
cause it to have a fatal error, typically a
SecurityException
.
|
|||||||||
int | MODE_IGNORED |
Result from
checkOp(String, int, String)
,
noteOp(String, int, String)
,
startOp(String, int, 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).
|
|||||||||
String | OPSTR_COARSE_LOCATION | Access to coarse location information. | |||||||||
String | OPSTR_FINE_LOCATION | Access to fine location information. | |||||||||
String | OPSTR_MONITOR_HIGH_POWER_LOCATION | Continually monitoring location data with a relatively high power request. | |||||||||
String | OPSTR_MONITOR_LOCATION | Continually monitoring location data. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Do a quick check for whether an application might be able to perform an operation.
|
||||||||||
|
Like
checkOp(String, int, String)
but instead of throwing a
SecurityException
it
returns
MODE_ERRORED
.
|
||||||||||
|
Do a quick check to validate if a package name belongs to a UID.
|
||||||||||
|
Report that an application is no longer performing an operation that had previously
been started with
startOp(String, int, String)
.
|
||||||||||
|
Make note of an application performing an operation.
|
||||||||||
|
Like
noteOp(String, int, String)
but instead of throwing a
SecurityException
it
returns
MODE_ERRORED
.
|
||||||||||
|
Report that an application has started executing a long-running operation.
|
||||||||||
|
Like
startOp(String, int, String)
but instead of throwing a
SecurityException
it
returns
MODE_ERRORED
.
|
||||||||||
|
Monitor for changes to the operating mode for the given op in the given app package.
|
||||||||||
|
Stop monitoring that was previously started with
startWatchingMode(String, String, AppOpsManager.OnOpChangedListener)
.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Result from
checkOp(String, int, String)
,
noteOp(String, int, String)
,
startOp(String, int, String)
: the given caller is
allowed to perform the given operation.
Result from
checkOpNoThrow(String, int, String)
,
noteOpNoThrow(String, int, String)
,
startOpNoThrow(String, int, String)
: the
given caller is not allowed to perform the given operation, and this attempt should
cause it to have a fatal error, typically a
SecurityException
.
Result from
checkOp(String, int, String)
,
noteOp(String, int, String)
,
startOp(String, int, 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).
Access to coarse location information.
Access to fine location information.
Continually monitoring location data with a relatively high power request.
Continually monitoring location data.
Do a quick check for whether an application might be able to perform an operation.
This is
not
a security check; you must use
noteOp(String, int, String)
or
startOp(String, int, String)
for your actual security checks, which also
ensure that the given uid and package name are consistent. This function can just be
used for a quick check to see if an operation has been disabled for the application,
as an early reject of some work. This does not modify the time stamp or other data
about the operation.
op | The operation to check. 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. |
---|
Like
checkOp(String, int, String)
but instead of throwing a
SecurityException
it
returns
MODE_ERRORED
.
Do a quick check to validate if a package name belongs to a UID.
SecurityException | if the package name doesn't belong to the given UID, or if ownership cannot be verified. |
---|
Report that an application is no longer performing an operation that had previously
been started with
startOp(String, int, String)
. There is no validation of input
or result; the parameters supplied here must be the exact same ones previously passed
in when starting the operation.
Make note of an application performing an operation. Note that you must pass
in both the uid and name of the application to be checked; this function will verify
that these two match, and if not, return
MODE_IGNORED
. If this call
succeeds, the last execution time of the operation for this app will be updated to
the current time.
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. |
---|
Like
noteOp(String, int, String)
but instead of throwing a
SecurityException
it
returns
MODE_ERRORED
.
Report that an application has started executing a long-running operation. Note that you
must pass in both the uid and name of the application to be checked; this function will
verify that these two match, and if not, return
MODE_IGNORED
. If this call
succeeds, the last execution time of the operation for this app will be updated to
the current time and the operation will be marked as "running". In this case you must
later call
finishOp(String, int, String)
to report when the application is no
longer performing the operation.
op | The operation to start. 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. |
---|
Like
startOp(String, int, String)
but instead of throwing a
SecurityException
it
returns
MODE_ERRORED
.
Monitor for changes to the operating mode for the given op in the given app package.
op | The operation to monitor, one of OPSTR_*. |
---|---|
packageName | The name of the application to monitor. |
callback | Where to report changes. |
Stop monitoring that was previously started with
startWatchingMode(String, String, AppOpsManager.OnOpChangedListener)
. All
monitoring associated with this callback will be removed.