am 50ff3afb: Start pulse fading exactly when screen is turned on

* commit '50ff3afb01f2ac4a93dba418a71d54ad8adeba9d':
  Start pulse fading exactly when screen is turned on
This commit is contained in:
Jorim Jaggi
2015-08-14 19:01:55 +00:00
committed by Android Git Automerger
9 changed files with 43 additions and 58 deletions

View File

@@ -260,12 +260,6 @@
<!-- Doze: pulse parameter - how long does it take to fade in after a pickup? --> <!-- Doze: pulse parameter - how long does it take to fade in after a pickup? -->
<integer name="doze_pulse_duration_in_pickup">300</integer> <integer name="doze_pulse_duration_in_pickup">300</integer>
<!-- Doze: pulse parameter - delay to wait for the screen to wake up -->
<integer name="doze_pulse_delay_in">200</integer>
<!-- Doze: pulse parameter - delay to wait for the screen to wake up after a pickup -->
<integer name="doze_pulse_delay_in_pickup">200</integer>
<!-- Doze: pulse parameter - once faded in, how long does it stay visible? --> <!-- Doze: pulse parameter - once faded in, how long does it stay visible? -->
<integer name="doze_pulse_duration_visible">3000</integer> <integer name="doze_pulse_duration_visible">3000</integer>

View File

