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

Commit c78799cc authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Screen on/off event cleanup"

parents 53850061 c2fbda95
Loading
Loading
Loading
Loading
+1 −40
Original line number Diff line number Diff line
@@ -94,7 +94,6 @@ import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternUtils;
import com.android.settingslib.WirelessUtils;
import com.android.settingslib.fuelgauge.BatteryStatus;
import com.android.systemui.DejankUtils;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.biometrics.AuthController;
@@ -173,7 +172,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private static final int MSG_SIM_SUBSCRIPTION_INFO_CHANGED = 328;
    private static final int MSG_AIRPLANE_MODE_CHANGED = 329;
    private static final int MSG_SERVICE_STATE_CHANGE = 330;
    private static final int MSG_SCREEN_TURNED_ON = 331;
    private static final int MSG_SCREEN_TURNED_OFF = 332;
    private static final int MSG_DREAMING_STATE_CHANGED = 333;
    private static final int MSG_USER_UNLOCKED = 334;
@@ -310,7 +308,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private boolean mSwitchingUser;

    private boolean mDeviceInteractive;
    private boolean mScreenOn;
    private SubscriptionManager mSubscriptionManager;
    private final TelephonyListenerManager mTelephonyListenerManager;
    private List<SubscriptionInfo> mSubscriptionInfo;
@@ -1300,10 +1297,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        }
    }

    public boolean isScreenOn() {
        return mScreenOn;
    }

    private void dispatchErrorMessage(CharSequence message) {
        Assert.isMainThread();
        for (int i = 0; i < mCallbacks.size(); i++) {
@@ -1692,29 +1685,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
    }

    private void handleScreenTurnedOn() {
        Assert.isMainThread();
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onScreenTurnedOn();
            }
        }
    }

    private void handleScreenTurnedOff() {
        final String tag = "KeyguardUpdateMonitor#handleScreenTurnedOff";
        DejankUtils.startDetectingBlockingIpcs(tag);
        Assert.isMainThread();
        mHardwareFingerprintUnavailableRetryCount = 0;
        mHardwareFaceUnavailableRetryCount = 0;
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onScreenTurnedOff();
            }
        }
        DejankUtils.stopDetectingBlockingIpcs(tag);
    }

    private void handleDreamingStateChanged(int dreamStart) {
@@ -1894,11 +1868,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                    case MSG_SERVICE_STATE_CHANGE:
                        handleServiceStateChange(msg.arg1, (ServiceState) msg.obj);
                        break;
                    case MSG_SCREEN_TURNED_ON:
                        handleScreenTurnedOn();
                        break;
                    case MSG_SCREEN_TURNED_OFF:
                        Trace.beginSection("KeyguardUpdateMonitor#handler MSG_SCREEN_TURNED_ON");
                        Trace.beginSection("KeyguardUpdateMonitor#handler MSG_SCREEN_TURNED_OFF");
                        handleScreenTurnedOff();
                        Trace.endSection();
                        break;
@@ -3319,17 +3290,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        mHandler.sendMessage(mHandler.obtainMessage(MSG_FINISHED_GOING_TO_SLEEP, why, 0));
    }

    public void dispatchScreenTurnedOn() {
        synchronized (this) {
            mScreenOn = true;
        }
        mHandler.sendEmptyMessage(MSG_SCREEN_TURNED_ON);
    }

    public void dispatchScreenTurnedOff() {
        synchronized (this) {
            mScreenOn = false;
        }
        mHandler.sendEmptyMessage(MSG_SCREEN_TURNED_OFF);
    }

