Merge "Move #overrideNotificationAppName from CoreStartable."

This commit is contained in:
TreeHugger Robot
2021-11-12 23:37:34 +00:00
committed by Android (Google) Code Review
5 changed files with 27 additions and 27 deletions

View File

@@ -16,10 +16,8 @@
package com.android.systemui;
import android.app.Notification;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import androidx.annotation.NonNull;
@@ -54,16 +52,4 @@ public abstract class CoreStartable implements Dumpable {
@VisibleForTesting
protected void onBootCompleted() {
}
/** TODO(b/205725937): Move this. SystemUIApplication? */
public static void overrideNotificationAppName(Context context, Notification.Builder n,
boolean system) {
final Bundle extras = new Bundle();
String appName = system
? context.getString(com.android.internal.R.string.notification_app_name_system)
: context.getString(com.android.internal.R.string.notification_app_name_settings);
extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, appName);
n.addExtras(extras);
}
}

View File

@@ -18,12 +18,14 @@ package com.android.systemui;
import android.app.ActivityThread;
import android.app.Application;
import android.app.Notification;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Process;
import android.os.SystemProperties;
import android.os.Trace;
@@ -275,4 +277,15 @@ public class SystemUIApplication extends Application implements
mContextAvailableCallback = callback;
}
/** Update a notifications application name. */
public static void overrideNotificationAppName(Context context, Notification.Builder n,
boolean system) {
final Bundle extras = new Bundle();
String appName = system
? context.getString(com.android.internal.R.string.notification_app_name_system)
: context.getString(com.android.internal.R.string.notification_app_name_settings);
extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, appName);
n.addExtras(extras);
}
}

View File

@@ -58,9 +58,9 @@ import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.settingslib.Utils;
import com.android.settingslib.fuelgauge.BatterySaverUtils;
import com.android.settingslib.utils.PowerUtil;
import com.android.systemui.CoreStartable;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.statusbar.phone.SystemUIDialog;
@@ -247,7 +247,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
.setContentText(mContext.getString(R.string.invalid_charger_text))
.setColor(mContext.getColor(
com.android.internal.R.color.system_notification_accent_color));
CoreStartable.overrideNotificationAppName(mContext, nb, false);
SystemUIApplication.overrideNotificationAppName(mContext, nb, false);
final Notification n = nb.build();
mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_POWER_LOW, UserHandle.ALL);
mNoMan.notifyAsUser(TAG_BATTERY, SystemMessage.NOTE_BAD_CHARGER, n, UserHandle.ALL);
@@ -298,7 +298,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
}
nb.setOnlyAlertOnce(!mPlaySound);
mPlaySound = false;
CoreStartable.overrideNotificationAppName(mContext, nb, false);
SystemUIApplication.overrideNotificationAppName(mContext, nb, false);
final Notification n = nb.build();
mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_BAD_CHARGER, UserHandle.ALL);
mNoMan.notifyAsUser(TAG_BATTERY, SystemMessage.NOTE_POWER_LOW, n, UserHandle.ALL);
@@ -320,7 +320,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
mContext.getString(R.string.no_auto_saver_action),
pendingBroadcast(ACTION_AUTO_SAVER_NO_THANKS));
CoreStartable.overrideNotificationAppName(mContext, nb, false);
SystemUIApplication.overrideNotificationAppName(mContext, nb, false);
final Notification n = nb.build();
mNoMan.notifyAsUser(
@@ -397,7 +397,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
.setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_TEMP_WARNING))
.setColor(Utils.getColorAttrDefaultColor(mContext,
android.R.attr.colorError));
CoreStartable.overrideNotificationAppName(mContext, nb, false);
SystemUIApplication.overrideNotificationAppName(mContext, nb, false);
final Notification n = nb.build();
mNoMan.notifyAsUser(TAG_TEMPERATURE, SystemMessage.NOTE_HIGH_TEMP, n, UserHandle.ALL);
}
@@ -484,7 +484,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
pendingBroadcast(ACTION_DISMISSED_THERMAL_SHUTDOWN_WARNING))
.setColor(Utils.getColorAttrDefaultColor(mContext,
android.R.attr.colorError));
CoreStartable.overrideNotificationAppName(mContext, nb, false);
SystemUIApplication.overrideNotificationAppName(mContext, nb, false);
final Notification n = nb.build();
mNoMan.notifyAsUser(
TAG_TEMPERATURE, SystemMessage.NOTE_THERMAL_SHUTDOWN, n, UserHandle.ALL);

View File

@@ -30,8 +30,8 @@ import android.util.DisplayMetrics;
import android.view.WindowManager;
import com.android.internal.messages.nano.SystemMessageProto;
import com.android.systemui.CoreStartable;
import com.android.systemui.R;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.util.NotificationChannels;
import javax.inject.Inject;
@@ -86,7 +86,7 @@ public class ScreenshotNotificationsController {
b.setContentIntent(pendingIntent);
}
CoreStartable.overrideNotificationAppName(mContext, b, true);
SystemUIApplication.overrideNotificationAppName(mContext, b, true);
Notification n = new Notification.BigTextStyle(b)
.bigText(errorMsg)

View File

@@ -45,6 +45,7 @@ import android.util.SparseArray;
import com.android.internal.R;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.systemui.CoreStartable;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.util.NotificationChannels;
import java.util.List;
@@ -224,7 +225,7 @@ public class StorageNotification extends CoreStartable {
.setCategory(Notification.CATEGORY_SYSTEM)
.setDeleteIntent(buildSnoozeIntent(fsUuid))
.extend(new Notification.TvExtender());
CoreStartable.overrideNotificationAppName(mContext, builder, false);
SystemUIApplication.overrideNotificationAppName(mContext, builder, false);
mNotificationManager.notifyAsUser(fsUuid, SystemMessage.NOTE_STORAGE_PRIVATE,
builder.build(), UserHandle.ALL);
@@ -252,7 +253,7 @@ public class StorageNotification extends CoreStartable {
.setLocalOnly(true)
.setCategory(Notification.CATEGORY_ERROR)
.extend(new Notification.TvExtender());
CoreStartable.overrideNotificationAppName(mContext, builder, false);
SystemUIApplication.overrideNotificationAppName(mContext, builder, false);
mNotificationManager.notifyAsUser(disk.getId(), SystemMessage.NOTE_STORAGE_DISK,
builder.build(), UserHandle.ALL);
@@ -527,7 +528,7 @@ public class StorageNotification extends CoreStartable {
.setCategory(Notification.CATEGORY_PROGRESS)
.setProgress(100, status, false)
.setOngoing(true);
CoreStartable.overrideNotificationAppName(mContext, builder, false);
SystemUIApplication.overrideNotificationAppName(mContext, builder, false);
mNotificationManager.notifyAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE,
builder.build(), UserHandle.ALL);
@@ -577,7 +578,7 @@ public class StorageNotification extends CoreStartable {
.setLocalOnly(true)
.setCategory(Notification.CATEGORY_SYSTEM)
.setAutoCancel(true);
CoreStartable.overrideNotificationAppName(mContext, builder, false);
SystemUIApplication.overrideNotificationAppName(mContext, builder, false);
mNotificationManager.notifyAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE,
builder.build(), UserHandle.ALL);
@@ -611,7 +612,7 @@ public class StorageNotification extends CoreStartable {
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true)
.extend(new Notification.TvExtender());
overrideNotificationAppName(mContext, builder, false);
SystemUIApplication.overrideNotificationAppName(mContext, builder, false);
return builder;
}