Compartir a través de


Binder.SetCallingWorkSourceUid(Int32) Method

Definition

Sets the work source for this thread.

[Android.Runtime.Register("setCallingWorkSourceUid", "(I)J", "", ApiSince=29)]
public static long SetCallingWorkSourceUid (int workSource);
[<Android.Runtime.Register("setCallingWorkSourceUid", "(I)J", "", ApiSince=29)>]
static member SetCallingWorkSourceUid : int -> int64

Parameters

workSource
Int32

The original UID responsible for the binder call.

Returns

token to restore original work source.

Attributes

Remarks

Sets the work source for this thread.

All the following binder calls on this thread will use the provided work source. If this is called during an on-going binder transaction, all the following binder calls will use the work source until the end of the transaction.

The concept of worksource is similar to WorkSource. However, for performance reasons, we only support one UID. This UID represents the original user responsible for the binder calls.

#restoreCallingWorkSource(long) must always be called after setting the worksource.

A typical use case would be

long token = Binder.setCallingWorkSourceUid(uid);
            try {
              // Call an API.
            } finally {
              Binder.restoreCallingWorkSource(token);
            }

The work source will be propagated for future outgoing binder transactions executed on this thread.

Java documentation for android.os.Binder.setCallingWorkSourceUid(int).

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