diff options
| author | 2022-12-05 14:33:51 +0000 | |
|---|---|---|
| committer | 2022-12-05 14:33:51 +0000 | |
| commit | e5a82fc9a2a9973c63abccb4a618147346e83022 (patch) | |
| tree | 55e1c0b2e33ec1af3ecad79e8d6f31b7fb6febdd | |
| parent | bfdf347dd899cbc355f8af7ba5f1fba855822dbf (diff) | |
| parent | b776aa9e89573499db8655e23e477484c2d097ec (diff) | |
Merge "Add hidden Binder.getCallingUidOrWtf"
| -rw-r--r-- | core/java/android/os/Binder.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index 0f3ed19e091c..2d244a9b469d 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -355,6 +355,26 @@ public class Binder implements IBinder { } /** + * Return the Linux UID assigned to the process that sent the transaction + * currently being processed. + * + * Logs WTF if the current thread is not currently + * executing an incoming transaction and the calling identity has not been + * explicitly set with {@link #clearCallingIdentity()} + * + * @hide + */ + public static final int getCallingUidOrWtf() { + if (!isDirectlyHandlingTransaction() && !hasExplicitIdentity()) { + Log.wtf(TAG, + "Thread is not in a binder transaction, " + + "and the calling identity has not been " + + "explicitly set with clearCallingIdentity"); + } + return getCallingUid(); + } + + /** * Return the UserHandle assigned to the process that sent you the * current transaction that is being processed. This is the user * of the caller. It is distinct from {@link #getCallingUid()} in that a |