Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b91b842b authored by Nan Wu's avatar Nan Wu Committed by Achim Thesmann
Browse files

Prevent PI creator to set pendingIntentBackgroundActiivtyLaunchAllowedByPermission to true

This activity option is only meant to be set by PI sender, evidenced
by the checking logic in BackgroundActivityStartController.
checkBackgroundActivityStartAllowedBySender checks it.
checkBackgroundActivityStartAllowedByCaller does not check it.

Bug: 272740688
Test: Manual test. Atest BackgroundActivityLaunchTest
Change-Id: Ifa40208b2fb934d89bff10786ad0c78ce8ab9571
parent 75c8b599
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -146,6 +146,21 @@ public class PendingIntentController {
                        ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED);
            }

            if (opts != null && opts.isPendingIntentBackgroundActivityLaunchAllowedByPermission()) {
                Slog.wtf(TAG,
                        "Resetting option pendingIntentBackgroundActivityLaunchAllowedByPermission"
                                + " which is set by the pending intent creator ("
                                + packageName
                                + ") because this option is meant for the pending intent sender");
                if (CompatChanges.isChangeEnabled(PendingIntent.PENDING_INTENT_OPTIONS_CHECK,
                        callingUid)) {
                    throw new IllegalArgumentException(
                            "pendingIntentBackgroundActivityLaunchAllowedByPermission "
                                    + "can not be set by creator of a PendingIntent");
                }
                opts.setPendingIntentBackgroundActivityLaunchAllowedByPermission(false);
            }

            final boolean noCreate = (flags & PendingIntent.FLAG_NO_CREATE) != 0;
            final boolean cancelCurrent = (flags & PendingIntent.FLAG_CANCEL_CURRENT) != 0;
            final boolean updateCurrent = (flags & PendingIntent.FLAG_UPDATE_CURRENT) != 0;