summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jean-Michel Trivi <jmtrivi@google.com> 2017-08-14 22:58:30 +0000
committer android-build-merger <android-build-merger@google.com> 2017-08-14 22:58:30 +0000
commitb34de16e3bbaba41332bafa53dd21eb37f099907 (patch)
tree85ac286f3b4a2b29c1cb7a22661a9f5118dac0fe
parentebd39077b5535c3e84e3f2a0604ad9ddf611b1c4 (diff)
parente2e8301083173136bccaaf8ddbbc6ebeaf68d5b9 (diff)
Merge "Merge "Fix logic for Intent.ACTION_HEADSET_PLUG for USB headsets" into oc-dr1-dev am: 21f3489653 am: b7aade045d" into oc-mr1-dev-plus-aosp
am: e2e8301083 Change-Id: Icc6c24fe9cceb0884b9cac5568fdcd4477c88626
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 2943b5c8805c..7a0c70652869 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -5450,10 +5450,21 @@ 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);
+ intent.putExtra("microphone", 0);
} else if (device == AudioSystem.DEVICE_OUT_USB_HEADSET) {
intent.setAction(Intent.ACTION_HEADSET_PLUG);
- intent.putExtra("microphone", 0);
+ intent.putExtra("microphone",
+ AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_IN_USB_HEADSET, "")
+ == AudioSystem.DEVICE_STATE_AVAILABLE ? 1 : 0);
+ } else if (device == AudioSystem.DEVICE_IN_USB_HEADSET) {
+ if (AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_USB_HEADSET, "")
+ == AudioSystem.DEVICE_STATE_AVAILABLE) {
+ intent.setAction(Intent.ACTION_HEADSET_PLUG);
+ intent.putExtra("microphone", 1);
+ } else {
+ // do not send ACTION_HEADSET_PLUG when only the input side is seen as changing
+ return;
+ }
} else if (device == AudioSystem.DEVICE_OUT_HDMI ||
device == AudioSystem.DEVICE_OUT_HDMI_ARC) {
configureHdmiPlugIntent(intent, state);