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

Commit 49d33a92 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Force IMPORTANCE_LOW for reserved channels" into main

parents 1e4e8644 cce92084
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -470,6 +470,10 @@ public class PreferencesHelper implements RankingConfig {
            int channelImportance = parser.getAttributeInt(
                    null, ATT_IMPORTANCE, DEFAULT_IMPORTANCE);
            if (!TextUtils.isEmpty(id) && !TextUtils.isEmpty(channelName)) {
                // Force IMPORTANCE_LOW for reserved channels
                if (notificationClassification() && SYSTEM_RESERVED_IDS.contains(id)) {
                    channelImportance = IMPORTANCE_LOW;
                }
                NotificationChannel channel = new NotificationChannel(
                        id, channelName, channelImportance);
                if (forRestore) {
+7 −4
Original line number Diff line number Diff line
@@ -650,8 +650,8 @@ public class PreferencesHelperTest extends UiServiceTestCase {
        NotificationChannel updateNews = null;
        if (notificationClassification()) {
            mHelper.createReservedChannel(PKG_N_MR1, UID_N_MR1, TYPE_NEWS);
            // change one of the reserved bundle channels to ensure changes are persisted across
            // boot
            // change one of the reserved bundle channels to ensure changes are not persisted
            // across boot
            updateNews = mHelper.getNotificationChannel(
                    PKG_N_MR1, UID_N_MR1, NEWS_ID, false).copy();
            updateNews.setImportance(IMPORTANCE_NONE);
@@ -666,7 +666,7 @@ public class PreferencesHelperTest extends UiServiceTestCase {

        ByteArrayOutputStream baos = writeXmlAndPurge(PKG_N_MR1, UID_N_MR1, false,
                UserHandle.USER_ALL, channel1.getId(), channel2.getId(),
                NotificationChannel.DEFAULT_CHANNEL_ID);
                NotificationChannel.DEFAULT_CHANNEL_ID, updateNews.getId());
        mHelper.onPackagesChanged(true, UserHandle.myUserId(), new String[]{PKG_N_MR1}, new int[]{
                UID_N_MR1});

@@ -683,10 +683,13 @@ public class PreferencesHelperTest extends UiServiceTestCase {
        compareChannels(channel2,
                mXmlHelper.getNotificationChannel(PKG_N_MR1, UID_N_MR1, channel2.getId(), false));
        if (notificationClassification()) {
            updateNews.setImportance(IMPORTANCE_LOW);
            assertThat(mXmlHelper.getNotificationChannel(PKG_N_MR1, UID_N_MR1, updateNews.getId(),
                    false)).isNotNull();
            assertThat(mXmlHelper.getNotificationChannel(PKG_N_MR1, UID_N_MR1, updateNews.getId(),
                    false)).isEqualTo(updateNews);
            assertThat(mXmlHelper.getNotificationChannel(PKG_N_MR1, UID_N_MR1, updateNews.getId(),
                    false).getImportance()).isEqualTo(IMPORTANCE_LOW);
        }

        List<NotificationChannelGroup> actualGroups = mXmlHelper.getNotificationChannelGroups(