Check PI sender instead of PI creator for BAL permission transfer
Check PI sender instead of PI creator for when the BAL flag provided by the sender is true and the sender has the BAL permission in order to transfer BAL privileges. Test: atest -d BackgroundActivityLaunchTest Bug: 162869907 Change-Id: I502e9e4fcaf3920c2e5a6fe45402e5ec88c911a5
This commit is contained in:
@@ -1328,26 +1328,23 @@ class ActivityStarter {
|
||||
: (realCallingAppId == Process.SYSTEM_UID)
|
||||
|| realCallingUidProcState <= ActivityManager.PROCESS_STATE_PERSISTENT_UI;
|
||||
|
||||
// If caller a legacy app, we won't check if caller has BAL permission.
|
||||
final boolean isPiBalOptionEnabled = CompatChanges.isChangeEnabled(
|
||||
ENABLE_PENDING_INTENT_BAL_OPTION, callingUid);
|
||||
|
||||
// Legacy behavior allows to use caller foreground state to bypass BAL restriction.
|
||||
final boolean balAllowedByPiSender =
|
||||
PendingIntentRecord.isPendingIntentBalAllowedByCaller(checkedOptions);
|
||||
|
||||
if (balAllowedByPiSender && realCallingUid != callingUid) {
|
||||
if (isPiBalOptionEnabled) {
|
||||
if (ActivityManager.checkComponentPermission(
|
||||
android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND,
|
||||
realCallingUid, -1, true)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
if (DEBUG_ACTIVITY_STARTS) {
|
||||
Slog.d(TAG, "Activity start allowed: realCallingUid (" + realCallingUid
|
||||
+ ") has BAL permission.");
|
||||
}
|
||||
return false;
|
||||
// If the caller is a legacy app, we won't check if the caller has BAL permission.
|
||||
final boolean isPiBalOptionEnabled = CompatChanges.isChangeEnabled(
|
||||
ENABLE_PENDING_INTENT_BAL_OPTION, realCallingUid);
|
||||
if (isPiBalOptionEnabled && ActivityManager.checkComponentPermission(
|
||||
android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND,
|
||||
realCallingUid, -1, true)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
if (DEBUG_ACTIVITY_STARTS) {
|
||||
Slog.d(TAG, "Activity start allowed: realCallingUid (" + realCallingUid
|
||||
+ ") has BAL permission.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// don't abort if the realCallingUid has a visible window
|
||||
|
||||
Reference in New Issue
Block a user