Don't rely on nav mode change listener for oriented state
When nav mode state changes, launcher gets
re-instantiated, which means the listener for
nav mode changes often gets destroyed before it
even gets fired. Rely on the initial setup to
set the correct nav mode.
The other bug with relying
on the initial value was that we were initially
getting the old nav mode when initFlags was called
from the ctor, but then the correct updated nav
mode when called from initListeners(). The first
call would enable rotation but then the second
call wasn't disabling it. Now we toggled based on
nav mode each time.
Another bug fix in RecentsView was not calling
update when launcher rotation is enabled. That was
added when previously we were using HOME_ROTATED
and PORTRAIT as different PagedViewHandlers to
differentiate when launcher rotation was enabled.
HOME_ROTATED is now removed, so we no longer need
to change the internal state of RecentsOrientedState.
Fixes: 159176222
Change-Id: I2a37880ce3cf835ca5b9b165ce3840537facee6c
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
index 873c672..caff713 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
@@ -1053,8 +1053,7 @@
private void animateRecentsRotationInPlace(int newRotation) {
if (mOrientationState.canLauncherRotate()) {
- // Update the rotation but let system take care of the rotation animation
- setLayoutRotation(newRotation, mOrientationState.getDisplayRotation());
+ // Let system take care of the rotation
return;
}
AnimatorSet pa = setRecentsChangedOrientation(true);
diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
index 8bd2281..2acc49c 100644
--- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
+++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
@@ -116,9 +116,6 @@
MASK_MULTIPLE_ORIENTATION_SUPPORTED_BY_DEVICE | FLAG_SYSTEM_ROTATION_ALLOWED
| FLAG_ROTATION_WATCHER_SUPPORTED | FLAG_ROTATION_WATCHER_ENABLED;
- private SysUINavigationMode.NavigationModeChangeListener mNavModeChangeListener =
- newMode -> setFlag(FLAG_ROTATION_WATCHER_SUPPORTED, newMode != TWO_BUTTONS);
-
private final Context mContext;
private final ContentResolver mContentResolver;
private final SharedPreferences mSharedPrefs;
@@ -268,10 +265,9 @@
private void initFlags() {
SysUINavigationMode.Mode currentMode = SysUINavigationMode.getMode(mContext);
- if (mOrientationListener.canDetectOrientation() &&
- currentMode != TWO_BUTTONS) {
- mFlags |= FLAG_ROTATION_WATCHER_SUPPORTED;
- }
+ boolean rotationWatcherSupported = mOrientationListener.canDetectOrientation() &&
+ currentMode != TWO_BUTTONS;
+ setFlag(FLAG_ROTATION_WATCHER_SUPPORTED, rotationWatcherSupported);
// initialize external flags
updateAutoRotateSetting();
@@ -288,9 +284,6 @@
mContentResolver.registerContentObserver(
Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION),
false, mSystemAutoRotateObserver);
- SysUINavigationMode.Mode currentMode =
- SysUINavigationMode.INSTANCE.get(mContext)
- .addModeChangeListener(mNavModeChangeListener);
}
initFlags();
}
@@ -302,8 +295,6 @@
if (isMultipleOrientationSupportedByDevice()) {
mSharedPrefs.unregisterOnSharedPreferenceChangeListener(this);
mContentResolver.unregisterContentObserver(mSystemAutoRotateObserver);
- SysUINavigationMode.INSTANCE.get(mContext)
- .removeModeChangeListener(mNavModeChangeListener);
}
setRotationWatcherEnabled(false);
}
@@ -349,20 +340,6 @@
setFlag(FLAG_ROTATION_WATCHER_ENABLED, isEnabled);
}
- public int getTouchRotationDegrees() {
- switch (mTouchRotation) {
- case ROTATION_90:
- return 90;
- case ROTATION_180:
- return 180;
- case ROTATION_270:
- return 270;
- case ROTATION_0:
- default:
- return 0;
- }
- }
-
/**
* Returns the scale and pivot so that the provided taskRect can fit the provided full size
*/