diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 93151fa8b86d7..12d3dc3d49d46 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1909,8 +1909,10 @@ Battery Screenshots - - General Messages + + Instant Apps + + Setup Storage diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/InstantAppNotifier.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/InstantAppNotifier.java index df412ed93f550..8cb18a06057e1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/InstantAppNotifier.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/InstantAppNotifier.java @@ -260,7 +260,7 @@ public class InstantAppNotifier extends CoreStartable Intent browserIntent = getTaskIntent(taskId, userId); Notification.Builder builder = - new Notification.Builder(mContext, NotificationChannels.GENERAL); + new Notification.Builder(mContext, NotificationChannels.INSTANT); if (browserIntent != null && browserIntent.isWebIntent()) { // Make sure that this doesn't resolve back to an instant app browserIntent diff --git a/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java b/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java index 76dfcb182e972..53da213eb38e0 100644 --- a/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java +++ b/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java @@ -35,11 +35,15 @@ import javax.inject.Inject; public class NotificationChannels extends CoreStartable { public static String ALERTS = "ALR"; public static String SCREENSHOTS_HEADSUP = "SCN_HEADSUP"; - public static String GENERAL = "GEN"; + // Deprecated. Please use or create a more specific channel that users will better understand + @Deprecated + static String GENERAL = "GEN"; public static String STORAGE = "DSK"; public static String BATTERY = "BAT"; public static String TVPIP = TvPipNotificationController.NOTIFICATION_CHANNEL; // "TVPIP" public static String HINTS = "HNT"; + public static String INSTANT = "INS"; + public static String SETUP = "STP"; @Inject public NotificationChannels(Context context) { @@ -64,11 +68,17 @@ public class NotificationChannels extends CoreStartable { context.getString(R.string.notification_channel_alerts), NotificationManager.IMPORTANCE_HIGH); - final NotificationChannel general = new NotificationChannel( - GENERAL, - context.getString(R.string.notification_channel_general), + final NotificationChannel instant = new NotificationChannel( + INSTANT, + context.getString(R.string.notification_channel_instant), NotificationManager.IMPORTANCE_MIN); + final NotificationChannel setup = new NotificationChannel( + SETUP, + context.getString(R.string.notification_channel_setup), + NotificationManager.IMPORTANCE_DEFAULT); + setup.setSound(null, null); + final NotificationChannel storage = new NotificationChannel( STORAGE, context.getString(R.string.notification_channel_storage), @@ -84,7 +94,8 @@ public class NotificationChannels extends CoreStartable { nm.createNotificationChannels(Arrays.asList( alerts, - general, + instant, + setup, storage, createScreenshotChannel( context.getString(R.string.notification_channel_screenshot)), @@ -123,6 +134,11 @@ public class NotificationChannels extends CoreStartable { @Override public void start() { createAll(mContext); + cleanUp(); + } + + private void cleanUp() { + mContext.getSystemService(NotificationManager.class).deleteNotificationChannel(GENERAL); } private static boolean isTv(Context context) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/ChannelsTest.java b/packages/SystemUI/tests/src/com/android/systemui/util/NotificationChannelsTest.java similarity index 81% rename from packages/SystemUI/tests/src/com/android/systemui/util/ChannelsTest.java rename to packages/SystemUI/tests/src/com/android/systemui/util/NotificationChannelsTest.java index c7bcdefdc4c34..900d7928fb440 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/util/ChannelsTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/util/NotificationChannelsTest.java @@ -28,7 +28,6 @@ import android.util.ArraySet; import androidx.test.runner.AndroidJUnit4; import com.android.systemui.SysuiTestCase; -import com.android.systemui.util.NotificationChannels; import org.junit.Before; import org.junit.Test; @@ -41,7 +40,7 @@ import java.util.Set; @SmallTest @RunWith(AndroidJUnit4.class) -public class ChannelsTest extends SysuiTestCase { +public class NotificationChannelsTest extends SysuiTestCase { private final NotificationManager mMockNotificationManager = mock(NotificationManager.class); @Before @@ -55,9 +54,10 @@ public class ChannelsTest extends SysuiTestCase { NotificationChannels.ALERTS, NotificationChannels.SCREENSHOTS_HEADSUP, NotificationChannels.STORAGE, - NotificationChannels.GENERAL, + NotificationChannels.INSTANT, NotificationChannels.BATTERY, - NotificationChannels.HINTS + NotificationChannels.HINTS, + NotificationChannels.SETUP )); NotificationChannels.createAll(mContext); ArgumentCaptor captor = ArgumentCaptor.forClass(List.class); @@ -67,4 +67,11 @@ public class ChannelsTest extends SysuiTestCase { list.forEach((chan) -> assertTrue(ALL_CHANNELS.contains(chan.getId()))); } + @Test + public void testChannelCleanup() { + new NotificationChannels(mContext).start(); + ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); + verify(mMockNotificationManager).deleteNotificationChannel(captor.capture()); + assertEquals(NotificationChannels.GENERAL, captor.getValue()); + } }