summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/doze
diff options
context:
space:
mode:
authorChristoph Studer <chstuder@google.com>2014-11-26 15:32:20 +0100
committerChristoph Studer <chstuder@google.com>2014-12-02 16:52:13 +0100
commit1f32c65697c22f423c2888cf4c53da1c95d602c1 (patch)
tree6529bca14485bfabf508f8df464044631a0115f8 /packages/SystemUI/src/com/android/systemui/doze
parentda39290460b30e5080769f039d6dff352b3c7808 (diff)
downloadframeworks_base-1f32c65697c22f423c2888cf4c53da1c95d602c1.zip
frameworks_base-1f32c65697c22f423c2888cf4c53da1c95d602c1.tar.gz
frameworks_base-1f32c65697c22f423c2888cf4c53da1c95d602c1.tar.bz2
NoMan/SysUI: Clear LEDs only when entering the shade
Don't clear notification LEDs when seeing notifications on the lockscreen. Also fix a bug where the LED didn't continue flashing after the screen turned off. For devices with doze capability, ensure that the LED continuing to flash after screen off doesn't cause an immediate pulses, but delay the first pulse by 10s. Bug: 15449039 Change-Id: Id34d51a2c91ceaf069e49add1ab690bb855f9638
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/doze')
-rw-r--r--packages/SystemUI/src/com/android/systemui/doze/DozeHost.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/doze/DozeService.java42
2 files changed, 34 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java b/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java
index e92f988..7070220 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java
@@ -28,6 +28,7 @@ public interface DozeHost {
void pulseWhileDozing(@NonNull PulseCallback callback);
void stopDozing();
boolean isPowerSaveActive();
+ boolean isNotificationLightOn();
public interface Callback {
void onNewNotifications();
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java
index 89b3e5b..f309e69 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java
@@ -56,6 +56,17 @@ public class DozeService extends DreamService {
private static final String NOTIFICATION_PULSE_ACTION = ACTION_BASE + ".notification_pulse";
private static final String EXTRA_INSTANCE = "instance";
+ /**
+ * Earliest time we pulse due to a notification light after the service started.
+ *
+ * <p>Incoming notification light events during the blackout period are
+ * delayed to the earliest time defined by this constant.</p>
+ *
+ * <p>This delay avoids a pulse immediately after screen off, at which
+ * point the notification light is re-enabled again by NoMan.</p>
+ */
+ private static final int EARLIEST_LIGHT_PULSE_AFTER_START_MS = 10 * 1000;
+
private final String mTag = String.format(TAG + ".%08x", hashCode());
private final Context mContext = this;
private final DozeParameters mDozeParameters = new DozeParameters(mContext);
@@ -77,6 +88,7 @@ public class DozeService extends DreamService {
private boolean mPowerSaveActive;
private boolean mCarMode;
private long mNotificationPulseTime;
+ private long mEarliestPulseDueToLight;
private int mScheduleResetsRemaining;
public DozeService() {
@@ -159,8 +171,9 @@ public class DozeService extends DreamService {
}
mDreaming = true;
- listenForPulseSignals(true);
rescheduleNotificationPulse(false /*predicate*/); // cancel any pending pulse alarms
+ mEarliestPulseDueToLight = System.currentTimeMillis() + EARLIEST_LIGHT_PULSE_AFTER_START_MS;
+ listenForPulseSignals(true);
// Ask the host to get things ready to start dozing.
// Once ready, we call startDozing() at which point the CPU may suspend
@@ -295,6 +308,12 @@ public class DozeService extends DreamService {
if (listen) {
resetNotificationResets();
mHost.addCallback(mHostCallback);
+
+ // Continue to pulse for existing LEDs.
+ mNotificationLightOn = mHost.isNotificationLightOn();
+ if (mNotificationLightOn) {
+ updateNotificationPulseDueToLight();
+ }
} else {
mHost.removeCallback(mHostCallback);
}
@@ -305,21 +324,26 @@ public class DozeService extends DreamService {
mScheduleResetsRemaining = mDozeParameters.getPulseScheduleResets();
}
- private void updateNotificationPulse() {
- if (DEBUG) Log.d(mTag, "updateNotificationPulse");
+ private void updateNotificationPulseDueToLight() {
+ long timeMs = System.currentTimeMillis();
+ timeMs = Math.max(timeMs, mEarliestPulseDueToLight);
+ updateNotificationPulse(timeMs);
+ }
+
+ private void updateNotificationPulse(long notificationTimeMs) {
+ if (DEBUG) Log.d(mTag, "updateNotificationPulse notificationTimeMs=" + notificationTimeMs);
if (!mDozeParameters.getPulseOnNotifications()) return;
if (mScheduleResetsRemaining <= 0) {
if (DEBUG) Log.d(mTag, "No more schedule resets remaining");
return;
}
- final long now = System.currentTimeMillis();
- if ((now - mNotificationPulseTime) < mDozeParameters.getPulseDuration()) {
+ if ((notificationTimeMs - mNotificationPulseTime) < mDozeParameters.getPulseDuration()) {
if (DEBUG) Log.d(mTag, "Recently updated, not resetting schedule");
return;
}
mScheduleResetsRemaining--;
if (DEBUG) Log.d(mTag, "mScheduleResetsRemaining = " + mScheduleResetsRemaining);
- mNotificationPulseTime = now;
+ mNotificationPulseTime = notificationTimeMs;
rescheduleNotificationPulse(true /*predicate*/);
}
@@ -401,14 +425,14 @@ public class DozeService extends DreamService {
private final DozeHost.Callback mHostCallback = new DozeHost.Callback() {
@Override
public void onNewNotifications() {
- if (DEBUG) Log.d(mTag, "onNewNotifications");
+ if (DEBUG) Log.d(mTag, "onNewNotifications (noop)");
// noop for now
}
@Override
public void onBuzzBeepBlinked() {
if (DEBUG) Log.d(mTag, "onBuzzBeepBlinked");
- updateNotificationPulse();
+ updateNotificationPulse(System.currentTimeMillis());
}
@Override
@@ -417,7 +441,7 @@ public class DozeService extends DreamService {
if (mNotificationLightOn == on) return;
mNotificationLightOn = on;
if (mNotificationLightOn) {
- updateNotificationPulse();
+ updateNotificationPulseDueToLight();
}
}