Ambient: Re-register all trigger sensors if one fires
am: 0288dcc825
Change-Id: Ia5e7c73eadb831e409aafd657427af98d242cdd2
This commit is contained in:
@@ -60,6 +60,11 @@ public class DozeService extends DreamService {
|
|||||||
private static final String ACTION_BASE = "com.android.systemui.doze";
|
private static final String ACTION_BASE = "com.android.systemui.doze";
|
||||||
private static final String PULSE_ACTION = ACTION_BASE + ".pulse";
|
private static final String PULSE_ACTION = ACTION_BASE + ".pulse";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, reregisters all trigger sensors when the screen turns off.
|
||||||
|
*/
|
||||||
|
private static final boolean REREGISTER_ALL_SENSORS_ON_SCREEN_OFF = true;
|
||||||
|
|
||||||
private final String mTag = String.format(TAG + ".%08x", hashCode());
|
private final String mTag = String.format(TAG + ".%08x", hashCode());
|
||||||
private final Context mContext = this;
|
private final Context mContext = this;
|
||||||
private final DozeParameters mDozeParameters = new DozeParameters(mContext);
|
private final DozeParameters mDozeParameters = new DozeParameters(mContext);
|
||||||
@@ -272,6 +277,9 @@ public class DozeService extends DreamService {
|
|||||||
public void onPulseFinished() {
|
public void onPulseFinished() {
|
||||||
if (mPulsing && mDreaming) {
|
if (mPulsing && mDreaming) {
|
||||||
mPulsing = false;
|
mPulsing = false;
|
||||||
|
if (REREGISTER_ALL_SENSORS_ON_SCREEN_OFF) {
|
||||||
|
reregisterAllSensors();
|
||||||
|
}
|
||||||
turnDisplayOff();
|
turnDisplayOff();
|
||||||
}
|
}
|
||||||
mWakeLock.release(); // needs to be unconditional to balance acquire
|
mWakeLock.release(); // needs to be unconditional to balance acquire
|
||||||
@@ -308,6 +316,15 @@ public class DozeService extends DreamService {
|
|||||||
listenForNotifications(listen);
|
listenForNotifications(listen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reregisterAllSensors() {
|
||||||
|
for (TriggerSensor s : mSensors) {
|
||||||
|
s.setListening(false);
|
||||||
|
}
|
||||||
|
for (TriggerSensor s : mSensors) {
|
||||||
|
s.setListening(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void listenForBroadcasts(boolean listen) {
|
private void listenForBroadcasts(boolean listen) {
|
||||||
if (listen) {
|
if (listen) {
|
||||||
final IntentFilter filter = new IntentFilter(PULSE_ACTION);
|
final IntentFilter filter = new IntentFilter(PULSE_ACTION);
|
||||||
|
|||||||
Reference in New Issue
Block a user