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

Commit 9775be8e authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "Don't force FREEFORM on FULLSCREEN displays."

parents e8cb4061 6e76a500
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(