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

Commit 3c0e3d8a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Developer setting to show toast for notifications without a channel" into oc-dev

parents 79777a5b 4c6eef21
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -10413,6 +10413,15 @@ public final class Settings {
         */
        public static final String MAX_NOTIFICATION_ENQUEUE_RATE = "max_notification_enqueue_rate";

        /**
         * Displays toasts when an app posts a notification that does not specify a valid channel.
         *
         * The value 1 - enable, 0 - disable
         * @hide
         */
        public static final String SHOW_NOTIFICATION_CHANNEL_WARNINGS =
                "show_notification_channel_warnings";

        /**
         * Whether cell is enabled/disabled
         * @hide
+5 −5
Original line number Diff line number Diff line
@@ -3199,10 +3199,8 @@ public class NotificationManagerService extends SystemService {
                    + ", incomingUserId=" + incomingUserId
                    + ", notificationUid=" + notificationUid
                    + ", notification=" + notification;
            // STOPSHIP TODO: should throw instead of logging or toasting.
            // throw new IllegalArgumentException(noChannelStr);
            Log.e(TAG, noChannelStr);
            doDebugOnlyToast("Developer warning for package \"" + pkg + "\"\n" +
            doChannelWarningToast("Developer warning for package \"" + pkg + "\"\n" +
                    "Failed to post notification on channel \"" + channelId + "\"\n" +
                    "See log for more details");
            return;
@@ -3238,8 +3236,10 @@ public class NotificationManagerService extends SystemService {
        mHandler.post(new EnqueueNotificationRunnable(userId, r));
    }

    private void doDebugOnlyToast(CharSequence toastText) {
        if (Build.IS_DEBUGGABLE) {
    private void doChannelWarningToast(CharSequence toastText) {
        final boolean warningEnabled = Settings.System.getInt(getContext().getContentResolver(),
                Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, 0) != 0;
        if (warningEnabled || Build.IS_DEBUGGABLE) {
            try {
                Toast toast = Toast.makeText(getContext(), toastText, Toast.LENGTH_LONG);
                toast.show();