am 1bd81e31: Merge "Doze: Make proximity check configurable." into lmp-mr1-dev
* commit '1bd81e31f31a6d8dc06af79985ca820effab970c': Doze: Make proximity check configurable.
This commit is contained in:
@@ -232,6 +232,9 @@
|
|||||||
<!-- Doze: should the pickup sensor be used as a pulse signal? -->
|
<!-- Doze: should the pickup sensor be used as a pulse signal? -->
|
||||||
<bool name="doze_pulse_on_pick_up">false</bool>
|
<bool name="doze_pulse_on_pick_up">false</bool>
|
||||||
|
|
||||||
|
<!-- Doze: check proximity sensor before pulsing? -->
|
||||||
|
<bool name="doze_proximity_check_before_pulse">true</bool>
|
||||||
|
|
||||||
<!-- Doze: should notifications be used as a pulse signal? -->
|
<!-- Doze: should notifications be used as a pulse signal? -->
|
||||||
<bool name="doze_pulse_on_notifications">true</bool>
|
<bool name="doze_pulse_on_notifications">true</bool>
|
||||||
|
|
||||||
|
|||||||
@@ -202,6 +202,12 @@ public class DozeService extends DreamService {
|
|||||||
// Here we need a wakelock to stay awake until the pulse is finished.
|
// Here we need a wakelock to stay awake until the pulse is finished.
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
mPulsing = true;
|
mPulsing = true;
|
||||||
|
if (!mDozeParameters.getProxCheckBeforePulse()) {
|
||||||
|
// skip proximity check
|
||||||
|
continuePulsing();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// perform a proximity check before pulsing
|
||||||
final long start = SystemClock.uptimeMillis();
|
final long start = SystemClock.uptimeMillis();
|
||||||
new ProximityCheck() {
|
new ProximityCheck() {
|
||||||
@Override
|
@Override
|
||||||
@@ -216,28 +222,32 @@ public class DozeService extends DreamService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// not in-pocket, continue pulsing
|
// not in-pocket, continue pulsing
|
||||||
mHost.pulseWhileDozing(new DozeHost.PulseCallback() {
|
continuePulsing();
|
||||||
@Override
|
|
||||||
public void onPulseStarted() {
|
|
||||||
if (mPulsing && mDreaming) {
|
|
||||||
turnDisplayOn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPulseFinished() {
|
|
||||||
if (mPulsing && mDreaming) {
|
|
||||||
mPulsing = false;
|
|
||||||
turnDisplayOff();
|
|
||||||
}
|
|
||||||
mWakeLock.release(); // needs to be unconditional to balance acquire
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}.check();
|
}.check();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void continuePulsing() {
|
||||||
|
mHost.pulseWhileDozing(new DozeHost.PulseCallback() {
|
||||||
|
@Override
|
||||||
|
public void onPulseStarted() {
|
||||||
|
if (mPulsing && mDreaming) {
|
||||||
|
turnDisplayOn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPulseFinished() {
|
||||||
|
if (mPulsing && mDreaming) {
|
||||||
|
mPulsing = false;
|
||||||
|
turnDisplayOff();
|
||||||
|
}
|
||||||
|
mWakeLock.release(); // needs to be unconditional to balance acquire
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void turnDisplayOff() {
|
private void turnDisplayOff() {
|
||||||
if (DEBUG) Log.d(mTag, "Display off");
|
if (DEBUG) Log.d(mTag, "Display off");
|
||||||
setDozeScreenState(Display.STATE_OFF);
|
setDozeScreenState(Display.STATE_OFF);
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public class DozeParameters {
|
|||||||
pw.print(" getVibrateOnSigMotion(): "); pw.println(getVibrateOnSigMotion());
|
pw.print(" getVibrateOnSigMotion(): "); pw.println(getVibrateOnSigMotion());
|
||||||
pw.print(" getPulseOnPickup(): "); pw.println(getPulseOnPickup());
|
pw.print(" getPulseOnPickup(): "); pw.println(getPulseOnPickup());
|
||||||
pw.print(" getVibrateOnPickup(): "); pw.println(getVibrateOnPickup());
|
pw.print(" getVibrateOnPickup(): "); pw.println(getVibrateOnPickup());
|
||||||
|
pw.print(" getProxCheckBeforePulse(): "); pw.println(getProxCheckBeforePulse());
|
||||||
pw.print(" getPulseOnNotifications(): "); pw.println(getPulseOnNotifications());
|
pw.print(" getPulseOnNotifications(): "); pw.println(getPulseOnNotifications());
|
||||||
pw.print(" getPulseSchedule(): "); pw.println(getPulseSchedule());
|
pw.print(" getPulseSchedule(): "); pw.println(getPulseSchedule());
|
||||||
pw.print(" getPulseScheduleResets(): "); pw.println(getPulseScheduleResets());
|
pw.print(" getPulseScheduleResets(): "); pw.println(getPulseScheduleResets());
|
||||||
@@ -101,6 +102,10 @@ public class DozeParameters {
|
|||||||
return SystemProperties.getBoolean("doze.vibrate.pickup", false);
|
return SystemProperties.getBoolean("doze.vibrate.pickup", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getProxCheckBeforePulse() {
|
||||||
|
return getBoolean("doze.pulse.proxcheck", R.bool.doze_proximity_check_before_pulse);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getPulseOnNotifications() {
|
public boolean getPulseOnNotifications() {
|
||||||
return getBoolean("doze.pulse.notifications", R.bool.doze_pulse_on_notifications);
|
return getBoolean("doze.pulse.notifications", R.bool.doze_pulse_on_notifications);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user