+0 −16
Original line number Diff line number Diff line
@@ -200,22 +200,6 @@ public class KeyguardUpdateMonitorCallback {
    @Deprecated
    public void onFinishedGoingToSleep(int why) { }

    /**
     * Called when the screen has been turned on.
     *
     * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}.
     */
    @Deprecated
    public void onScreenTurnedOn() { }

    /**
     * Called when the screen has been turned off.
     *
     * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}.
     */
    @Deprecated
    public void onScreenTurnedOff() { }

    /**
     * Called when trust changes for a user.
     */
+0 −10
Original line number Diff line number Diff line
@@ -69,16 +69,6 @@ public interface KeyguardViewController {
     */
    default void onStartedWakingUp() {};

    /**
     * Called when the device started turning on.
     */
    default void onScreenTurningOn() {};

    /**
     * Called when the device has finished turning on.
     */
    default void onScreenTurnedOn() {};

    /**
     * Sets whether the Keyguard needs input.
     * @param needsInput
+3 −22
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ import dagger.Lazy;
 * so that once the screen comes on, it will be ready immediately.
 *
 * Example queries about the keyguard:
 * - is {movement, key} one that should wake the keygaurd?
 * - is {movement, key} one that should wake the keyguard?
 * - is the keyguard showing?
 * - are input events restricted due to the state of the keyguard?
 *
@@ -429,11 +429,6 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
     */
    private WorkLockActivityController mWorkLockController;

    /**
     * @see #setPulsing(boolean)
     */
    private boolean mPulsing;

    private boolean mLockLater;
    private boolean mShowHomeOverLockscreen;
    private boolean mInGestureNavigationMode;
@@ -1263,7 +1258,6 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
    public void onScreenTurnedOn() {
        Trace.beginSection("KeyguardViewMediator#onScreenTurnedOn");
        notifyScreenTurnedOn();
        mUpdateMonitor.dispatchScreenTurnedOn();
        Trace.endSection();
    }

@@ -1283,7 +1277,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
            // Skipping the lockscreen because we're not yet provisioned, but we still need to
            // notify the StrongAuthTracker that it's now safe to run trust agents, in case the
            // user sets a credential later.
            getLockPatternUtils().userPresent(KeyguardUpdateMonitor.getCurrentUser());
            mLockPatternUtils.userPresent(KeyguardUpdateMonitor.getCurrentUser());
        }
    }

@@ -1984,7 +1978,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
                    for (int profileId : um.getProfileIdsWithDisabled(currentUser.getIdentifier())) {
                        mContext.sendBroadcastAsUser(USER_PRESENT_INTENT, UserHandle.of(profileId));
                    }
                    getLockPatternUtils().userPresent(currentUserId);
                    mLockPatternUtils.userPresent(currentUserId);
                });
            } else {
                mBootSendUserPresent = true;
@@ -2584,7 +2578,6 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
                        .onScreenTurningOn(mPendingDrawnTasks.registerTask("fold-to-aod"));
            }

            mKeyguardViewControllerLazy.get().onScreenTurningOn();
            if (callback != null) {
                if (mWakeAndUnlocking) {
                    mWakeAndUnlockingDrawnCallback =
@@ -2603,7 +2596,6 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
            if (DEBUG) Log.d(TAG, "handleNotifyScreenTurnedOn");

            mPendingDrawnTasks.reset();
            mKeyguardViewControllerLazy.get().onScreenTurnedOn();
        }
        Trace.endSection();
    }
