Merge "Removing PiP notification channel." into oc-dev
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index bf17e38..0c0bdeb 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1869,9 +1869,6 @@
<!-- Title of menu shown over picture-in-picture. Used for accessibility. -->
<string name="pip_menu_title">Picture in picture menu</string>
- <!-- User visible notification channel name for the PiP BTW notification. [CHAR LIMIT=NONE] -->
- <string name="pip_notification_channel_name">Picture-in-picture</string>
-
<!-- PiP BTW notification title. [CHAR LIMIT=50] -->
<string name="pip_notification_title"><xliff:g id="name" example="Google Maps">%s</xliff:g> is in picture-in-picture</string>
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipNotificationController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipNotificationController.java
index bdd6b65..9bf6d6e 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipNotificationController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipNotificationController.java
@@ -16,7 +16,6 @@
package com.android.systemui.pip.phone;
-import static android.app.NotificationManager.IMPORTANCE_MIN;
import static android.app.PendingIntent.FLAG_CANCEL_CURRENT;
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
@@ -24,7 +23,6 @@
import android.app.IActivityManager;
import android.app.Notification;
-import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ComponentName;
@@ -40,6 +38,7 @@
import com.android.systemui.R;
import com.android.systemui.SystemUI;
+import com.android.systemui.util.NotificationChannels;
/**
* Manages the BTW notification that shows whenever an activity enters or leaves picture-in-picture.
@@ -47,8 +46,8 @@
public class PipNotificationController {
private static final String TAG = PipNotificationController.class.getSimpleName();
- private static final String CHANNEL_ID = PipNotificationController.class.getName();
- private static final int BTW_NOTIFICATION_ID = 0;
+ private static final String NOTIFICATION_TAG = PipNotificationController.class.getName();
+ private static final int NOTIFICATION_ID = 0;
private Context mContext;
private IActivityManager mActivityManager;
@@ -58,25 +57,25 @@
mContext = context;
mActivityManager = activityManager;
mNotificationManager = NotificationManager.from(context);
- createNotificationChannel();
}
public void onActivityPinned(String packageName) {
// Clear any existing notification
- mNotificationManager.cancel(CHANNEL_ID, BTW_NOTIFICATION_ID);
+ mNotificationManager.cancel(NOTIFICATION_TAG, NOTIFICATION_ID);
// Build a new notification
- final Notification.Builder builder = new Notification.Builder(mContext, CHANNEL_ID)
- .setLocalOnly(true)
- .setOngoing(true)
- .setSmallIcon(R.drawable.pip_notification_icon)
- .setColor(mContext.getColor(
- com.android.internal.R.color.system_notification_accent_color));
+ final Notification.Builder builder =
+ new Notification.Builder(mContext, NotificationChannels.GENERAL)
+ .setLocalOnly(true)
+ .setOngoing(true)
+ .setSmallIcon(R.drawable.pip_notification_icon)
+ .setColor(mContext.getColor(
+ com.android.internal.R.color.system_notification_accent_color));
if (updateNotificationForApp(builder, packageName)) {
SystemUI.overrideNotificationAppName(mContext, builder);
// Show the new notification
- mNotificationManager.notify(CHANNEL_ID, BTW_NOTIFICATION_ID, builder.build());
+ mNotificationManager.notify(NOTIFICATION_TAG, NOTIFICATION_ID, builder.build());
}
}
@@ -85,26 +84,11 @@
if (topPipActivity != null) {
onActivityPinned(topPipActivity.getPackageName());
} else {
- mNotificationManager.cancel(CHANNEL_ID, BTW_NOTIFICATION_ID);
+ mNotificationManager.cancel(NOTIFICATION_TAG, NOTIFICATION_ID);
}
}
/**
- * Create the notification channel for the PiP BTW notifications if necessary.
- */
- private NotificationChannel createNotificationChannel() {
- NotificationChannel channel = mNotificationManager.getNotificationChannel(CHANNEL_ID);
- if (channel == null) {
- channel = new NotificationChannel(CHANNEL_ID,
- mContext.getString(R.string.pip_notification_channel_name), IMPORTANCE_MIN);
- channel.enableLights(false);
- channel.enableVibration(false);
- mNotificationManager.createNotificationChannel(channel);
- }
- return channel;
- }
-
- /**
* Updates the notification builder with app-specific information, returning whether it was
* successful.
*/