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

Commit 439d9219 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"...

Merge "Developer setting to show toast for notifications without a channel" into oc-dev am: 3c0e3d8a
am: 44448d64

Change-Id: Ie2a407039d2df43da24f10047e91a7d98a85eaba
parents 2e0059ce 44448d64
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -10443,6 +10443,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();