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

Commit 3eaaa968 authored by Christophe Pinelli's avatar Christophe Pinelli Committed by Android Build Coastguard Worker
Browse files

Restrict activity launch when caller is running in the background

Test: atest BackgroundActivityLaunchTest#testBackgroundActivityBlockedInStartNextMatchingActivity
Bug: 230492947
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e1edaa27ea2f6911977556c5bba876a2319d5e2d)
Merged-In: Ic88dd1e79b867b44cdcd6fc86650f5de6ebcc23d
Change-Id: Ic88dd1e79b867b44cdcd6fc86650f5de6ebcc23d
parent d6f71887
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -1412,6 +1412,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {

            final long origId = Binder.clearCallingIdentity();
            // TODO(b/64750076): Check if calling pid should really be -1.
            try {
                if (options == null) {
                    options = new SafeActivityOptions(ActivityOptions.makeBasic());
                }
                options.getOptions(r).setAvoidMoveToFront();
                final int res = getActivityStartController()
                    .obtainStarter(intent, "startNextMatchingActivity")
                    .setCaller(r.app.getThread())
@@ -1428,13 +1433,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                    .setRealCallingUid(r.launchedFromUid)
                    .setActivityOptions(options)
                    .execute();
            Binder.restoreCallingIdentity(origId);

                r.finishing = wasFinishing;
            if (res != ActivityManager.START_SUCCESS) {
                return false;
                return res == ActivityManager.START_SUCCESS;
            } finally {
                Binder.restoreCallingIdentity(origId);
            }
            return true;
        }
    }