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

Commit c6a371d2 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[Pod] Move #overrideNotificationAppName out of SystemUIApplication.

SystemUIApplication will be moved to its own build target soon, so
no one should be directly depending on it.

Bug: 307607958
Test: mp sysuig
Flag: EXEMPT refactor
Change-Id: I82d0ac5338859a61bcf4bbb4257cb60016ae458d
parent 80acbab4
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -20,13 +20,11 @@ import android.animation.Animator;
import android.annotation.SuppressLint;
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.res.Configuration;
import android.os.Bundle;
import android.os.Process;
import android.os.Trace;
import android.tracing.perfetto.InitArguments;
@@ -498,18 +496,6 @@ 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);
    }

    @NonNull
    @Override
    public WMComponent getWMComponent() {
+6 −6
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ import com.android.internal.logging.UiEventLogger;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.settingslib.Utils;
import com.android.settingslib.fuelgauge.BatterySaverUtils;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.animation.DialogCuj;
import com.android.systemui.animation.DialogTransitionAnimator;
import com.android.systemui.animation.Expandable;
@@ -73,6 +72,7 @@ import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.res.R;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.util.NotificationChannels;
@@ -288,7 +288,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));
        SystemUIApplication.overrideNotificationAppName(mContext, nb, false);
        NotificationUtils.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);
@@ -337,7 +337,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
        }
        nb.setOnlyAlertOnce(!mPlaySound);
        mPlaySound = false;
        SystemUIApplication.overrideNotificationAppName(mContext, nb, false);
        NotificationUtils.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);
@@ -375,7 +375,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                mContext.getString(R.string.no_auto_saver_action),
                pendingBroadcast(ACTION_AUTO_SAVER_NO_THANKS));

        SystemUIApplication.overrideNotificationAppName(mContext, nb, false);
        NotificationUtils.overrideNotificationAppName(mContext, nb, false);

        final Notification n = nb.build();
        mNoMan.notifyAsUser(
@@ -444,7 +444,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                        .setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_TEMP_WARNING))
                        .setColor(Utils.getColorAttrDefaultColor(mContext,
                                android.R.attr.colorError));
        SystemUIApplication.overrideNotificationAppName(mContext, nb, false);
        NotificationUtils.overrideNotificationAppName(mContext, nb, false);
        final Notification n = nb.build();
        mNoMan.notifyAsUser(TAG_TEMPERATURE, SystemMessage.NOTE_HIGH_TEMP, n, UserHandle.ALL);
    }
@@ -531,7 +531,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                                pendingBroadcast(ACTION_DISMISSED_THERMAL_SHUTDOWN_WARNING))
                        .setColor(Utils.getColorAttrDefaultColor(mContext,
                                android.R.attr.colorError));
        SystemUIApplication.overrideNotificationAppName(mContext, nb, false);
        NotificationUtils.overrideNotificationAppName(mContext, nb, false);
        final Notification n = nb.build();
        mNoMan.notifyAsUser(
                TAG_TEMPERATURE, SystemMessage.NOTE_THERMAL_SHUTDOWN, n, UserHandle.ALL);
+3 −3
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import android.os.UserHandle
import android.view.Display
import com.android.internal.R
import com.android.internal.messages.nano.SystemMessageProto
import com.android.systemui.SystemUIApplication
import com.android.systemui.statusbar.notification.NotificationUtils
import com.android.systemui.util.NotificationChannels
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
@@ -81,11 +81,11 @@ internal constructor(
                    intent,
                    PendingIntent.FLAG_IMMUTABLE,
                    null,
                    UserHandle.CURRENT
                    UserHandle.CURRENT,
                )
            builder.setContentIntent(pendingIntent)
        }
        SystemUIApplication.overrideNotificationAppName(context, builder, true)
        NotificationUtils.overrideNotificationAppName(context, builder, true)
        val notification = Notification.BigTextStyle(builder).bigText(errorMsg).build()
        // A different id for external displays to keep the 2 error notifications separated.
        val id =
+13 −0
Original line number Diff line number Diff line
@@ -17,8 +17,10 @@
package com.android.systemui.statusbar.notification;

import android.annotation.Nullable;
import android.app.Notification;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

@@ -105,4 +107,15 @@ public class NotificationUtils {
        return key.replace("\n", "");
    }

    /** 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);
    }
}
+6 −6
Original line number Diff line number Diff line
@@ -45,9 +45,9 @@ 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.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.util.NotificationChannels;

import java.util.List;
@@ -251,7 +251,7 @@ public class StorageNotification implements CoreStartable {
                                .setCategory(Notification.CATEGORY_SYSTEM)
                                .setDeleteIntent(buildSnoozeIntent(fsUuid))
                                .extend(new Notification.TvExtender());
                SystemUIApplication.overrideNotificationAppName(mContext, builder, false);
                NotificationUtils.overrideNotificationAppName(mContext, builder, false);

                mNotificationManager.notifyAsUser(fsUuid, SystemMessage.NOTE_STORAGE_PRIVATE,
                        builder.build(), UserHandle.ALL);
@@ -279,7 +279,7 @@ public class StorageNotification implements CoreStartable {
                            .setLocalOnly(true)
                            .setCategory(Notification.CATEGORY_ERROR)
                            .extend(new Notification.TvExtender());
            SystemUIApplication.overrideNotificationAppName(mContext, builder, false);
            NotificationUtils.overrideNotificationAppName(mContext, builder, false);

            mNotificationManager.notifyAsUser(disk.getId(), SystemMessage.NOTE_STORAGE_DISK,
                    builder.build(), UserHandle.ALL);
@@ -556,7 +556,7 @@ public class StorageNotification implements CoreStartable {
                        .setCategory(Notification.CATEGORY_PROGRESS)
                        .setProgress(100, status, false)
                        .setOngoing(true);
        SystemUIApplication.overrideNotificationAppName(mContext, builder, false);
        NotificationUtils.overrideNotificationAppName(mContext, builder, false);

        mNotificationManager.notifyAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE,
                builder.build(), UserHandle.ALL);
@@ -606,7 +606,7 @@ public class StorageNotification implements CoreStartable {
                        .setLocalOnly(true)
                        .setCategory(Notification.CATEGORY_SYSTEM)
                        .setAutoCancel(true);
        SystemUIApplication.overrideNotificationAppName(mContext, builder, false);
        NotificationUtils.overrideNotificationAppName(mContext, builder, false);

        mNotificationManager.notifyAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE,
                builder.build(), UserHandle.ALL);
@@ -640,7 +640,7 @@ public class StorageNotification implements CoreStartable {
                        .setVisibility(Notification.VISIBILITY_PUBLIC)
                        .setLocalOnly(true)
                        .extend(new Notification.TvExtender());
        SystemUIApplication.overrideNotificationAppName(mContext, builder, false);
        NotificationUtils.overrideNotificationAppName(mContext, builder, false);
        return builder;
    }