Fix double auth issue
This was a regression from a security fix b/135289187 Test: reach, auth, swipe up Test: reach, auth, ait for timeout, reach again Fixes: 138851575 Change-Id: Icd457dc79cb6f86a7cbb22a78ee80ebfbb4380a7
This commit is contained in:
@@ -25,7 +25,7 @@ import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
*/
|
||||
public class DozeAuthRemover implements DozeMachine.Part {
|
||||
|
||||
KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
|
||||
public DozeAuthRemover(Context context) {
|
||||
mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(context);
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.android.systemui.R;
|
||||
import com.android.systemui.SystemUIApplication;
|
||||
import com.android.systemui.dock.DockManager;
|
||||
import com.android.systemui.plugins.FalsingManager;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
import com.android.systemui.statusbar.phone.BiometricUnlockController;
|
||||
import com.android.systemui.statusbar.phone.DozeParameters;
|
||||
import com.android.systemui.util.AsyncSensorManager;
|
||||
@@ -47,6 +48,7 @@ public class DozeFactory {
|
||||
SensorManager sensorManager = Dependency.get(AsyncSensorManager.class);
|
||||
AlarmManager alarmManager = context.getSystemService(AlarmManager.class);
|
||||
DockManager dockManager = Dependency.get(DockManager.class);
|
||||
WakefulnessLifecycle wakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
|
||||
|
||||
DozeHost host = getHost(dozeService);
|
||||
AmbientDisplayConfiguration config = new AmbientDisplayConfiguration(context);
|
||||
@@ -61,7 +63,8 @@ public class DozeFactory {
|
||||
wrappedService = DozeSuspendScreenStatePreventingAdapter.wrapIfNeeded(wrappedService,
|
||||
params);
|
||||
|
||||
DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock);
|
||||
DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock,
|
||||
wakefulnessLifecycle);
|
||||
machine.setParts(new DozeMachine.Part[]{
|
||||
new DozePauser(handler, machine, alarmManager, params.getPolicy()),
|
||||
new DozeFalsingManagerAdapter(falsingManager),
|
||||
|
||||
@@ -24,6 +24,8 @@ import android.util.Log;
|
||||
import android.view.Display;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle.Wakefulness;
|
||||
import com.android.systemui.statusbar.phone.DozeParameters;
|
||||
import com.android.systemui.util.Assert;
|
||||
import com.android.systemui.util.wakelock.WakeLock;
|
||||
@@ -118,6 +120,7 @@ public class DozeMachine {
|
||||
private final Service mDozeService;
|
||||
private final WakeLock mWakeLock;
|
||||
private final AmbientDisplayConfiguration mConfig;
|
||||
private final WakefulnessLifecycle mWakefulnessLifecycle;
|
||||
private Part[] mParts;
|
||||
|
||||
private final ArrayList<State> mQueuedRequests = new ArrayList<>();
|
||||
@@ -126,9 +129,10 @@ public class DozeMachine {
|
||||
private boolean mWakeLockHeldForCurrentState = false;
|
||||
|
||||
public DozeMachine(Service service, AmbientDisplayConfiguration config,
|
||||
WakeLock wakeLock) {
|
||||
WakeLock wakeLock, WakefulnessLifecycle wakefulnessLifecycle) {
|
||||
mDozeService = service;
|
||||
mConfig = config;
|
||||
mWakefulnessLifecycle = wakefulnessLifecycle;
|
||||
mWakeLock = wakeLock;
|
||||
}
|
||||
|
||||
@@ -334,9 +338,18 @@ public class DozeMachine {
|
||||
switch (state) {
|
||||
case INITIALIZED:
|
||||
case DOZE_PULSE_DONE:
|
||||
transitionTo(mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)
|
||||
? DozeMachine.State.DOZE_AOD : DozeMachine.State.DOZE,
|
||||
DozeLog.PULSE_REASON_NONE);
|
||||
final State nextState;
|
||||
@Wakefulness int wakefulness = mWakefulnessLifecycle.getWakefulness();
|
||||
if (wakefulness == WakefulnessLifecycle.WAKEFULNESS_AWAKE
|
||||
|| wakefulness == WakefulnessLifecycle.WAKEFULNESS_WAKING) {
|
||||
nextState = State.FINISH;
|
||||
} else if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)) {
|
||||
nextState = State.DOZE_AOD;
|
||||
} else {
|
||||
nextState = State.DOZE;
|
||||
}
|
||||
|
||||
transitionTo(nextState, DozeLog.PULSE_REASON_NONE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -16,12 +16,15 @@
|
||||
|
||||
package com.android.systemui.keyguard;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.os.Trace;
|
||||
|
||||
import com.android.systemui.Dumpable;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@@ -33,6 +36,15 @@ import javax.inject.Singleton;
|
||||
public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observer> implements
|
||||
Dumpable {
|
||||
|
||||
@IntDef(prefix = { "WAKEFULNESS_" }, value = {
|
||||
WAKEFULNESS_ASLEEP,
|
||||
WAKEFULNESS_WAKING,
|
||||
WAKEFULNESS_AWAKE,
|
||||
WAKEFULNESS_GOING_TO_SLEEP,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface Wakefulness {}
|
||||
|
||||
public static final int WAKEFULNESS_ASLEEP = 0;
|
||||
public static final int WAKEFULNESS_WAKING = 1;
|
||||
public static final int WAKEFULNESS_AWAKE = 2;
|
||||
@@ -44,7 +56,7 @@ public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observe
|
||||
public WakefulnessLifecycle() {
|
||||
}
|
||||
|
||||
public int getWakefulness() {
|
||||
public @Wakefulness int getWakefulness() {
|
||||
return mWakefulness;
|
||||
}
|
||||
|
||||
@@ -86,7 +98,7 @@ public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observe
|
||||
pw.println(" mWakefulness=" + mWakefulness);
|
||||
}
|
||||
|
||||
private void setWakefulness(int wakefulness) {
|
||||
private void setWakefulness(@Wakefulness int wakefulness) {
|
||||
mWakefulness = wakefulness;
|
||||
Trace.traceCounter(Trace.TRACE_TAG_APP, "wakefulness", wakefulness);
|
||||
}
|
||||
|
||||
@@ -45,11 +45,14 @@ import android.testing.UiThreadTest;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
import com.android.systemui.util.wakelock.WakeLockFake;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@@ -58,6 +61,8 @@ public class DozeMachineTest extends SysuiTestCase {
|
||||
|
||||
DozeMachine mMachine;
|
||||
|
||||
@Mock
|
||||
private WakefulnessLifecycle mWakefulnessLifecycle;
|
||||
private DozeServiceFake mServiceFake;
|
||||
private WakeLockFake mWakeLockFake;
|
||||
private AmbientDisplayConfiguration mConfigMock;
|
||||
@@ -65,12 +70,13 @@ public class DozeMachineTest extends SysuiTestCase {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mServiceFake = new DozeServiceFake();
|
||||
mWakeLockFake = new WakeLockFake();
|
||||
mConfigMock = mock(AmbientDisplayConfiguration.class);
|
||||
mPartMock = mock(DozeMachine.Part.class);
|
||||
|
||||
mMachine = new DozeMachine(mServiceFake, mConfigMock, mWakeLockFake);
|
||||
mMachine = new DozeMachine(mServiceFake, mConfigMock, mWakeLockFake, mWakefulnessLifecycle);
|
||||
|
||||
mMachine.setParts(new DozeMachine.Part[]{mPartMock});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user