Skip to content
Commit b776aa9e authored by mattgilbride's avatar mattgilbride
Browse files

Add hidden Binder.getCallingUidOrWtf

Binder.getCallingUidOrThrow throws if the caller is NOT:
1) Called from within a binder transaction OR
2) Called from within a
   Binder.clearCallingIdentity/restoreCallingIdentity block

Number 2 was added in I162db933f9e52cd6f9f46796bda11ad6216d3d66
to allow us to migrate from Binder.getCallingUid to it. There are
many use cases where callers are not in a Binder transaction, but
have set the calling UID "explicitly" by calling clearCallingIdentity.

In order to further ease the migration from Binder.getCallingUid to
Binder.getCallingUidOrThrow, this hidden API behaves similarly,
but logs at WTF level instead of throwing IllegalStateException.

The motivation is to first migrate to the WTF version, so that
system_server will log and continue. The goal is to only use this
in the system (hence @hide). It will provide early signals as to the
feasibility of a given migration.

For example, its desirable to migrate the permission checking in code
generated by the @EnforcePermission annotation (via the AIDL compiler).
This call site is widely used, and itself subject to mass migrations to
@EnforcePermission instead of manual permission enforcement.

Bug: 252975769
Test: TH
Change-Id: I11ea3fdf889689d76211506e81420e694238ee68
parent 634c15d3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment