From d6bc1292317e16e6d24d8f571a45ce8ecfa3113e Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Thu, 14 Jan 2021 23:44:17 +0000 Subject: [PATCH] Ensure setRequestedOrientation is called when unfolding the device - In RotationHelper, mLastActivityFlags defaults to -1, which is the same value as SCREEN_ORIENTATION_UNSPECIFIED. When the screen is folded, a new instance of RotationHelper is created, which attempts to reset setRequestedOrientation to SCREEN_ORIENTATION_UNSPECIFIED. But SCREEN_ORIENTATION_UNSPECIFIED is equal to mLastActivityFlags, and the call is skipped. - The simpel fix is to default mLastActivityFlags to something else that is not a a valid value of setRequestedOrientation Bug: 177320461 Change-Id: I1ca284149598745bfa612ee12e4da3b940b60288 (cherry picked from commit 8aa592f44620a8f57fa104819f8bba57c4360f95) --- src/com/android/launcher3/states/RotationHelper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/states/RotationHelper.java b/src/com/android/launcher3/states/RotationHelper.java index ecf4f36c52..0638861f2e 100644 --- a/src/com/android/launcher3/states/RotationHelper.java +++ b/src/com/android/launcher3/states/RotationHelper.java @@ -76,7 +76,8 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { private boolean mInitialized; private boolean mDestroyed; - private int mLastActivityFlags = -1; + // Initialize mLastActivityFlags to a value not used by SCREEN_ORIENTATION flags + private int mLastActivityFlags = -999; public RotationHelper(Activity activity) { mActivity = activity;