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

Commit 627df3cd authored by Roman Birg's avatar Roman Birg
Browse files

SystemUI: fix lock screen tile state refresh



Now should instantly reflect the proper state after clicking. In certain
situations it would not update immediately.

Ref: CYNGNOS-1607

Change-Id: I97a5e3417f91315ca5d06a832fa799938981e284
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 9ee493ac
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -290,7 +290,7 @@ public class KeyguardViewMediator extends SystemUI {
    /**
     * Whether we are disabling the lock screen internally
     */
    private boolean mInternallyDisabled = false;
    private Boolean mInternallyDisabled = null;

    /**
     * we send this intent when the keyguard is dismissed.
@@ -690,11 +690,22 @@ public class KeyguardViewMediator extends SystemUI {
                        CMSettings.Secure.LOCKSCREEN_INTERNALLY_ENABLED,
                        getPersistedDefaultOldSetting() ? 1 : 0,
                        UserHandle.USER_CURRENT) == 0;
                if (newDisabledState != mInternallyDisabled && mKeyguardBound) {

                if (mKeyguardBound) {
                    if (mInternallyDisabled == null) {
                        // if it's enabled on boot, don't go through the notions of
                        // setting it enabled, as it might cause a flicker, just set the state
                        if (newDisabledState) {
                            setKeyguardEnabledInternal(false); // will set mInternallyDisabled
                        } else {
                            mInternallyDisabled = false;
                        }
                    } else if (newDisabledState != mInternallyDisabled) {
                        // it was updated,
                        setKeyguardEnabledInternal(!newDisabledState);
                    }
                }
            }
        };
    }

+7 −12
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState>

    private KeyguardViewMediator mKeyguardViewMediator;
    private KeyguardMonitor mKeyguard;
    private boolean mPersistedState;
    private boolean mListening;

    private KeyguardViewMediator.LockscreenEnabledSettingsObserver mSettingsObserver;
@@ -52,15 +51,12 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState>

            @Override
            public void update() {
                boolean newEnabledState = CMSettings.Secure.getIntForUser(
                boolean newState = CMSettings.Secure.getIntForUser(
                        mContext.getContentResolver(),
                        CMSettings.Secure.LOCKSCREEN_INTERNALLY_ENABLED,
                        getPersistedDefaultOldSetting() ? 1 : 0,
                        UserHandle.USER_CURRENT) != 0;
                if (newEnabledState != mPersistedState) {
                    mPersistedState = newEnabledState;
                    refreshState();
                }
                refreshState(newState);
            }
        };

@@ -89,8 +85,9 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState>

    @Override
    protected void handleClick() {
        setPersistedState(!mPersistedState);
        refreshState();
        final boolean newState = !getState().value;
        setPersistedState(newState);
        refreshState(newState);
    }

    @Override
@@ -101,9 +98,8 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState>
    @Override
    protected void handleUpdateState(BooleanState state, Object arg) {
        final boolean lockscreenEnforced = mKeyguardViewMediator.lockscreenEnforcedByDevicePolicy();
        final boolean lockscreenEnabled = lockscreenEnforced
                || mPersistedState
                || mKeyguardViewMediator.getKeyguardEnabledInternal();
        final boolean lockscreenEnabled = lockscreenEnforced ||
                arg != null ? (Boolean) arg : mKeyguardViewMediator.getKeyguardEnabledInternal();

        state.value = lockscreenEnabled;
        state.visible = mKeyguardViewMediator.isKeyguardBound();
@@ -147,6 +143,5 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState>
        CMSettings.Secure.putIntForUser(mContext.getContentResolver(),
                CMSettings.Secure.LOCKSCREEN_INTERNALLY_ENABLED,
                enabled ? 1 : 0, UserHandle.USER_CURRENT);
        mPersistedState = enabled;
    }
}