Listen to DisplayController for ignoreAutoRotateSettings
- Also skip most of initDeviceProfile/onIdpChanged if DeviceProfile didn't actually change to effectively skip the 2nd unexpected onConfigurationChangeded caused by setRequestedOrientation (b/211763738)
Test: Change display size while in app or at home screen
Fix: 240019605
Change-Id: If307742639bd269622140a7da0dc900887c67937
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 9c62251..d2fe8bd 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -636,7 +636,10 @@
@Override
public void onIdpChanged(boolean modelPropertiesChanged) {
- initDeviceProfile(mDeviceProfile.inv);
+ if (!initDeviceProfile(mDeviceProfile.inv)) {
+ return;
+ }
+
dispatchDeviceProfileChanged();
reapplyUi();
mDragLayer.recreateControllers();
@@ -659,9 +662,17 @@
mDragLayer.onOneHandedModeStateChanged(activated);
}
- protected void initDeviceProfile(InvariantDeviceProfile idp) {
+ /**
+ * Returns {@code true} if a new DeviceProfile is initialized, and {@code false} otherwise.
+ */
+ protected boolean initDeviceProfile(InvariantDeviceProfile idp) {
// Load configuration-specific DeviceProfile
- mDeviceProfile = idp.getDeviceProfile(this);
+ DeviceProfile deviceProfile = idp.getDeviceProfile(this);
+ if (mDeviceProfile == deviceProfile) {
+ return false;
+ }
+
+ mDeviceProfile = deviceProfile;
if (isInMultiWindowMode()) {
mDeviceProfile = mDeviceProfile.getMultiWindowProfile(
this, getMultiWindowDisplaySize());
@@ -669,6 +680,7 @@
onDeviceProfileInitiated();
mModelWriter = mModel.getWriter(getDeviceProfile().isVerticalBarLayout(), true, this);
+ return true;
}
public RotationHelper getRotationHelper() {