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

Commit 81ad527b authored by d34d's avatar d34d Committed by Gerrit Code Review
Browse files

LLS: Fix screen off event firing when not interactive

Track PowerManager's interactivity to accurately report screen off.
While we did not get the screen on when in ambient display, the
screen off event would still fire.  Keep track of the interactivity
and send screen off event accordingly.

Change-Id: I633cacbf3a5d22b416e1bd6550d7b8d661c16c3d
TICKET: CYNGNOS-2519
parent 463c328c
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ public class LiveLockScreenController {

    private boolean mLlsHasFocus = false;

    private boolean mScreenOnAndInteractive;

    public LiveLockScreenController(Context context, PhoneStatusBar bar,
            NotificationPanelView panelView) {
        mContext = context;
@@ -202,16 +204,21 @@ public class LiveLockScreenController {
    }

    public void onScreenTurnedOn() {
        if (mLiveLockScreenView != null && mPowerManager.isInteractive()) {
            mLiveLockScreenView.onScreenTurnedOn();
        mScreenOnAndInteractive = mPowerManager.isInteractive();
        if (mScreenOnAndInteractive) {
            if (mLiveLockScreenView != null) mLiveLockScreenView.onScreenTurnedOn();
            EventLog.writeEvent(EventLogTags.SYSUI_LLS_KEYGUARD_SHOWING, 1);
        }
    }

    public void onScreenTurnedOff() {
        if (mScreenOnAndInteractive) {
            if (mLiveLockScreenView != null) mLiveLockScreenView.onScreenTurnedOff();
            if (mStatusBarState != StatusBarState.SHADE) {
                EventLog.writeEvent(EventLogTags.SYSUI_LLS_KEYGUARD_SHOWING, 0);
            }
            mScreenOnAndInteractive = false;
        }
    }

    public void onLiveLockScreenFocusChanged(boolean hasFocus) {
@@ -226,6 +233,7 @@ public class LiveLockScreenController {
    }

    public void onKeyguardDismissed() {
        if (mLiveLockScreenView != null) mLiveLockScreenView.onKeyguardDismissed();
        EventLog.writeEvent(EventLogTags.SYSUI_LLS_KEYGUARD_DISMISSED, mLlsHasFocus ? 1 : 0);
    }