AppOpsManager.NoteOp Method

Definition

Overloads

Name Description
NoteOp(String, Int32, String)

This method was deprecated in API level 30.

NoteOp(String, Int32, String, String, String)

Make note of an application performing an operation and check if the application is allowed to perform it.

NoteOp(String, Int32, String)

This method was deprecated in API level 30.

[Android.Runtime.Register("noteOp", "(Ljava/lang/String;ILjava/lang/String;)I", "GetNoteOp_Ljava_lang_String_ILjava_lang_String_Handler")]
public virtual Android.App.AppOpsManagerMode NoteOp(string op, int uid, string packageName);
[<Android.Runtime.Register("noteOp", "(Ljava/lang/String;ILjava/lang/String;)I", "GetNoteOp_Ljava_lang_String_ILjava_lang_String_Handler")>]
abstract member NoteOp : string * int * string -> Android.App.AppOpsManagerMode
override this.NoteOp : string * int * string -> Android.App.AppOpsManagerMode

Parameters

op
String

String: This value cannot be null.

uid
Int32

int

packageName
String

String: This value cannot be null.

Returns

Attributes

Remarks

This method was deprecated in API level 30. Use noteOp(String,int,String,String,String) instead

Android reference for android.app.AppOpsManager.noteOp.

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

NoteOp(String, Int32, String, String, String)

Make note of an application performing an operation and check if the application is allowed to perform it.

[Android.Runtime.Register("noteOp", "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)I", "GetNoteOp_Ljava_lang_String_ILjava_lang_String_Ljava_lang_String_Ljava_lang_String_Handler", ApiSince=30)]
public virtual Android.App.AppOpsManagerMode NoteOp(string op, int uid, string? packageName, string? attributionTag, string? message);
[<Android.Runtime.Register("noteOp", "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)I", "GetNoteOp_Ljava_lang_String_ILjava_lang_String_Ljava_lang_String_Ljava_lang_String_Handler", ApiSince=30)>]
abstract member NoteOp : string * int * string * string * string -> Android.App.AppOpsManagerMode
override this.NoteOp : string * int * string * string * string -> Android.App.AppOpsManagerMode

Parameters

op
String

String: The operation to note. One of the OPSTR_* constants. This value cannot be null.

uid
Int32

int: The uid of the application attempting to perform the operation.

packageName
String

String: The name of the application attempting to perform the operation. This value may be null.

attributionTag
String

String: The attribution tag of the calling context or null for default attribution

message
String

String: A message describing why the op was noted. This value may be null.

Returns

Attributes

Remarks

Make note of an application performing an operation and check if the application is allowed to perform it. If this is a check that is not preceding the protected operation, use unsafeCheckOp(String, int, String) instead. The identity of the package the app-op is noted for is specified by the uid and packageName parameters. If this is noted for a regular app both should be set and the package needs to be part of the uid. In the very rare case that an app-op is noted for an entity that does not have a package name, the package can be null. As it is possible that a single process contains more than one package the packageName should be read from the context of the caller of the API (in the app process) that eventually triggers this check. If this op is not noted for a running process the packageName cannot be read from the context, but it should be clear which package the note is for. If the uid and packageName do not match this return MODE_IGNORED. Beside the access check this method also records the access. While the access check is based on uid and/or packageName the access recording is done based on the packageName and attributionTag. The attributionTag should be read from the same context the package name is read from. In the case the check is not related to an API call, the attributionTag should be null. Please note that e.g. registering a callback for later is still an API call and the code should store the attribution tag along the package name for being used in this method later. The message parameter only needs to be set when this method is not called in a two-way binder call from the client. In this case the message is a free form text that is meant help the app developer determine what part of the app's code triggered the note. This message is passed back to the app in the OnOpNotedCallback.onAsyncNoted(AsyncNotedAppOp) callback. A good example of a useful message is including the System.identityHashCode(Object) of the listener that will receive data or the name of the manifest-receiver.

Throws: SecurityException If the app has been configured to crash on this op.

Android reference for android.app.AppOpsManager.noteOp.

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