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

Commit c666c5e7 authored by Andreas Bexell's avatar Andreas Bexell Committed by Ed Savage-Jones
Browse files

Make GlobalActionsDialogLite directly injectable

When GlobalActionsDialogLite was made injectable by
commit c88a2d7f, it was
in the form of a dagger.Lazy. This was probably a mistake, as
a local reference to the content of this dagger.Lazy was also
kept, and this messes up the lifecycle and may, in strange
cases, allow the use of a Dialog that has been destroyed,
with consequences that are difficult to predict.

A direct injection of the GlobalActionsDialogLite is
probably more appropriate.

Test: manual
Change-Id: I1646c883b9a15db737bfc897c41dd26fb584d539
parent 7a25b6f3
Loading
Loading
Loading
Loading
+5 −12
Original line number Diff line number Diff line
@@ -41,26 +41,23 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;

import javax.inject.Inject;

import dagger.Lazy;

public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks {

    private final Context mContext;
    private final Lazy<GlobalActionsDialogLite> mGlobalActionsDialogLazy;
    private final KeyguardStateController mKeyguardStateController;
    private final DeviceProvisionedController mDeviceProvisionedController;
    private final BlurUtils mBlurUtils;
    private final CommandQueue mCommandQueue;
    private GlobalActionsDialogLite mGlobalActionsDialog;
    private final GlobalActionsDialogLite mGlobalActionsDialog;
    private boolean mDisabled;

    @Inject
    public GlobalActionsImpl(Context context, CommandQueue commandQueue,
            Lazy<GlobalActionsDialogLite> globalActionsDialogLazy, BlurUtils blurUtils,
            GlobalActionsDialogLite globalActionsDialog, BlurUtils blurUtils,
            KeyguardStateController keyguardStateController,
            DeviceProvisionedController deviceProvisionedController) {
        mContext = context;
        mGlobalActionsDialogLazy = globalActionsDialogLazy;
        mGlobalActionsDialog = globalActionsDialog;
        mKeyguardStateController = keyguardStateController;
        mDeviceProvisionedController = deviceProvisionedController;
        mCommandQueue = commandQueue;
@@ -71,16 +68,12 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks
    @Override
    public void destroy() {
        mCommandQueue.removeCallback(this);
        if (mGlobalActionsDialog != null) {
        mGlobalActionsDialog.destroy();
            mGlobalActionsDialog = null;
        }
    }

    @Override
    public void showGlobalActions(GlobalActionsManager manager) {
        if (mDisabled) return;
        mGlobalActionsDialog = mGlobalActionsDialogLazy.get();
        mGlobalActionsDialog.showOrHideDialog(mKeyguardStateController.isShowing(),
                mDeviceProvisionedController.isDeviceProvisioned());
    }
@@ -189,7 +182,7 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks
        final boolean disabled = (state2 & DISABLE2_GLOBAL_ACTIONS) != 0;
        if (displayId != mContext.getDisplayId() || disabled == mDisabled) return;
        mDisabled = disabled;
        if (disabled && mGlobalActionsDialog != null) {
        if (disabled) {
            mGlobalActionsDialog.dismissDialog();
        }
    }