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

Commit 5f516354 authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Add setting to disable automatic USB audio routing

Bug: 16381952
Change-Id: I7335ed4c3ec8d5f9cb9a9bd2a9d2f9e0f3a63c43
parent 9413b245
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2374,6 +2374,16 @@ public final class Settings {
         */
        public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing";

        /**
         * Whether automatic routing of system audio to USB audio peripheral is disabled.
         * The value is boolean (1 or 0), where 1 means automatic routing is disabled,
         * and 0 means automatic routing is enabled.
         *
         * @hide
         */
        public static final String USB_AUDIO_AUTOMATIC_ROUTING_DISABLED =
                "usb_audio_automatic_routing_disabled";

        /**
         * Whether the audible DTMF tones are played by the dialer when dialing. The value is
         * boolean (1 or 0).
+11 −0
Original line number Diff line number Diff line
@@ -4573,6 +4573,17 @@ public class AudioService extends IAudioService.Stub {
                outDevice = AudioSystem.DEVICE_OUT_USB_ACCESSORY;
                setWiredDeviceConnectionState(outDevice, state, params);
            } else if (action.equals(Intent.ACTION_USB_AUDIO_DEVICE_PLUG)) {
                // FIXME Does not yet handle the case where the setting is changed
                // after device connection.  Ideally we should handle the settings change
                // in SettingsObserver. Here we should log that a USB device is connected
                // and disconnected with its address (card , device) and force the
                // connection or disconnection when the setting changes.
                int isDisabled = Settings.System.getInt(mContentResolver,
                        Settings.System.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0);
                if (isDisabled != 0) {
                    return;
                }

                state = intent.getIntExtra("state", 0);

                int alsaCard = intent.getIntExtra("card", -1);