Merge "Update isWiredHeadsetOn() to support USB headsets." into oc-dr1-dev
This commit is contained in:
@@ -1501,7 +1501,9 @@ public class AudioManager {
|
||||
if (AudioSystem.getDeviceConnectionState(DEVICE_OUT_WIRED_HEADSET,"")
|
||||
== AudioSystem.DEVICE_STATE_UNAVAILABLE &&
|
||||
AudioSystem.getDeviceConnectionState(DEVICE_OUT_WIRED_HEADPHONE,"")
|
||||
== AudioSystem.DEVICE_STATE_UNAVAILABLE) {
|
||||
== AudioSystem.DEVICE_STATE_UNAVAILABLE &&
|
||||
AudioSystem.getDeviceConnectionState(DEVICE_OUT_USB_HEADSET, "")
|
||||
== AudioSystem.DEVICE_STATE_UNAVAILABLE) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -3323,6 +3325,9 @@ public class AudioManager {
|
||||
/** @hide
|
||||
* The audio output device code for a wired headphone without attached microphone */
|
||||
public static final int DEVICE_OUT_WIRED_HEADPHONE = AudioSystem.DEVICE_OUT_WIRED_HEADPHONE;
|
||||
/** @hide
|
||||
* The audio output device code for a USB headphone with attached microphone */
|
||||
public static final int DEVICE_OUT_USB_HEADSET = AudioSystem.DEVICE_OUT_USB_HEADSET;
|
||||
/** @hide
|
||||
* The audio output device code for generic Bluetooth SCO, for voice */
|
||||
public static final int DEVICE_OUT_BLUETOOTH_SCO = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO;
|
||||
|
||||
@@ -5413,6 +5413,9 @@ public class AudioService extends IAudioService.Stub
|
||||
} else if (device == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE ||
|
||||
device == AudioSystem.DEVICE_OUT_LINE) {
|
||||
intent.setAction(Intent.ACTION_HEADSET_PLUG);
|
||||
intent.putExtra("microphone", (device & AudioSystem.DEVICE_BIT_IN) != 0 ? 1 : 0);
|
||||
} else if (device == AudioSystem.DEVICE_OUT_USB_HEADSET) {
|
||||
intent.setAction(Intent.ACTION_HEADSET_PLUG);
|
||||
intent.putExtra("microphone", 0);
|
||||
} else if (device == AudioSystem.DEVICE_OUT_HDMI ||
|
||||
device == AudioSystem.DEVICE_OUT_HDMI_ARC) {
|
||||
@@ -5452,9 +5455,7 @@ public class AudioService extends IAudioService.Stub
|
||||
if ((state == 0) && ((device & DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG) != 0)) {
|
||||
setBluetoothA2dpOnInt(true);
|
||||
}
|
||||
boolean isUsb = ((device & ~AudioSystem.DEVICE_OUT_ALL_USB) == 0) ||
|
||||
(((device & AudioSystem.DEVICE_BIT_IN) != 0) &&
|
||||
((device & ~AudioSystem.DEVICE_IN_ALL_USB) == 0));
|
||||
|
||||
if (!handleDeviceConnection(state == 1, device, address, deviceName)) {
|
||||
// change of connection state failed, bailout
|
||||
return;
|
||||
@@ -5494,7 +5495,7 @@ public class AudioService extends IAudioService.Stub
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isUsb && device != AudioSystem.DEVICE_IN_WIRED_HEADSET) {
|
||||
if (device != AudioSystem.DEVICE_IN_WIRED_HEADSET) {
|
||||
sendDeviceConnectionIntent(device, state, address, deviceName);
|
||||
}
|
||||
updateAudioRoutes(device, state);
|
||||
|
||||
Reference in New Issue
Block a user