Grant app visibility if launching app opts in to sharing identity

Android U introduced new APIs to allow a launching app to opt-in to
sharing its identity with a launched activity; this allows the
launched activity to perform authorization checks against the
launching app. This commit grants app visibility to allow the
launched activity to access the details and signing identity of
the launching app.

Bug: 262605364
Test: atest ShareIdentityTest
Change-Id: I2b4b2acbd127b01f231c4852704ba69e31c4aaed
This commit is contained in:
Michael Groover
2022-12-20 17:28:00 -06:00
parent a1fba70f4f
commit d8e0b093e4

View File

@@ -1661,6 +1661,12 @@ class ActivityStarter {
pmInternal.grantImplicitAccess(mStartActivity.mUserId, mIntent,
UserHandle.getAppId(mStartActivity.info.applicationInfo.uid) /*recipient*/,
resultToUid /*visible*/, true /*direct*/);
} else if (mStartActivity.mShareIdentity) {
final PackageManagerInternal pmInternal =
mService.getPackageManagerInternalLocked();
pmInternal.grantImplicitAccess(mStartActivity.mUserId, mIntent,
UserHandle.getAppId(mStartActivity.info.applicationInfo.uid) /*recipient*/,
r.launchedFromUid /*visible*/, true /*direct*/);
}
final Task startedTask = mStartActivity.getTask();
if (newTask) {