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

Commit 86a48238 authored by Jason Monk's avatar Jason Monk Committed by gitbuildkicker
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
(cherry picked from commit ed507a3f)
parent d9fd9ec5
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,12 +41,17 @@ 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);
        mStatusBarInternal.setGlobalActionsListener(this);
    }

    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;
@@ -56,6 +62,7 @@ class GlobalActions implements GlobalActionsListener {
            mHandler.postDelayed(mShowTimeout, 5000);
        } else {
            // SysUI isn't alive, show legacy menu.
            ensureLegacyCreated();
            mLegacyGlobalActions.showDialog(mKeyguardShowing, mDeviceProvisioned);
        }
    }
@@ -79,6 +86,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);
        }
    }
@@ -88,6 +96,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);
        }
    };