Merge "Send notification state event more frequently" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
13cbd65608
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.server.notification;
|
package com.android.server.notification;
|
||||||
|
|
||||||
|
import static android.app.NotificationManager.IMPORTANCE_MIN;
|
||||||
import static android.app.NotificationManager.IMPORTANCE_NONE;
|
import static android.app.NotificationManager.IMPORTANCE_NONE;
|
||||||
import static android.content.pm.PackageManager.FEATURE_LEANBACK;
|
import static android.content.pm.PackageManager.FEATURE_LEANBACK;
|
||||||
import static android.content.pm.PackageManager.FEATURE_TELEVISION;
|
import static android.content.pm.PackageManager.FEATURE_TELEVISION;
|
||||||
@@ -3659,14 +3660,6 @@ public class NotificationManagerService extends SystemService {
|
|||||||
" intercept=" + record.isIntercepted()
|
" 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.
|
// If we're not supposed to beep, vibrate, etc. then don't.
|
||||||
final String disableEffects = disableNotificationEffects(record);
|
final String disableEffects = disableNotificationEffects(record);
|
||||||
if (disableEffects != null) {
|
if (disableEffects != null) {
|
||||||
@@ -3676,50 +3669,53 @@ public class NotificationManagerService extends SystemService {
|
|||||||
// Remember if this notification already owns the notification channels.
|
// Remember if this notification already owns the notification channels.
|
||||||
boolean wasBeep = key != null && key.equals(mSoundNotificationKey);
|
boolean wasBeep = key != null && key.equals(mSoundNotificationKey);
|
||||||
boolean wasBuzz = key != null && key.equals(mVibrateNotificationKey);
|
boolean wasBuzz = key != null && key.equals(mVibrateNotificationKey);
|
||||||
|
|
||||||
// These are set inside the conditional if the notification is allowed to make noise.
|
// These are set inside the conditional if the notification is allowed to make noise.
|
||||||
boolean hasValidVibrate = false;
|
boolean hasValidVibrate = false;
|
||||||
boolean hasValidSound = 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();
|
if (isNotificationForCurrentUser(record)) {
|
||||||
hasValidSound = soundUri != null && !Uri.EMPTY.equals(soundUri);
|
// If the notification will appear in the status bar, it should send an accessibility
|
||||||
long[] vibration = record.getVibration();
|
// event
|
||||||
// Demote sound to vibration if vibration missing & phone in vibration mode.
|
if (!record.isUpdate && record.getImportance() > IMPORTANCE_MIN) {
|
||||||
if (vibration == null
|
|
||||||
&& hasValidSound
|
|
||||||
&& (mAudioManager.getRingerModeInternal()
|
|
||||||
== AudioManager.RINGER_MODE_VIBRATE)) {
|
|
||||||
vibration = mFallbackVibrationPattern;
|
|
||||||
}
|
|
||||||
hasValidVibrate = vibration != null;
|
|
||||||
|
|
||||||
if (!shouldMuteNotificationLocked(record)) {
|
|
||||||
sendAccessibilityEvent(notification, record.sbn.getPackageName());
|
sendAccessibilityEvent(notification, record.sbn.getPackageName());
|
||||||
|
}
|
||||||
|
|
||||||
if (hasValidSound) {
|
if (disableEffects == null
|
||||||
mSoundNotificationKey = key;
|
&& canInterrupt
|
||||||
if (mInCall) {
|
&& mSystemReady
|
||||||
playInCallNotification();
|
&& mAudioManager != null) {
|
||||||
beep = true;
|
if (DBG) Slog.v(TAG, "Interrupting!");
|
||||||
} else {
|
Uri soundUri = record.getSound();
|
||||||
beep = playSound(record, soundUri);
|
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;
|
||||||
|
|
||||||
final boolean ringerModeSilent =
|
if (!shouldMuteNotificationLocked(record)) {
|
||||||
mAudioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT;
|
if (hasValidSound) {
|
||||||
if (!mInCall && hasValidVibrate && !ringerModeSilent) {
|
mSoundNotificationKey = key;
|
||||||
mVibrateNotificationKey = key;
|
if (mInCall) {
|
||||||
|
playInCallNotification();
|
||||||
|
beep = true;
|
||||||
|
} else {
|
||||||
|
beep = playSound(record, soundUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buzz = playVibration(record, vibration);
|
final boolean ringerModeSilent =
|
||||||
|
mAudioManager.getRingerModeInternal()
|
||||||
|
== AudioManager.RINGER_MODE_SILENT;
|
||||||
|
if (!mInCall && hasValidVibrate && !ringerModeSilent) {
|
||||||
|
mVibrateNotificationKey = key;
|
||||||
|
|
||||||
|
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() {
|
private void playInCallNotification() {
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user