From 0288dcc8251013992ad676ad823550d184f2f6b1 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Tue, 4 Oct 2016 16:35:10 -0400 Subject: [PATCH] Ambient: Re-register all trigger sensors if one fires Works around an issue where triggering one trigger sensor can affect other trigger sensors. To be sure, re-register them all. Change-Id: I4a0999275638e8a78c3c604fda6527aff0d9365a Fixes: 31933894 --- .../com/android/systemui/doze/DozeService.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java index 261d2411bf29b..56f6b8df866b9 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java @@ -60,6 +60,11 @@ public class DozeService extends DreamService { private static final String ACTION_BASE = "com.android.systemui.doze"; 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 Context mContext = this; private final DozeParameters mDozeParameters = new DozeParameters(mContext); @@ -272,6 +277,9 @@ public class DozeService extends DreamService { public void onPulseFinished() { if (mPulsing && mDreaming) { mPulsing = false; + if (REREGISTER_ALL_SENSORS_ON_SCREEN_OFF) { + reregisterAllSensors(); + } turnDisplayOff(); } mWakeLock.release(); // needs to be unconditional to balance acquire @@ -308,6 +316,15 @@ public class DozeService extends DreamService { listenForNotifications(listen); } + private void reregisterAllSensors() { + for (TriggerSensor s : mSensors) { + s.setListening(false); + } + for (TriggerSensor s : mSensors) { + s.setListening(true); + } + } + private void listenForBroadcasts(boolean listen) { if (listen) { final IntentFilter filter = new IntentFilter(PULSE_ACTION);