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

Commit 8e032e15 authored by Dan Sandler's avatar Dan Sandler
Browse files

Notification Channels come to SystemUI's own notifications.

There are five channels at present:
    ALERTS - low battery etc.
    SCREENSHOTS - progress & result
    SECURITY - notifications hidden due to policy
    STORAGE - disk low
    STATUS - basically everything else

The importance for each channel should match the legacy
priority of the notifications it carries.

Bug: 34250937
Test: runtest systemui
Change-Id: I5915ca453258caea63b0d9bd756893db05e8d600
parent d1b6dcbe
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -51,6 +51,9 @@ public class PluginInstanceManager<T extends Plugin> {
    private static final String TAG = "PluginInstanceManager";
    private static final String PLUGIN_PERMISSION = "com.android.systemui.permission.PLUGIN";

    // must be one of the channels created in NotificationChannels.java
    private static final String NOTIFICATION_CHANNEL_ID = "ALR";

    private final Context mContext;
    private final PluginListener<T> mListener;
    private final String mAction;
@@ -312,7 +315,7 @@ public class PluginInstanceManager<T extends Plugin> {
                            .setSmallIcon(icon)
                            .setWhen(0)
                            .setShowWhen(false)
                            .setPriority(Notification.PRIORITY_MAX)
                            .setChannel(NOTIFICATION_CHANNEL_ID)
                            .setVisibility(Notification.VISIBILITY_PUBLIC)
                            .setColor(mContext.getColor(color));
                    String label = cls;
+11 −0
Original line number Diff line number Diff line
@@ -1800,4 +1800,15 @@
    <!-- SysUI Tuner: Switch to control if device gets unlocked [CHAR LIMIT=60] -->
    <string name="lockscreen_unlock">Prompt for password</string>

    <!-- Title for the notification channel containing important alerts like low battery. [CHAR LIMIT=NONE] -->
    <string name="notification_channel_alerts">Alerts</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 urgent security issues. [CHAR LIMIT=NONE] -->
    <string name="notification_channel_security">Security</string>
    <!-- Title for the notification channel containing multi-user status information. [CHAR LIMIT=NONE] -->
    <string name="notification_channel_user_status">User status</string>
    <!-- Title for the notification channel for problems with storage (i.e. low disk). [CHAR LIMIT=NONE] -->
    <string name="notification_channel_storage">Storage</string>

</resources>
+2 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.systemui.statusbar.SystemBars;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.usb.StorageNotification;
import com.android.systemui.util.NotificationChannels;
import com.android.systemui.volume.VolumeUI;

import java.util.HashMap;
@@ -66,6 +67,7 @@ public class SystemUIApplication extends Application implements SysUiServiceProv
            Dependency.class,
            FragmentService.class,
            TunerService.class,
            NotificationChannels.class,
            CommandQueue.CommandQueueStart.class,
            KeyguardViewMediator.class,
            Recents.class,
+4 −4
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.util.NotificationChannels;

import java.io.PrintWriter;
import java.text.NumberFormat;
@@ -151,8 +152,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                .setOngoing(true)
                .setContentTitle(mContext.getString(R.string.invalid_charger_title))
                .setContentText(mContext.getString(R.string.invalid_charger_text))
                .setPriority(Notification.PRIORITY_MAX)
                .setVisibility(Notification.VISIBILITY_PUBLIC)
                .setChannel(NotificationChannels.ALERTS)
                .setColor(mContext.getColor(
                        com.android.internal.R.color.system_notification_accent_color));
        SystemUI.overrideNotificationAppName(mContext, nb);
@@ -173,7 +173,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                .setContentText(mContext.getString(textRes, percentage))
                .setOnlyAlertOnce(true)
                .setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_WARNING))
                .setPriority(Notification.PRIORITY_MAX)
                .setChannel(NotificationChannels.ALERTS)
                .setVisibility(Notification.VISIBILITY_PUBLIC)
                .setColor(mContext.getColor(
                        com.android.internal.R.color.battery_saver_mode_color));
@@ -241,7 +241,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                .setShowWhen(false)
                .setContentTitle(mContext.getString(R.string.high_temp_title))
                .setContentText(mContext.getString(R.string.high_temp_notif_message))
                .setPriority(Notification.PRIORITY_HIGH)
                .setChannel(NotificationChannels.ALERTS)
                .setVisibility(Notification.VISIBILITY_PUBLIC)
                .setContentIntent(pendingBroadcast(ACTION_CLICKED_TEMP_WARNING))
                .setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_TEMP_WARNING))
+5 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import android.widget.ImageView;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.util.NotificationChannels;

import java.io.File;
import java.io.FileOutputStream;
@@ -178,6 +179,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {

        // The public notification will show similar info but with the actual screenshot omitted
        mPublicNotificationBuilder = new Notification.Builder(context)
                .setChannel(NotificationChannels.SCREENSHOTS)
                .setContentTitle(r.getString(R.string.screenshot_saving_title))
                .setContentText(r.getString(R.string.screenshot_saving_text))
                .setSmallIcon(R.drawable.stat_notify_image)
@@ -189,6 +191,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
        SystemUI.overrideNotificationAppName(context, mPublicNotificationBuilder);

        mNotificationBuilder = new Notification.Builder(context)
            .setChannel(NotificationChannels.SCREENSHOTS)
            .setTicker(r.getString(R.string.screenshot_saving_ticker)
                    + (mTickerAddSpace ? " " : ""))
            .setContentTitle(r.getString(R.string.screenshot_saving_title))
@@ -332,6 +335,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {

            // Update the text and the icon for the existing notification
            mPublicNotificationBuilder
                    .setChannel(NotificationChannels.SCREENSHOTS)
                    .setContentTitle(r.getString(R.string.screenshot_saved_title))
                    .setContentText(r.getString(R.string.screenshot_saved_text))
                    .setContentIntent(PendingIntent.getActivity(mParams.context, 0, launchIntent, 0))
@@ -340,6 +344,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
                    .setColor(context.getColor(
                            com.android.internal.R.color.system_notification_accent_color));
            mNotificationBuilder
                .setChannel(NotificationChannels.SCREENSHOTS)
                .setContentTitle(r.getString(R.string.screenshot_saved_title))
                .setContentText(r.getString(R.string.screenshot_saved_text))
                .setContentIntent(PendingIntent.getActivity(mParams.context, 0, launchIntent, 0))
Loading