summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Julia Reynolds <juliacr@google.com> 2017-05-25 12:35:36 -0400
committer Julia Reynolds <juliacr@google.com> 2017-05-25 20:42:15 +0000
commit7c96b58cc7c08abcf9c97907afa60abf13dfd259 (patch)
tree26d1c944377b37347a9a4f55352c1632b980b2b3
parentef4e38f96fa696e92629e87edaabad151e5248f8 (diff)
Send notification state event more frequently
- For all new notifications that will appear in the status bar. Change-Id: I7f3414d4007be26558f8f4b7ec72dde17a538b05 Fixes: 38500162 Test: manual
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java97
1 files changed, 53 insertions, 44 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 4668156538c4..e377d57a0ead 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -16,6 +16,7 @@
package com.android.server.notification;
+import static android.app.NotificationManager.IMPORTANCE_MIN;
import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.content.pm.PackageManager.FEATURE_LEANBACK;
import static android.content.pm.PackageManager.FEATURE_TELEVISION;
@@ -3659,14 +3660,6 @@ public class NotificationManagerService extends SystemService {
" intercept=" + record.isIntercepted()
);
- final int currentUser;
- final long token = Binder.clearCallingIdentity();
- try {
- currentUser = ActivityManager.getCurrentUser();
- } finally {
- Binder.restoreCallingIdentity(token);
- }
-
// If we're not supposed to beep, vibrate, etc. then don't.
final String disableEffects = disableNotificationEffects(record);
if (disableEffects != null) {
@@ -3676,50 +3669,53 @@ public class NotificationManagerService extends SystemService {
// Remember if this notification already owns the notification channels.
boolean wasBeep = key != null && key.equals(mSoundNotificationKey);
boolean wasBuzz = key != null && key.equals(mVibrateNotificationKey);
-
// These are set inside the conditional if the notification is allowed to make noise.
boolean hasValidVibrate = false;
boolean hasValidSound = false;
- if (disableEffects == null
- && (record.getUserId() == UserHandle.USER_ALL ||
- record.getUserId() == currentUser ||
- mUserProfiles.isCurrentProfile(record.getUserId()))
- && canInterrupt
- && mSystemReady
- && mAudioManager != null) {
- if (DBG) Slog.v(TAG, "Interrupting!");
-
- Uri soundUri = record.getSound();
- hasValidSound = soundUri != null && !Uri.EMPTY.equals(soundUri);
- long[] vibration = record.getVibration();
- // Demote sound to vibration if vibration missing & phone in vibration mode.
- if (vibration == null
- && hasValidSound
- && (mAudioManager.getRingerModeInternal()
- == AudioManager.RINGER_MODE_VIBRATE)) {
- vibration = mFallbackVibrationPattern;
- }
- hasValidVibrate = vibration != null;
-
- if (!shouldMuteNotificationLocked(record)) {
+
+ if (isNotificationForCurrentUser(record)) {
+ // If the notification will appear in the status bar, it should send an accessibility
+ // event
+ if (!record.isUpdate && record.getImportance() > IMPORTANCE_MIN) {
sendAccessibilityEvent(notification, record.sbn.getPackageName());
+ }
- if (hasValidSound) {
- mSoundNotificationKey = key;
- if (mInCall) {
- playInCallNotification();
- beep = true;
- } else {
- beep = playSound(record, soundUri);
- }
+ if (disableEffects == null
+ && canInterrupt
+ && mSystemReady
+ && mAudioManager != null) {
+ if (DBG) Slog.v(TAG, "Interrupting!");
+ Uri soundUri = record.getSound();
+ hasValidSound = soundUri != null && !Uri.EMPTY.equals(soundUri);
+ long[] vibration = record.getVibration();
+ // Demote sound to vibration if vibration missing & phone in vibration mode.
+ if (vibration == null
+ && hasValidSound
+ && (mAudioManager.getRingerModeInternal()
+ == AudioManager.RINGER_MODE_VIBRATE)) {
+ vibration = mFallbackVibrationPattern;
}
+ hasValidVibrate = vibration != null;
+
+ if (!shouldMuteNotificationLocked(record)) {
+ if (hasValidSound) {
+ mSoundNotificationKey = key;
+ if (mInCall) {
+ playInCallNotification();
+ beep = true;
+ } else {
+ beep = playSound(record, soundUri);
+ }
+ }
- final boolean ringerModeSilent =
- mAudioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT;
- if (!mInCall && hasValidVibrate && !ringerModeSilent) {
- mVibrateNotificationKey = key;
+ final boolean ringerModeSilent =
+ mAudioManager.getRingerModeInternal()
+ == AudioManager.RINGER_MODE_SILENT;
+ if (!mInCall && hasValidVibrate && !ringerModeSilent) {
+ mVibrateNotificationKey = key;
- buzz = playVibration(record, vibration);
+ buzz = playVibration(record, vibration);
+ }
}
}
}
@@ -3819,6 +3815,19 @@ public class NotificationManagerService extends SystemService {
}
}
+ private boolean isNotificationForCurrentUser(NotificationRecord record) {
+ final int currentUser;
+ final long token = Binder.clearCallingIdentity();
+ try {
+ currentUser = ActivityManager.getCurrentUser();
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ return (record.getUserId() == UserHandle.USER_ALL ||
+ record.getUserId() == currentUser ||
+ mUserProfiles.isCurrentProfile(record.getUserId()));
+ }
+
private void playInCallNotification() {
new Thread() {
@Override