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

Commit befe6482 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Keep current orientation if the activity doesn't provide orientation" into main

parents f3081eda 2afc5c41
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1950,6 +1950,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                activityOrientation = r.getOverrideOrientation();
            }
        }
        if (activityOrientation == SCREEN_ORIENTATION_UNSPECIFIED && !r.providesOrientation()) {
            return ROTATION_UNDEFINED;
        }
        if (r.inMultiWindowMode() || r.getRequestedConfigurationOrientation(true /* forDisplay */,
                activityOrientation) == getConfiguration().orientation) {
            return ROTATION_UNDEFINED;
+1 −0
Original line number Diff line number Diff line
@@ -1626,6 +1626,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        return source;
    }

    /** Returns true if unspecified orientation should be reported to parent. */
    boolean providesOrientation() {
        return fillsParent();
    }
+20 −0
Original line number Diff line number Diff line
@@ -1737,6 +1737,26 @@ public class DisplayContentTests extends WindowTestsBase {
        assertFalse(mDisplayContent.hasTopFixedRotationLaunchingApp());
    }

    @Test
    public void testRotationForActivityInDifferentOrientation() {
        mDisplayContent.setIgnoreOrientationRequest(false);
        final ActivityRecord app = new ActivityBuilder(mAtm).setCreateTask(true).build();
        final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation();
        final int rotation = displayRotation.getRotation();
        spyOn(displayRotation);
        doReturn((rotation + 1) % 4).when(displayRotation).rotationForOrientation(
                anyInt() /* orientation */, anyInt() /* lastRotation */);

        assertTrue(app.providesOrientation());
        assertNotEquals(WindowConfiguration.ROTATION_UNDEFINED,
                mDisplayContent.rotationForActivityInDifferentOrientation(app));

        doReturn(false).when(app).providesOrientation();

        assertEquals(WindowConfiguration.ROTATION_UNDEFINED,
                mDisplayContent.rotationForActivityInDifferentOrientation(app));
    }

    @Test
    public void testRespectNonTopVisibleFixedOrientation() {
        spyOn(mWm.mAppCompatConfiguration);