@@ -167,13 +167,7 @@ public abstract class BaseStatusBar extends SystemUI implements
// on-screen navigation buttons // on-screen navigation buttons
protected NavigationBarView mNavigationBarView = null; protected NavigationBarView mNavigationBarView = null;
protected Boolean mScreenOn; protected boolean mDeviceInteractive;
// The second field is a bit different from the first one because it only listens to screen on/
// screen of events from Keyguard. We need this so we don't have a race condition with the
// broadcast. In the future, we should remove the first field altogether and rename the second
// field.
protected boolean mScreenOnFromKeyguard;
protected boolean mVisible; protected boolean mVisible;
@@ -1619,7 +1613,7 @@ public abstract class BaseStatusBar extends SystemUI implements
protected void updateVisibleToUser() { protected void updateVisibleToUser() {
boolean oldVisibleToUser = mVisibleToUser; boolean oldVisibleToUser = mVisibleToUser;
mVisibleToUser = mVisible && mScreenOnFromKeyguard; mVisibleToUser = mVisible && mDeviceInteractive;
if (oldVisibleToUser != mVisibleToUser) { if (oldVisibleToUser != mVisibleToUser) {
handleVisibleToUserChanged(mVisibleToUser); handleVisibleToUserChanged(mVisibleToUser);

View File

@@ -50,8 +50,6 @@ public class DozeParameters {
pw.print(" getPulseDuration(pickup=true): "); pw.println(getPulseDuration(true)); pw.print(" getPulseDuration(pickup=true): "); pw.println(getPulseDuration(true));
pw.print(" getPulseInDuration(pickup=false): "); pw.println(getPulseInDuration(false)); pw.print(" getPulseInDuration(pickup=false): "); pw.println(getPulseInDuration(false));
pw.print(" getPulseInDuration(pickup=true): "); pw.println(getPulseInDuration(true)); pw.print(" getPulseInDuration(pickup=true): "); pw.println(getPulseInDuration(true));
pw.print(" getPulseInDelay(pickup=false): "); pw.println(getPulseInDelay(false));
pw.print(" getPulseInDelay(pickup=true): "); pw.println(getPulseInDelay(true));
pw.print(" getPulseInVisibleDuration(): "); pw.println(getPulseVisibleDuration()); pw.print(" getPulseInVisibleDuration(): "); pw.println(getPulseVisibleDuration());
pw.print(" getPulseOutDuration(): "); pw.println(getPulseOutDuration()); pw.print(" getPulseOutDuration(): "); pw.println(getPulseOutDuration());
pw.print(" getPulseOnSigMotion(): "); pw.println(getPulseOnSigMotion()); pw.print(" getPulseOnSigMotion(): "); pw.println(getPulseOnSigMotion());
@@ -80,12 +78,6 @@ public class DozeParameters {
: getInt("doze.pulse.duration.in", R.integer.doze_pulse_duration_in); : getInt("doze.pulse.duration.in", R.integer.doze_pulse_duration_in);
} }
public int getPulseInDelay(boolean pickup) {
return pickup
? getInt("doze.pulse.delay.in.pickup", R.integer.doze_pulse_delay_in_pickup)
: getInt("doze.pulse.delay.in", R.integer.doze_pulse_delay_in);
}
public int getPulseVisibleDuration() { public int getPulseVisibleDuration() {
return getInt("doze.pulse.duration.visible", R.integer.doze_pulse_duration_visible); return getInt("doze.pulse.duration.visible", R.integer.doze_pulse_duration_visible);
} }

View File

@@ -100,6 +100,16 @@ public class DozeScrimController {
mHandler.post(mPulseIn); mHandler.post(mPulseIn);
} }
public void onScreenTurnedOn() {
if (isPulsing()) {
final boolean pickup = mPulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
startScrimAnimation(true /* inFront */, 0f,
mDozeParameters.getPulseInDuration(pickup),
pickup ? mPulseInInterpolatorPickup : mPulseInInterpolator,
mPulseInFinished);
}
}
public boolean isPulsing() { public boolean isPulsing() {
return mPulseCallback != null; return mPulseCallback != null;
} }
@@ -138,12 +148,11 @@ public class DozeScrimController {
private void startScrimAnimation(final boolean inFront, float target, long duration, private void startScrimAnimation(final boolean inFront, float target, long duration,
Interpolator interpolator) { Interpolator interpolator) {
startScrimAnimation(inFront, target, duration, interpolator, 0 /* delay */, startScrimAnimation(inFront, target, duration, interpolator, null /* endRunnable */);
null /* endRunnable */);
} }
private void startScrimAnimation(final boolean inFront, float target, long duration, private void startScrimAnimation(final boolean inFront, float target, long duration,
Interpolator interpolator, long delay, final Runnable endRunnable) { Interpolator interpolator, final Runnable endRunnable) {
Animator current = getCurrentAnimator(inFront); Animator current = getCurrentAnimator(inFront);
if (current != null) { if (current != null) {
float currentTarget = getCurrentTarget(inFront); float currentTarget = getCurrentTarget(inFront);
@@ -162,7 +171,6 @@ public class DozeScrimController {
}); });
anim.setInterpolator(interpolator); anim.setInterpolator(interpolator);
anim.setDuration(duration); anim.setDuration(duration);
anim.setStartDelay(delay);
anim.addListener(new AnimatorListenerAdapter() { anim.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
@@ -222,12 +230,6 @@ public class DozeScrimController {
+ DozeLog.pulseReasonToString(mPulseReason)); + DozeLog.pulseReasonToString(mPulseReason));
if (!mDozing) return; if (!mDozing) return;
DozeLog.tracePulseStart(mPulseReason); DozeLog.tracePulseStart(mPulseReason);
final boolean pickup = mPulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
startScrimAnimation(true /* inFront */, 0f,
mDozeParameters.getPulseInDuration(pickup),
pickup ? mPulseInInterpolatorPickup : mPulseInInterpolator,
mDozeParameters.getPulseInDelay(pickup),
mPulseInFinished);
// Signal that the pulse is ready to turn the screen on and draw. // Signal that the pulse is ready to turn the screen on and draw.
pulseStarted(); pulseStarted();
@@ -249,7 +251,7 @@ public class DozeScrimController {
if (DEBUG) Log.d(TAG, "Pulse out, mDozing=" + mDozing); if (DEBUG) Log.d(TAG, "Pulse out, mDozing=" + mDozing);
if (!mDozing) return; if (!mDozing) return;
startScrimAnimation(true /* inFront */, 1f, mDozeParameters.getPulseOutDuration(), startScrimAnimation(true /* inFront */, 1f, mDozeParameters.getPulseOutDuration(),
mPulseOutInterpolator, 0 /* delay */, mPulseOutFinished); mPulseOutInterpolator, mPulseOutFinished);
} }
}; };

View File

@@ -918,7 +918,7 @@ public class NotificationPanelView extends PanelView implements
} }
private int getFalsingThreshold() { private int getFalsingThreshold() {
float factor = mStatusBar.isScreenOnComingFromTouch() ? 1.5f : 1.0f; float factor = mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
return (int) (mQsFalsingThreshold * factor); return (int) (mQsFalsingThreshold * factor);
} }
@@ -2075,7 +2075,7 @@ public class NotificationPanelView extends PanelView implements
@Override @Override
public float getAffordanceFalsingFactor() { public float getAffordanceFalsingFactor() {
return mStatusBar.isScreenOnComingFromTouch() ? 1.5f : 1.0f; return mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
} }
@Override @Override

View File

@@ -382,7 +382,7 @@ public abstract class PanelView extends FrameLayout {
|| forceCancel; || forceCancel;
DozeLog.traceFling(expand, mTouchAboveFalsingThreshold, DozeLog.traceFling(expand, mTouchAboveFalsingThreshold,
mStatusBar.isFalsingThresholdNeeded(), mStatusBar.isFalsingThresholdNeeded(),
mStatusBar.isScreenOnComingFromTouch()); mStatusBar.isWakeUpComingFromTouch());
// Log collapse gesture if on lock screen. // Log collapse gesture if on lock screen.
if (!expand && mStatusBar.getBarState() == StatusBarState.KEYGUARD) { if (!expand && mStatusBar.getBarState() == StatusBarState.KEYGUARD) {
float displayDensity = mStatusBar.getDisplayDensity(); float displayDensity = mStatusBar.getDisplayDensity();
@@ -411,7 +411,7 @@ public abstract class PanelView extends FrameLayout {
} }
private int getFalsingThreshold() { private int getFalsingThreshold() {
float factor = mStatusBar.isScreenOnComingFromTouch() ? 1.5f : 1.0f; float factor = mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
return (int) (mUnlockFalsingThreshold * factor); return (int) (mUnlockFalsingThreshold * factor);
} }

View File

@@ -282,8 +282,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
private StatusBarWindowManager mStatusBarWindowManager; private StatusBarWindowManager mStatusBarWindowManager;
private UnlockMethodCache mUnlockMethodCache; private UnlockMethodCache mUnlockMethodCache;
private DozeServiceHost mDozeServiceHost; private DozeServiceHost mDozeServiceHost;
private boolean mScreenOnComingFromTouch; private boolean mWakeUpComingFromTouch;
private PointF mScreenOnTouchLocation; private PointF mWakeUpTouchLocation;
int mPixelFormat; int mPixelFormat;
Object mQueueLock = new Object(); Object mQueueLock = new Object();
@@ -1913,8 +1913,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
return mNotificationPanel.isQsExpanded(); return mNotificationPanel.isQsExpanded();
} }
public boolean isScreenOnComingFromTouch() { public boolean isWakeUpComingFromTouch() {
return mScreenOnComingFromTouch; return mWakeUpComingFromTouch;
} }
public boolean isFalsingThresholdNeeded() { public boolean isFalsingThresholdNeeded() {
@@ -2474,7 +2474,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
private void checkBarMode(int mode, int windowState, BarTransitions transitions, private void checkBarMode(int mode, int windowState, BarTransitions transitions,
boolean noAnimation) { boolean noAnimation) {
final boolean powerSave = mBatteryController.isPowerSave(); final boolean powerSave = mBatteryController.isPowerSave();
final boolean anim = !noAnimation && (mScreenOn == null || mScreenOn) final boolean anim = !noAnimation && mDeviceInteractive
&& windowState != WINDOW_STATE_HIDDEN && !powerSave; && windowState != WINDOW_STATE_HIDDEN && !powerSave;
if (powerSave && getBarState() == StatusBarState.SHADE) { if (powerSave && getBarState() == StatusBarState.SHADE) {
mode = MODE_WARNING; mode = MODE_WARNING;
@@ -2882,14 +2882,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
} }
} }
else if (Intent.ACTION_SCREEN_OFF.equals(action)) { else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
mScreenOn = false;
notifyNavigationBarScreenOn(false); notifyNavigationBarScreenOn(false);
notifyHeadsUpScreenOff(); notifyHeadsUpScreenOff();
finishBarAnimations(); finishBarAnimations();
resetUserExpandedStates(); resetUserExpandedStates();
} }
else if (Intent.ACTION_SCREEN_ON.equals(action)) { else if (Intent.ACTION_SCREEN_ON.equals(action)) {
mScreenOn = true;
notifyNavigationBarScreenOn(true); notifyNavigationBarScreenOn(true);
} }
} }
@@ -3343,7 +3341,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
setBarState(StatusBarState.KEYGUARD); setBarState(StatusBarState.KEYGUARD);
updateKeyguardState(false /* goingToFullShade */, false /* fromShadeLocked */); updateKeyguardState(false /* goingToFullShade */, false /* fromShadeLocked */);
if (!mScreenOnFromKeyguard) { if (!mDeviceInteractive) {
// If the screen is off already, we need to disable touch events because these might // If the screen is off already, we need to disable touch events because these might
// collapse the panel after we expanded it, and thus we would end up with a blank // collapse the panel after we expanded it, and thus we would end up with a blank
@@ -3563,7 +3561,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
private void updateDozingState() { private void updateDozingState() {
boolean animate = !mDozing && mDozeScrimController.isPulsing(); boolean animate = !mDozing && mDozeScrimController.isPulsing();
mNotificationPanel.setDozing(mDozing, animate); mNotificationPanel.setDozing(mDozing, animate);
mStackScroller.setDark(mDozing, animate, mScreenOnTouchLocation); mStackScroller.setDark(mDozing, animate, mWakeUpTouchLocation);
mScrimController.setDozing(mDozing); mScrimController.setDozing(mDozing);
mDozeScrimController.setDozing(mDozing, animate); mDozeScrimController.setDozing(mDozing, animate);
} }
@@ -3616,7 +3614,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
} }
public boolean onSpacePressed() { public boolean onSpacePressed() {
if (mScreenOn != null && mScreenOn if (mDeviceInteractive
&& (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) { && (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) {
animateCollapsePanels( animateCollapsePanels(
CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */);
@@ -3826,16 +3824,16 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
disable(mDisabledUnmodified1, mDisabledUnmodified2, true /* animate */); disable(mDisabledUnmodified1, mDisabledUnmodified2, true /* animate */);
} }
public void onScreenTurnedOff() { public void onFinishedGoingToSleep() {
mScreenOnFromKeyguard = false; mDeviceInteractive = false;
mScreenOnComingFromTouch = false; mWakeUpComingFromTouch = false;
mScreenOnTouchLocation = null; mWakeUpTouchLocation = null;
mStackScroller.setAnimationsEnabled(false); mStackScroller.setAnimationsEnabled(false);
updateVisibleToUser(); updateVisibleToUser();
} }
public void onScreenTurnedOn() { public void onStartedWakingUp() {
mScreenOnFromKeyguard = true; mDeviceInteractive = true;
mStackScroller.setAnimationsEnabled(true); mStackScroller.setAnimationsEnabled(true);
mNotificationPanel.setTouchDisabled(false); mNotificationPanel.setTouchDisabled(false);
updateVisibleToUser(); updateVisibleToUser();
@@ -3845,6 +3843,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mNotificationPanel.onScreenTurningOn(); mNotificationPanel.onScreenTurningOn();
} }
public void onScreenTurnedOn() {
mDozeScrimController.onScreenTurnedOn();
}
/** /**
* This handles long-press of both back and recents. They are * This handles long-press of both back and recents. They are
* handled together to capture them both being long-pressed * handled together to capture them both being long-pressed
@@ -3959,8 +3961,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
if (mDozing && mDozeScrimController.isPulsing()) { if (mDozing && mDozeScrimController.isPulsing()) {
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
pm.wakeUp(time, "com.android.systemui:NODOZE"); pm.wakeUp(time, "com.android.systemui:NODOZE");
mScreenOnComingFromTouch = true; mWakeUpComingFromTouch = true;
mScreenOnTouchLocation = new PointF(event.getX(), event.getY()); mWakeUpTouchLocation = new PointF(event.getX(), event.getY());
mNotificationPanel.setTouchDisabled(false); mNotificationPanel.setTouchDisabled(false);
mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested();
} }

View File

@@ -162,14 +162,14 @@ public class StatusBarKeyguardViewManager {
public void onFinishedGoingToSleep() { public void onFinishedGoingToSleep() {
mDeviceInteractive = false; mDeviceInteractive = false;
mPhoneStatusBar.onScreenTurnedOff(); mPhoneStatusBar.onFinishedGoingToSleep();
mBouncer.onScreenTurnedOff(); mBouncer.onScreenTurnedOff();
} }
public void onStartedWakingUp() { public void onStartedWakingUp() {
mDeviceInteractive = true; mDeviceInteractive = true;
mDeviceWillWakeUp = false; mDeviceWillWakeUp = false;
mPhoneStatusBar.onScreenTurnedOn(); mPhoneStatusBar.onStartedWakingUp();
} }
public void onScreenTurningOn() { public void onScreenTurningOn() {
@@ -184,6 +184,7 @@ public class StatusBarKeyguardViewManager {
animateScrimControllerKeyguardFadingOut(0, 200); animateScrimControllerKeyguardFadingOut(0, 200);
updateStates(); updateStates();
} }
mPhoneStatusBar.onScreenTurnedOn();
} }
public void onScreenTurnedOff() { public void onScreenTurnedOff() {

View File

@@ -653,7 +653,7 @@ public class NotificationStackScrollLayout extends ViewGroup
@Override @Override
public float getFalsingThresholdFactor() { public float getFalsingThresholdFactor() {
return mPhoneStatusBar.isScreenOnComingFromTouch() ? 1.5f : 1.0f; return mPhoneStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
} }
public View getChildAtPosition(MotionEvent ev) { public View getChildAtPosition(MotionEvent ev) {