Merge "Make DozeParameters responsible for setting PowerManager#setDozeAfterScreenOff." into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a56af9677f
@@ -40,7 +40,6 @@ public interface DozeHost {
|
|||||||
void extendPulse(int reason);
|
void extendPulse(int reason);
|
||||||
|
|
||||||
void setAnimateWakeup(boolean animateWakeup);
|
void setAnimateWakeup(boolean animateWakeup);
|
||||||
void setAnimateScreenOff(boolean animateScreenOff);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports that a tap event happend on the Sensors Low Power Island.
|
* Reports that a tap event happend on the Sensors Low Power Island.
|
||||||
|
|||||||
@@ -21,22 +21,17 @@ import static com.android.systemui.doze.DozeMachine.State.DOZE_AOD_PAUSED;
|
|||||||
|
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.doze.dagger.DozeScope;
|
import com.android.systemui.doze.dagger.DozeScope;
|
||||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||||
import com.android.systemui.statusbar.phone.DozeParameters;
|
import com.android.systemui.statusbar.phone.DozeParameters;
|
||||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
|
||||||
import com.android.systemui.tuner.TunerService;
|
|
||||||
import com.android.systemui.util.AlarmTimeout;
|
import com.android.systemui.util.AlarmTimeout;
|
||||||
import com.android.systemui.util.wakelock.WakeLock;
|
import com.android.systemui.util.wakelock.WakeLock;
|
||||||
|
|
||||||
@@ -50,8 +45,7 @@ import dagger.Lazy;
|
|||||||
* The policy controlling doze.
|
* The policy controlling doze.
|
||||||
*/
|
*/
|
||||||
@DozeScope
|
@DozeScope
|
||||||
public class DozeUi implements DozeMachine.Part, TunerService.Tunable,
|
public class DozeUi implements DozeMachine.Part {
|
||||||
ConfigurationController.ConfigurationListener {
|
|
||||||
// if enabled, calls dozeTimeTick() whenever the time changes:
|
// if enabled, calls dozeTimeTick() whenever the time changes:
|
||||||
private static final boolean BURN_IN_TESTING_ENABLED = false;
|
private static final boolean BURN_IN_TESTING_ENABLED = false;
|
||||||
private static final long TIME_TICK_DEADLINE_MILLIS = 90 * 1000; // 1.5min
|
private static final long TIME_TICK_DEADLINE_MILLIS = 90 * 1000; // 1.5min
|
||||||
@@ -65,18 +59,8 @@ public class DozeUi implements DozeMachine.Part, TunerService.Tunable,
|
|||||||
private final DozeParameters mDozeParameters;
|
private final DozeParameters mDozeParameters;
|
||||||
private final DozeLog mDozeLog;
|
private final DozeLog mDozeLog;
|
||||||
private final Lazy<StatusBarStateController> mStatusBarStateController;
|
private final Lazy<StatusBarStateController> mStatusBarStateController;
|
||||||
private final TunerService mTunerService;
|
|
||||||
private final ConfigurationController mConfigurationController;
|
|
||||||
|
|
||||||
private boolean mKeyguardShowing;
|
|
||||||
private final KeyguardUpdateMonitorCallback mKeyguardVisibilityCallback =
|
private final KeyguardUpdateMonitorCallback mKeyguardVisibilityCallback =
|
||||||
new KeyguardUpdateMonitorCallback() {
|
new KeyguardUpdateMonitorCallback() {
|
||||||
@Override
|
|
||||||
public void onKeyguardVisibilityChanged(boolean showing) {
|
|
||||||
mKeyguardShowing = showing;
|
|
||||||
updateAnimateScreenOff();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimeChanged() {
|
public void onTimeChanged() {
|
||||||
if (BURN_IN_TESTING_ENABLED && mStatusBarStateController != null
|
if (BURN_IN_TESTING_ENABLED && mStatusBarStateController != null
|
||||||
@@ -88,11 +72,6 @@ public class DozeUi implements DozeMachine.Part, TunerService.Tunable,
|
|||||||
mHandler.post(mWakeLock.wrap(() -> {}));
|
mHandler.post(mWakeLock.wrap(() -> {}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onShadeExpandedChanged(boolean expanded) {
|
|
||||||
updateAnimateScreenOff();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private long mLastTimeTickElapsed = 0;
|
private long mLastTimeTickElapsed = 0;
|
||||||
@@ -101,9 +80,7 @@ public class DozeUi implements DozeMachine.Part, TunerService.Tunable,
|
|||||||
public DozeUi(Context context, AlarmManager alarmManager,
|
public DozeUi(Context context, AlarmManager alarmManager,
|
||||||
WakeLock wakeLock, DozeHost host, @Main Handler handler,
|
WakeLock wakeLock, DozeHost host, @Main Handler handler,
|
||||||
DozeParameters params, KeyguardUpdateMonitor keyguardUpdateMonitor,
|
DozeParameters params, KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||||
DozeLog dozeLog, TunerService tunerService,
|
DozeLog dozeLog, Lazy<StatusBarStateController> statusBarStateController) {
|
||||||
Lazy<StatusBarStateController> statusBarStateController,
|
|
||||||
ConfigurationController configurationController) {
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mWakeLock = wakeLock;
|
mWakeLock = wakeLock;
|
||||||
mHost = host;
|
mHost = host;
|
||||||
@@ -113,19 +90,7 @@ public class DozeUi implements DozeMachine.Part, TunerService.Tunable,
|
|||||||
mTimeTicker = new AlarmTimeout(alarmManager, this::onTimeTick, "doze_time_tick", handler);
|
mTimeTicker = new AlarmTimeout(alarmManager, this::onTimeTick, "doze_time_tick", handler);
|
||||||
keyguardUpdateMonitor.registerCallback(mKeyguardVisibilityCallback);
|
keyguardUpdateMonitor.registerCallback(mKeyguardVisibilityCallback);
|
||||||
mDozeLog = dozeLog;
|
mDozeLog = dozeLog;
|
||||||
mTunerService = tunerService;
|
|
||||||
mStatusBarStateController = statusBarStateController;
|
mStatusBarStateController = statusBarStateController;
|
||||||
|
|
||||||
mTunerService.addTunable(this, Settings.Secure.DOZE_ALWAYS_ON);
|
|
||||||
|
|
||||||
mConfigurationController = configurationController;
|
|
||||||
mConfigurationController.addCallback(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void destroy() {
|
|
||||||
mTunerService.removeTunable(this);
|
|
||||||
mConfigurationController.removeCallback(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -133,21 +98,6 @@ public class DozeUi implements DozeMachine.Part, TunerService.Tunable,
|
|||||||
mMachine = dozeMachine;
|
mMachine = dozeMachine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Decide if we're taking over the screen-off animation
|
|
||||||
* when the device was configured to skip doze after screen off.
|
|
||||||
*/
|
|
||||||
private void updateAnimateScreenOff() {
|
|
||||||
if (mCanAnimateTransition) {
|
|
||||||
final boolean controlScreenOff =
|
|
||||||
mDozeParameters.getAlwaysOn()
|
|
||||||
&& (mKeyguardShowing || mDozeParameters.shouldControlUnlockedScreenOff())
|
|
||||||
&& !mHost.isPowerSaveActive();
|
|
||||||
mDozeParameters.setControlScreenOffAnimation(controlScreenOff);
|
|
||||||
mHost.setAnimateScreenOff(controlScreenOff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pulseWhileDozing(int reason) {
|
private void pulseWhileDozing(int reason) {
|
||||||
mHost.pulseWhileDozing(
|
mHost.pulseWhileDozing(
|
||||||
new DozeHost.PulseCallback() {
|
new DozeHost.PulseCallback() {
|
||||||
@@ -276,21 +226,4 @@ public class DozeUi implements DozeMachine.Part, TunerService.Tunable,
|
|||||||
|
|
||||||
scheduleTimeTick();
|
scheduleTimeTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
KeyguardUpdateMonitorCallback getKeyguardCallback() {
|
|
||||||
return mKeyguardVisibilityCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTuningChanged(String key, String newValue) {
|
|
||||||
if (key.equals(Settings.Secure.DOZE_ALWAYS_ON)) {
|
|
||||||
updateAnimateScreenOff();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConfigChanged(Configuration newConfig) {
|
|
||||||
updateAnimateScreenOff();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.phone;
|
package com.android.systemui.statusbar.phone;
|
||||||
|
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.hardware.display.AmbientDisplayConfiguration;
|
import android.hardware.display.AmbientDisplayConfiguration;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
@@ -26,7 +27,10 @@ import android.util.Log;
|
|||||||
import android.util.MathUtils;
|
import android.util.MathUtils;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
|
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||||
import com.android.systemui.Dumpable;
|
import com.android.systemui.Dumpable;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.dagger.SysUISingleton;
|
import com.android.systemui.dagger.SysUISingleton;
|
||||||
@@ -35,7 +39,9 @@ import com.android.systemui.doze.AlwaysOnDisplayPolicy;
|
|||||||
import com.android.systemui.doze.DozeScreenState;
|
import com.android.systemui.doze.DozeScreenState;
|
||||||
import com.android.systemui.dump.DumpManager;
|
import com.android.systemui.dump.DumpManager;
|
||||||
import com.android.systemui.flags.FeatureFlags;
|
import com.android.systemui.flags.FeatureFlags;
|
||||||
|
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||||
import com.android.systemui.statusbar.policy.BatteryController;
|
import com.android.systemui.statusbar.policy.BatteryController;
|
||||||
|
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||||
import com.android.systemui.statusbar.policy.DevicePostureController;
|
import com.android.systemui.statusbar.policy.DevicePostureController;
|
||||||
import com.android.systemui.tuner.TunerService;
|
import com.android.systemui.tuner.TunerService;
|
||||||
|
|
||||||
@@ -53,7 +59,8 @@ import javax.inject.Inject;
|
|||||||
public class DozeParameters implements
|
public class DozeParameters implements
|
||||||
TunerService.Tunable,
|
TunerService.Tunable,
|
||||||
com.android.systemui.plugins.statusbar.DozeParameters,
|
com.android.systemui.plugins.statusbar.DozeParameters,
|
||||||
Dumpable {
|
Dumpable, ConfigurationController.ConfigurationListener,
|
||||||
|
StatusBarStateController.StateListener {
|
||||||
private static final int MAX_DURATION = 60 * 1000;
|
private static final int MAX_DURATION = 60 * 1000;
|
||||||
public static final boolean FORCE_NO_BLANKING =
|
public static final boolean FORCE_NO_BLANKING =
|
||||||
SystemProperties.getBoolean("debug.force_no_blanking", false);
|
SystemProperties.getBoolean("debug.force_no_blanking", false);
|
||||||
@@ -74,6 +81,22 @@ public class DozeParameters implements
|
|||||||
private boolean mDozeAlwaysOn;
|
private boolean mDozeAlwaysOn;
|
||||||
private boolean mControlScreenOffAnimation;
|
private boolean mControlScreenOffAnimation;
|
||||||
|
|
||||||
|
private boolean mKeyguardShowing;
|
||||||
|
@VisibleForTesting
|
||||||
|
final KeyguardUpdateMonitorCallback mKeyguardVisibilityCallback =
|
||||||
|
new KeyguardUpdateMonitorCallback() {
|
||||||
|
@Override
|
||||||
|
public void onKeyguardVisibilityChanged(boolean showing) {
|
||||||
|
mKeyguardShowing = showing;
|
||||||
|
updateControlScreenOff();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onShadeExpandedChanged(boolean expanded) {
|
||||||
|
updateControlScreenOff();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected DozeParameters(
|
protected DozeParameters(
|
||||||
@Main Resources resources,
|
@Main Resources resources,
|
||||||
@@ -84,7 +107,10 @@ public class DozeParameters implements
|
|||||||
TunerService tunerService,
|
TunerService tunerService,
|
||||||
DumpManager dumpManager,
|
DumpManager dumpManager,
|
||||||
FeatureFlags featureFlags,
|
FeatureFlags featureFlags,
|
||||||
UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) {
|
UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
|
||||||
|
KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||||
|
ConfigurationController configurationController,
|
||||||
|
StatusBarStateController statusBarStateController) {
|
||||||
mResources = resources;
|
mResources = resources;
|
||||||
mAmbientDisplayConfiguration = ambientDisplayConfiguration;
|
mAmbientDisplayConfiguration = ambientDisplayConfiguration;
|
||||||
mAlwaysOnPolicy = alwaysOnDisplayPolicy;
|
mAlwaysOnPolicy = alwaysOnDisplayPolicy;
|
||||||
@@ -97,10 +123,13 @@ public class DozeParameters implements
|
|||||||
mFeatureFlags = featureFlags;
|
mFeatureFlags = featureFlags;
|
||||||
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
|
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
|
||||||
|
|
||||||
|
keyguardUpdateMonitor.registerCallback(mKeyguardVisibilityCallback);
|
||||||
tunerService.addTunable(
|
tunerService.addTunable(
|
||||||
this,
|
this,
|
||||||
Settings.Secure.DOZE_ALWAYS_ON,
|
Settings.Secure.DOZE_ALWAYS_ON,
|
||||||
Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
|
Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
|
||||||
|
configurationController.addCallback(this);
|
||||||
|
statusBarStateController.addCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getDisplayStateSupported() {
|
public boolean getDisplayStateSupported() {
|
||||||
@@ -221,13 +250,29 @@ public class DozeParameters implements
|
|||||||
mPowerManager.setDozeAfterScreenOff(!controlScreenOffAnimation);
|
mPowerManager.setDozeAfterScreenOff(!controlScreenOffAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void updateControlScreenOff() {
|
||||||
|
if (!getDisplayNeedsBlanking()) {
|
||||||
|
final boolean controlScreenOff =
|
||||||
|
getAlwaysOn() && (mKeyguardShowing || shouldControlUnlockedScreenOff());
|
||||||
|
setControlScreenOffAnimation(controlScreenOff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether we want to control the screen off animation when the device is unlocked. If we do,
|
* Whether we want to control the screen off animation when the device is unlocked. If we do,
|
||||||
* we'll animate in AOD before turning off the screen, rather than simply fading to black and
|
* we'll animate in AOD before turning off the screen, rather than simply fading to black and
|
||||||
* then abruptly showing AOD.
|
* then abruptly showing AOD.
|
||||||
|
*
|
||||||
|
* There are currently several reasons we might not want to control the screen off even if we
|
||||||
|
* are able to, such as the shade being expanded, being in landscape, or having animations
|
||||||
|
* disabled for a11y.
|
||||||
*/
|
*/
|
||||||
public boolean shouldControlUnlockedScreenOff() {
|
public boolean shouldControlUnlockedScreenOff() {
|
||||||
return mUnlockedScreenOffAnimationController.shouldPlayUnlockedScreenOffAnimation();
|
return canControlUnlockedScreenOff()
|
||||||
|
&& mUnlockedScreenOffAnimationController.shouldPlayUnlockedScreenOffAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -308,11 +353,26 @@ public class DozeParameters implements
|
|||||||
@Override
|
@Override
|
||||||
public void onTuningChanged(String key, String newValue) {
|
public void onTuningChanged(String key, String newValue) {
|
||||||
mDozeAlwaysOn = mAmbientDisplayConfiguration.alwaysOnEnabled(UserHandle.USER_CURRENT);
|
mDozeAlwaysOn = mAmbientDisplayConfiguration.alwaysOnEnabled(UserHandle.USER_CURRENT);
|
||||||
|
|
||||||
|
if (key.equals(Settings.Secure.DOZE_ALWAYS_ON)) {
|
||||||
|
updateControlScreenOff();
|
||||||
|
}
|
||||||
|
|
||||||
for (Callback callback : mCallbacks) {
|
for (Callback callback : mCallbacks) {
|
||||||
callback.onAlwaysOnChange();
|
callback.onAlwaysOnChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigChanged(Configuration newConfig) {
|
||||||
|
updateControlScreenOff();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStatePostChange() {
|
||||||
|
updateControlScreenOff();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
|
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
|
||||||
pw.print("getAlwaysOn(): "); pw.println(getAlwaysOn());
|
pw.print("getAlwaysOn(): "); pw.println(getAlwaysOn());
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ public final class DozeServiceHost implements DozeHost {
|
|||||||
private final DozeLog mDozeLog;
|
private final DozeLog mDozeLog;
|
||||||
private final PowerManager mPowerManager;
|
private final PowerManager mPowerManager;
|
||||||
private boolean mAnimateWakeup;
|
private boolean mAnimateWakeup;
|
||||||
private boolean mAnimateScreenOff;
|
|
||||||
private boolean mIgnoreTouchWhilePulsing;
|
private boolean mIgnoreTouchWhilePulsing;
|
||||||
private Runnable mPendingScreenOffCallback;
|
private Runnable mPendingScreenOffCallback;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -356,11 +355,6 @@ public final class DozeServiceHost implements DozeHost {
|
|||||||
mAnimateWakeup = animateWakeup;
|
mAnimateWakeup = animateWakeup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAnimateScreenOff(boolean animateScreenOff) {
|
|
||||||
mAnimateScreenOff = animateScreenOff;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSlpiTap(float screenX, float screenY) {
|
public void onSlpiTap(float screenX, float screenY) {
|
||||||
if (screenX > 0 && screenY > 0 && mAmbientIndicationContainer != null
|
if (screenX > 0 && screenY > 0 && mAmbientIndicationContainer != null
|
||||||
@@ -440,10 +434,6 @@ public final class DozeServiceHost implements DozeHost {
|
|||||||
return mAnimateWakeup;
|
return mAnimateWakeup;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean shouldAnimateScreenOff() {
|
|
||||||
return mAnimateScreenOff;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean getIgnoreTouchWhilePulsing() {
|
boolean getIgnoreTouchWhilePulsing() {
|
||||||
return mIgnoreTouchWhilePulsing;
|
return mIgnoreTouchWhilePulsing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3190,7 +3190,7 @@ public class StatusBar extends SystemUI implements
|
|||||||
boolean wakeAndUnlock = mBiometricUnlockController.getMode()
|
boolean wakeAndUnlock = mBiometricUnlockController.getMode()
|
||||||
== BiometricUnlockController.MODE_WAKE_AND_UNLOCK;
|
== BiometricUnlockController.MODE_WAKE_AND_UNLOCK;
|
||||||
boolean animate = (!mDozing && mDozeServiceHost.shouldAnimateWakeup() && !wakeAndUnlock)
|
boolean animate = (!mDozing && mDozeServiceHost.shouldAnimateWakeup() && !wakeAndUnlock)
|
||||||
|| (mDozing && mDozeServiceHost.shouldAnimateScreenOff()
|
|| (mDozing && mDozeParameters.shouldControlScreenOff()
|
||||||
&& visibleNotOccludedOrWillBe);
|
&& visibleNotOccludedOrWillBe);
|
||||||
|
|
||||||
mNotificationPanelViewController.setDozing(mDozing, animate, mWakeUpTouchLocation);
|
mNotificationPanelViewController.setDozing(mDozing, animate, mWakeUpTouchLocation);
|
||||||
|
|||||||
@@ -226,10 +226,6 @@ class UnlockedScreenOffAnimationController @Inject constructor(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dozeParameters.get().canControlUnlockedScreenOff()) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// If animations are disabled system-wide, don't play this one either.
|
// If animations are disabled system-wide, don't play this one either.
|
||||||
if (Settings.Global.getString(
|
if (Settings.Global.getString(
|
||||||
context.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE) == "0") {
|
context.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE) == "0") {
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import static org.mockito.ArgumentMatchers.anyInt;
|
|||||||
import static org.mockito.ArgumentMatchers.anyLong;
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.clearInvocations;
|
import static org.mockito.Mockito.clearInvocations;
|
||||||
import static org.mockito.Mockito.never;
|
|
||||||
import static org.mockito.Mockito.reset;
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -91,8 +89,7 @@ public class DozeUiTest extends SysuiTestCase {
|
|||||||
mHandler = mHandlerThread.getThreadHandler();
|
mHandler = mHandlerThread.getThreadHandler();
|
||||||
|
|
||||||
mDozeUi = new DozeUi(mContext, mAlarmManager, mWakeLock, mHost, mHandler,
|
mDozeUi = new DozeUi(mContext, mAlarmManager, mWakeLock, mHost, mHandler,
|
||||||
mDozeParameters, mKeyguardUpdateMonitor, mDozeLog, mTunerService,
|
mDozeParameters, mKeyguardUpdateMonitor, mDozeLog, () -> mStatusBarStateController);
|
||||||
() -> mStatusBarStateController, mConfigurationController);
|
|
||||||
mDozeUi.setDozeMachine(mMachine);
|
mDozeUi.setDozeMachine(mMachine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +101,7 @@ public class DozeUiTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pausingAndUnpausingAod_registersTimeTickAfterUnpausing() throws Exception {
|
public void pausingAndUnpausingAod_registersTimeTickAfterUnpausing() {
|
||||||
mDozeUi.transitionTo(UNINITIALIZED, INITIALIZED);
|
mDozeUi.transitionTo(UNINITIALIZED, INITIALIZED);
|
||||||
mDozeUi.transitionTo(INITIALIZED, DOZE_AOD);
|
mDozeUi.transitionTo(INITIALIZED, DOZE_AOD);
|
||||||
mDozeUi.transitionTo(DOZE_AOD, DOZE_AOD_PAUSED);
|
mDozeUi.transitionTo(DOZE_AOD, DOZE_AOD_PAUSED);
|
||||||
@@ -117,45 +114,9 @@ public class DozeUiTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void propagatesAnimateScreenOff_noAlwaysOn() {
|
public void transitionSetsAnimateWakeup_noAlwaysOn() {
|
||||||
reset(mHost);
|
mDozeUi.transitionTo(UNINITIALIZED, DOZE);
|
||||||
when(mDozeParameters.getAlwaysOn()).thenReturn(false);
|
verify(mHost).setAnimateWakeup(eq(false));
|
||||||
when(mDozeParameters.getDisplayNeedsBlanking()).thenReturn(false);
|
|
||||||
|
|
||||||
mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(false);
|
|
||||||
verify(mHost).setAnimateScreenOff(eq(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void propagatesAnimateScreenOff_alwaysOn() {
|
|
||||||
reset(mHost);
|
|
||||||
when(mDozeParameters.getAlwaysOn()).thenReturn(true);
|
|
||||||
when(mDozeParameters.getDisplayNeedsBlanking()).thenReturn(false);
|
|
||||||
|
|
||||||
// Take over when the keyguard is visible.
|
|
||||||
mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(true);
|
|
||||||
verify(mHost).setAnimateScreenOff(eq(true));
|
|
||||||
|
|
||||||
// Do not animate screen-off when keyguard isn't visible - PowerManager will do it.
|
|
||||||
mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(false);
|
|
||||||
verify(mHost).setAnimateScreenOff(eq(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void neverAnimateScreenOff_whenNotSupported() {
|
|
||||||
// Re-initialize DozeParameters saying that the display requires blanking.
|
|
||||||
reset(mDozeParameters);
|
|
||||||
reset(mHost);
|
|
||||||
when(mDozeParameters.getDisplayNeedsBlanking()).thenReturn(true);
|
|
||||||
mDozeUi = new DozeUi(mContext, mAlarmManager, mWakeLock, mHost, mHandler,
|
|
||||||
mDozeParameters, mKeyguardUpdateMonitor, mDozeLog, mTunerService,
|
|
||||||
() -> mStatusBarStateController, mConfigurationController);
|
|
||||||
mDozeUi.setDozeMachine(mMachine);
|
|
||||||
|
|
||||||
// Never animate if display doesn't support it.
|
|
||||||
mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(true);
|
|
||||||
mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(false);
|
|
||||||
verify(mHost, never()).setAnimateScreenOff(eq(false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -165,49 +126,4 @@ public class DozeUiTest extends SysuiTestCase {
|
|||||||
mDozeUi.transitionTo(UNINITIALIZED, DOZE);
|
mDozeUi.transitionTo(UNINITIALIZED, DOZE);
|
||||||
verify(mHost).setAnimateWakeup(eq(true));
|
verify(mHost).setAnimateWakeup(eq(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void keyguardVisibility_changesControlScreenOffAnimation() {
|
|
||||||
// Pre-condition
|
|
||||||
reset(mDozeParameters);
|
|
||||||
when(mDozeParameters.getAlwaysOn()).thenReturn(true);
|
|
||||||
when(mDozeParameters.getDisplayNeedsBlanking()).thenReturn(false);
|
|
||||||
|
|
||||||
mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(false);
|
|
||||||
verify(mDozeParameters).setControlScreenOffAnimation(eq(false));
|
|
||||||
mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(true);
|
|
||||||
verify(mDozeParameters).setControlScreenOffAnimation(eq(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void transitionSetsAnimateWakeup_noAlwaysOn() {
|
|
||||||
mDozeUi.transitionTo(UNINITIALIZED, DOZE);
|
|
||||||
verify(mHost).setAnimateWakeup(eq(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void controlScreenOffTrueWhenKeyguardNotShowingAndControlUnlockedScreenOff() {
|
|
||||||
when(mDozeParameters.getAlwaysOn()).thenReturn(true);
|
|
||||||
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true);
|
|
||||||
|
|
||||||
// Tell doze that keyguard is not visible.
|
|
||||||
mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(false /* showing */);
|
|
||||||
|
|
||||||
// Since we're controlling the unlocked screen off animation, verify that we've asked to
|
|
||||||
// control the screen off animation despite being unlocked.
|
|
||||||
verify(mDozeParameters).setControlScreenOffAnimation(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void controlScreenOffFalseWhenKeyguardNotShowingAndControlUnlockedScreenOffFalse() {
|
|
||||||
when(mDozeParameters.getAlwaysOn()).thenReturn(true);
|
|
||||||
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(false);
|
|
||||||
|
|
||||||
// Tell doze that keyguard is not visible.
|
|
||||||
mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(false /* showing */);
|
|
||||||
|
|
||||||
// Since we're not controlling the unlocked screen off animation, verify that we haven't
|
|
||||||
// asked to control the screen off animation since we're unlocked.
|
|
||||||
verify(mDozeParameters).setControlScreenOffAnimation(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,9 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.reset;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@@ -34,12 +33,15 @@ import android.test.suitebuilder.annotation.SmallTest;
|
|||||||
|
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.doze.AlwaysOnDisplayPolicy;
|
import com.android.systemui.doze.AlwaysOnDisplayPolicy;
|
||||||
import com.android.systemui.doze.DozeScreenState;
|
import com.android.systemui.doze.DozeScreenState;
|
||||||
import com.android.systemui.dump.DumpManager;
|
import com.android.systemui.dump.DumpManager;
|
||||||
import com.android.systemui.flags.FeatureFlags;
|
import com.android.systemui.flags.FeatureFlags;
|
||||||
|
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||||
import com.android.systemui.statusbar.policy.BatteryController;
|
import com.android.systemui.statusbar.policy.BatteryController;
|
||||||
|
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||||
import com.android.systemui.tuner.TunerService;
|
import com.android.systemui.tuner.TunerService;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@@ -52,7 +54,6 @@ import org.mockito.MockitoAnnotations;
|
|||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class DozeParametersTest extends SysuiTestCase {
|
public class DozeParametersTest extends SysuiTestCase {
|
||||||
|
|
||||||
private DozeParameters mDozeParameters;
|
private DozeParameters mDozeParameters;
|
||||||
|
|
||||||
@Mock Resources mResources;
|
@Mock Resources mResources;
|
||||||
@@ -64,10 +65,31 @@ public class DozeParametersTest extends SysuiTestCase {
|
|||||||
@Mock private FeatureFlags mFeatureFlags;
|
@Mock private FeatureFlags mFeatureFlags;
|
||||||
@Mock private DumpManager mDumpManager;
|
@Mock private DumpManager mDumpManager;
|
||||||
@Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
|
@Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
|
||||||
|
@Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
|
@Mock private StatusBarStateController mStatusBarStateController;
|
||||||
|
@Mock private ConfigurationController mConfigurationController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current value of PowerManager's dozeAfterScreenOff property.
|
||||||
|
*
|
||||||
|
* This property controls whether System UI is controlling the screen off animation. If it's
|
||||||
|
* false (PowerManager should not doze after screen off) then System UI is controlling the
|
||||||
|
* animation. If true, we're not controlling it and PowerManager will doze immediately.
|
||||||
|
*/
|
||||||
|
private boolean mPowerManagerDozeAfterScreenOff;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
// Save the current value set for dozeAfterScreenOff so we can make assertions. This method
|
||||||
|
// is only called if the value changes, which makes it difficult to check that it was set
|
||||||
|
// correctly in tests.
|
||||||
|
doAnswer(invocation -> {
|
||||||
|
mPowerManagerDozeAfterScreenOff = invocation.getArgument(0);
|
||||||
|
return mPowerManagerDozeAfterScreenOff;
|
||||||
|
}).when(mPowerManager).setDozeAfterScreenOff(anyBoolean());
|
||||||
|
|
||||||
mDozeParameters = new DozeParameters(
|
mDozeParameters = new DozeParameters(
|
||||||
mResources,
|
mResources,
|
||||||
mAmbientDisplayConfiguration,
|
mAmbientDisplayConfiguration,
|
||||||
@@ -77,23 +99,30 @@ public class DozeParametersTest extends SysuiTestCase {
|
|||||||
mTunerService,
|
mTunerService,
|
||||||
mDumpManager,
|
mDumpManager,
|
||||||
mFeatureFlags,
|
mFeatureFlags,
|
||||||
mUnlockedScreenOffAnimationController
|
mUnlockedScreenOffAnimationController,
|
||||||
|
mKeyguardUpdateMonitor,
|
||||||
|
mConfigurationController,
|
||||||
|
mStatusBarStateController
|
||||||
);
|
);
|
||||||
}
|
|
||||||
@Test
|
when(mFeatureFlags.useNewLockscreenAnimations()).thenReturn(true);
|
||||||
public void testSetControlScreenOffAnimation_setsDozeAfterScreenOff_false() {
|
|
||||||
mDozeParameters.setControlScreenOffAnimation(true);
|
setAodEnabledForTest(true);
|
||||||
reset(mPowerManager);
|
setShouldControlUnlockedScreenOffForTest(true);
|
||||||
mDozeParameters.setControlScreenOffAnimation(false);
|
setDisplayNeedsBlankingForTest(false);
|
||||||
verify(mPowerManager).setDozeAfterScreenOff(eq(true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetControlScreenOffAnimation_setsDozeAfterScreenOff_true() {
|
public void testSetControlScreenOffAnimation_setsDozeAfterScreenOff_correctly() {
|
||||||
mDozeParameters.setControlScreenOffAnimation(false);
|
// If we want to control screen off, we do NOT want PowerManager to doze after screen off.
|
||||||
reset(mPowerManager);
|
// Obviously.
|
||||||
mDozeParameters.setControlScreenOffAnimation(true);
|
mDozeParameters.setControlScreenOffAnimation(true);
|
||||||
verify(mPowerManager).setDozeAfterScreenOff(eq(false));
|
assertFalse(mPowerManagerDozeAfterScreenOff);
|
||||||
|
|
||||||
|
// If we don't want to control screen off, PowerManager is free to doze after screen off if
|
||||||
|
// that's what'll make it happy.
|
||||||
|
mDozeParameters.setControlScreenOffAnimation(false);
|
||||||
|
assertTrue(mPowerManagerDozeAfterScreenOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -122,37 +151,124 @@ public class DozeParametersTest extends SysuiTestCase {
|
|||||||
assertThat(mDozeParameters.getAlwaysOn()).isFalse();
|
assertThat(mDozeParameters.getAlwaysOn()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PowerManager.setDozeAfterScreenOff(true) means we are not controlling screen off, and calling
|
||||||
|
* it with false means we are. Confusing, but sure - make sure that we call PowerManager with
|
||||||
|
* the correct value depending on whether we want to control screen off.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testControlUnlockedScreenOffAnimation_dozeAfterScreenOff_false() {
|
public void testControlUnlockedScreenOffAnimation_dozeAfterScreenOff_false() {
|
||||||
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
|
// If AOD is disabled, we shouldn't want to control screen off. Also, let's double check
|
||||||
mDozeParameters.onTuningChanged(Settings.Secure.DOZE_ALWAYS_ON, "1");
|
// that when that value is updated, we called through to PowerManager.
|
||||||
when(mFeatureFlags.useNewLockscreenAnimations()).thenReturn(true);
|
setAodEnabledForTest(false);
|
||||||
when(mUnlockedScreenOffAnimationController.shouldPlayUnlockedScreenOffAnimation())
|
assertFalse(mDozeParameters.shouldControlScreenOff());
|
||||||
.thenReturn(true);
|
assertTrue(mPowerManagerDozeAfterScreenOff);
|
||||||
assertTrue(mDozeParameters.shouldControlUnlockedScreenOff());
|
|
||||||
|
|
||||||
// Trigger the setter for the current value.
|
// And vice versa...
|
||||||
mDozeParameters.setControlScreenOffAnimation(mDozeParameters.shouldControlScreenOff());
|
setAodEnabledForTest(true);
|
||||||
|
assertTrue(mDozeParameters.shouldControlScreenOff());
|
||||||
// We should have asked power manager not to doze after screen off no matter what, since
|
assertFalse(mPowerManagerDozeAfterScreenOff);
|
||||||
// we're animating and controlling screen off.
|
|
||||||
verify(mPowerManager).setDozeAfterScreenOff(eq(false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testControlUnlockedScreenOffAnimationDisabled_dozeAfterScreenOff() {
|
public void testControlUnlockedScreenOffAnimationDisabled_dozeAfterScreenOff() {
|
||||||
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
|
setShouldControlUnlockedScreenOffForTest(true);
|
||||||
mDozeParameters.onTuningChanged(Settings.Secure.DOZE_ALWAYS_ON, "1");
|
|
||||||
when(mFeatureFlags.useNewLockscreenAnimations()).thenReturn(false);
|
when(mFeatureFlags.useNewLockscreenAnimations()).thenReturn(false);
|
||||||
|
|
||||||
assertFalse(mDozeParameters.shouldControlUnlockedScreenOff());
|
assertFalse(mDozeParameters.shouldControlUnlockedScreenOff());
|
||||||
|
|
||||||
// Trigger the setter for the current value.
|
// Trigger the setter for the current value.
|
||||||
mDozeParameters.setControlScreenOffAnimation(mDozeParameters.shouldControlScreenOff());
|
mDozeParameters.setControlScreenOffAnimation(mDozeParameters.shouldControlScreenOff());
|
||||||
|
assertFalse(mDozeParameters.shouldControlScreenOff());
|
||||||
|
}
|
||||||
|
|
||||||
// We should have asked power manager to doze only if we're not controlling screen off
|
@Test
|
||||||
// normally.
|
public void propagatesAnimateScreenOff_noAlwaysOn() {
|
||||||
verify(mPowerManager).setDozeAfterScreenOff(
|
setAodEnabledForTest(false);
|
||||||
eq(!mDozeParameters.shouldControlScreenOff()));
|
setDisplayNeedsBlankingForTest(false);
|
||||||
|
|
||||||
|
mDozeParameters.mKeyguardVisibilityCallback.onKeyguardVisibilityChanged(false);
|
||||||
|
assertFalse(mDozeParameters.shouldControlScreenOff());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void propagatesAnimateScreenOff_alwaysOn() {
|
||||||
|
setAodEnabledForTest(true);
|
||||||
|
setDisplayNeedsBlankingForTest(false);
|
||||||
|
setShouldControlUnlockedScreenOffForTest(false);
|
||||||
|
|
||||||
|
// Take over when the keyguard is visible.
|
||||||
|
mDozeParameters.mKeyguardVisibilityCallback.onKeyguardVisibilityChanged(true);
|
||||||
|
assertTrue(mDozeParameters.shouldControlScreenOff());
|
||||||
|
|
||||||
|
// Do not animate screen-off when keyguard isn't visible.
|
||||||
|
mDozeParameters.mKeyguardVisibilityCallback.onKeyguardVisibilityChanged(false);
|
||||||
|
assertFalse(mDozeParameters.shouldControlScreenOff());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void neverAnimateScreenOff_whenNotSupported() {
|
||||||
|
setDisplayNeedsBlankingForTest(true);
|
||||||
|
|
||||||
|
// Never animate if display doesn't support it.
|
||||||
|
mDozeParameters.mKeyguardVisibilityCallback.onKeyguardVisibilityChanged(true);
|
||||||
|
assertFalse(mDozeParameters.shouldControlScreenOff());
|
||||||
|
mDozeParameters.mKeyguardVisibilityCallback.onKeyguardVisibilityChanged(false);
|
||||||
|
assertFalse(mDozeParameters.shouldControlScreenOff());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void controlScreenOffTrueWhenKeyguardNotShowingAndControlUnlockedScreenOff() {
|
||||||
|
setShouldControlUnlockedScreenOffForTest(true);
|
||||||
|
|
||||||
|
// Tell doze that keyguard is not visible.
|
||||||
|
mDozeParameters.mKeyguardVisibilityCallback.onKeyguardVisibilityChanged(
|
||||||
|
false /* showing */);
|
||||||
|
|
||||||
|
// Since we're controlling the unlocked screen off animation, verify that we've asked to
|
||||||
|
// control the screen off animation despite being unlocked.
|
||||||
|
assertTrue(mDozeParameters.shouldControlScreenOff());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void keyguardVisibility_changesControlScreenOffAnimation() {
|
||||||
|
setShouldControlUnlockedScreenOffForTest(false);
|
||||||
|
|
||||||
|
mDozeParameters.mKeyguardVisibilityCallback.onKeyguardVisibilityChanged(false);
|
||||||
|
assertFalse(mDozeParameters.shouldControlScreenOff());
|
||||||
|
mDozeParameters.mKeyguardVisibilityCallback.onKeyguardVisibilityChanged(true);
|
||||||
|
assertTrue(mDozeParameters.shouldControlScreenOff());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void keyguardVisibility_changesControlScreenOffAnimation_respectsUnlockedScreenOff() {
|
||||||
|
setShouldControlUnlockedScreenOffForTest(true);
|
||||||
|
|
||||||
|
// Even if the keyguard is gone, we should control screen off if we can control unlocked
|
||||||
|
// screen off.
|
||||||
|
mDozeParameters.mKeyguardVisibilityCallback.onKeyguardVisibilityChanged(false);
|
||||||
|
assertTrue(mDozeParameters.shouldControlScreenOff());
|
||||||
|
|
||||||
|
mDozeParameters.mKeyguardVisibilityCallback.onKeyguardVisibilityChanged(true);
|
||||||
|
assertTrue(mDozeParameters.shouldControlScreenOff());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDisplayNeedsBlankingForTest(boolean needsBlanking) {
|
||||||
|
when(mResources.getBoolean(
|
||||||
|
com.android.internal.R.bool.config_displayBlanksAfterDoze)).thenReturn(
|
||||||
|
needsBlanking);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAodEnabledForTest(boolean enabled) {
|
||||||
|
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(enabled);
|
||||||
|
mDozeParameters.onTuningChanged(Settings.Secure.DOZE_ALWAYS_ON, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setShouldControlUnlockedScreenOffForTest(boolean shouldControl) {
|
||||||
|
when(mUnlockedScreenOffAnimationController.shouldPlayUnlockedScreenOffAnimation())
|
||||||
|
.thenReturn(shouldControl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user