summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2013-05-15 12:59:42 +0200
committerDanny Baumann <dannybaumann@web.de>2013-05-16 12:41:55 +0200
commit75c82dc67b357ee6a56099c365aae3fd60b4d904 (patch)
tree2eacd0de459841604036920f50045231a8bd6614
parentcdd98977f5089eb829724579943dbe23480ea272 (diff)
downloadframeworks_base-75c82dc67b357ee6a56099c365aae3fd60b4d904.zip
frameworks_base-75c82dc67b357ee6a56099c365aae3fd60b4d904.tar.gz
frameworks_base-75c82dc67b357ee6a56099c365aae3fd60b4d904.tar.bz2
Fix up notification LED behaviour
- Commit 5713307e3d2eb457ba148df3683ad09733727506 (in ICS) attempted to fix the problem that the notification LED wasn't reenabled after turning off the screen again, but introduced another bug in the process: If another pending notification with LED at the time when the notification with the new magic flag introduced by that commit (which was used by phone and MMS apps) was active, the LED still wouldn't be turned on at screen off time. Also, this commit didn't handle locking correctly. This commit essentially reverts 5713307e and makes sure the LED is reevaluated when the screen is turned off again. - This change also makes the assignment of the LED when multiple pending notifications want to use the LED more clear: The notification with highest priority gets the LED. If multiple notifications with same priority exist, the most recent one gets the LED. JIRA:CYAN-652 Change-Id: I1df0b40cca2af7a08c240677d22d2a95097b7184
-rw-r--r--core/java/android/app/Notification.java9
-rw-r--r--services/java/com/android/server/NotificationManagerService.java36
2 files changed, 11 insertions, 34 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 8e920cc..3f8e16c 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -437,15 +437,6 @@ public class Notification implements Parcelable
*/
public static final String EXTRA_PEOPLE = "android.people";
- /**
- * Bit to be bitwise-ored into the {@link #flags} field that should be
- * set if this notification should force the led to pulse even if the
- * screen has been shut off while the notification was active.
- *
- * @hide
- */
- public static final int FLAG_FORCE_LED_SCREEN_OFF = 0x00000100;
-
private Bundle extras;
/**
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index 9087997..1f50c8f 100644
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -149,7 +149,6 @@ public class NotificationManagerService extends INotificationManager.Stub
// for enabling and disabling notification pulse behaviour
private boolean mScreenOn = true;
- private boolean mWasScreenOn = false;
private boolean mInCall = false;
private boolean mNotificationPulseEnabled;
private HashMap<String, NotificationLedValues> mNotificationPulseCustomLedValues;
@@ -587,8 +586,7 @@ public class NotificationManagerService extends INotificationManager.Stub
mScreenOn = true;
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
mScreenOn = false;
- mWasScreenOn = true;
- updateLightsLocked();
+ updateNotificationPulse();
} else if (action.equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
mInCall = (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(
TelephonyManager.EXTRA_STATE_OFFHOOK));
@@ -1312,6 +1310,8 @@ public class NotificationManagerService extends INotificationManager.Stub
if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0
&& canInterrupt) {
mLights.add(r);
+ // force reevaluation of active light
+ mLedNotification = null;
updateLightsLocked();
} else {
if (old != null
@@ -1582,32 +1582,17 @@ public class NotificationManagerService extends INotificationManager.Stub
{
// handle notification lights
if (mLedNotification == null) {
- // get next notification, if any
- int n = mLights.size();
- if (n > 0) {
- mLedNotification = mLights.get(n-1);
+ // use most recent light with highest score
+ for (int i = mLights.size(); i > 0; i--) {
+ NotificationRecord r = mLights.get(i - 1);
+ if (mLedNotification == null || r.score > mLedNotification.score) {
+ mLedNotification = r;
+ }
}
}
- boolean wasScreenOn = mWasScreenOn;
- mWasScreenOn = false;
-
- if (mLedNotification == null) {
- mNotificationLight.turnOff();
- return;
- }
-
- // We can assume that if the user turned the screen off while there was
- // still an active notification then they wanted to keep the notification
- // for later. In this case we shouldn't flash the notification light.
- // For special notifications that automatically turn the screen on (such
- // as missed calls), we use this flag to force the notification light
- // even if the screen was turned off.
- boolean forceWithScreenOff = (mLedNotification.notification.flags &
- Notification.FLAG_FORCE_LED_SCREEN_OFF) != 0;
-
// Don't flash while we are in a call, screen is on or we are in quiet hours with light dimmed
- if (mInCall || mScreenOn || (inQuietHours() && mQuietHoursDim) || (wasScreenOn && !forceWithScreenOff)) {
+ if (mLedNotification == null || mInCall || mScreenOn || (inQuietHours() && mQuietHoursDim)) {
mNotificationLight.turnOff();
} else {
int ledARGB;
@@ -1757,6 +1742,7 @@ public class NotificationManagerService extends INotificationManager.Stub
pw.println(" mSoundNotification=" + mSoundNotification);
pw.println(" mVibrateNotification=" + mVibrateNotification);
+ pw.println(" mLedNotification=" + mLedNotification);
pw.println(" mDisabledNotifications=0x" + Integer.toHexString(mDisabledNotifications));
pw.println(" mSystemReady=" + mSystemReady);
}