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

Commit 44448d64 authored by Geoffrey Pitsch's avatar Geoffrey Pitsch Committed by android-build-merger
Browse files

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

am: 3c0e3d8a

Change-Id: Ib5f7130e2940365b3868f735fe2f9881a54f0e71
parents cb632442 3c0e3d8a
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();