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

Commit ed507a3f authored by Jason Monk's avatar Jason Monk
Browse files

Don't inflate LegacyGlobalActions until its shown

It has some buggy code that depends on it being shown directly
after being instantiated, so make sure we don't instantiate it
until we need it.

Test: See bug, its complicated
Change-Id: Ic4863f53abaeb2d2070258a7f65b214376fb2889
Fixes: 36556777
parent 350948e9
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -29,9 +29,10 @@ class GlobalActions implements GlobalActionsListener {
    private static final boolean DEBUG = false;

    private final Context mContext;
    private final LegacyGlobalActions mLegacyGlobalActions;
    private final StatusBarManagerInternal mStatusBarInternal;
    private final Handler mHandler;
    private final WindowManagerFuncs mWindowManagerFuncs;
    private LegacyGlobalActions mLegacyGlobalActions;
    private boolean mKeyguardShowing;
    private boolean mDeviceProvisioned;
    private boolean mStatusBarConnected;
@@ -40,8 +41,7 @@ class GlobalActions implements GlobalActionsListener {
    public GlobalActions(Context context, WindowManagerFuncs windowManagerFuncs) {
        mContext = context;
        mHandler = new Handler();
        mLegacyGlobalActions = new LegacyGlobalActions(context, windowManagerFuncs,
                this::onGlobalActionsDismissed);
        mWindowManagerFuncs = windowManagerFuncs;
        mStatusBarInternal = LocalServices.getService(StatusBarManagerInternal.class);

        // Some form factors do not have a status bar.
@@ -50,6 +50,12 @@ class GlobalActions implements GlobalActionsListener {
        }
    }

    private void ensureLegacyCreated() {
        if (mLegacyGlobalActions != null) return;
        mLegacyGlobalActions = new LegacyGlobalActions(mContext, mWindowManagerFuncs,
                this::onGlobalActionsDismissed);
    }

    public void showDialog(boolean keyguardShowing, boolean deviceProvisioned) {
        if (DEBUG) Slog.d(TAG, "showDialog " + keyguardShowing + " " + deviceProvisioned);
        mKeyguardShowing = keyguardShowing;
@@ -60,6 +66,7 @@ class GlobalActions implements GlobalActionsListener {
            mHandler.postDelayed(mShowTimeout, 5000);
        } else {
            // SysUI isn't alive, show legacy menu.
            ensureLegacyCreated();
            mLegacyGlobalActions.showDialog(mKeyguardShowing, mDeviceProvisioned);
        }
    }
@@ -83,6 +90,7 @@ class GlobalActions implements GlobalActionsListener {
        mStatusBarConnected = connected;
        if (mShowing && !mStatusBarConnected) {
            // Status bar died but we need to be showing global actions still, show the legacy.
            ensureLegacyCreated();
            mLegacyGlobalActions.showDialog(mKeyguardShowing, mDeviceProvisioned);
        }
    }
@@ -92,6 +100,7 @@ class GlobalActions implements GlobalActionsListener {
        public void run() {
            if (DEBUG) Slog.d(TAG, "Global actions timeout");
            // We haven't heard from sysui, show the legacy dialog.
            ensureLegacyCreated();
            mLegacyGlobalActions.showDialog(mKeyguardShowing, mDeviceProvisioned);
        }
    };