Merge "Doze: Fast path for pickup pulses." into lmp-mr1-dev

This commit is contained in:
John Spurlock
2014-12-03 19:49:24 +00:00
committed by Android (Google) Code Review
5 changed files with 43 additions and 18 deletions

View File

@@ -251,12 +251,21 @@
<!-- Doze: duration to avoid false pickup gestures triggered by notification vibrations -->
<integer name="doze_pickup_vibration_threshold">2000</integer>
<!-- Doze: can we assume the pickup sensor includes a proximity check? -->
<bool name="doze_pickup_performs_proximity_check">false</bool>
<!-- Doze: pulse parameter - how long does it take to fade in? -->
<integer name="doze_pulse_duration_in">900</integer>
<!-- Doze: pulse parameter - delay for fading so the screen can wake up before -->
<!-- Doze: pulse parameter - how long does it take to fade in after a pickup? -->
<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? -->
<integer name="doze_pulse_duration_visible">3000</integer>

View File

@@ -153,7 +153,7 @@ public class DozeLog {
sProxStats[pulseReason][near ? 0 : 1].append();
}
private static String pulseReasonToString(int pulseReason) {
public static String pulseReasonToString(int pulseReason) {
switch (pulseReason) {
case PULSE_REASON_INTENT: return "intent";
case PULSE_REASON_NOTIFICATION: return "notification";

View File

@@ -217,7 +217,9 @@ public class DozeService extends DreamService {
// Here we need a wakelock to stay awake until the pulse is finished.
mWakeLock.acquire();
mPulsing = true;
if (!mDozeParameters.getProxCheckBeforePulse()) {
if (!mDozeParameters.getProxCheckBeforePulse() ||
reason == DozeLog.PULSE_REASON_SENSOR_PICKUP
&& mDozeParameters.getPickupPerformsProxCheck()) {
// skip proximity check
continuePulsing(reason);
return;
@@ -340,7 +342,8 @@ public class DozeService extends DreamService {
if (DEBUG) Log.d(mTag, "No more schedule resets remaining");
return;
}
if ((notificationTimeMs - mNotificationPulseTime) < mDozeParameters.getPulseDuration()) {
final long pulseDuration = mDozeParameters.getPulseDuration(false /*pickup*/);
if ((notificationTimeMs - mNotificationPulseTime) < pulseDuration) {
if (DEBUG) Log.d(mTag, "Recently updated, not resetting schedule");
return;
}

View File

@@ -46,9 +46,12 @@ public class DozeParameters {
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(" getPulseInDelay(): "); pw.println(getPulseInDelay());
pw.print(" getPulseDuration(pickup=false): "); pw.println(getPulseDuration(false));
pw.print(" getPulseDuration(pickup=true): "); pw.println(getPulseDuration(true));
pw.print(" getPulseInDuration(pickup=false): "); pw.println(getPulseInDuration(false));
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(" getPulseOutDuration(): "); pw.println(getPulseOutDuration());
pw.print(" getPulseOnSigMotion(): "); pw.println(getPulseOnSigMotion());
@@ -60,22 +63,27 @@ public class DozeParameters {
pw.print(" getPulseSchedule(): "); pw.println(getPulseSchedule());
pw.print(" getPulseScheduleResets(): "); pw.println(getPulseScheduleResets());
pw.print(" getPickupVibrationThreshold(): "); pw.println(getPickupVibrationThreshold());
pw.print(" getPickupPerformsProxCheck(): "); pw.println(getPickupPerformsProxCheck());
}
public boolean getDisplayStateSupported() {
return getBoolean("doze.display.supported", R.bool.doze_display_state_supported);
}
public int getPulseDuration() {
return getPulseInDuration() + getPulseVisibleDuration() + getPulseOutDuration();
public int getPulseDuration(boolean pickup) {
return getPulseInDuration(pickup) + getPulseVisibleDuration() + getPulseOutDuration();
}
public int getPulseInDuration() {
return getInt("doze.pulse.duration.in", R.integer.doze_pulse_duration_in);
public int getPulseInDuration(boolean pickup) {
return pickup
? getInt("doze.pulse.duration.in.pickup", R.integer.doze_pulse_duration_in_pickup)
: getInt("doze.pulse.duration.in", R.integer.doze_pulse_duration_in);
}
public int getPulseInDelay() {
return getInt("doze.pulse.delay.in", R.integer.doze_pulse_delay_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() {
@@ -106,6 +114,10 @@ public class DozeParameters {
return getBoolean("doze.pulse.proxcheck", R.bool.doze_proximity_check_before_pulse);
}
public boolean getPickupPerformsProxCheck() {
return getBoolean("doze.pickup.proxcheck", R.bool.doze_pickup_performs_proximity_check);
}
public boolean getPulseOnNotifications() {
return getBoolean("doze.pulse.notifications", R.bool.doze_pulse_on_notifications);
}

View File

@@ -21,10 +21,8 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.NonNull;
import android.content.Context;
import android.graphics.Color;
import android.os.Handler;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
@@ -219,11 +217,14 @@ public class DozeScrimController {
private final Runnable mPulseIn = new Runnable() {
@Override
public void run() {
if (DEBUG) Log.d(TAG, "Pulse in, mDozing=" + mDozing);
if (DEBUG) Log.d(TAG, "Pulse in, mDozing=" + mDozing + " mPulseReason="
+ DozeLog.pulseReasonToString(mPulseReason));
if (!mDozing) return;
DozeLog.tracePulseStart(mPulseReason);
startScrimAnimation(true /* inFront */, 0f, mDozeParameters.getPulseInDuration(),
mPulseInInterpolator, mDozeParameters.getPulseInDelay(), mPulseInFinished);
final boolean pickup = mPulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
startScrimAnimation(true /* inFront */, 0f, mDozeParameters.getPulseInDuration(pickup),
mPulseInInterpolator, mDozeParameters.getPulseInDelay(pickup),
mPulseInFinished);
// Signal that the pulse is ready to turn the screen on and draw.
pulseStarted();