Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f00adbeb authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Do not recreate taskbar due to unestimated bounds

The change around configuration and display cutout to support flexible
display setup is making the received display info is not calculated as
the hard-coded way in taskbar. It will cause the taskbar recreated when
the device reaches a given rotation for the first time.

The recreation is not necessary as it is only a hint of taskbar's
estimation doesn't match the result. Block the recreation in that case
to avoid user visible animation issue.

Bug: 302387383
Test: Rotate a device with movable cutout and no recreation happens
Flag: ACONFIG com.android.window.flags.allows_screen_size_decoupled_from_status_bar_and_cutout TRUNKFOOD
Flag: ACONFIG com.android.window.flags.movable_cutout_configuration DEVELOPMENT
Change-Id: I1aa6add57ec49a49cc7473bfaada6d9212c1fc4b
parent 1a0c6844
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@ import static com.android.launcher3.BaseActivity.EVENT_DESTROYED;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION;
import static com.android.launcher3.config.FeatureFlags.enableTaskbarNoRecreate;
import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY;
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
import static com.android.launcher3.util.DisplayController.CHANGE_TASKBAR_PINNING;
import static com.android.launcher3.util.DisplayController.TASKBAR_NOT_DESTROYED_TAG;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
@@ -55,7 +58,6 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile.OnIDPChangeListener;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.statemanager.StatefulActivity;
@@ -71,7 +73,6 @@ import com.android.quickstep.util.AssistUtils;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.unfold.UnfoldTransitionProgressProvider;
import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider;
import com.android.wm.shell.Flags;

import java.io.PrintWriter;
import java.util.StringJoiner;
@@ -135,7 +136,17 @@ public class TaskbarManager {
     * We use WindowManager's ComponentCallbacks() for internal UI changes (similar to an Activity)
     * which comes via a different channel
     */
    private final OnIDPChangeListener mIdpChangeListener = c -> recreateTaskbar();
    private final RecreationListener mRecreationListener = new RecreationListener();

    private class RecreationListener implements DisplayController.DisplayInfoChangeListener {
        @Override
        public void onDisplayInfoChanged(Context context, DisplayController.Info info, int flags) {
            if ((flags & (CHANGE_DENSITY | CHANGE_NAVIGATION_MODE
                    | CHANGE_TASKBAR_PINNING)) != 0) {
                recreateTaskbar();
            }
        }
    }
    private final SettingsCache.OnChangeListener mOnSettingsChangeListener = c -> recreateTaskbar();

    private boolean mUserUnlocked = false;
@@ -353,7 +364,7 @@ public class TaskbarManager {
     */
    public void onUserUnlocked() {
        mUserUnlocked = true;
        LauncherAppState.getIDP(mContext).addOnChangeListener(mIdpChangeListener);
        DisplayController.INSTANCE.get(mContext).addChangeListener(mRecreationListener);
        recreateTaskbar();
        addTaskbarRootViewToWindow();
    }
@@ -551,7 +562,7 @@ public class TaskbarManager {
                () -> mTaskbarBroadcastReceiver.unregisterReceiverSafely(mContext));
        destroyExistingTaskbar();
        if (mUserUnlocked) {
            LauncherAppState.getIDP(mContext).removeOnChangeListener(mIdpChangeListener);
            DisplayController.INSTANCE.get(mContext).removeChangeListener(mRecreationListener);
        }
        SettingsCache.INSTANCE.get(mContext)
                .unregister(USER_SETUP_COMPLETE_URI, mOnSettingsChangeListener);