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

Commit e416a420 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "SystemUI: Override notification app name" into nyc-dev

parents 0f101342 e25c18da
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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 @@ public abstract class SystemUI {
            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);
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.provider.Settings;
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 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                .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 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
            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) {
+4 −7
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import android.view.animation.Interpolator;
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 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
        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 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
                .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 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
            .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 @@ class GlobalScreenshot {
            .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)
+1 −1
Original line number Diff line number Diff line
@@ -844,7 +844,6 @@ public abstract class BaseStatusBar extends SystemUI implements
                    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)
@@ -860,6 +859,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                    .addAction(R.drawable.ic_settings,
                            mContext.getString(R.string.hidden_notifications_setup),
                            setupIntent);
            overrideNotificationAppName(mContext, note);

            NotificationManager noMan =
                    (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
+9 −8
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.internal.util.UserIcons;
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 @@ public class UserSwitcherController {
        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 @@ public class UserSwitcherController {
                    .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 @@ public class UserSwitcherController {
        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 @@ public class UserSwitcherController {
                .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() {
Loading