From e05817ff03b9274a52e6d1b54d18576badfb0355 Mon Sep 17 00:00:00 2001 From: Steve Elliott Date: Fri, 17 May 2019 14:39:53 -0400 Subject: [PATCH] Fix dropped rotation events when unlocking orientation When unlocking orientation on the same frame as a rotation takes place (example: orientation is locked to landscape, but phone is physically oriented to portrait), onConfigurationChange is not invoked, and so Global Actions is positioned as if it were in the locked orientation, even though it has been rotated. We work around this by post()ing the rotation unlock, so that it happens on the next frame, at which point onConfigurationChange is correctly invoked and the layout is re-oriented properly. Fixes: 132581161 Test: manual Change-Id: I1c11844e24bea115f9f44560fef8db863d19d7af --- .../globalactions/GlobalActionsDialog.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index dcabb780ee3ab..7b8a4243a455d 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -1564,8 +1564,11 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } // Unlock rotation, so user can choose to rotate to portrait to see the panel. - RotationPolicy.setRotationLockAtAngle( - mContext, false, RotationUtils.ROTATION_NONE); + // This call is posted so that the rotation does not change until post-layout, + // otherwise onConfigurationChanged() may not get invoked. + mGlobalActionsLayout.post(() -> + RotationPolicy.setRotationLockAtAngle( + mContext, false, RotationUtils.ROTATION_NONE)); } } else { if (!rotationLocked) { @@ -1575,8 +1578,11 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } // Lock to portrait, so the user doesn't accidentally hide the panel. - RotationPolicy.setRotationLockAtAngle( - mContext, true, RotationUtils.ROTATION_NONE); + // This call is posted so that the rotation does not change until post-layout, + // otherwise onConfigurationChanged() may not get invoked. + mGlobalActionsLayout.post(() -> + RotationPolicy.setRotationLockAtAngle( + mContext, true, RotationUtils.ROTATION_NONE)); } // Disable rotation suggestions, if enabled