SystemUI: Override notification app name
Overrides the notification app name for all SystemUI notifications.
Change-Id: Ic7676069aa03d5b83f0fbe0e8c3ad9820453118a
Fixes: 26517701
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUI.java b/packages/SystemUI/src/com/android/systemui/SystemUI.java
index 85befff..f30baee 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUI.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUI.java
@@ -16,8 +16,10 @@
package com.android.systemui;
+import android.app.Notification;
import android.content.Context;
import android.content.res.Configuration;
+import android.os.Bundle;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -48,4 +50,12 @@
mComponents.put(interfaceType, component);
}
}
+
+ public static void overrideNotificationAppName(Context context, Notification.Builder n) {
+ final Bundle extras = new Bundle();
+ extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
+ context.getString(com.android.internal.R.string.android_system_label));
+
+ n.addExtras(extras);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
index ea1c9bf..b831235 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
@@ -38,6 +38,7 @@
import android.util.Slog;
import com.android.systemui.R;
+import com.android.systemui.SystemUI;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.phone.SystemUIDialog;
@@ -143,6 +144,7 @@
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setColor(mContext.getColor(
com.android.internal.R.color.system_notification_accent_color));
+ SystemUI.overrideNotificationAppName(mContext, nb);
final Notification n = nb.build();
mNoMan.notifyAsUser(TAG_NOTIFICATION, R.id.notification_power, n, UserHandle.ALL);
}
@@ -173,8 +175,8 @@
attachLowBatterySound(nb);
mPlaySound = false;
}
- final Notification n = nb.build();
- mNoMan.notifyAsUser(TAG_NOTIFICATION, R.id.notification_power, n, UserHandle.ALL);
+ SystemUI.overrideNotificationAppName(mContext, nb);
+ mNoMan.notifyAsUser(TAG_NOTIFICATION, R.id.notification_power, nb.build(), UserHandle.ALL);
}
private PendingIntent pendingActivity(Intent intent) {
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index e6cbbea..d789477 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -60,6 +60,7 @@
import android.widget.ImageView;
import com.android.systemui.R;
+import com.android.systemui.SystemUI;
import java.io.File;
import java.io.FileOutputStream;
@@ -165,11 +166,6 @@
c.drawColor(overlayColor);
c.setBitmap(null);
- // swap "System UI" out for "Android System"
- final Bundle extras = new Bundle();
- extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
- context.getString(com.android.internal.R.string.android_system_label));
-
// Show the intermediate notification
mTickerAddSpace = !mTickerAddSpace;
mNotificationManager = nManager;
@@ -187,9 +183,9 @@
.setCategory(Notification.CATEGORY_PROGRESS)
.setWhen(now)
.setShowWhen(true)
- .addExtras(extras)
.setColor(r.getColor(
com.android.internal.R.color.system_notification_accent_color));
+ SystemUI.overrideNotificationAppName(context, mPublicNotificationBuilder);
mNotificationBuilder = new Notification.Builder(context)
.setTicker(r.getString(R.string.screenshot_saving_ticker)
@@ -199,11 +195,11 @@
.setSmallIcon(R.drawable.stat_notify_image)
.setWhen(now)
.setShowWhen(true)
- .addExtras(extras)
.setColor(r.getColor(com.android.internal.R.color.system_notification_accent_color))
.setStyle(mNotificationStyle)
.setPublicVersion(mPublicNotificationBuilder.build());
mNotificationBuilder.setFlag(Notification.FLAG_NO_CLEAR, true);
+ SystemUI.overrideNotificationAppName(context, mNotificationBuilder);
mNotificationManager.notify(R.id.notification_screenshot, mNotificationBuilder.build());
@@ -864,6 +860,7 @@
.setAutoCancel(true)
.setColor(context.getColor(
com.android.internal.R.color.system_notification_accent_color));
+ SystemUI.overrideNotificationAppName(context, b);
Notification n = new Notification.BigTextStyle(b)
.bigText(errorMsg)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 91889d3..fbc84cf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -840,7 +840,6 @@
new Intent(BANNER_ACTION_SETUP).setPackage(packageName),
PendingIntent.FLAG_CANCEL_CURRENT);
- final Resources res = mContext.getResources();
final int colorRes = com.android.internal.R.color.system_notification_accent_color;
Notification.Builder note = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_android)
@@ -856,6 +855,7 @@
.addAction(R.drawable.ic_settings,
mContext.getString(R.string.hidden_notifications_setup),
setupIntent);
+ overrideNotificationAppName(mContext, note);
NotificationManager noMan =
(NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
index 415b7a1..89d2712 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
@@ -51,6 +51,7 @@
import com.android.settingslib.RestrictedLockUtils;
import com.android.systemui.GuestResumeSessionReceiver;
import com.android.systemui.R;
+import com.android.systemui.SystemUI;
import com.android.systemui.SystemUISecondaryUserService;
import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.tiles.UserDetailView;
@@ -523,7 +524,7 @@
private void showLogoutNotification(int userId) {
PendingIntent logoutPI = PendingIntent.getBroadcastAsUser(mContext,
0, new Intent(ACTION_LOGOUT_USER), 0, UserHandle.SYSTEM);
- Notification notification = new Notification.Builder(mContext)
+ Notification.Builder builder = new Notification.Builder(mContext)
.setVisibility(Notification.VISIBILITY_SECRET)
.setPriority(Notification.PRIORITY_MIN)
.setSmallIcon(R.drawable.ic_person)
@@ -534,10 +535,10 @@
.setShowWhen(false)
.addAction(R.drawable.ic_delete,
mContext.getString(R.string.user_logout_notification_action),
- logoutPI)
- .build();
+ logoutPI);
+ SystemUI.overrideNotificationAppName(mContext, builder);
NotificationManager.from(mContext).notifyAsUser(TAG_LOGOUT_USER, ID_LOGOUT_USER,
- notification, new UserHandle(userId));
+ builder.build(), new UserHandle(userId));
}
};
@@ -547,7 +548,7 @@
PendingIntent removeGuestPI = canSwitchUsers ? PendingIntent.getBroadcastAsUser(mContext,
0, new Intent(ACTION_REMOVE_GUEST), 0, UserHandle.SYSTEM) : null;
- Notification notification = new Notification.Builder(mContext)
+ Notification.Builder builder = new Notification.Builder(mContext)
.setVisibility(Notification.VISIBILITY_SECRET)
.setPriority(Notification.PRIORITY_MIN)
.setSmallIcon(R.drawable.ic_person)
@@ -557,10 +558,10 @@
.setShowWhen(false)
.addAction(R.drawable.ic_delete,
mContext.getString(R.string.guest_notification_remove_action),
- removeGuestPI)
- .build();
+ removeGuestPI);
+ SystemUI.overrideNotificationAppName(mContext, builder);
NotificationManager.from(mContext).notifyAsUser(TAG_REMOVE_GUEST, ID_REMOVE_GUEST,
- notification, new UserHandle(guestUserId));
+ builder.build(), new UserHandle(guestUserId));
}
private final Runnable mUnpauseRefreshUsers = new Runnable() {
diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
index 36dd727..97d5e10 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
@@ -198,7 +198,7 @@
rec.getNickname());
final CharSequence text = mContext.getString(R.string.ext_media_missing_message);
- final Notification notif = new Notification.Builder(mContext)
+ Notification.Builder builder = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_sd_card_48dp)
.setColor(mContext.getColor(R.color.system_notification_accent_color))
.setContentTitle(title)
@@ -208,10 +208,11 @@
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true)
.setCategory(Notification.CATEGORY_SYSTEM)
- .setDeleteIntent(buildSnoozeIntent(fsUuid))
- .build();
+ .setDeleteIntent(buildSnoozeIntent(fsUuid));
+ SystemUI.overrideNotificationAppName(mContext, builder);
- mNotificationManager.notifyAsUser(fsUuid, PRIVATE_ID, notif, UserHandle.ALL);
+ mNotificationManager.notifyAsUser(fsUuid, PRIVATE_ID, builder
+ .build(), UserHandle.ALL);
}
}
}
@@ -224,7 +225,7 @@
final CharSequence text = mContext.getString(
R.string.ext_media_unsupported_notification_message, disk.getDescription());
- final Notification notif = new Notification.Builder(mContext)
+ Notification.Builder builder = new Notification.Builder(mContext)
.setSmallIcon(getSmallIcon(disk, VolumeInfo.STATE_UNMOUNTABLE))
.setColor(mContext.getColor(R.color.system_notification_accent_color))
.setContentTitle(title)
@@ -233,10 +234,11 @@
.setStyle(new Notification.BigTextStyle().bigText(text))
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true)
- .setCategory(Notification.CATEGORY_ERROR)
- .build();
+ .setCategory(Notification.CATEGORY_ERROR);
+ SystemUI.overrideNotificationAppName(mContext, builder);
- mNotificationManager.notifyAsUser(disk.getId(), DISK_ID, notif, UserHandle.ALL);
+ mNotificationManager.notifyAsUser(disk.getId(), DISK_ID, builder.build(),
+ UserHandle.ALL);
} else {
// Yay, we have volumes!
@@ -471,7 +473,7 @@
intent = buildWizardMigratePendingIntent(move);
}
- final Notification notif = new Notification.Builder(mContext)
+ Notification.Builder builder = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_sd_card_48dp)
.setColor(mContext.getColor(R.color.system_notification_accent_color))
.setContentTitle(title)
@@ -483,10 +485,11 @@
.setCategory(Notification.CATEGORY_PROGRESS)
.setPriority(Notification.PRIORITY_LOW)
.setProgress(100, status, false)
- .setOngoing(true)
- .build();
+ .setOngoing(true);
+ SystemUI.overrideNotificationAppName(mContext, builder);
- mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, notif, UserHandle.ALL);
+ mNotificationManager.notifyAsUser(move.packageName, MOVE_ID,
+ builder.build(), UserHandle.ALL);
}
private void onMoveFinished(MoveInfo move, int status) {
@@ -520,7 +523,7 @@
intent = null;
}
- final Notification notif = new Notification.Builder(mContext)
+ Notification.Builder builder = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_sd_card_48dp)
.setColor(mContext.getColor(R.color.system_notification_accent_color))
.setContentTitle(title)
@@ -531,10 +534,11 @@
.setLocalOnly(true)
.setCategory(Notification.CATEGORY_SYSTEM)
.setPriority(Notification.PRIORITY_LOW)
- .setAutoCancel(true)
- .build();
+ .setAutoCancel(true);
+ SystemUI.overrideNotificationAppName(mContext, builder);
- mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, notif, UserHandle.ALL);
+ mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, builder.build(),
+ UserHandle.ALL);
}
private int getSmallIcon(DiskInfo disk, int state) {
@@ -555,7 +559,7 @@
private Notification.Builder buildNotificationBuilder(VolumeInfo vol, CharSequence title,
CharSequence text) {
- return new Notification.Builder(mContext)
+ Notification.Builder builder = new Notification.Builder(mContext)
.setSmallIcon(getSmallIcon(vol.getDisk(), vol.getState()))
.setColor(mContext.getColor(R.color.system_notification_accent_color))
.setContentTitle(title)
@@ -563,6 +567,8 @@
.setStyle(new Notification.BigTextStyle().bigText(text))
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true);
+ overrideNotificationAppName(mContext, builder);
+ return builder;
}
private PendingIntent buildInitPendingIntent(DiskInfo disk) {
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
index 2688813..c820302 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
@@ -228,22 +228,23 @@
}
final Intent intent = new Intent(Receiver.DISABLE)
.putExtra(Receiver.EXTRA_COMPONENT, component);
+ Notification.Builder builder = new Notification.Builder(mContext)
+ .setSmallIcon(R.drawable.ic_volume_media)
+ .setWhen(0)
+ .setShowWhen(false)
+ .setOngoing(true)
+ .setContentTitle(mContext.getString(
+ R.string.volumeui_notification_title, getAppLabel(component)))
+ .setContentText(mContext.getString(R.string.volumeui_notification_text))
+ .setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT))
+ .setPriority(Notification.PRIORITY_MIN)
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
+ .setColor(mContext.getColor(
+ com.android.internal.R.color.system_notification_accent_color));
+ overrideNotificationAppName(mContext, builder);
mNotificationManager.notify(R.id.notification_volumeui,
- new Notification.Builder(mContext)
- .setSmallIcon(R.drawable.ic_volume_media)
- .setWhen(0)
- .setShowWhen(false)
- .setOngoing(true)
- .setContentTitle(mContext.getString(
- R.string.volumeui_notification_title, getAppLabel(component)))
- .setContentText(mContext.getString(R.string.volumeui_notification_text))
- .setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent,
- PendingIntent.FLAG_UPDATE_CURRENT))
- .setPriority(Notification.PRIORITY_MIN)
- .setVisibility(Notification.VISIBILITY_PUBLIC)
- .setColor(mContext.getColor(
- com.android.internal.R.color.system_notification_accent_color))
- .build());
+ builder.build());
}
}
}