Unify and change notification channel to package name
Test: Manually
Bug: 378665160
Change-Id: I4b288dbb2a208b27c383f7d859e25022e900e55b
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/InstallerService.java b/android/TerminalApp/java/com/android/virtualization/terminal/InstallerService.java
index 2ce0cdc..b785416 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/InstallerService.java
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/InstallerService.java
@@ -54,7 +54,6 @@
public class InstallerService extends Service {
private static final String TAG = "InstallerService";
- private static final String NOTIFICATION_CHANNEL_ID = "installer";
private static final int NOTIFICATION_ID = 1313; // any unique number among notifications
private static final String IMAGE_URL =
@@ -81,23 +80,12 @@
public void onCreate() {
super.onCreate();
- // Create mandatory notification
- NotificationManager manager = getSystemService(NotificationManager.class);
- if (manager.getNotificationChannel(NOTIFICATION_CHANNEL_ID) == null) {
- NotificationChannel channel =
- new NotificationChannel(
- NOTIFICATION_CHANNEL_ID,
- getString(R.string.installer_notif_title_text),
- NotificationManager.IMPORTANCE_DEFAULT);
- manager.createNotificationChannel(channel);
- }
-
Intent intent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent =
PendingIntent.getActivity(
this, /* requestCode= */ 0, intent, PendingIntent.FLAG_IMMUTABLE);
mNotification =
- new Notification.Builder(this, NOTIFICATION_CHANNEL_ID)
+ new Notification.Builder(this, this.getPackageName())
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setContentTitle(getString(R.string.installer_notif_title_text))
.setContentText(getString(R.string.installer_notif_desc_text))
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java b/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
index fdf1f3b..e8fd2d2 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
@@ -95,15 +95,18 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- boolean launchInstaller = installIfNecessary();
-
NotificationManager notificationManager = getSystemService(NotificationManager.class);
- if (notificationManager.getNotificationChannel(TAG) == null) {
- NotificationChannel notificationChannel =
- new NotificationChannel(TAG, TAG, NotificationManager.IMPORTANCE_LOW);
- notificationManager.createNotificationChannel(notificationChannel);
+ if (notificationManager.getNotificationChannel(this.getPackageName()) == null) {
+ NotificationChannel channel =
+ new NotificationChannel(
+ this.getPackageName(),
+ getString(R.string.app_name),
+ NotificationManager.IMPORTANCE_DEFAULT);
+ notificationManager.createNotificationChannel(channel);
}
+ boolean launchInstaller = installIfNecessary();
+
setContentView(R.layout.activity_headless);
diskSizeStep = getResources().getInteger(
R.integer.disk_size_round_up_step_size_in_mb) << 20;
@@ -471,8 +474,7 @@
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
Icon icon = Icon.createWithResource(getResources(), R.drawable.ic_launcher_foreground);
Notification notification =
- new Notification.Builder(this, TAG)
- .setChannelId(TAG)
+ new Notification.Builder(this, this.getPackageName())
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setContentTitle(
getResources().getString(R.string.service_notification_title))