Merge "Don't consider uri empty a valid sound" into oc-dev

This commit is contained in:
Julia Reynolds
2017-04-24 21:16:57 +00:00
committed by Android (Google) Code Review
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!"); if (DBG) Slog.v(TAG, "Interrupting!");
Uri soundUri = record.getSound(); Uri soundUri = record.getSound();
hasValidSound = (soundUri != null); hasValidSound = soundUri != null && !Uri.EMPTY.equals(soundUri);
long[] vibration = record.getVibration(); long[] vibration = record.getVibration();
// Demote sound to vibration if vibration missing & phone in vibration mode. // Demote sound to vibration if vibration missing & phone in vibration mode.
if (vibration == null if (vibration == null

View File

@@ -15,6 +15,8 @@
*/ */
package com.android.server.notification; package com.android.server.notification;
import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.assertTrue;
@@ -198,7 +200,7 @@ public class BuzzBeepBlinkTest {
boolean noisy, boolean buzzy, boolean lights, boolean defaultVibration, boolean noisy, boolean buzzy, boolean lights, boolean defaultVibration,
boolean defaultSound, boolean defaultLights) { boolean defaultSound, boolean defaultLights) {
NotificationChannel channel = NotificationChannel channel =
new NotificationChannel("test", "test", NotificationManager.IMPORTANCE_HIGH); new NotificationChannel("test", "test", IMPORTANCE_HIGH);
final Builder builder = new Builder(getContext()) final Builder builder = new Builder(getContext())
.setContentTitle("foo") .setContentTitle("foo")
.setSmallIcon(android.R.drawable.sym_def_app_icon) .setSmallIcon(android.R.drawable.sym_def_app_icon)
@@ -680,6 +682,23 @@ public class BuzzBeepBlinkTest {
verifyStopVibrate(); 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> { static class VibrateRepeatMatcher implements ArgumentMatcher<VibrationEffect> {
private final int mRepeatIndex; private final int mRepeatIndex;