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

Commit d55e21ed authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add missing sound to important channels."

parents 0e9acb53 31b2baac
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ParceledListSlice;
import android.os.Build;
import android.os.UserHandle;
import android.provider.Settings;
import android.service.notification.NotificationListenerService.Ranking;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -516,6 +517,10 @@ public class RankingHelper implements RankingConfig {
        if (!r.showBadge) {
            channel.setShowBadge(false);
        }
        if (channel.getSound() == null) {
            channel.setSound(Settings.System.DEFAULT_NOTIFICATION_URI,
                    Notification.AUDIO_ATTRIBUTES_DEFAULT);
        }
        r.channels.put(channel.getId(), channel);
        updateConfig();
    }
+20 −0
Original line number Diff line number Diff line
@@ -775,6 +775,26 @@ public class RankingHelperTest {
                mHelper.getNotificationChannel(pkg, uid, newChannel.getId(), false));
    }

    @Test
    public void testCreateChannel_addMissingSound() throws Exception {
        final NotificationChannel channel =
                new NotificationChannel("id2", "name2", IMPORTANCE_LOW);
        mHelper.createNotificationChannel(pkg, uid, channel, true);
        assertNotNull(mHelper.getNotificationChannel(
                pkg, uid, channel.getId(), false).getSound());
    }

    @Test
    public void testCreateChannel_noOverrideSound() throws Exception {
        Uri sound = new Uri.Builder().scheme("test").build();
        final NotificationChannel channel = new NotificationChannel("id2", "name2",
                 NotificationManager.IMPORTANCE_DEFAULT);
        channel.setSound(sound, mAudioAttributes);
        mHelper.createNotificationChannel(pkg, uid, channel, true);
        assertEquals(sound, mHelper.getNotificationChannel(
                pkg, uid, channel.getId(), false).getSound());
    }

    @Test
    public void testPermanentlyDeleteChannels() throws Exception {
        NotificationChannel channel1 =