@@ -2762,10 +2754,6 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
        return mViewMediatorCallback;
    }

    public LockPatternUtils getLockPatternUtils() {
        return mLockPatternUtils;
    }

    @Override
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.print("  mSystemReady: "); pw.println(mSystemReady);
@@ -2826,13 +2814,6 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
        }
    }

    /**
     * @param pulsing true when device temporarily wakes up to display an incoming notification.
     */
    public void setPulsing(boolean pulsing) {
        mPulsing = pulsing;
    }

    /**
     * Set if the wallpaper supports ambient mode. This is used to trigger the right animation.
     * In case it does support it, we have to fade in the incoming app, otherwise we'll reveal it
+20 −14
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewCont
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_RESTING;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_TRUST;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_USER_LOCKED;
import static com.android.systemui.keyguard.ScreenLifecycle.SCREEN_ON;
import static com.android.systemui.plugins.FalsingManager.LOW_PENALTY;

import android.animation.Animator;
@@ -78,6 +79,7 @@ import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dock.DockManager;
import com.android.systemui.keyguard.KeyguardIndication;
import com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
@@ -172,6 +174,18 @@ public class KeyguardIndicationController {
                    return view == mIndicationArea;
                }
            };
    private ScreenLifecycle mScreenLifecycle;
    private final ScreenLifecycle.Observer mScreenObserver = new ScreenLifecycle.Observer() {
        @Override
        public void onScreenTurnedOn() {
            if (mMessageToShowOnScreenOn != null) {
                showBiometricMessage(mMessageToShowOnScreenOn);
                // We want to keep this message around in case the screen was off
                hideBiometricMessageDelayed(BaseKeyguardCallback.HIDE_DELAY_MS);
                mMessageToShowOnScreenOn = null;
            }
        }
    };

    /**
     * Creates a new KeyguardIndicationController and registers callbacks.
@@ -190,6 +204,7 @@ public class KeyguardIndicationController {
            @Main DelayableExecutor executor,
            FalsingManager falsingManager,
            LockPatternUtils lockPatternUtils,
            ScreenLifecycle screenLifecycle,
            IActivityManager iActivityManager,
            KeyguardBypassController keyguardBypassController) {
        mContext = context;
@@ -208,7 +223,8 @@ public class KeyguardIndicationController {
        mIActivityManager = iActivityManager;
        mFalsingManager = falsingManager;
        mKeyguardBypassController = keyguardBypassController;

        mScreenLifecycle = screenLifecycle;
        mScreenLifecycle.addObserver(mScreenObserver);
    }

    /** Call this after construction to finish setting up the instance. */
@@ -991,7 +1007,7 @@ public class KeyguardIndicationController {
            if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
                mStatusBarKeyguardViewManager.showBouncerMessage(helpString,
                        mInitialTextColorState);
            } else if (mKeyguardUpdateMonitor.isScreenOn()) {
            } else if (mScreenLifecycle.getScreenState() == SCREEN_ON) {
                if (biometricSourceType == BiometricSourceType.FACE
                        && shouldSuppressFaceMsgAndShowTryFingerprintMsg()) {
                    showTryFingerprintMsg(msgId, helpString);
@@ -1013,7 +1029,7 @@ public class KeyguardIndicationController {
            if (biometricSourceType == BiometricSourceType.FACE
                    && shouldSuppressFaceMsgAndShowTryFingerprintMsg()
                    && !mStatusBarKeyguardViewManager.isBouncerShowing()
                    && mKeyguardUpdateMonitor.isScreenOn()) {
                    && mScreenLifecycle.getScreenState() == SCREEN_ON) {
                showTryFingerprintMsg(msgId, errString);
                return;
            }
@@ -1035,7 +1051,7 @@ public class KeyguardIndicationController {
                }
            } else if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
                mStatusBarKeyguardViewManager.showBouncerMessage(errString, mInitialTextColorState);
            } else if (mKeyguardUpdateMonitor.isScreenOn()) {
            } else if (mScreenLifecycle.getScreenState() == SCREEN_ON) {
                showBiometricMessage(errString);
            } else {
                mMessageToShowOnScreenOn = errString;
@@ -1085,16 +1101,6 @@ public class KeyguardIndicationController {
            showBiometricMessage(message);
        }

        @Override
        public void onScreenTurnedOn() {
            if (mMessageToShowOnScreenOn != null) {
                showBiometricMessage(mMessageToShowOnScreenOn);
                // We want to keep this message around in case the screen was off
                hideBiometricMessageDelayed(HIDE_DELAY_MS);
                mMessageToShowOnScreenOn = null;
            }
        }

        @Override
        public void onBiometricRunningStateChanged(boolean running,
                BiometricSourceType biometricSourceType) {
Loading