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

Commit 8f07029f authored by Andrii Kulian's avatar Andrii Kulian
Browse files

Fix consequent activity launch on virtual displays

When activity is launched from a secondary display, it
by default should land on the same display. This was broken
by recent restrictions added for virtual displays.

Bug: 63117330
Test: android.server.cts.ActivityManagerDisplayTests
Test: #testConsequentLaunchActivityFromVirtualDisplay
Test: #testConsequentLaunchActivityFromVirtualDisplayToTargetDisplay
Test: #testConsequentLaunchActivityFromVirtualDisplayNoEmbedding
Change-Id: Ie8adfe8eacb3cf8a05115c13bcad881dba51badb
parent 3df5aa6f
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -1705,6 +1705,9 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            return true;
            return true;
        }
        }


        // Check if caller is already present on display
        final boolean uidPresentOnDisplay = activityDisplay.isUidPresent(callingUid);

        final int displayOwnerUid = activityDisplay.mDisplay.getOwnerUid();
        final int displayOwnerUid = activityDisplay.mDisplay.getOwnerUid();
        if (activityDisplay.mDisplay.getType() == TYPE_VIRTUAL && displayOwnerUid != SYSTEM_UID
        if (activityDisplay.mDisplay.getType() == TYPE_VIRTUAL && displayOwnerUid != SYSTEM_UID
                && displayOwnerUid != aInfo.applicationInfo.uid) {
                && displayOwnerUid != aInfo.applicationInfo.uid) {
@@ -1717,7 +1720,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            }
            }
            // Check if the caller is allowed to embed activities from other apps.
            // Check if the caller is allowed to embed activities from other apps.
            if (mService.checkPermission(ACTIVITY_EMBEDDING, callingPid, callingUid)
            if (mService.checkPermission(ACTIVITY_EMBEDDING, callingPid, callingUid)
                    == PERMISSION_DENIED) {
                    == PERMISSION_DENIED && !uidPresentOnDisplay) {
                if (DEBUG_TASKS) Slog.d(TAG, "Launch on display check:"
                if (DEBUG_TASKS) Slog.d(TAG, "Launch on display check:"
                        + " disallow activity embedding without permission.");
                        + " disallow activity embedding without permission.");
                return false;
                return false;
@@ -1738,8 +1741,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            return true;
            return true;
        }
        }


        // Check if caller is present on display
        if (uidPresentOnDisplay) {
        if (activityDisplay.isUidPresent(callingUid)) {
            if (DEBUG_TASKS) Slog.d(TAG, "Launch on display check:"
            if (DEBUG_TASKS) Slog.d(TAG, "Launch on display check:"
                    + " allow launch for caller present on the display");
                    + " allow launch for caller present on the display");
            return true;
            return true;