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

Commit 72e7d305 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Simplify parameters of ensureActivityConfiguration

Move setRelaunchingAfterRequestedOrientationChanged to caller
because it only cares about if the activity is requested to be
relaunching when calling setRequestedOrientation.

Bug: 163976519
Test: SizeCompatTests#testFixedAspectRatioOrientationChangeOrientation
Change-Id: I43a0c5f08c18a90c33c609f24ce47c9563594721
parent 02b61abc
Loading
Loading
Loading
Loading
+6 −14
Original line number Diff line number Diff line
@@ -7979,6 +7979,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (mLetterboxUiController.shouldIgnoreRequestedOrientation(requestedOrientation)) {
            return;
        }
        final int originalRelaunchingCount = mPendingRelaunchCount;
        // This is necessary in order to avoid going into size compat mode when the orientation
        // change request comes from the app
        if (getRequestedConfigurationOrientation(false, requestedOrientation)
@@ -7996,8 +7997,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // the request is handled at task level with letterbox.
        if (!getMergedOverrideConfiguration().equals(
                mLastReportedConfiguration.getMergedConfiguration())) {
            ensureActivityConfiguration(
                    false /* ignoreVisibility */, true /* isRequestedOrientationChanged */);
            ensureActivityConfiguration(false /* ignoreVisibility */);
            if (mPendingRelaunchCount > originalRelaunchingCount) {
                mLetterboxUiController.setRelaunchingAfterRequestedOrientationChanged(true);
            }
            if (mTransitionController.inPlayingTransition(this)) {
                mTransitionController.mValidateActivityCompat.add(this);
            }
@@ -9503,11 +9506,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return ensureActivityConfiguration(false /* ignoreVisibility */);
    }

    boolean ensureActivityConfiguration(boolean ignoreVisibility) {
        return ensureActivityConfiguration(ignoreVisibility,
                false /* isRequestedOrientationChanged */);
    }

    /**
     * Make sure the given activity matches the current configuration. Ensures the HistoryRecord
     * is updated with the correct configuration and all other bookkeeping is handled.
@@ -9516,13 +9514,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     *                         (stopped state). This is useful for the case where we know the
     *                         activity will be visible soon and we want to ensure its configuration
     *                         before we make it visible.
     * @param isRequestedOrientationChanged whether this is triggered in response to an app calling
     *                                      {@link android.app.Activity#setRequestedOrientation}.
     * @return False if the activity was relaunched and true if it wasn't relaunched because we
     *         can't or the app handles the specific configuration that is changing.
     */
    boolean ensureActivityConfiguration(boolean ignoreVisibility,
            boolean isRequestedOrientationChanged) {
    boolean ensureActivityConfiguration(boolean ignoreVisibility) {
        final Task rootTask = getRootTask();
        if (rootTask.mConfigWillChange) {
            ProtoLog.v(WM_DEBUG_CONFIGURATION, "Skipping config check "
@@ -9659,9 +9654,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            } else {
                mRelaunchReason = RELAUNCH_REASON_NONE;
            }
            if (isRequestedOrientationChanged) {
                mLetterboxUiController.setRelaunchingAfterRequestedOrientationChanged(true);
            }
            if (mState == PAUSING) {
                // A little annoying: we are waiting for this activity to finish pausing. Let's not
                // do anything now, but just flag that it needs to be restarted when done pausing.
+2 −2
Original line number Diff line number Diff line
@@ -2131,8 +2131,8 @@ public class DisplayContentTests extends WindowTestsBase {
        // Once transition starts, rotation is applied and transition shows DC rotating.
        testPlayer.startTransition();
        waitUntilHandlersIdle();
        verify(activity1).ensureActivityConfiguration(anyBoolean(), anyBoolean());
        verify(activity2).ensureActivityConfiguration(anyBoolean(), anyBoolean());
        verify(activity1).ensureActivityConfiguration(anyBoolean());
        verify(activity2).ensureActivityConfiguration(anyBoolean());
        assertNotEquals(origRot, dc.getConfiguration().windowConfiguration.getRotation());
        assertNotNull(testPlayer.mLastReady);
        assertTrue(testPlayer.mController.isPlaying());
+9 −0
Original line number Diff line number Diff line
@@ -1020,8 +1020,17 @@ public class SizeCompatTests extends WindowTestsBase {
        // Activity is sandboxed due to fixed aspect ratio.
        assertActivityMaxBoundsSandboxed();

        // Prepare the states for verifying relaunching after changing orientation.
        mActivity.finishRelaunching();
        mActivity.setState(RESUMED, "testFixedAspectRatioOrientationChangeOrientation");
        mActivity.setLastReportedConfiguration(mAtm.getGlobalConfiguration(),
                mActivity.getConfiguration());

        // Change the fixed orientation.
        mActivity.setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE);
        assertTrue(mActivity.isRelaunching());
        assertTrue(mActivity.mLetterboxUiController
                .getIsRelaunchingAfterRequestedOrientationChanged());

        assertFitted();
        assertEquals(originalBounds.width(), mActivity.getBounds().height());