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