Merge "Flicker free screen-on from AOD" into oc-dr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5f62026b4e
@@ -91,6 +91,7 @@ public class DozeMachine {
|
||||
case UNINITIALIZED:
|
||||
case INITIALIZED:
|
||||
case DOZE:
|
||||
case DOZE_REQUEST_PULSE:
|
||||
case DOZE_AOD_PAUSED:
|
||||
return Display.STATE_OFF;
|
||||
case DOZE_PULSING:
|
||||
|
||||
@@ -811,6 +811,7 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
synchronized (this) {
|
||||
mDeviceInteractive = false;
|
||||
mGoingToSleep = false;
|
||||
mWakeAndUnlocking = false;
|
||||
|
||||
resetKeyguardDonePendingLocked();
|
||||
mHideAnimationRun = false;
|
||||
@@ -1957,7 +1958,6 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
if (DEBUG) Log.d(TAG, "handleNotifyScreenTurnedOff");
|
||||
mStatusBarKeyguardViewManager.onScreenTurnedOff();
|
||||
mDrawnCallback = null;
|
||||
mWakeAndUnlocking = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ public class DozeScrimController {
|
||||
// be invoked when we're done so that the caller can drop the pulse wakelock.
|
||||
mPulseCallback = callback;
|
||||
mPulseReason = reason;
|
||||
mScrimController.setDozeInFrontAlpha(1f);
|
||||
mHandler.post(mPulseIn);
|
||||
}
|
||||
|
||||
@@ -290,10 +291,6 @@ public class DozeScrimController {
|
||||
|
||||
// Signal that the pulse is ready to turn the screen on and draw.
|
||||
pulseStarted();
|
||||
|
||||
if (mDozeParameters.getAlwaysOn()) {
|
||||
mHandler.post(DozeScrimController.this::onScreenTurnedOn);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
|
||||
if (!mUpdateMonitor.isDeviceInteractive()) {
|
||||
if (!mStatusBarKeyguardViewManager.isShowing()) {
|
||||
return MODE_ONLY_WAKE;
|
||||
} else if (pulsingOrAod() && unlockingAllowed) {
|
||||
} else if (mDozeScrimController.isPulsing() && unlockingAllowed) {
|
||||
return MODE_WAKE_AND_UNLOCK_PULSING;
|
||||
} else if (unlockingAllowed || !mUnlockMethodCache.isMethodSecure()) {
|
||||
return MODE_WAKE_AND_UNLOCK;
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.util.MathUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -120,6 +119,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
private boolean mKeyguardFadingOutInProgress;
|
||||
private boolean mAnimatingDozeUnlock;
|
||||
private ValueAnimator mKeyguardFadeoutAnimation;
|
||||
/** Wake up from AOD transition is starting; need fully opaque front scrim */
|
||||
private boolean mWakingUpFromAodStarting;
|
||||
/** Wake up from AOD transition is in progress; need black tint */
|
||||
private boolean mWakingUpFromAodInProgress;
|
||||
/** Wake up from AOD transition is animating; need to reset when animation finishes */
|
||||
private boolean mWakingUpFromAodAnimationRunning;
|
||||
|
||||
public ScrimController(LightBarController lightBarController, ScrimView scrimBehind,
|
||||
ScrimView scrimInFront, View headsUpScrim) {
|
||||
@@ -187,9 +192,32 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
public void prepareWakeUpFromAod() {
|
||||
mWakingUpFromAodInProgress = true;
|
||||
mWakingUpFromAodStarting = true;
|
||||
mAnimateChange = false;
|
||||
scheduleUpdate();
|
||||
onPreDraw();
|
||||
}
|
||||
|
||||
public void wakeUpFromAod() {
|
||||
if (mWakeAndUnlocking || mAnimateKeyguardFadingOut) {
|
||||
// Wake and unlocking has a separate transition that must not be interfered with.
|
||||
mWakingUpFromAodStarting = false;
|
||||
return;
|
||||
}
|
||||
if (mWakingUpFromAodStarting) {
|
||||
mWakingUpFromAodInProgress = true;
|
||||
mWakingUpFromAodStarting = false;
|
||||
mAnimateChange = true;
|
||||
scheduleUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setWakeAndUnlocking() {
|
||||
mWakeAndUnlocking = true;
|
||||
mAnimatingDozeUnlock = true;
|
||||
mWakingUpFromAodStarting = false;
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
@@ -356,7 +384,11 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
setScrimBehindAlpha(mScrimBehindAlpha);
|
||||
} else {
|
||||
float fraction = Math.max(0, Math.min(mFraction, 1));
|
||||
setScrimInFrontAlpha(0f);
|
||||
if (mWakingUpFromAodStarting) {
|
||||
setScrimInFrontAlpha(1f);
|
||||
} else {
|
||||
setScrimInFrontAlpha(0f);
|
||||
}
|
||||
setScrimBehindAlpha(fraction
|
||||
* (mScrimBehindAlphaKeyguard - mScrimBehindAlphaUnlocking)
|
||||
+ mScrimBehindAlphaUnlocking);
|
||||
@@ -426,7 +458,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
scrimView.setViewAlpha(alpha);
|
||||
|
||||
int dozeTint = Color.TRANSPARENT;
|
||||
if (mAnimatingDozeUnlock || mDozing) {
|
||||
|
||||
boolean dozing = mAnimatingDozeUnlock || mDozing;
|
||||
boolean frontScrimDozing = mWakingUpFromAodInProgress;
|
||||
if (dozing || frontScrimDozing && scrim == mScrimInFront) {
|
||||
dozeTint = Color.BLACK;
|
||||
}
|
||||
scrimView.setTint(dozeTint);
|
||||
@@ -458,6 +493,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
mKeyguardFadingOutInProgress = false;
|
||||
mAnimatingDozeUnlock = false;
|
||||
}
|
||||
if (mWakingUpFromAodAnimationRunning) {
|
||||
mWakingUpFromAodAnimationRunning = false;
|
||||
mWakingUpFromAodInProgress = false;
|
||||
}
|
||||
scrim.setTag(TAG_KEY_ANIM, null);
|
||||
scrim.setTag(TAG_KEY_ANIM_TARGET, null);
|
||||
}
|
||||
@@ -467,6 +506,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
mKeyguardFadingOutInProgress = true;
|
||||
mKeyguardFadeoutAnimation = anim;
|
||||
}
|
||||
if (mWakingUpFromAodInProgress) {
|
||||
mWakingUpFromAodAnimationRunning = true;
|
||||
}
|
||||
if (mSkipFirstFrame) {
|
||||
anim.setCurrentPlayTime(16);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
|
||||
import static android.app.StatusBarManager.windowStateToString;
|
||||
import static android.content.res.Configuration.UI_MODE_TYPE_CAR;
|
||||
|
||||
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_ASLEEP;
|
||||
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWAKE;
|
||||
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_WAKING;
|
||||
import static com.android.systemui.statusbar.notification.NotificationInflater.InflationCallback;
|
||||
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT;
|
||||
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT;
|
||||
@@ -4208,13 +4211,16 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
}
|
||||
|
||||
private boolean updateIsKeyguard() {
|
||||
boolean wakeAndUnlocking = mFingerprintUnlockController.getMode()
|
||||
== FingerprintUnlockController.MODE_WAKE_AND_UNLOCK;
|
||||
|
||||
// For dozing, keyguard needs to be shown whenever the device is non-interactive. Otherwise
|
||||
// there's no surface we can show to the user. Note that the device goes fully interactive
|
||||
// late in the transition, so we also allow the device to start dozing once the screen has
|
||||
// turned off fully.
|
||||
boolean keyguardForDozing = mDozingRequested &&
|
||||
(!mDeviceInteractive || isGoingToSleep() && (isScreenFullyOff() || mIsKeyguard));
|
||||
boolean shouldBeKeyguard = mKeyguardRequested || keyguardForDozing;
|
||||
boolean shouldBeKeyguard = (mKeyguardRequested || keyguardForDozing) && !wakeAndUnlocking;
|
||||
if (keyguardForDozing) {
|
||||
updatePanelExpansionForKeyguard();
|
||||
}
|
||||
@@ -4256,7 +4262,8 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
}
|
||||
|
||||
private void updatePanelExpansionForKeyguard() {
|
||||
if (mState == StatusBarState.KEYGUARD) {
|
||||
if (mState == StatusBarState.KEYGUARD && mFingerprintUnlockController.getMode()
|
||||
!= FingerprintUnlockController.MODE_WAKE_AND_UNLOCK) {
|
||||
instantExpandNotificationsPanel();
|
||||
} else if (mState == StatusBarState.FULLSCREEN_USER_SWITCHER) {
|
||||
instantCollapseNotificationPanel();
|
||||
@@ -5156,6 +5163,13 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
public void onScreenTurningOn() {
|
||||
mFalsingManager.onScreenTurningOn();
|
||||
mNotificationPanel.onScreenTurningOn();
|
||||
|
||||
int wakefulness = mWakefulnessLifecycle.getWakefulness();
|
||||
if (mDozing && (wakefulness == WAKEFULNESS_WAKING
|
||||
|| wakefulness == WAKEFULNESS_ASLEEP) && !isPulsing()) {
|
||||
mScrimController.prepareWakeUpFromAod();
|
||||
}
|
||||
|
||||
if (mLaunchCameraOnScreenTurningOn) {
|
||||
mNotificationPanel.launchCamera(false, mLastCameraLaunchSource);
|
||||
mLaunchCameraOnScreenTurningOn = false;
|
||||
@@ -5164,13 +5178,18 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
|
||||
@Override
|
||||
public void onScreenTurnedOn() {
|
||||
mScrimController.wakeUpFromAod();
|
||||
mDozeScrimController.onScreenTurnedOn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScreenTurnedOff() {
|
||||
mFalsingManager.onScreenOff();
|
||||
updateIsKeyguard();
|
||||
// If we pulse in from AOD, we turn the screen off first. However, updatingIsKeyguard
|
||||
// in that case destroys the HeadsUpManager state, so don't do it in that case.
|
||||
if (!isPulsing()) {
|
||||
updateIsKeyguard();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -86,13 +86,13 @@ public class DozeScreenStateTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScreen_onInRequestPulseWithAoD() {
|
||||
public void testScreen_offInRequestPulseWithAoD() {
|
||||
mScreen.transitionTo(UNINITIALIZED, INITIALIZED);
|
||||
mScreen.transitionTo(INITIALIZED, DOZE_AOD);
|
||||
|
||||
mScreen.transitionTo(DOZE, DOZE_REQUEST_PULSE);
|
||||
|
||||
assertEquals(Display.STATE_DOZE_SUSPEND, mServiceFake.screenState);
|
||||
assertEquals(Display.STATE_OFF, mServiceFake.screenState);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user