am f55ad284: am ffc050ad: Merge "Track active notifications by key, not by reference." into lmp-mr1-dev

* commit 'f55ad284448d226b047815715bb10e193c88ae0d':
  Track active notifications by key, not by reference.
This commit is contained in:
Chris Wren
2014-12-05 15:51:48 +00:00
committed by Android Git Automerger

View File

@@ -201,8 +201,8 @@ public class NotificationManagerService extends SystemService {
private boolean mDisableNotificationEffects; private boolean mDisableNotificationEffects;
private int mCallState; private int mCallState;
NotificationRecord mSoundNotification; private String mSoundNotificationKey;
NotificationRecord mVibrateNotification; private String mVibrateNotificationKey;
private final ArraySet<ManagedServiceInfo> mListenersDisablingEffects = new ArraySet<>(); private final ArraySet<ManagedServiceInfo> mListenersDisablingEffects = new ArraySet<>();
private ComponentName mEffectsSuppressor; private ComponentName mEffectsSuppressor;
@@ -222,8 +222,8 @@ public class NotificationManagerService extends SystemService {
final ArrayList<ToastRecord> mToastQueue = new ArrayList<ToastRecord>(); final ArrayList<ToastRecord> mToastQueue = new ArrayList<ToastRecord>();
final ArrayMap<String, NotificationRecord> mSummaryByGroupKey = new ArrayMap<>(); final ArrayMap<String, NotificationRecord> mSummaryByGroupKey = new ArrayMap<>();
ArrayList<String> mLights = new ArrayList<String>(); // The last key in this list owns the hardware.
NotificationRecord mLedNotification; ArrayList<String> mLights = new ArrayList<>();
private AppOpsManager mAppOps; private AppOpsManager mAppOps;
@@ -595,7 +595,7 @@ public class NotificationManagerService extends SystemService {
if (DBG) Slog.d(TAG, "clearEffects"); if (DBG) Slog.d(TAG, "clearEffects");
// sound // sound
mSoundNotification = null; mSoundNotificationKey = null;
long identity = Binder.clearCallingIdentity(); long identity = Binder.clearCallingIdentity();
try { try {
@@ -609,7 +609,7 @@ public class NotificationManagerService extends SystemService {
} }
// vibrate // vibrate
mVibrateNotification = null; mVibrateNotificationKey = null;
identity = Binder.clearCallingIdentity(); identity = Binder.clearCallingIdentity();
try { try {
mVibrator.cancel(); mVibrator.cancel();
@@ -619,7 +619,6 @@ public class NotificationManagerService extends SystemService {
// light // light
mLights.clear(); mLights.clear();
mLedNotification = null;
updateLightsLocked(); updateLightsLocked();
} }
} }
@@ -1624,14 +1623,19 @@ public class NotificationManagerService extends SystemService {
if (N > 0) { if (N > 0) {
pw.println(" Lights List:"); pw.println(" Lights List:");
for (int i=0; i<N; i++) { for (int i=0; i<N; i++) {
pw.println(" " + mLights.get(i)); if (i == N - 1) {
pw.print(" > ");
} else {
pw.print(" ");
}
pw.println(mLights.get(i));
} }
pw.println(" "); pw.println(" ");
} }
pw.println(" mUseAttentionLight=" + mUseAttentionLight); pw.println(" mUseAttentionLight=" + mUseAttentionLight);
pw.println(" mNotificationPulseEnabled=" + mNotificationPulseEnabled); pw.println(" mNotificationPulseEnabled=" + mNotificationPulseEnabled);
pw.println(" mSoundNotification=" + mSoundNotification); pw.println(" mSoundNotificationKey=" + mSoundNotificationKey);
pw.println(" mVibrateNotification=" + mVibrateNotification); pw.println(" mVibrateNotificationKey=" + mVibrateNotificationKey);
pw.println(" mDisableNotificationEffects=" + mDisableNotificationEffects); pw.println(" mDisableNotificationEffects=" + mDisableNotificationEffects);
pw.println(" mCallState=" + callStateToString(mCallState)); pw.println(" mCallState=" + callStateToString(mCallState));
pw.println(" mSystemReady=" + mSystemReady); pw.println(" mSystemReady=" + mSystemReady);
@@ -2058,7 +2062,7 @@ public class NotificationManagerService extends SystemService {
boolean looping = boolean looping =
(notification.flags & Notification.FLAG_INSISTENT) != 0; (notification.flags & Notification.FLAG_INSISTENT) != 0;
AudioAttributes audioAttributes = audioAttributesForNotification(notification); AudioAttributes audioAttributes = audioAttributesForNotification(notification);
mSoundNotification = record; mSoundNotificationKey = record.getKey();
// do not play notifications if stream volume is 0 (typically because // do not play notifications if stream volume is 0 (typically because
// ringer mode is silent) or if there is a user of exclusive audio focus // ringer mode is silent) or if there is a user of exclusive audio focus
if ((mAudioManager.getStreamVolume( if ((mAudioManager.getStreamVolume(
@@ -2101,7 +2105,7 @@ public class NotificationManagerService extends SystemService {
if ((useDefaultVibrate || convertSoundToVibration || hasCustomVibrate) if ((useDefaultVibrate || convertSoundToVibration || hasCustomVibrate)
&& !(mAudioManager.getRingerModeInternal() && !(mAudioManager.getRingerModeInternal()
== AudioManager.RINGER_MODE_SILENT)) { == AudioManager.RINGER_MODE_SILENT)) {
mVibrateNotification = record; mVibrateNotificationKey = record.getKey();
if (useDefaultVibrate || convertSoundToVibration) { if (useDefaultVibrate || convertSoundToVibration) {
// Escalate privileges so we can use the vibrator even if the // Escalate privileges so we can use the vibrator even if the
@@ -2132,9 +2136,6 @@ public class NotificationManagerService extends SystemService {
// light // light
// release the light // release the light
boolean wasShowLights = mLights.remove(record.getKey()); boolean wasShowLights = mLights.remove(record.getKey());
if (mLedNotification != null && record.getKey().equals(mLedNotification.getKey())) {
mLedNotification = null;
}
if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0 && aboveThreshold) { if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0 && aboveThreshold) {
mLights.add(record.getKey()); mLights.add(record.getKey());
updateLightsLocked(); updateLightsLocked();
@@ -2458,9 +2459,11 @@ public class NotificationManagerService extends SystemService {
mListeners.notifyRemovedLocked(r.sbn); mListeners.notifyRemovedLocked(r.sbn);
} }
final String canceledKey = r.getKey();
// sound // sound
if (mSoundNotification == r) { if (canceledKey.equals(mSoundNotificationKey)) {
mSoundNotification = null; mSoundNotificationKey = null;
final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity();
try { try {
final IRingtonePlayer player = mAudioManager.getRingtonePlayer(); final IRingtonePlayer player = mAudioManager.getRingtonePlayer();
@@ -2474,8 +2477,8 @@ public class NotificationManagerService extends SystemService {
} }
// vibrate // vibrate
if (mVibrateNotification == r) { if (canceledKey.equals(mVibrateNotificationKey)) {
mVibrateNotification = null; mVibrateNotificationKey = null;
long identity = Binder.clearCallingIdentity(); long identity = Binder.clearCallingIdentity();
try { try {
mVibrator.cancel(); mVibrator.cancel();
@@ -2486,10 +2489,7 @@ public class NotificationManagerService extends SystemService {
} }
// light // light
mLights.remove(r.getKey()); mLights.remove(canceledKey);
if (mLedNotification == r) {
mLedNotification = null;
}
// Record usage stats // Record usage stats
switch (reason) { switch (reason) {
@@ -2521,7 +2521,7 @@ public class NotificationManagerService extends SystemService {
// Save it for users of getHistoricalNotifications() // Save it for users of getHistoricalNotifications()
mArchive.record(r.sbn); mArchive.record(r.sbn);
EventLogTags.writeNotificationCanceled(r.getKey(), reason); EventLogTags.writeNotificationCanceled(canceledKey, reason);
} }
/** /**
@@ -2727,20 +2727,22 @@ public class NotificationManagerService extends SystemService {
void updateLightsLocked() void updateLightsLocked()
{ {
// handle notification lights // handle notification lights
if (mLedNotification == null) { NotificationRecord ledNotification = null;
// get next notification, if any while (ledNotification == null && !mLights.isEmpty()) {
int n = mLights.size(); final String owner = mLights.get(mLights.size() - 1);
if (n > 0) { ledNotification = mNotificationsByKey.get(owner);
mLedNotification = mNotificationsByKey.get(mLights.get(n-1)); if (ledNotification == null) {
Slog.wtfStack(TAG, "LED Notification does not exist: " + owner);
mLights.remove(owner);
} }
} }
// Don't flash while we are in a call or screen is on // Don't flash while we are in a call or screen is on
if (mLedNotification == null || mInCall || mScreenOn) { if (ledNotification == null || mInCall || mScreenOn) {
mNotificationLight.turnOff(); mNotificationLight.turnOff();
mStatusBar.notificationLightOff(); mStatusBar.notificationLightOff();
} else { } else {
final Notification ledno = mLedNotification.sbn.getNotification(); final Notification ledno = ledNotification.sbn.getNotification();
int ledARGB = ledno.ledARGB; int ledARGB = ledno.ledARGB;
int ledOnMS = ledno.ledOnMS; int ledOnMS = ledno.ledOnMS;
int ledOffMS = ledno.ledOffMS; int ledOffMS = ledno.ledOffMS;