Merge "AOD: selectively register sensors that use prox" into sc-dev
This commit is contained in:
@@ -174,6 +174,23 @@
|
||||
<!-- Doze: check proximity sensor before pulsing? -->
|
||||
<bool name="doze_proximity_check_before_pulse">true</bool>
|
||||
|
||||
<!-- Doze: only register sensors that use prox when device is in certain Display states. This
|
||||
delays registering sensors when device first shows dozing UI but the
|
||||
Display & Power state hasn't changed to low-power mode yet. -->
|
||||
<bool name="doze_selectively_register_prox">false</bool>
|
||||
|
||||
<!-- Doze: whether the single tap sensor uses the proximity sensor.
|
||||
If both this parameter and doze_selectively_register_prox are true, registration for the
|
||||
sensor will be delayed when the device first enters dozing but the device has not entered its
|
||||
low powered state yet. -->
|
||||
<bool name="doze_single_tap_uses_prox">true</bool>
|
||||
|
||||
<!-- Doze: whether the long press sensor uses the proximity sensor.
|
||||
If both this parameter and doze_selectively_register_prox are true, registration for the
|
||||
sensor will be delayed when the device first enters dozing but the device has not entered its
|
||||
low powered state yet. -->
|
||||
<bool name="doze_long_press_uses_prox">true</bool>
|
||||
|
||||
<!-- Doze: should notifications be used as a pulse signal? -->
|
||||
<bool name="doze_pulse_on_notifications">true</bool>
|
||||
|
||||
|
||||
@@ -81,6 +81,10 @@ public class DozeSensors {
|
||||
private boolean mSettingRegistered;
|
||||
private boolean mListening;
|
||||
private boolean mListeningTouchScreenSensors;
|
||||
private boolean mListeningProxSensors;
|
||||
|
||||
// whether to only register sensors that use prox when the display state is dozing or off
|
||||
private boolean mSelectivelyRegisterProxSensors;
|
||||
|
||||
@VisibleForTesting
|
||||
public enum DozeSensorsUiEvent implements UiEventLogger.UiEventEnum {
|
||||
@@ -112,6 +116,8 @@ public class DozeSensors {
|
||||
mSecureSettings = secureSettings;
|
||||
mCallback = callback;
|
||||
mProximitySensor = proximitySensor;
|
||||
mSelectivelyRegisterProxSensors = dozeParameters.getSelectivelyRegisterSensorsUsingProx();
|
||||
mListeningProxSensors = !mSelectivelyRegisterProxSensors;
|
||||
|
||||
boolean udfpsEnrolled =
|
||||
authController.isUdfpsEnrolled(KeyguardUpdateMonitor.getCurrentUser());
|
||||
@@ -131,6 +137,7 @@ public class DozeSensors {
|
||||
DozeLog.REASON_SENSOR_PICKUP, false /* touchCoords */,
|
||||
false /* touchscreen */,
|
||||
false /* ignoresSetting */,
|
||||
false /* requires prox */,
|
||||
dozeLog),
|
||||
new TriggerSensor(
|
||||
findSensorWithType(config.doubleTapSensorType()),
|
||||
@@ -143,10 +150,13 @@ public class DozeSensors {
|
||||
new TriggerSensor(
|
||||
findSensorWithType(config.tapSensorType()),
|
||||
Settings.Secure.DOZE_TAP_SCREEN_GESTURE,
|
||||
true /* settingDef */,
|
||||
true /* configured */,
|
||||
DozeLog.REASON_SENSOR_TAP,
|
||||
false /* reports touch coordinates */,
|
||||
true /* touchscreen */,
|
||||
false /* ignoresSetting */,
|
||||
dozeParameters.singleTapUsesProx() /* requiresProx */,
|
||||
dozeLog),
|
||||
new TriggerSensor(
|
||||
findSensorWithType(config.longPressSensorType()),
|
||||
@@ -156,6 +166,8 @@ public class DozeSensors {
|
||||
DozeLog.PULSE_REASON_SENSOR_LONG_PRESS,
|
||||
true /* reports touch coordinates */,
|
||||
true /* touchscreen */,
|
||||
false /* ignoresSetting */,
|
||||
dozeParameters.longPressUsesProx() /* requiresProx */,
|
||||
dozeLog),
|
||||
new TriggerSensor(
|
||||
findSensorWithType(config.udfpsLongPressSensorType()),
|
||||
@@ -165,6 +177,8 @@ public class DozeSensors {
|
||||
DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS,
|
||||
true /* reports touch coordinates */,
|
||||
true /* touchscreen */,
|
||||
false /* ignoresSetting */,
|
||||
dozeParameters.longPressUsesProx(),
|
||||
dozeLog),
|
||||
new PluginSensor(
|
||||
new SensorManagerPlugin.Sensor(TYPE_WAKE_DISPLAY),
|
||||
@@ -254,6 +268,23 @@ public class DozeSensors {
|
||||
updateListening();
|
||||
}
|
||||
|
||||
/**
|
||||
* If sensors should be registered and sending signals.
|
||||
*/
|
||||
public void setListening(boolean listen, boolean includeTouchScreenSensors,
|
||||
boolean lowPowerStateOrOff) {
|
||||
final boolean shouldRegisterProxSensors =
|
||||
!mSelectivelyRegisterProxSensors || lowPowerStateOrOff;
|
||||
if (mListening == listen && mListeningTouchScreenSensors == includeTouchScreenSensors
|
||||
&& mListeningProxSensors == shouldRegisterProxSensors) {
|
||||
return;
|
||||
}
|
||||
mListening = listen;
|
||||
mListeningTouchScreenSensors = includeTouchScreenSensors;
|
||||
mListeningProxSensors = shouldRegisterProxSensors;
|
||||
updateListening();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers/unregisters sensors based on internal state.
|
||||
*/
|
||||
@@ -261,7 +292,8 @@ public class DozeSensors {
|
||||
boolean anyListening = false;
|
||||
for (TriggerSensor s : mSensors) {
|
||||
boolean listen = mListening
|
||||
&& (!s.mRequiresTouchscreen || mListeningTouchScreenSensors);
|
||||
&& (!s.mRequiresTouchscreen || mListeningTouchScreenSensors)
|
||||
&& (!s.mRequiresProx || mListeningProxSensors);
|
||||
s.setListening(listen);
|
||||
if (listen) {
|
||||
anyListening = true;
|
||||
@@ -337,6 +369,8 @@ public class DozeSensors {
|
||||
public void dump(PrintWriter pw) {
|
||||
pw.println("mListening=" + mListening);
|
||||
pw.println("mListeningTouchScreenSensors=" + mListeningTouchScreenSensors);
|
||||
pw.println("mSelectivelyRegisterProxSensors=" + mSelectivelyRegisterProxSensors);
|
||||
pw.println("mListeningProxSensors=" + mListeningProxSensors);
|
||||
IndentingPrintWriter idpw = new IndentingPrintWriter(pw);
|
||||
idpw.increaseIndent();
|
||||
for (TriggerSensor s : mSensors) {
|
||||
@@ -361,6 +395,7 @@ public class DozeSensors {
|
||||
private final boolean mReportsTouchCoordinates;
|
||||
private final boolean mSettingDefault;
|
||||
private final boolean mRequiresTouchscreen;
|
||||
private final boolean mRequiresProx;
|
||||
|
||||
protected boolean mRequested;
|
||||
protected boolean mRegistered;
|
||||
@@ -378,12 +413,14 @@ public class DozeSensors {
|
||||
boolean configured, int pulseReason, boolean reportsTouchCoordinates,
|
||||
boolean requiresTouchscreen, DozeLog dozeLog) {
|
||||
this(sensor, setting, settingDef, configured, pulseReason, reportsTouchCoordinates,
|
||||
requiresTouchscreen, false /* ignoresSetting */, dozeLog);
|
||||
requiresTouchscreen, false /* ignoresSetting */,
|
||||
false /* requiresProx */, dozeLog);
|
||||
}
|
||||
|
||||
private TriggerSensor(Sensor sensor, String setting, boolean settingDef,
|
||||
boolean configured, int pulseReason, boolean reportsTouchCoordinates,
|
||||
boolean requiresTouchscreen, boolean ignoresSetting, DozeLog dozeLog) {
|
||||
boolean requiresTouchscreen, boolean ignoresSetting, boolean requiresProx,
|
||||
DozeLog dozeLog) {
|
||||
mSensor = sensor;
|
||||
mSetting = setting;
|
||||
mSettingDefault = settingDef;
|
||||
@@ -392,6 +429,7 @@ public class DozeSensors {
|
||||
mReportsTouchCoordinates = reportsTouchCoordinates;
|
||||
mRequiresTouchscreen = requiresTouchscreen;
|
||||
mIgnoresSetting = ignoresSetting;
|
||||
mRequiresProx = requiresProx;
|
||||
mDozeLog = dozeLog;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.systemui.doze;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.UiModeManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -42,7 +41,6 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.biometrics.AuthController;
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
import com.android.systemui.dagger.qualifiers.Background;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.dock.DockManager;
|
||||
import com.android.systemui.doze.dagger.DozeScope;
|
||||
@@ -101,15 +99,16 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
||||
private final AuthController mAuthController;
|
||||
private final DelayableExecutor mMainExecutor;
|
||||
private final DelayableExecutor mBgExecutor;
|
||||
|
||||
private long mNotificationPulseTime;
|
||||
private boolean mPulsePending;
|
||||
|
||||
private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
|
||||
private boolean mWantProx;
|
||||
private boolean mWantSensors;
|
||||
|
||||
/** see {@link #onProximityFar} prox for callback */
|
||||
private boolean mWantProxSensor;
|
||||
private boolean mWantTouchScreenSensors;
|
||||
private boolean mWantSensors;
|
||||
|
||||
@VisibleForTesting
|
||||
public enum DozingUpdateUiEvent implements UiEventLogger.UiEventEnum {
|
||||
@@ -177,13 +176,13 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
|
||||
@Inject
|
||||
public DozeTriggers(Context context, DozeHost dozeHost,
|
||||
AlarmManager alarmManager, AmbientDisplayConfiguration config,
|
||||
AmbientDisplayConfiguration config,
|
||||
DozeParameters dozeParameters, AsyncSensorManager sensorManager,
|
||||
WakeLock wakeLock, DockManager dockManager,
|
||||
ProximitySensor proximitySensor, ProximitySensor.ProximityCheck proxCheck,
|
||||
DozeLog dozeLog, BroadcastDispatcher broadcastDispatcher,
|
||||
SecureSettings secureSettings, AuthController authController,
|
||||
@Main DelayableExecutor mainExecutor, @Background DelayableExecutor bgExecutor) {
|
||||
@Main DelayableExecutor mainExecutor) {
|
||||
mContext = context;
|
||||
mDozeHost = dozeHost;
|
||||
mConfig = config;
|
||||
@@ -201,7 +200,6 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
mBroadcastDispatcher = broadcastDispatcher;
|
||||
mAuthController = authController;
|
||||
mMainExecutor = mainExecutor;
|
||||
mBgExecutor = bgExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -459,7 +457,7 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
break;
|
||||
case DOZE:
|
||||
case DOZE_AOD:
|
||||
mWantProx = newState != DozeMachine.State.DOZE;
|
||||
mWantProxSensor = newState != DozeMachine.State.DOZE;
|
||||
mWantSensors = true;
|
||||
mWantTouchScreenSensors = true;
|
||||
if (newState == DozeMachine.State.DOZE_AOD && !sWakeDisplaySensorState) {
|
||||
@@ -468,15 +466,15 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
break;
|
||||
case DOZE_AOD_PAUSED:
|
||||
case DOZE_AOD_PAUSING:
|
||||
mWantProx = true;
|
||||
mWantProxSensor = true;
|
||||
break;
|
||||
case DOZE_PULSING:
|
||||
case DOZE_PULSING_BRIGHT:
|
||||
mWantProx = true;
|
||||
mWantProxSensor = true;
|
||||
mWantTouchScreenSensors = false;
|
||||
break;
|
||||
case DOZE_AOD_DOCKED:
|
||||
mWantProx = false;
|
||||
mWantProxSensor = false;
|
||||
mWantTouchScreenSensors = false;
|
||||
break;
|
||||
case DOZE_PULSE_DONE:
|
||||
@@ -490,7 +488,7 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
mDozeSensors.setListening(false, false);
|
||||
mDozeSensors.setProxListening(false);
|
||||
mWantSensors = false;
|
||||
mWantProx = false;
|
||||
mWantProxSensor = false;
|
||||
mWantTouchScreenSensors = false;
|
||||
break;
|
||||
default:
|
||||
@@ -501,10 +499,10 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
@Override
|
||||
public void onScreenState(int state) {
|
||||
mDozeSensors.onScreenState(state);
|
||||
mDozeSensors.setProxListening(mWantProx && (state == Display.STATE_DOZE
|
||||
|| state == Display.STATE_DOZE_SUSPEND
|
||||
|| state == Display.STATE_OFF));
|
||||
mDozeSensors.setListening(mWantSensors, mWantTouchScreenSensors);
|
||||
final boolean lowPowerStateOrOff = state == Display.STATE_DOZE
|
||||
|| state == Display.STATE_DOZE_SUSPEND || state == Display.STATE_OFF;
|
||||
mDozeSensors.setProxListening(mWantProxSensor && lowPowerStateOrOff);
|
||||
mDozeSensors.setListening(mWantSensors, mWantTouchScreenSensors, lowPowerStateOrOff);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,15 +24,20 @@ import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.util.MathUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.systemui.Dumpable;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.doze.AlwaysOnDisplayPolicy;
|
||||
import com.android.systemui.doze.DozeScreenState;
|
||||
import com.android.systemui.dump.DumpManager;
|
||||
import com.android.systemui.statusbar.FeatureFlags;
|
||||
import com.android.systemui.statusbar.policy.BatteryController;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -42,7 +47,7 @@ import javax.inject.Inject;
|
||||
*/
|
||||
@SysUISingleton
|
||||
public class DozeParameters implements TunerService.Tunable,
|
||||
com.android.systemui.plugins.statusbar.DozeParameters {
|
||||
com.android.systemui.plugins.statusbar.DozeParameters, Dumpable {
|
||||
private static final int MAX_DURATION = 60 * 1000;
|
||||
public static final boolean FORCE_NO_BLANKING =
|
||||
SystemProperties.getBoolean("debug.force_no_blanking", false);
|
||||
@@ -68,11 +73,13 @@ public class DozeParameters implements TunerService.Tunable,
|
||||
PowerManager powerManager,
|
||||
BatteryController batteryController,
|
||||
TunerService tunerService,
|
||||
DumpManager dumpManager,
|
||||
FeatureFlags featureFlags) {
|
||||
mResources = resources;
|
||||
mAmbientDisplayConfiguration = ambientDisplayConfiguration;
|
||||
mAlwaysOnPolicy = alwaysOnDisplayPolicy;
|
||||
mBatteryController = batteryController;
|
||||
dumpManager.registerDumpable("DozeParameters", this);
|
||||
|
||||
mControlScreenOffAnimation = !getDisplayNeedsBlanking();
|
||||
mPowerManager = powerManager;
|
||||
@@ -85,20 +92,6 @@ public class DozeParameters implements TunerService.Tunable,
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
|
||||
}
|
||||
|
||||
public void dump(PrintWriter pw) {
|
||||
pw.println(" DozeParameters:");
|
||||
pw.print(" getDisplayStateSupported(): "); pw.println(getDisplayStateSupported());
|
||||
pw.print(" getPulseDuration(): "); pw.println(getPulseDuration());
|
||||
pw.print(" getPulseInDuration(): "); pw.println(getPulseInDuration());
|
||||
pw.print(" getPulseInVisibleDuration(): "); pw.println(getPulseVisibleDuration());
|
||||
pw.print(" getPulseOutDuration(): "); pw.println(getPulseOutDuration());
|
||||
pw.print(" getPulseOnSigMotion(): "); pw.println(getPulseOnSigMotion());
|
||||
pw.print(" getVibrateOnSigMotion(): "); pw.println(getVibrateOnSigMotion());
|
||||
pw.print(" getVibrateOnPickup(): "); pw.println(getVibrateOnPickup());
|
||||
pw.print(" getProxCheckBeforePulse(): "); pw.println(getProxCheckBeforePulse());
|
||||
pw.print(" getPickupVibrationThreshold(): "); pw.println(getPickupVibrationThreshold());
|
||||
}
|
||||
|
||||
public boolean getDisplayStateSupported() {
|
||||
return getBoolean("doze.display.supported", R.bool.doze_display_state_supported);
|
||||
}
|
||||
@@ -144,6 +137,16 @@ public class DozeParameters implements TunerService.Tunable,
|
||||
return getBoolean("doze.pulse.proxcheck", R.bool.doze_proximity_check_before_pulse);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if we should only register for sensors that use the proximity sensor when the
|
||||
* display state is {@link android.view.Display.STATE_OFF},
|
||||
* {@link android.view.Display.STATE_DOZE} or {@link android.view.Display.STATE_DOZE_SUSPEND}
|
||||
*/
|
||||
public boolean getSelectivelyRegisterSensorsUsingProx() {
|
||||
return getBoolean("doze.prox.selectively_register",
|
||||
R.bool.doze_selectively_register_prox);
|
||||
}
|
||||
|
||||
public int getPickupVibrationThreshold() {
|
||||
return getInt("doze.pickup.vibration.threshold", R.integer.doze_pickup_vibration_threshold);
|
||||
}
|
||||
@@ -233,8 +236,38 @@ public class DozeParameters implements TunerService.Tunable,
|
||||
return mResources.getBoolean(R.bool.doze_double_tap_reports_touch_coordinates);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the single tap sensor uses the proximity sensor.
|
||||
*/
|
||||
public boolean singleTapUsesProx() {
|
||||
return mResources.getBoolean(R.bool.doze_single_tap_uses_prox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the long press sensor uses the proximity sensor.
|
||||
*/
|
||||
public boolean longPressUsesProx() {
|
||||
return mResources.getBoolean(R.bool.doze_long_press_uses_prox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTuningChanged(String key, String newValue) {
|
||||
mDozeAlwaysOn = mAmbientDisplayConfiguration.alwaysOnEnabled(UserHandle.USER_CURRENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
|
||||
pw.print("getDisplayStateSupported(): "); pw.println(getDisplayStateSupported());
|
||||
pw.print("getPulseDuration(): "); pw.println(getPulseDuration());
|
||||
pw.print("getPulseInDuration(): "); pw.println(getPulseInDuration());
|
||||
pw.print("getPulseInVisibleDuration(): "); pw.println(getPulseVisibleDuration());
|
||||
pw.print("getPulseOutDuration(): "); pw.println(getPulseOutDuration());
|
||||
pw.print("getPulseOnSigMotion(): "); pw.println(getPulseOnSigMotion());
|
||||
pw.print("getVibrateOnSigMotion(): "); pw.println(getVibrateOnSigMotion());
|
||||
pw.print("getVibrateOnPickup(): "); pw.println(getVibrateOnPickup());
|
||||
pw.print("getProxCheckBeforePulse(): "); pw.println(getProxCheckBeforePulse());
|
||||
pw.print("getPickupVibrationThreshold(): "); pw.println(getPickupVibrationThreshold());
|
||||
pw.print("getSelectivelyRegisterSensorsUsingProx(): ");
|
||||
pw.println(getSelectivelyRegisterSensorsUsingProx());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ public class DozeConfigurationUtil {
|
||||
when(params.getProxCheckBeforePulse()).thenReturn(true);
|
||||
when(params.doubleTapReportsTouchCoordinates()).thenReturn(false);
|
||||
when(params.getDisplayNeedsBlanking()).thenReturn(false);
|
||||
when(params.getSelectivelyRegisterSensorsUsingProx()).thenReturn(false);
|
||||
when(params.singleTapUsesProx()).thenReturn(true);
|
||||
when(params.longPressUsesProx()).thenReturn(true);
|
||||
|
||||
doneHolder[0] = true;
|
||||
return params;
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
package com.android.systemui.doze;
|
||||
|
||||
import static com.android.systemui.doze.DozeLog.REASON_SENSOR_TAP;
|
||||
import static com.android.systemui.plugins.SensorManagerPlugin.Sensor.TYPE_WAKE_LOCK_SCREEN;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyFloat;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
@@ -87,6 +89,7 @@ public class DozeSensorsTest extends SysuiTestCase {
|
||||
private SensorManagerPlugin.SensorEventListener mWakeLockScreenListener;
|
||||
private TestableLooper mTestableLooper;
|
||||
private DozeSensors mDozeSensors;
|
||||
private TriggerSensor mSensorTap;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -149,6 +152,24 @@ public class DozeSensorsTest extends SysuiTestCase {
|
||||
verify(mTriggerSensor).setListening(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegisterSensorsUsingProx() {
|
||||
// GIVEN we only should register sensors using prox when not in low-powered mode / off
|
||||
// and the single tap sensor uses the proximity sensor
|
||||
when(mDozeParameters.getSelectivelyRegisterSensorsUsingProx()).thenReturn(true);
|
||||
when(mDozeParameters.singleTapUsesProx()).thenReturn(true);
|
||||
TestableDozeSensors dozeSensors = new TestableDozeSensors();
|
||||
|
||||
// THEN on initialization, the tap sensor isn't requested
|
||||
assertFalse(mSensorTap.mRequested);
|
||||
|
||||
// WHEN we're now in a low powered state
|
||||
dozeSensors.setListening(true, true, true);
|
||||
|
||||
// THEN the tap sensor is registered
|
||||
assertTrue(mSensorTap.mRequested);
|
||||
}
|
||||
|
||||
private class TestableDozeSensors extends DozeSensors {
|
||||
|
||||
TestableDozeSensors() {
|
||||
@@ -160,9 +181,11 @@ public class DozeSensorsTest extends SysuiTestCase {
|
||||
&& ((PluginSensor) sensor).mPluginSensor.getType()
|
||||
== TYPE_WAKE_LOCK_SCREEN) {
|
||||
mWakeLockScreenListener = (PluginSensor) sensor;
|
||||
} else if (sensor.mPulseReason == REASON_SENSOR_TAP) {
|
||||
mSensorTap = sensor;
|
||||
}
|
||||
}
|
||||
mSensors = new TriggerSensor[] {mTriggerSensor};
|
||||
mSensors = new TriggerSensor[] {mTriggerSensor, mSensorTap};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.display.AmbientDisplayConfiguration;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
@@ -70,8 +69,6 @@ public class DozeTriggersTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private DozeHost mHost;
|
||||
@Mock
|
||||
private AlarmManager mAlarmManager;
|
||||
@Mock
|
||||
private BroadcastDispatcher mBroadcastDispatcher;
|
||||
@Mock
|
||||
private DockManager mDockManager;
|
||||
@@ -89,8 +86,14 @@ public class DozeTriggersTest extends SysuiTestCase {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
AmbientDisplayConfiguration config = DozeConfigurationUtil.createMockConfig();
|
||||
DozeParameters parameters = DozeConfigurationUtil.createMockParameters();
|
||||
setupDozeTriggers(
|
||||
DozeConfigurationUtil.createMockConfig(),
|
||||
DozeConfigurationUtil.createMockParameters());
|
||||
}
|
||||
|
||||
private void setupDozeTriggers(
|
||||
AmbientDisplayConfiguration config,
|
||||
DozeParameters dozeParameters) throws Exception {
|
||||
mSensors = spy(new FakeSensorManager(mContext));
|
||||
mTapSensor = mSensors.getFakeTapSensor().getSensor();
|
||||
WakeLock wakeLock = new WakeLockFake();
|
||||
@@ -101,10 +104,10 @@ public class DozeTriggersTest extends SysuiTestCase {
|
||||
thresholdSensor.setLoaded(true);
|
||||
mProximitySensor = new FakeProximitySensor(thresholdSensor, null, mExecutor);
|
||||
|
||||
mTriggers = new DozeTriggers(mContext, mHost, mAlarmManager, config, parameters,
|
||||
mTriggers = new DozeTriggers(mContext, mHost, config, dozeParameters,
|
||||
asyncSensorManager, wakeLock, mDockManager, mProximitySensor,
|
||||
mProximityCheck, mock(DozeLog.class), mBroadcastDispatcher, new FakeSettings(),
|
||||
mAuthController, mExecutor, mExecutor);
|
||||
mAuthController, mExecutor);
|
||||
mTriggers.setDozeMachine(mMachine);
|
||||
waitForSensorManager();
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import androidx.test.runner.AndroidJUnit4;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.doze.AlwaysOnDisplayPolicy;
|
||||
import com.android.systemui.doze.DozeScreenState;
|
||||
import com.android.systemui.dump.DumpManager;
|
||||
import com.android.systemui.statusbar.FeatureFlags;
|
||||
import com.android.systemui.statusbar.policy.BatteryController;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
@@ -61,6 +62,7 @@ public class DozeParametersTest extends SysuiTestCase {
|
||||
@Mock private TunerService mTunerService;
|
||||
@Mock private BatteryController mBatteryController;
|
||||
@Mock private FeatureFlags mFeatureFlags;
|
||||
@Mock private DumpManager mDumpManager;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -72,6 +74,7 @@ public class DozeParametersTest extends SysuiTestCase {
|
||||
mPowerManager,
|
||||
mBatteryController,
|
||||
mTunerService,
|
||||
mDumpManager,
|
||||
mFeatureFlags
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user