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

Commit 6e76a500 authored by erosky's avatar erosky Committed by Evan Rosky
Browse files

Don't force FREEFORM on FULLSCREEN displays.

Was previously forcing FREEFORM on FREEFORM displays even if
ActivityOptions specifically requested another mode

Bug: 124409167
Test: atest TaskLaunchParamsModifierTests

Change-Id: I1229725dffd24a536802d71106c0c06797b95ef1
parent 311af9ea
Loading
Loading
Loading
Loading
+1 −21
Original line number Diff line number Diff line
@@ -235,8 +235,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
        // STEP 2.3: Adjust launch parameters as needed for freeform display. We enforce the policy
        // that legacy (pre-D) apps and those apps that can't handle multiple screen density well
        // are forced to be maximized. The rest of this step is to define the default policy when
        // there is no initial bounds or a fully resolved current params from callers. Right now we
        // launch all possible tasks/activities that can handle freeform into freeform mode.
        // there is no initial bounds or a fully resolved current params from callers.
        if (display.inFreeformWindowingMode()) {
            if (launchMode == WINDOWING_MODE_PINNED) {
                if (DEBUG) appendLog("picture-in-picture");
@@ -247,17 +246,6 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
                launchMode = WINDOWING_MODE_FULLSCREEN;
                outParams.mBounds.setEmpty();
                if (DEBUG) appendLog("forced-maximize");
            } else if (fullyResolvedCurrentParam) {
                // Don't adjust launch mode if that's inherited, except when we're launching an
                // activity that should be forced to maximize.
                if (DEBUG) appendLog("skip-adjustment-fully-resolved-params");
            } else if (launchMode != WINDOWING_MODE_FREEFORM
                    && (isNOrGreater(root) || isPreNResizeable(root))) {
                // We're launching a pre-N and post-D activity that supports resizing, or a post-N
                // activity. They can handle freeform nicely so launch them in freeform.
                // Use undefined because we know we're in a freeform display.
                launchMode = WINDOWING_MODE_UNDEFINED;
                if (DEBUG) appendLog("should-be-freeform");
            }
        } else {
            if (DEBUG) appendLog("non-freeform-display");
@@ -441,10 +429,6 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
        return !root.isResizeable();
    }

    private boolean isNOrGreater(@NonNull ActivityRecord root) {
        return root.appInfo.targetSdkVersion >= Build.VERSION_CODES.N;
    }

    /**
     * Resolves activity requested orientation to 4 categories:
     * 1) {@link ActivityInfo#SCREEN_ORIENTATION_LOCKED} indicating app wants to lock down
@@ -485,10 +469,6 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
        return orientation;
    }

    private boolean isPreNResizeable(ActivityRecord root) {
        return root.appInfo.targetSdkVersion < Build.VERSION_CODES.N && root.isResizeable();
    }

    private void cascadeBounds(@NonNull Rect srcBounds, @NonNull ActivityDisplay display,
            @NonNull Rect outBounds) {
        outBounds.set(srcBounds);
+16 −2
Original line number Diff line number Diff line
@@ -29,13 +29,11 @@ import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.util.DisplayMetrics.DENSITY_DEFAULT;
import static android.view.Display.DEFAULT_DISPLAY;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;
import static com.android.server.wm.LaunchParamsController.LaunchParamsModifier.RESULT_CONTINUE;
import static com.android.server.wm.LaunchParamsController.LaunchParamsModifier.RESULT_SKIP;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;

import android.app.ActivityOptions;
import android.content.pm.ActivityInfo;
@@ -473,6 +471,22 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
                WINDOWING_MODE_FULLSCREEN);
    }

    @Test
    public void testUsesFullscreenWhenRequestedOnFreeformDisplay() {
        final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
                WINDOWING_MODE_FREEFORM);

        final ActivityOptions options = ActivityOptions.makeBasic();
        options.setLaunchDisplayId(freeformDisplay.mDisplayId);
        options.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN);

        assertEquals(RESULT_CONTINUE, mTarget.onCalculate(/* task */ null, /* layout */ null,
                mActivity, /* source */ null, options, mCurrent, mResult));

        assertEquivalentWindowingMode(WINDOWING_MODE_FULLSCREEN, mResult.mWindowingMode,
                WINDOWING_MODE_FREEFORM);
    }

    @Test
    public void testUsesFreeformByDefaultForPostNApp() {
        final TestActivityDisplay freeformDisplay = createNewActivityDisplay(