Loading packages/SystemUI/res/values/strings.xml +4 −2 Original line number Diff line number Diff line Loading @@ -1909,8 +1909,10 @@ <string name="notification_channel_battery">Battery</string> <!-- Title for the notification channel dedicated to screenshot progress. [CHAR LIMIT=NONE] --> <string name="notification_channel_screenshot">Screenshots</string> <!-- Title for the notification channel for miscellaneous notices. [CHAR LIMIT=NONE] --> <string name="notification_channel_general">General Messages</string> <!-- Title for the notification channel for instant app notices. [CHAR LIMIT=NONE] --> <string name="notification_channel_instant">Instant Apps</string> <!-- Title for the notification channel for setup notices. [CHAR LIMIT=NONE] --> <string name="notification_channel_setup">Setup</string> <!-- Title for the notification channel for problems with storage (i.e. low disk). [CHAR LIMIT=NONE] --> <string name="notification_channel_storage">Storage</string> <!-- Title for the notification channel for hints and suggestions. [CHAR LIMIT=NONE] --> Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/InstantAppNotifier.java +1 −1 Original line number Diff line number Diff line Loading @@ -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 Loading packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java +21 −5 Original line number Diff line number Diff line Loading @@ -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) { Loading @@ -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), Loading @@ -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)), Loading Loading @@ -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) { Loading packages/SystemUI/tests/src/com/android/systemui/util/ChannelsTest.java→packages/SystemUI/tests/src/com/android/systemui/util/NotificationChannelsTest.java +11 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading @@ -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<List> captor = ArgumentCaptor.forClass(List.class); Loading @@ -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<String> captor = ArgumentCaptor.forClass(String.class); verify(mMockNotificationManager).deleteNotificationChannel(captor.capture()); assertEquals(NotificationChannels.GENERAL, captor.getValue()); } } Loading
packages/SystemUI/res/values/strings.xml +4 −2 Original line number Diff line number Diff line Loading @@ -1909,8 +1909,10 @@ <string name="notification_channel_battery">Battery</string> <!-- Title for the notification channel dedicated to screenshot progress. [CHAR LIMIT=NONE] --> <string name="notification_channel_screenshot">Screenshots</string> <!-- Title for the notification channel for miscellaneous notices. [CHAR LIMIT=NONE] --> <string name="notification_channel_general">General Messages</string> <!-- Title for the notification channel for instant app notices. [CHAR LIMIT=NONE] --> <string name="notification_channel_instant">Instant Apps</string> <!-- Title for the notification channel for setup notices. [CHAR LIMIT=NONE] --> <string name="notification_channel_setup">Setup</string> <!-- Title for the notification channel for problems with storage (i.e. low disk). [CHAR LIMIT=NONE] --> <string name="notification_channel_storage">Storage</string> <!-- Title for the notification channel for hints and suggestions. [CHAR LIMIT=NONE] --> Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/InstantAppNotifier.java +1 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java +21 −5 Original line number Diff line number Diff line Loading @@ -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) { Loading @@ -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), Loading @@ -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)), Loading Loading @@ -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) { Loading
packages/SystemUI/tests/src/com/android/systemui/util/ChannelsTest.java→packages/SystemUI/tests/src/com/android/systemui/util/NotificationChannelsTest.java +11 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading @@ -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<List> captor = ArgumentCaptor.forClass(List.class); Loading @@ -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<String> captor = ArgumentCaptor.forClass(String.class); verify(mMockNotificationManager).deleteNotificationChannel(captor.capture()); assertEquals(NotificationChannels.GENERAL, captor.getValue()); } }