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

Commit 28c3d164 authored by Beverly's avatar Beverly
Browse files

Only play in-call notification if ringer is normal

- Add secure setting to enable/disable in call notifications
- Can toggle system setting using the following adb command:
adb shell settings put secure in_call_notification_enabled [0/1]

Bug: 71586014
Test: manual
Change-Id: I32e1d1d6dcae806e655ae6875a43d07ca83e77f4
parent d3989e4d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -6028,6 +6028,15 @@ public final class Settings {
        private static final Validator MANUAL_RINGER_TOGGLE_COUNT_VALIDATOR =
                NON_NEGATIVE_INTEGER_VALIDATOR;
        /**
         * Whether the in call notification is enabled to play sound during calls.  The value is
         * boolean (1 or 0).
         * @hide
         */
        public static final String IN_CALL_NOTIFICATION_ENABLED = "in_call_notification_enabled";
        private static final Validator IN_CALL_NOTIFICATION_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
        /**
         * Uri of the slice that's presented on the keyguard.
         * Defaults to a slice with the date and next alarm.
@@ -8048,6 +8057,7 @@ public final class Settings {
            VOLUME_HUSH_GESTURE,
            MANUAL_RINGER_TOGGLE_COUNT,
            HUSH_GESTURE_USED,
            IN_CALL_NOTIFICATION_ENABLED,
        };
        /**
@@ -8193,6 +8203,7 @@ public final class Settings {
                    ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES_VALIDATOR); //legacy restore setting
            VALIDATORS.put(HUSH_GESTURE_USED, HUSH_GESTURE_USED_VALIDATOR);
            VALIDATORS.put(MANUAL_RINGER_TOGGLE_COUNT, MANUAL_RINGER_TOGGLE_COUNT_VALIDATOR);
            VALIDATORS.put(IN_CALL_NOTIFICATION_ENABLED, IN_CALL_NOTIFICATION_ENABLED_VALIDATOR);
        }
        /**
+22 −18
Original line number Diff line number Diff line
@@ -4979,6 +4979,9 @@ public class NotificationManagerService extends SystemService {
    }

    protected void playInCallNotification() {
        if (mAudioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_NORMAL
                && Settings.Secure.getInt(getContext().getContentResolver(),
                Settings.Secure.IN_CALL_NOTIFICATION_ENABLED, 1) != 0) {
            new Thread() {
                @Override
                public void run() {
@@ -5001,6 +5004,7 @@ public class NotificationManagerService extends SystemService {
                }
            }.start();
        }
    }

    @GuardedBy("mToastQueue")
    void showNextToastLocked() {