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

Commit 5bbf36c7 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Allow runtime-opaque activity to provide unspecified orientation

If the activity changes to occlude parent (opaque), the other
activities behind it will be invisible. So it is fine to respect
the requested orientation.

It still preserves the behavior that when an opaque changes to
translucent, it won't lose the ability to keep its unspecified
orientation. So the orientation won't be changed by the activity
behind during a scene transition that toggles opaque.

Fix: 305222629
Test: ActivityRecordTests#testGetOrientation,
      testShouldStartWhenMakeClientActive
Change-Id: I66b15daf70f0ef281a2cce471e52a29181bcf556
parent c9d20f37
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3055,7 +3055,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    @Override
    boolean providesOrientation() {
        return mStyleFillsParent;
        return mStyleFillsParent || mOccludesParent;
    }

    @Override
+7 −0
Original line number Diff line number Diff line
@@ -2627,6 +2627,13 @@ public class ActivityRecordTests extends WindowTestsBase {
        // Can specify orientation if the current orientation candidate is orientation behind.
        assertEquals(SCREEN_ORIENTATION_LANDSCAPE,
                activity.getOrientation(SCREEN_ORIENTATION_BEHIND));

        final ActivityRecord translucentActivity = new ActivityBuilder(mAtm)
                .setActivityTheme(android.R.style.Theme_Translucent)
                .setCreateTask(true).build();
        assertFalse(translucentActivity.providesOrientation());
        translucentActivity.setOccludesParent(true);
        assertTrue(translucentActivity.providesOrientation());
    }

    @Test
+12 −0
Original line number Diff line number Diff line
@@ -1184,6 +1184,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
        private boolean mCreateTask = false;
        private Task mParentTask;
        private int mActivityFlags;
        private int mActivityTheme;
        private int mLaunchMode;
        private int mResizeMode = RESIZE_MODE_RESIZEABLE;
        private float mMaxAspectRatio;
@@ -1232,6 +1233,14 @@ class WindowTestsBase extends SystemServiceTestsBase {
            return this;
        }

        ActivityBuilder setActivityTheme(int theme) {
            mActivityTheme = theme;
            // Use the real package of test so it can get a valid context for theme.
            mComponent = ComponentName.createRelative(mService.mContext.getPackageName(),
                    DEFAULT_COMPONENT_CLASS_NAME + sCurrentActivityId++);
            return this;
        }

        ActivityBuilder setActivityFlags(int flags) {
            mActivityFlags = flags;
            return this;
@@ -1381,6 +1390,9 @@ class WindowTestsBase extends SystemServiceTestsBase {
            if (mTargetActivity != null) {
                aInfo.targetActivity = mTargetActivity;
            }
            if (mActivityTheme != 0) {
                aInfo.theme = mActivityTheme;
            }
            aInfo.flags |= mActivityFlags;
            aInfo.launchMode = mLaunchMode;
            aInfo.resizeMode = mResizeMode;