Skip to content

Commit 850d437

Browse files
author
John Qualls
authored
AHOYAPPS-653: Add additional device classes to support more bluetooth headset devices (#20)
* Add additional device classes to support more bluetooth headset devices * Update changelog with bug fix
1 parent 4ad5051 commit 850d437

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Enhancements
66

77
- Added the library source to release artifacts. The sources will now be available when jumping to a library class definition in Android Studio.
88

9+
Bug Fixes
10+
11+
- Added a fix for certain valid bluetooth device classes not being considered as headset devices as reported in [issue #16](https://github.com/twilio/audioswitch/issues/16).
12+
913
### 0.1.1
1014

1115
- Fixes bug that did not correctly abandon audio request after deactivate

audioswitch/src/main/java/com/twilio/audioswitch/bluetooth/BluetoothHeadsetReceiver.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package com.twilio.audioswitch.bluetooth
22

33
import android.bluetooth.BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO
44
import android.bluetooth.BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE
5+
import android.bluetooth.BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES
56
import android.bluetooth.BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET
7+
import android.bluetooth.BluetoothClass.Device.Major.UNCATEGORIZED
68
import android.bluetooth.BluetoothDevice.ACTION_ACL_CONNECTED
79
import android.bluetooth.BluetoothDevice.ACTION_ACL_DISCONNECTED
810
import android.content.BroadcastReceiver
@@ -83,6 +85,8 @@ internal class BluetoothHeadsetReceiver(
8385
deviceWrapper.deviceClass?.let { deviceClass ->
8486
deviceClass == AUDIO_VIDEO_HANDSFREE ||
8587
deviceClass == AUDIO_VIDEO_WEARABLE_HEADSET ||
86-
deviceClass == AUDIO_VIDEO_CAR_AUDIO
88+
deviceClass == AUDIO_VIDEO_CAR_AUDIO ||
89+
deviceClass == AUDIO_VIDEO_HEADPHONES ||
90+
deviceClass == UNCATEGORIZED
8791
} ?: false
8892
}

audioswitch/src/test/java/com/twilio/audioswitch/bluetooth/BluetoothHeadsetReceiverTest.kt

+8
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,21 @@ class BluetoothHeadsetReceiverTest {
5050
val audioVideoCarDevice = mock<BluetoothClass> {
5151
whenever(mock.deviceClass).thenReturn(BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO)
5252
}
53+
val headphonesDevice = mock<BluetoothClass> {
54+
whenever(mock.deviceClass).thenReturn(BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES)
55+
}
56+
val uncategorizedDevice = mock<BluetoothClass> {
57+
whenever(mock.deviceClass).thenReturn(BluetoothClass.Device.Major.UNCATEGORIZED)
58+
}
5359
val wrongDevice = mock<BluetoothClass> {
5460
whenever(mock.deviceClass).thenReturn(BluetoothClass.Device.AUDIO_VIDEO_VIDEO_MONITOR)
5561
}
5662
return arrayOf(
5763
arrayOf(handsFreeDevice, true),
5864
arrayOf(audioVideoHeadsetDevice, true),
5965
arrayOf(audioVideoCarDevice, true),
66+
arrayOf(headphonesDevice, true),
67+
arrayOf(uncategorizedDevice, true),
6068
arrayOf(wrongDevice, false),
6169
arrayOf(null, false)
6270
)

0 commit comments

Comments
 (0)