From 09b40241fc01df7c132405b42d7b787ca73f5a00 Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Fri, 27 Aug 2021 13:29:01 +0800 Subject: [PATCH] Always refresh device profile when multi window mode changed Launcher monitors multi-window mode changed and updates device profile through configuration chagned callback. It's possible that a new configuration contains multi-window mode changed but without screen size size change that across screen layout qualifier. Client apps might not even receive onConfingurationChagned. Updates Launcher to monitor multi-window mode changed through onMultiWindowModeChanged to make sure it always refreshes device profile that matches with the latest mulati-window mode. Fix: 197835119 Test: manual check the repo steps. Change-Id: Ie99045a1fc8493ff37645b95e7ccd9d15478d862 --- src/com/android/launcher3/Launcher.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 6ea7b17871..a02f8eedfd 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -554,6 +554,14 @@ public class Launcher extends StatefulActivity implements Launche AbstractFloatingView.closeOpenViews(this, false, TYPE_ICON_SURFACE); } + @Override + public void onMultiWindowModeChanged(boolean isInMultiWindowMode, Configuration newConfig) { + super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig); + // Always update device profile when multi window mode changed. + initDeviceProfile(mDeviceProfile.inv); + dispatchDeviceProfileChanged(); + } + @Override public void onConfigurationChanged(Configuration newConfig) { int diff = newConfig.diff(mOldConfig); @@ -592,11 +600,9 @@ public class Launcher extends StatefulActivity implements Launche private void initDeviceProfile(InvariantDeviceProfile idp) { // Load configuration-specific DeviceProfile - mDeviceProfile = idp.getDeviceProfile(this); - if (isInMultiWindowMode()) { - mDeviceProfile = mDeviceProfile.getMultiWindowProfile( - this, getMultiWindowDisplaySize()); - } + mDeviceProfile = isInMultiWindowMode() + ? mDeviceProfile.getMultiWindowProfile(this, getMultiWindowDisplaySize()) + : idp.getDeviceProfile(this); onDeviceProfileInitiated(); mModelWriter = mModel.getWriter(getDeviceProfile().isVerticalBarLayout(), true, this);