diff options
author | 2017-04-17 16:23:49 +0000 | |
---|---|---|
committer | 2017-04-17 16:23:55 +0000 | |
commit | ed8f49efdc9c43a3efd2c96e76ee9944b83a4e7c (patch) | |
tree | 15aa73f2b6d4df175b718ffa2d1b1e11be6ffa0d | |
parent | bbcf5fba1c9dc5e67d54b75187bfd9fdf212ee32 (diff) | |
parent | b9e712ebde010c4b94536db0fa6edcf2b9580be2 (diff) |
Merge "Also use the notification's sound for the misc channel" into oc-dev
3 files changed, 19 insertions, 2 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 9a22d2a87e48..ed316bd72956 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -2339,7 +2339,9 @@ public class Notification implements Parcelable @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("Notification(pri="); + sb.append("Notification(channel="); + sb.append(getChannel()); + sb.append(" pri="); sb.append(priority); sb.append(" contentView="); if (contentView != null) { diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java index b7d31735a728..b48fd5c75574 100644 --- a/services/core/java/com/android/server/notification/NotificationRecord.java +++ b/services/core/java/com/android/server/notification/NotificationRecord.java @@ -172,7 +172,7 @@ public final class NotificationRecord { final boolean useDefaultSound = (n.defaults & Notification.DEFAULT_SOUND) != 0; if (useDefaultSound) { sound = Settings.System.DEFAULT_NOTIFICATION_URI; - } else if (n.sound != null) { + } else { sound = n.sound; } } diff --git a/services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java b/services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java index 946044d57e03..b2e6ef9f817f 100644 --- a/services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java +++ b/services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java @@ -124,6 +124,9 @@ public class NotificationRecordTest { builder.setSound(CUSTOM_SOUND, CUSTOM_ATTRIBUTES); channel.setSound(CUSTOM_SOUND, CUSTOM_ATTRIBUTES); } + } else { + channel.setSound(null, null); + builder.setSound(null, null); } if (buzzy) { if (defaultVibration) { @@ -206,6 +209,18 @@ public class NotificationRecordTest { } @Test + public void testSound_noSound_preUpgrade() throws Exception { + // pre upgrade, default sound. + StatusBarNotification sbn = getNotification(true /*preO */, false /* noisy */, + false /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, + false /* lights */, false /*defaultLights */); + + NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel); + assertEquals(null, record.getSound()); + assertEquals(Notification.AUDIO_ATTRIBUTES_DEFAULT, record.getAudioAttributes()); + } + + @Test public void testSound_default_upgradeUsesChannel() throws Exception { channel.setSound(CUSTOM_SOUND, CUSTOM_ATTRIBUTES); // post upgrade, default sound. |