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

Commit 6f6a62fd authored by Beverly Tai's avatar Beverly Tai Committed by Automerger Merge Worker
Browse files

Merge "Send AOD auth interrupt only after display state is ON" into sc-dev am: 7ed65c1d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14984537

Change-Id: Ib5853c5ed44ef597d7b4896afafcf0026dd6c39e
parents 6f21b544 7ed65c1d
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.systemui.biometrics.AuthController;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dock.DockManager;
import com.android.systemui.doze.DozeMachine.State;
import com.android.systemui.doze.dagger.DozeScope;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.util.Assert;
@@ -96,6 +97,7 @@ public class DozeTriggers implements DozeMachine.Part {

    private long mNotificationPulseTime;
    private boolean mPulsePending;
    private Runnable mAodInterruptRunnable;

    /** see {@link #onProximityFar} prox for callback */
    private boolean mWantProxSensor;
@@ -303,11 +305,16 @@ public class DozeTriggers implements DozeMachine.Part {
                } else if (isPickup) {
                    gentleWakeUp(pulseReason);
                } else if (isUdfpsLongPress) {
                    requestPulse(DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS, true, null);
                    // Since the gesture won't be received by the UDFPS view, manually inject an
                    // event.
                    final State state = mMachine.getState();
                    if (state == State.DOZE_AOD || state == State.DOZE) {
                        // Since the gesture won't be received by the UDFPS view, we need to
                        // manually inject an event once the display is ON
                        mAodInterruptRunnable = () ->
                            mAuthController.onAodInterrupt((int) screenX, (int) screenY,
                                rawValues[3] /* major */, rawValues[4] /* minor */);
                    }

                    requestPulse(DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS, true, null);
                } else {
                    mDozeHost.extendPulse(pulseReason);
                }
@@ -439,6 +446,7 @@ public class DozeTriggers implements DozeMachine.Part {
    public void transitionTo(DozeMachine.State oldState, DozeMachine.State newState) {
        switch (newState) {
            case INITIALIZED:
                mAodInterruptRunnable = null;
                sWakeDisplaySensorState = true;
                mBroadcastReceiver.register(mBroadcastDispatcher);
                mDozeHost.addCallback(mHostCallback);
@@ -448,6 +456,7 @@ public class DozeTriggers implements DozeMachine.Part {
                break;
            case DOZE:
            case DOZE_AOD:
                mAodInterruptRunnable = null;
                mWantProxSensor = newState != DozeMachine.State.DOZE;
                mWantSensors = true;
                mWantTouchScreenSensors = true;
@@ -494,6 +503,11 @@ public class DozeTriggers implements DozeMachine.Part {
                || state == Display.STATE_DOZE_SUSPEND || state == Display.STATE_OFF;
        mDozeSensors.setProxListening(mWantProxSensor && lowPowerStateOrOff);
        mDozeSensors.setListening(mWantSensors, mWantTouchScreenSensors, lowPowerStateOrOff);

        if (mAodInterruptRunnable != null && state == Display.STATE_ON) {
            mAodInterruptRunnable.run();
            mAodInterruptRunnable = null;
        }
    }

    /**
@@ -576,6 +590,8 @@ public class DozeTriggers implements DozeMachine.Part {

    @Override
    public void dump(PrintWriter pw) {
        pw.println(" mAodInterruptRunnable=" + mAodInterruptRunnable);

        pw.print(" notificationPulseTime=");
        pw.println(Formatter.formatShortElapsedTime(mContext, mNotificationPulseTime));

+20 −3
Original line number Diff line number Diff line
@@ -16,7 +16,10 @@

package com.android.systemui.doze;

import static com.android.systemui.doze.DozeMachine.State.DOZE_AOD;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
@@ -161,7 +164,7 @@ public class DozeTriggersTest extends SysuiTestCase {

        clearInvocations(mSensors);
        mTriggers.transitionTo(DozeMachine.State.DOZE_PULSING, DozeMachine.State.DOZE_PULSE_DONE);
        mTriggers.transitionTo(DozeMachine.State.DOZE_PULSE_DONE, DozeMachine.State.DOZE_AOD);
        mTriggers.transitionTo(DozeMachine.State.DOZE_PULSE_DONE, DOZE_AOD);
        waitForSensorManager();
        verify(mSensors).requestTriggerSensor(any(), eq(mTapSensor));
    }
@@ -207,7 +210,7 @@ public class DozeTriggersTest extends SysuiTestCase {
        mTriggers.onSensor(DozeLog.REASON_SENSOR_QUICK_PICKUP, 100, 100, null);

        // THEN device goes into aod (shows clock with black background)
        verify(mMachine).requestState(DozeMachine.State.DOZE_AOD);
        verify(mMachine).requestState(DOZE_AOD);

        // THEN a log is taken that quick pick up was triggered
        verify(mUiEventLogger).log(DozingUpdateUiEvent.DOZING_UPDATE_QUICK_PICKUP);
@@ -218,7 +221,7 @@ public class DozeTriggersTest extends SysuiTestCase {
        // GIVEN quick pickup is triggered when device is in DOZE
        when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE);
        mTriggers.onSensor(DozeLog.REASON_SENSOR_QUICK_PICKUP, 100, 100, null);
        verify(mMachine).requestState(DozeMachine.State.DOZE_AOD);
        verify(mMachine).requestState(DOZE_AOD);
        verify(mMachine, never()).requestState(DozeMachine.State.DOZE);

        // WHEN next executable is run
@@ -234,6 +237,8 @@ public class DozeTriggersTest extends SysuiTestCase {

    @Test
    public void testOnSensor_Fingerprint() {
        // GIVEN dozing state
        when(mMachine.getState()).thenReturn(DOZE_AOD);
        final int screenX = 100;
        final int screenY = 100;
        final float misc = -1;
@@ -241,8 +246,20 @@ public class DozeTriggersTest extends SysuiTestCase {
        final float major = 3f;
        final int reason = DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS;
        float[] rawValues = new float[]{screenX, screenY, misc, major, minor};

        // WHEN longpress gesture is triggered
        mTriggers.onSensor(reason, screenX, screenY, rawValues);

        // THEN
        // * don't immediately send interrupt
        // * immediately extend pulse
        verify(mAuthController, never()).onAodInterrupt(anyInt(), anyInt(), anyFloat(), anyFloat());
        verify(mHost).extendPulse(reason);

        // WHEN display state changes to ON
        mTriggers.onScreenState(Display.STATE_ON);

        // THEN send interrupt
        verify(mAuthController).onAodInterrupt(eq(screenX), eq(screenY), eq(major), eq(minor));
    }