Merge "Don't consider uri empty a valid sound" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
db5f5c3a17
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user