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

Commit c85fa896 authored by Hani Kazmi's avatar Hani Kazmi
Browse files

Allow ASM launch if callingUid on top

Fix for
CtsAppTestCases:android.app.cts.AppTaskTests#testStartActivityInTask_NoNewTask.
We would previosuly not allow launches by the top uid for in task starts if
ActivityStarter did not have a source record present as well.

Bug: 288759911
Test: atest AppTaskTest BackgroundActivityLaunchTest
ActivitySecuityModelTest

Change-Id: I0fa72c8b2445d98f909eeeac247f3da9b064df71
parent 68c816f3
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -1993,11 +1993,7 @@ class ActivityStarter {
            }
        }

        boolean shouldBlockActivityStart = true;
        // Used for logging/toasts. Would we block the start if target sdk was U and feature was
        // enabled?
        boolean wouldBlockActivityStartIgnoringFlags = true;

        Pair<Boolean, Boolean> pair = null;
        if (mSourceRecord != null) {
            boolean passesAsmChecks = true;
            Task sourceTask = mSourceRecord.getTask();
@@ -2013,14 +2009,25 @@ class ActivityStarter {

            if (passesAsmChecks) {
                Task taskToCheck = taskToFront ? sourceTask : targetTask;
                // first == false means Should Block
                // second == false means Would Block disregarding flags
                Pair<Boolean, Boolean> pair = ActivityTaskSupervisor
                pair = ActivityTaskSupervisor
                        .doesTopActivityMatchingUidExistForAsm(taskToCheck, mSourceRecord.getUid(),
                                mSourceRecord);
                shouldBlockActivityStart = !pair.first;
                wouldBlockActivityStartIgnoringFlags = !pair.second;
            }
        } else if (!taskToFront) {
            // We don't have a sourceRecord, and we're launching into an existing task.
            // Allow if callingUid is top of stack.
            pair = ActivityTaskSupervisor
                    .doesTopActivityMatchingUidExistForAsm(targetTask, mCallingUid,
                            /*sourceRecord*/null);
        }

        boolean shouldBlockActivityStart = true;
        if (pair != null) {
            // We block if feature flag is enabled
            shouldBlockActivityStart = !pair.first;
            // Used for logging/toasts. Would we block if target sdk was U and feature was
            // enabled? If so, we can't return here but we also might not block at the end
            boolean wouldBlockActivityStartIgnoringFlags = !pair.second;

            if (!wouldBlockActivityStartIgnoringFlags) {
                return true;