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

Commit 5de953a9 authored by Achim Thesmann's avatar Achim Thesmann
Browse files

Feature Flag for restricting PendingIntents by same UID

One of the common cases impacted by BAL blocking are apps that create a
PendingIntent and send it itself. Since both sender and creator have the
same permissions (as they are running as the same UID) and the
PendingIntent is not injected from another app, there should be no
security risk.

Test: atest BackgroundActivityLaunchTest
Bug: 314033453
Change-Id: I584536f1947773fbe26f56b8b72969b82bddace0
parent ccfbc759
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -7,6 +7,13 @@ flag {
    bug: "296478951"
    bug: "296478951"
}
}


flag {
    name: "bal_require_opt_in_same_uid"
    namespace: "responsible_apis"
    description: "Require the PendingIntent creator/sender to opt in if it is the same UID"
    bug: "296478951"
}

flag {
flag {
    name: "bal_dont_bring_existing_background_task_stack_to_fg"
    name: "bal_dont_bring_existing_background_task_stack_to_fg"
    namespace: "responsible_apis"
    namespace: "responsible_apis"
+3 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import static com.android.server.wm.ActivityTaskManagerService.APP_SWITCH_ALLOW;
import static com.android.server.wm.ActivityTaskManagerService.APP_SWITCH_FG_ONLY;
import static com.android.server.wm.ActivityTaskManagerService.APP_SWITCH_FG_ONLY;
import static com.android.server.wm.ActivityTaskSupervisor.getApplicationLabel;
import static com.android.server.wm.ActivityTaskSupervisor.getApplicationLabel;
import static com.android.window.flags.Flags.balRequireOptInByPendingIntentCreator;
import static com.android.window.flags.Flags.balRequireOptInByPendingIntentCreator;
import static com.android.window.flags.Flags.balRequireOptInSameUid;
import static com.android.window.flags.Flags.balShowToasts;
import static com.android.window.flags.Flags.balShowToasts;
import static com.android.window.flags.Flags.balShowToastsBlocked;
import static com.android.window.flags.Flags.balShowToastsBlocked;
import static com.android.server.wm.PendingRemoteAnimationRegistry.TIMEOUT_MS;
import static com.android.server.wm.PendingRemoteAnimationRegistry.TIMEOUT_MS;
@@ -277,6 +278,8 @@ public class BackgroundActivityStartController {
                mAutoOptInReason = "notPendingIntent";
                mAutoOptInReason = "notPendingIntent";
            } else if (balRequireOptInByPendingIntentCreator() && mIsCallForResult) {
            } else if (balRequireOptInByPendingIntentCreator() && mIsCallForResult) {
                mAutoOptInReason = "callForResult";
                mAutoOptInReason = "callForResult";
            } else if (callingUid == realCallingUid && !balRequireOptInSameUid()) {
                mAutoOptInReason = "sameUid";
            } else {
            } else {
                mAutoOptInReason = null;
                mAutoOptInReason = null;
            }
            }