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

Commit 95cb52a6 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Don't lock rotation to natural rotation when entering overview

Overview (recents) will use fixed portrait orientation if home
rotation is disabled, then the orientation will be portrait when
leaving overview to a application which was rotated to landscape.
Which is inconsistent from user perspective.

This change ignores the rotation change caused by the overview
once. So the original user rotation can be preserved.

Bug: 148982179
Test: 1. Disable auto-rotation and home rotation.
      2. Launch an activity in portrait.
      3. Rotate the device to landscape and press rotation button.
      4. Enter overview (recents).
      5. Return to the application.
      Check with 2-button, 3-button, and gesture navigation.
      The device should be in landscape after step 5.
      And the behavior doesn't change with home rotation enabled.

Change-Id: I43005753031b13e66c3c388b221d51ce3fd543bf
parent a4614b0f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ public class OverviewProxyRecentsImpl implements RecentsImplementation {
                try {
                    if (mOverviewProxyService.getProxy() != null) {
                        mOverviewProxyService.getProxy().onOverviewToggle();
                        mOverviewProxyService.notifyToggleRecentApps();
                    }
                } catch (RemoteException e) {
                    Log.e(TAG, "Cannot send toggle recents through proxy service.", e);
+8 −0
Original line number Diff line number Diff line
@@ -871,6 +871,12 @@ public class OverviewProxyService extends CurrentUserTracker implements
        }
    }

    void notifyToggleRecentApps() {
        for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
            mConnectionCallbacks.get(i).onToggleRecentApps();
        }
    }

    private void updateEnabledState() {
        mIsEnabled = mContext.getPackageManager().resolveServiceAsUser(mQuickStepIntent,
                MATCH_SYSTEM_ONLY,
@@ -901,6 +907,8 @@ public class OverviewProxyService extends CurrentUserTracker implements
        default void onQuickSwitchToNewTask(@Surface.Rotation int rotation) {}
        default void onOverviewShown(boolean fromHome) {}
        default void onQuickScrubStarted() {}
        /** Notify the recents app (overview) is started by 3-button navigation. */
        default void onToggleRecentApps() {}
        /** Notify changes in the nav bar button alpha */
        default void onNavBarButtonAlphaChanged(float alpha, boolean animate) {}
        default void onSystemUiStateChanged(int sysuiStateFlags) {}
+14 −0
Original line number Diff line number Diff line
@@ -323,6 +323,20 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
                buttonDispatcher.setAlpha(forceVisible ? 1f : alpha, animate);
            }
        }

        @Override
        public void onOverviewShown(boolean fromHome) {
            // If the overview has fixed orientation that may change display to natural rotation,
            // we don't want the user rotation to be reset. So after user returns to application,
            // it can keep in the original rotation.
            mNavigationBarView.getRotationButtonController().setSkipOverrideUserLockPrefsOnce();
        }

        @Override
        public void onToggleRecentApps() {
            // The same case as onOverviewShown but only for 3-button navigation.
            mNavigationBarView.getRotationButtonController().setSkipOverrideUserLockPrefsOnce();
        }
    };

    private NavigationBarTransitions.DarkIntensityListener mOrientationHandleIntensityListener =
+14 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class RotationButtonController {
    private Consumer<Integer> mRotWatcherListener;
    private boolean mListenersRegistered = false;
    private boolean mIsNavigationBarShowing;
    private boolean mSkipOverrideUserLockPrefsOnce;

    private final Runnable mRemoveRotationProposal =
            () -> setRotateSuggestionButtonState(false /* visible */);
@@ -349,7 +350,20 @@ public class RotationButtonController {
        mUiEventLogger.log(RotationButtonEvent.ROTATION_SUGGESTION_SHOWN);
    }

    /**
     * Makes {@link #shouldOverrideUserLockPrefs} always return {@code false} once. It is used to
     * avoid losing original user rotation when display rotation is changed by entering the fixed
     * orientation overview.
     */
    void setSkipOverrideUserLockPrefsOnce() {
        mSkipOverrideUserLockPrefsOnce = true;
    }

    private boolean shouldOverrideUserLockPrefs(final int rotation) {
        if (mSkipOverrideUserLockPrefsOnce) {
            mSkipOverrideUserLockPrefsOnce = false;
            return false;
        }
        // Only override user prefs when returning to the natural rotation (normally portrait).
        // Don't let apps that force landscape or 180 alter user lock.
        return rotation == NATURAL_ROTATION;