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

Commit 26557a3b authored by LuK1337's avatar LuK1337 Committed by Nolen Johnson
Browse files

Fallback to global actions if assistant is not available

Change-Id: I8c5c34f8b29967eace022ab3eed035b1e68efcb6
parent c141ca8b
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -585,6 +585,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {


    private int mCurrentUserId;
    private int mCurrentUserId;


    private AssistUtils mAssistUtils;

    // Maps global key codes to the components that will handle them.
    // Maps global key codes to the components that will handle them.
    private GlobalKeyManager mGlobalKeyManager;
    private GlobalKeyManager mGlobalKeyManager;


@@ -1180,6 +1182,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
        }
    }
    }


    private boolean hasAssistant() {
        return mAssistUtils.getAssistComponentForUser(mCurrentUserId) != null;
    }

    private int getResolvedLongPressOnPowerBehavior() {
    private int getResolvedLongPressOnPowerBehavior() {
        if (FactoryTest.isLongPressOnPowerOffEnabled()) {
        if (FactoryTest.isLongPressOnPowerOffEnabled()) {
            return LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;
            return LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;
@@ -1187,7 +1193,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {


        // If the config indicates the assistant behavior but the device isn't yet provisioned, show
        // If the config indicates the assistant behavior but the device isn't yet provisioned, show
        // global actions instead.
        // global actions instead.
        if (mLongPressOnPowerBehavior == LONG_PRESS_POWER_ASSISTANT && !isDeviceProvisioned()) {
        if (mLongPressOnPowerBehavior == LONG_PRESS_POWER_ASSISTANT &&
                (!isDeviceProvisioned() || !hasAssistant())) {
            return LONG_PRESS_POWER_GLOBAL_ACTIONS;
            return LONG_PRESS_POWER_GLOBAL_ACTIONS;
        }
        }


@@ -1804,6 +1811,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(),
        mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(),
                com.android.internal.R.array.config_safeModeEnabledVibePattern);
                com.android.internal.R.array.config_safeModeEnabledVibePattern);


        mAssistUtils = new AssistUtils(context);

        mGlobalKeyManager = new GlobalKeyManager(mContext);
        mGlobalKeyManager = new GlobalKeyManager(mContext);


        // Controls rotation and the like.
        // Controls rotation and the like.