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

Commit 0810f54b authored by Jiaming Liu's avatar Jiaming Liu Committed by Android (Google) Code Review
Browse files

Merge "Make embedded TF provide override orientation only when visible" into main

parents e9de25f1 77e09269
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1971,6 +1971,15 @@ class TaskFragment extends WindowContainer<WindowContainer> {
        return SCREEN_ORIENTATION_UNSET;
    }

    @ActivityInfo.ScreenOrientation
    @Override
    protected int getOverrideOrientation() {
        if (isEmbedded() && !isVisibleRequested()) {
            return SCREEN_ORIENTATION_UNSPECIFIED;
        }
        return super.getOverrideOrientation();
    }

    /**
     * Whether or not to allow this container to specify an app requested orientation.
     *
+2 −0
Original line number Diff line number Diff line
@@ -1050,6 +1050,8 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
        // TaskFragment override orientation should be set for a system organizer.
        final TaskFragment taskFragment = mWindowOrganizerController.getTaskFragment(fragmentToken);
        assertNotNull(taskFragment);

        taskFragment.setVisibleRequested(true);
        assertEquals(SCREEN_ORIENTATION_BEHIND, taskFragment.getOverrideOrientation());
    }

+21 −0
Original line number Diff line number Diff line
@@ -757,6 +757,7 @@ public class TaskFragmentTest extends WindowTestsBase {
        final Task task = createTask(mDisplayContent);
        final TaskFragment tf = createTaskFragmentWithActivity(task);
        final ActivityRecord activity = tf.getTopMostActivity();
        tf.setVisibleRequested(true);
        tf.setOverrideOrientation(SCREEN_ORIENTATION_BEHIND);

        // Should report the override orientation
@@ -767,6 +768,26 @@ public class TaskFragmentTest extends WindowTestsBase {
        assertEquals(SCREEN_ORIENTATION_BEHIND, tf.getOrientation(SCREEN_ORIENTATION_UNSET));
    }

    @Test
    public void testGetOrientation_reportOverrideOrientation_whenInvisible() {
        final Task task = createTask(mDisplayContent);
        final TaskFragment tf = createTaskFragmentWithActivity(task);
        final ActivityRecord activity = tf.getTopMostActivity();
        tf.setVisibleRequested(false);
        tf.setOverrideOrientation(SCREEN_ORIENTATION_BEHIND);

        // Should report SCREEN_ORIENTATION_UNSPECIFIED for the override orientation when invisible
        assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, tf.getOverrideOrientation());

        // Should report SCREEN_ORIENTATION_UNSET for the orientation
        assertEquals(SCREEN_ORIENTATION_UNSET, tf.getOrientation(SCREEN_ORIENTATION_UNSET));

        // Should report SCREEN_ORIENTATION_UNSET even if the activity requests a different
        // value
        activity.setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE);
        assertEquals(SCREEN_ORIENTATION_UNSET, tf.getOrientation(SCREEN_ORIENTATION_UNSET));
    }

    @Test
    public void testUpdateImeParentForActivityEmbedding() {
        // Setup two activities in ActivityEmbedding.