AppOpsManager.UnsafeCheckOp(String, Int32, String) Method

Definition

Do a quick check for whether an application might be able to perform an operation.

[Android.Runtime.Register("unsafeCheckOp", "(Ljava/lang/String;ILjava/lang/String;)I", "GetUnsafeCheckOp_Ljava_lang_String_ILjava_lang_String_Handler", ApiSince=29)]
public virtual Android.App.AppOpsManagerMode UnsafeCheckOp (string op, int uid, string packageName);
[<Android.Runtime.Register("unsafeCheckOp", "(Ljava/lang/String;ILjava/lang/String;)I", "GetUnsafeCheckOp_Ljava_lang_String_ILjava_lang_String_Handler", ApiSince=29)>]
abstract member UnsafeCheckOp : string * int * string -> Android.App.AppOpsManagerMode
override this.UnsafeCheckOp : string * int * string -> Android.App.AppOpsManagerMode

Parameters

op
String

The operation to check. One of the OPSTR_* constants.

uid
Int32

The user id of the application attempting to perform the operation.

packageName
String

The name of the application attempting to perform the operation.

Returns

Returns #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).

Attributes

Remarks

Do a quick check for whether an application might be able to perform an operation. This is <em>not</em> a security check; you must use #noteOp(String, int, String, String, String) or #startOp(String, int, String, String, 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.

Important things this will not do (which you need to ultimate use #noteOp(String, int, String, String, String) or #startOp(String, int, String, String, String) to cover):

<ul> <li>Verifying the uid and package are consistent, so callers can't spoof their identity.</li> <li>Taking into account the current foreground/background state of the app; apps whose mode varies by this state will always be reported as #MODE_ALLOWED.</li> </ul>

Java documentation for android.app.AppOpsManager.unsafeCheckOp(java.lang.String, int, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to