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

Commit 94b2e552 authored by Lingyu Feng's avatar Lingyu Feng
Browse files

Guard "Prevent activity being launched on a display that cannot host

tasks" by the display content mode flag

Since Display.canHostTasks() is guarded by the display content mode
flag, we should check both flags when determining if a display is being
used for mirroring. Otherwise, an exception will be thrown even if the
display is not mirroring.

Bug: 427816070
Flag: com.android.server.display.feature.flags.enable_display_content_mode_management
Test: presubmit
Change-Id: I344d39b7bfa279c4e374ae71eea0f18156c539c7
parent 559b2b6a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1281,7 +1281,8 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
            return false;
        }

        if (DesktopExperienceFlags.ENABLE_MIRROR_DISPLAY_NO_ACTIVITY.isTrue()) {
        if (DesktopExperienceFlags.ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT.isTrue()
                && DesktopExperienceFlags.ENABLE_MIRROR_DISPLAY_NO_ACTIVITY.isTrue()) {
            if (!displayContent.mDisplay.canHostTasks()) {
                Slog.w(TAG, "Launch on display check: activity launch is not allowed on a "
                        + "display that cannot host tasks");
+7 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.spy;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.times;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.server.display.feature.flags.Flags.FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT;
import static com.android.server.wm.ActivityStarter.canEmbedActivity;
import static com.android.server.wm.TaskFragment.EMBEDDING_ALLOWED;
import static com.android.server.wm.TaskFragment.EMBEDDING_DISALLOWED_MIN_DIMENSION_VIOLATION;
@@ -98,6 +99,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.platform.test.annotations.Presubmit;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.provider.DeviceConfig;
import android.service.voice.IVoiceInteractionSession;
import android.util.Pair;
@@ -115,6 +117,7 @@ import com.android.server.pm.pkg.AndroidPackage;
import com.android.server.wm.BackgroundActivityStartController.BalVerdict;
import com.android.server.wm.LaunchParamsController.LaunchParamsModifier;
import com.android.server.wm.utils.MockTracker;
import com.android.window.flags.Flags;

import org.junit.After;
import org.junit.Before;
@@ -1075,6 +1078,10 @@ public class ActivityStarterTests extends WindowTestsBase {
     * disallowed, and a SecurityException should be thrown.
     */
    @Test
    @RequiresFlagsEnabled({
            FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT,
            Flags.FLAG_ENABLE_MIRROR_DISPLAY_NO_ACTIVITY
    })
    public void testStartActivityOnDisplayCannotHostTasks() {
        final ActivityStarter starter = prepareStarter(0);

+6 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.reset;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.server.display.feature.flags.Flags.FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT;

import static com.google.common.truth.Truth.assertThat;

@@ -62,6 +63,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.Presubmit;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.view.Display;

import androidx.test.filters.MediumTest;
@@ -359,8 +361,11 @@ public class ActivityTaskSupervisorTests extends WindowTestsBase {
     * Ensures that an arbitrary activity can be launched on a display the can host tasks, and
     * cannot be launched on a display that cannot host tasks.
     */
    @EnableFlags(Flags.FLAG_ENABLE_MIRROR_DISPLAY_NO_ACTIVITY)
    @Test
    @RequiresFlagsEnabled({
            FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT,
            Flags.FLAG_ENABLE_MIRROR_DISPLAY_NO_ACTIVITY
    })
    public void testDisplayCanLaunchActivities_canHostTasksDisplay() {
        final Display display = mDisplayContent.mDisplay;
        // An empty info without FLAG_ALLOW_EMBEDDED.