Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db5f5c3a authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

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

parents 5d1c6597 ca80d163
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+20 −1
Original line number Diff line number Diff line
@@ -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;