summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulia Reynolds <juliacr@google.com>2019-01-03 14:35:38 -0500
committerJulia Reynolds <juliacr@google.com>2019-01-15 15:25:33 +0000
commit9aee2841e857b217115e354631842febbfab42f9 (patch)
treeaa8a05b18bfbfa8d08a1bb124b7fca53cca399dc
parentb9596e5febccbaf1452de7e7a681a4619f9c3825 (diff)
downloadbase-9aee2841e857b217115e354631842febbfab42f9.tar.gz
Actually use listener hints?
Mute notifications based on their audio attributes if HINT_HOST_DISABLE_NOTIFICATION_EFFECTS or HINT_HOST_DISABLE_CALL_EFFECTS is enabled. Test: atest Change-Id: I6404eecdce17f390154b3bafee7aa4d18a8ca5b2 Merged-In: db7081e30a6c2d369caeb5b1d26cc00aff788db3 Fixes: 120505040 (cherry picked from commit db7081e30a6c2d369caeb5b1d26cc00aff788db3)
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java19
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java18
2 files changed, 26 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index b7247166855d..a70377fa9e36 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1249,6 +1249,11 @@ public class NotificationManagerService extends SystemService {
}
@VisibleForTesting
+ void setHints(int hints) {
+ mListenerHints = hints;
+ }
+
+ @VisibleForTesting
void setVibrator(Vibrator vibrator) {
mVibrator = vibrator;
}
@@ -3689,6 +3694,20 @@ public class NotificationManagerService extends SystemService {
if ((mListenerHints & HINT_HOST_DISABLE_EFFECTS) != 0) {
return "listenerHints";
}
+ if (record != null && record.getAudioAttributes() != null) {
+ if ((mListenerHints & HINT_HOST_DISABLE_NOTIFICATION_EFFECTS) != 0) {
+ if (record.getAudioAttributes().getUsage()
+ != AudioAttributes.USAGE_VOICE_COMMUNICATION) {
+ return "listenerNoti";
+ }
+ }
+ if ((mListenerHints & HINT_HOST_DISABLE_CALL_EFFECTS) != 0) {
+ if (record.getAudioAttributes().getUsage()
+ == AudioAttributes.USAGE_VOICE_COMMUNICATION) {
+ return "listenerCall";
+ }
+ }
+ }
if (mCallState != TelephonyManager.CALL_STATE_IDLE && !mZenModeHelper.isCall(record)) {
return "callState";
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java b/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java
index bdba3d5cd677..2e6992704880 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java
@@ -58,6 +58,7 @@ import android.os.UserHandle;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.provider.Settings;
+import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
@@ -112,7 +113,7 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase {
private static final Uri CUSTOM_SOUND = Settings.System.DEFAULT_ALARM_ALERT_URI;
private static final AudioAttributes CUSTOM_ATTRIBUTES = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN)
- .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
+ .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
.build();
private static final int CUSTOM_LIGHT_COLOR = Color.BLACK;
private static final int CUSTOM_LIGHT_ON = 10000;
@@ -230,11 +231,11 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase {
false /* noisy */, false /* buzzy*/, true /* lights */);
}
- private NotificationRecord getCustomLightsNotification() {
- return getNotificationRecord(mId, false /* insistent */, true /* once */,
- false /* noisy */, true /* buzzy*/, true /* lights */,
- true /* defaultVibration */, true /* defaultSound */, false /* defaultLights */,
- null, Notification.GROUP_ALERT_ALL, false);
+ private NotificationRecord getCallRecord(int id, boolean insistent) {
+ return getNotificationRecord(id, false, false /* once */, true /* noisy */,
+ false /* buzzy */, false /* lights */, false /* default vib */,
+ false /* default sound */, false /* default lights */, "",
+ Notification.GROUP_ALERT_ALL, false);
}
private NotificationRecord getNotificationRecord(int id, boolean insistent, boolean once,
@@ -344,11 +345,6 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase {
eq(false), (AudioAttributes) anyObject());
}
- private void verifyCustomBeep() throws RemoteException {
- verify(mRingtonePlayer, times(1)).playAsync(eq(CUSTOM_SOUND), (UserHandle) anyObject(),
- eq(false), (AudioAttributes) anyObject());
- }
-
private void verifyNeverStopAudio() throws RemoteException {
verify(mRingtonePlayer, never()).stopAsync();
}