Skip to content

Commit 72af075

Browse files
gkastenAndroid (Google) Code Review
authored andcommitted
Merge "Add setting to disable automatic USB audio routing" into lmp-dev
2 parents 256e1a6 + 5f51635 commit 72af075

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

core/java/android/provider/Settings.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,16 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
23742374
*/
23752375
public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
23762376

2377+
/**
2378+
* Whether automatic routing of system audio to USB audio peripheral is disabled.
2379+
* The value is boolean (1 or 0), where 1 means automatic routing is disabled,
2380+
* and 0 means automatic routing is enabled.
2381+
*
2382+
* @hide
2383+
*/
2384+
public static final String USB_AUDIO_AUTOMATIC_ROUTING_DISABLED =
2385+
"usb_audio_automatic_routing_disabled";
2386+
23772387
/**
23782388
* Whether the audible DTMF tones are played by the dialer when dialing. The value is
23792389
* boolean (1 or 0).

media/java/android/media/AudioService.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4573,6 +4573,17 @@ public void onReceive(Context context, Intent intent) {
45734573
outDevice = AudioSystem.DEVICE_OUT_USB_ACCESSORY;
45744574
setWiredDeviceConnectionState(outDevice, state, params);
45754575
} else if (action.equals(Intent.ACTION_USB_AUDIO_DEVICE_PLUG)) {
4576+
// FIXME Does not yet handle the case where the setting is changed
4577+
// after device connection. Ideally we should handle the settings change
4578+
// in SettingsObserver. Here we should log that a USB device is connected
4579+
// and disconnected with its address (card , device) and force the
4580+
// connection or disconnection when the setting changes.
4581+
int isDisabled = Settings.System.getInt(mContentResolver,
4582+
Settings.System.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0);
4583+
if (isDisabled != 0) {
4584+
return;
4585+
}
4586+
45764587
state = intent.getIntExtra("state", 0);
45774588

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

0 commit comments

Comments
 (0)