Add ComponentCaller with getUid(), getPackage() APIs for Activity
In preparation for the future CL where we're going to check activity caller access to content URIs, sending this first CL to introduce ComponentCaller class (which will contain that check API) and introduce the set of two methods for querying UID and package name there, as agreed. To give some context, currently, if an app launches another app with startActivity(intent), the launched app can't check if the caller had access to content URIs provided in the intent. That is because the launched app would have to have access to the caller's identity, which can't be achieved for usual cases unless the caller shares their identity or the launched app is privileged enough. Hence, this change is one of the several changes that will mitigate this issue. In this change, we're introducing: 1. A new ComponentCaller class that represents the calling app via tokens. For now, it has 2 APIs: - getUid() - returns the caller's UID - getPackage() - returns the caller's package In V, apps can only retrieve ComponentCaller instances belonging to Activity, so these 2 APIs have similar restrictions as Activity#getLaunchedFromUid/Package(), i.e. the caller must have opted in to sharing their identity, or the caller is considered internal. 2. Activity#getInitialCaller for apps to retrieve the initial caller. Bug: 293467489 Test: atest CtsAndroidAppTestCases:android.app.cts.ShareIdentityTest Test: atest FrameworksMockingCoreTests:android.app.activity.ActivityThreadClientTest Test: atest FrameworksCoreTests:ObjectPoolTests Test: atest FrameworksCoreTests:TransactionParcelTests Change-Id: I67ce2f2c04c9639f362aca8b171f5b9baaf6513a
Loading
Please register or sign in to comment