hal: check device type before handling connection/disconnection
Device is assumed to be an output device when handling connection
or disconnection. Besides the BIT_IN, as the input device could
share same bit definition with the output device, thus disconnecting
input device may cause output device disconnected unexpectly.
Check for device type to avoid mishandling.
Change-Id: Iab637220bd43d16bc2cabb53f610ed978e1e5fea
diff --git a/hal/audio_extn/a2dp.c b/hal/audio_extn/a2dp.c
index 4393418..2a2bd6f 100644
--- a/hal/audio_extn/a2dp.c
+++ b/hal/audio_extn/a2dp.c
@@ -905,9 +905,9 @@
ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_CONNECT, value,
sizeof(value));
- if( ret >= 0) {
+ if (ret >= 0) {
val = atoi(value);
- if (val & AUDIO_DEVICE_OUT_ALL_A2DP) {
+ if (audio_is_a2dp_out_device(val)) {
ALOGV("Received device connect request for A2DP");
open_a2dp_output();
}
@@ -917,9 +917,9 @@
ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_DISCONNECT, value,
sizeof(value));
- if( ret >= 0) {
+ if (ret >= 0) {
val = atoi(value);
- if (val & AUDIO_DEVICE_OUT_ALL_A2DP) {
+ if (audio_is_a2dp_out_device(val)) {
ALOGV("Received device dis- connect request");
reset_a2dp_enc_config_params();
close_a2dp_output();