Don't consider uri empty a valid sound

Test: runtest systemui-notification
Change-Id: Ia838237e04eb11bd79e3ad5990bbb52c7ab853ee
Fixes: 36848349
This commit is contained in:
Julia Reynolds
2017-04-23 12:39:32 -04:00
parent 9da73961a7
commit ca80d1632e
2 changed files with 21 additions and 2 deletions

View File

@@ -3648,7 +3648,7 @@ public class NotificationManagerService extends SystemService {
if (DBG) Slog.v(TAG, "Interrupting!");
Uri soundUri = record.getSound();
hasValidSound = (soundUri != null);
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

View File

@@ -15,6 +15,8 @@
*/
package com.android.server.notification;
import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
@@ -198,7 +200,7 @@ public class BuzzBeepBlinkTest {
boolean noisy, boolean buzzy, boolean lights, boolean defaultVibration,
boolean defaultSound, boolean defaultLights) {
NotificationChannel channel =
new NotificationChannel("test", "test", NotificationManager.IMPORTANCE_HIGH);
new NotificationChannel("test", "test", IMPORTANCE_HIGH);
final Builder builder = new Builder(getContext())
.setContentTitle("foo")
.setSmallIcon(android.R.drawable.sym_def_app_icon)
@@ -680,6 +682,23 @@ public class BuzzBeepBlinkTest {
verifyStopVibrate();
}
@Test
public void testEmptyUriSoundTreatedAsNoSound() throws Exception {
NotificationChannel channel = new NotificationChannel("test", "test", IMPORTANCE_HIGH);
channel.setSound(Uri.EMPTY, null);
final Notification n = new Builder(getContext(), "test")
.setSmallIcon(android.R.drawable.sym_def_app_icon).build();
StatusBarNotification sbn = new StatusBarNotification(mPkg, mPkg, 0, mTag, mUid,
mPid, n, mUser, null, System.currentTimeMillis());
NotificationRecord r = new NotificationRecord(getContext(), sbn, channel);
mService.addNotification(r);
mService.buzzBeepBlinkLocked(r);
verifyNeverBeep();
}
static class VibrateRepeatMatcher implements ArgumentMatcher<VibrationEffect> {
private final int mRepeatIndex;