diff --git a/CHANGELOG.md b/CHANGELOG.md index b2721b2..0f81353 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,13 @@ # Changelog -### 1.1.10 (In Progress) +### 1.1.10 (In progress) Enhancements - Updated gradle version to 8.4 - Updated gradle plugin to 8.3.1 - - -### 1.1.10 (March 21, 2024) - -Enhancements - - BluetoothHeadsetConnectionListener now can be added to AudioSwitch to notify when bluetooth device has connected or failed to connect. +- BLUETOOTH_CONNECT and/or BLUETOOTH permission have been removed and are optional now. If not provided bluetooth device +will not appear in the list of available devices and no callbacks will be received for BluetoothHeadsetConnectionListener. ### 1.1.9 (July 13, 2023) diff --git a/README.md b/README.md index 58c0c0b..d1a44d3 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ audioSwitch.deactivate() ## Bluetooth Support Multiple connected bluetooth headsets are supported. + - Bluetooth support requires BLUETOOTH_CONNECT or BLUETOOTH permission. These permission have to be added to the application using AudioSwitch, they do not come with the library. - The library will accurately display the up to date active bluetooth headset within the `AudioSwitch` `availableAudioDevices` and `selectedAudioDevice` functions. - Other connected headsets are not stored by the library at this moment. - In the event of a failure to connecting audio to a bluetooth headset, the library will revert the selected audio device (this is usually the Earpiece on a phone). diff --git a/audioswitch/src/androidTest/AndroidManifest.xml b/audioswitch/src/androidTest/AndroidManifest.xml index 0d4956e..fced572 100644 --- a/audioswitch/src/androidTest/AndroidManifest.xml +++ b/audioswitch/src/androidTest/AndroidManifest.xml @@ -6,4 +6,7 @@ - \ No newline at end of file + + + + diff --git a/audioswitch/src/androidTest/java/com.twilio.audioswitch/TestUtil.kt b/audioswitch/src/androidTest/java/com.twilio.audioswitch/TestUtil.kt index 162310c..0567dc0 100644 --- a/audioswitch/src/androidTest/java/com.twilio.audioswitch/TestUtil.kt +++ b/audioswitch/src/androidTest/java/com.twilio.audioswitch/TestUtil.kt @@ -64,7 +64,7 @@ internal fun setupFakeAudioSwitch( preferredDevicesList, audioDeviceManager, wiredHeadsetReceiver, - headsetManager, + bluetoothHeadsetManager = headsetManager, ), headsetManager!!, wiredHeadsetReceiver, diff --git a/audioswitch/src/main/AndroidManifest.xml b/audioswitch/src/main/AndroidManifest.xml index 7adbd4c..479d906 100644 --- a/audioswitch/src/main/AndroidManifest.xml +++ b/audioswitch/src/main/AndroidManifest.xml @@ -1,7 +1,5 @@ - - diff --git a/audioswitch/src/main/java/com/twilio/audioswitch/AudioSwitch.kt b/audioswitch/src/main/java/com/twilio/audioswitch/AudioSwitch.kt index 889815a..78b6c54 100644 --- a/audioswitch/src/main/java/com/twilio/audioswitch/AudioSwitch.kt +++ b/audioswitch/src/main/java/com/twilio/audioswitch/AudioSwitch.kt @@ -1,7 +1,10 @@ package com.twilio.audioswitch +import android.Manifest +import android.annotation.SuppressLint import android.bluetooth.BluetoothAdapter import android.content.Context +import android.content.pm.PackageManager.PERMISSION_GRANTED import android.media.AudioManager import android.media.AudioManager.OnAudioFocusChangeListener import androidx.annotation.VisibleForTesting @@ -13,6 +16,7 @@ import com.twilio.audioswitch.AudioSwitch.State.ACTIVATED import com.twilio.audioswitch.AudioSwitch.State.STARTED import com.twilio.audioswitch.AudioSwitch.State.STOPPED import com.twilio.audioswitch.android.Logger +import com.twilio.audioswitch.android.PermissionsCheckStrategy import com.twilio.audioswitch.android.ProductionLogger import com.twilio.audioswitch.bluetooth.BluetoothHeadsetConnectionListener import com.twilio.audioswitch.bluetooth.BluetoothHeadsetManager @@ -20,6 +24,7 @@ import com.twilio.audioswitch.wired.WiredDeviceConnectionListener import com.twilio.audioswitch.wired.WiredHeadsetReceiver private const val TAG = "AudioSwitch" +private const val PERMISSION_ERROR_MESSAGE = "Bluetooth unsupported, permissions not granted" /** * This class enables developers to enumerate available audio devices and select which device audio @@ -27,7 +32,7 @@ private const val TAG = "AudioSwitch" * accessed from a single application thread. Accessing an instance from multiple threads may cause * synchronization problems. * - * @property bluetoothHeadsetConnectionListener Listener to notify if Bluetooth device state has + * @property bluetoothHeadsetConnectionListener Requires bluetooth permission. Listener to notify if Bluetooth device state has * changed (connect, disconnect, audio connect, audio disconnect) or failed to connect. Null by default. * @property loggingEnabled A property to configure AudioSwitch logging behavior. AudioSwitch logging is disabled by * default. @@ -47,6 +52,7 @@ class AudioSwitch { private var bluetoothHeadsetManager: BluetoothHeadsetManager? = null private val preferredDeviceList: List> private var bluetoothHeadsetConnectionListener: BluetoothHeadsetConnectionListener? = null + private val permissionsRequestStrategy: PermissionsCheckStrategy internal var state: State = STOPPED internal enum class State { @@ -138,7 +144,8 @@ class AudioSwitch { audioFocusChangeListener = audioFocusChangeListener, ), wiredHeadsetReceiver: WiredHeadsetReceiver = WiredHeadsetReceiver(context, logger), - headsetManager: BluetoothHeadsetManager? = BluetoothHeadsetManager.newInstance( + permissionsCheckStrategy: PermissionsCheckStrategy = DefaultPermissionsCheckStrategy(context), + bluetoothHeadsetManager: BluetoothHeadsetManager? = BluetoothHeadsetManager.newInstance( context, logger, BluetoothAdapter.getDefaultAdapter(), @@ -149,8 +156,14 @@ class AudioSwitch { this.bluetoothHeadsetConnectionListener = bluetoothHeadsetConnectionListener this.audioDeviceManager = audioDeviceManager this.wiredHeadsetReceiver = wiredHeadsetReceiver - this.bluetoothHeadsetManager = headsetManager this.preferredDeviceList = getPreferredDeviceList(preferredDeviceList) + this.permissionsRequestStrategy = permissionsCheckStrategy + this.bluetoothHeadsetManager = if (hasPermissions()) { + bluetoothHeadsetManager + } else { + logger.w(TAG, PERMISSION_ERROR_MESSAGE) + null + } logger.d(TAG, "AudioSwitch($VERSION)") logger.d(TAG, "Preferred device list = ${this.preferredDeviceList.map { it.simpleName }}") } @@ -387,6 +400,31 @@ class AudioSwitch { audioDeviceChangeListener = null } + internal fun hasPermissions() = permissionsRequestStrategy.hasPermissions() + + internal class DefaultPermissionsCheckStrategy(private val context: Context) : PermissionsCheckStrategy { + + @SuppressLint("NewApi") + override fun hasPermissions(): Boolean { + return if (context.applicationInfo.targetSdkVersion <= android.os.Build.VERSION_CODES.R || + android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.R + ) { + PERMISSION_GRANTED == context.checkPermission( + Manifest.permission.BLUETOOTH, + android.os.Process.myPid(), + android.os.Process.myUid(), + ) + } else { + // for android 12/S or newer + PERMISSION_GRANTED == context.checkPermission( + Manifest.permission.BLUETOOTH_CONNECT, + android.os.Process.myPid(), + android.os.Process.myUid(), + ) + } + } + } + companion object { /** * The version of the AudioSwitch library. diff --git a/audioswitch/src/main/java/com/twilio/audioswitch/android/BluetoothDeviceWrapperImpl.kt b/audioswitch/src/main/java/com/twilio/audioswitch/android/BluetoothDeviceWrapperImpl.kt index 02edfde..aa9a95f 100644 --- a/audioswitch/src/main/java/com/twilio/audioswitch/android/BluetoothDeviceWrapperImpl.kt +++ b/audioswitch/src/main/java/com/twilio/audioswitch/android/BluetoothDeviceWrapperImpl.kt @@ -1,9 +1,11 @@ package com.twilio.audioswitch.android +import android.annotation.SuppressLint import android.bluetooth.BluetoothDevice internal const val DEFAULT_DEVICE_NAME = "Bluetooth" +@SuppressLint("MissingPermission") internal data class BluetoothDeviceWrapperImpl( val device: BluetoothDevice, override val name: String = device.name ?: DEFAULT_DEVICE_NAME, diff --git a/audioswitch/src/main/java/com/twilio/audioswitch/bluetooth/BluetoothHeadsetManager.kt b/audioswitch/src/main/java/com/twilio/audioswitch/bluetooth/BluetoothHeadsetManager.kt index 60fc892..1ceebb7 100644 --- a/audioswitch/src/main/java/com/twilio/audioswitch/bluetooth/BluetoothHeadsetManager.kt +++ b/audioswitch/src/main/java/com/twilio/audioswitch/bluetooth/BluetoothHeadsetManager.kt @@ -1,6 +1,5 @@ package com.twilio.audioswitch.bluetooth -import android.Manifest import android.annotation.SuppressLint import android.bluetooth.BluetoothAdapter import android.bluetooth.BluetoothClass @@ -16,7 +15,6 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter -import android.content.pm.PackageManager.PERMISSION_GRANTED import android.media.AudioManager import android.media.AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED import android.media.AudioManager.SCO_AUDIO_STATE_CONNECTED @@ -31,7 +29,6 @@ import com.twilio.audioswitch.android.BluetoothDeviceWrapper import com.twilio.audioswitch.android.BluetoothIntentProcessor import com.twilio.audioswitch.android.BluetoothIntentProcessorImpl import com.twilio.audioswitch.android.Logger -import com.twilio.audioswitch.android.PermissionsCheckStrategy import com.twilio.audioswitch.android.SystemClockWrapper import com.twilio.audioswitch.bluetooth.BluetoothHeadsetManager.HeadsetState.AudioActivated import com.twilio.audioswitch.bluetooth.BluetoothHeadsetManager.HeadsetState.AudioActivating @@ -40,7 +37,6 @@ import com.twilio.audioswitch.bluetooth.BluetoothHeadsetManager.HeadsetState.Con import com.twilio.audioswitch.bluetooth.BluetoothHeadsetManager.HeadsetState.Disconnected private const val TAG = "BluetoothHeadsetManager" -private const val PERMISSION_ERROR_MESSAGE = "Bluetooth unsupported, permissions not granted" internal class BluetoothHeadsetManager @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) @@ -54,7 +50,6 @@ internal constructor( systemClockWrapper: SystemClockWrapper = SystemClockWrapper(), private val bluetoothIntentProcessor: BluetoothIntentProcessor = BluetoothIntentProcessorImpl(), private var headsetProxy: BluetoothHeadset? = null, - private val permissionsRequestStrategy: PermissionsCheckStrategy = DefaultPermissionsCheckStrategy(context), private var hasRegisteredReceivers: Boolean = false, ) : BluetoothProfile.ServiceListener, BroadcastReceiver() { @@ -100,6 +95,7 @@ internal constructor( } } + @SuppressLint("MissingPermission") override fun onServiceConnected(profile: Int, bluetoothProfile: BluetoothProfile) { headsetProxy = bluetoothProfile as BluetoothHeadset bluetoothProfile.connectedDevices.forEach { device -> @@ -200,56 +196,44 @@ internal constructor( } fun start(headsetListener: BluetoothHeadsetConnectionListener) { - if (hasPermissions()) { - this.headsetListener = headsetListener - - bluetoothAdapter.getProfileProxy( - context, + this.headsetListener = headsetListener + + bluetoothAdapter.getProfileProxy( + context, + this, + BluetoothProfile.HEADSET, + ) + if (!hasRegisteredReceivers) { + context.registerReceiver( this, - BluetoothProfile.HEADSET, + IntentFilter(ACTION_CONNECTION_STATE_CHANGED), ) - if (!hasRegisteredReceivers) { - context.registerReceiver( - this, - IntentFilter(ACTION_CONNECTION_STATE_CHANGED), - ) - context.registerReceiver( - this, - IntentFilter(ACTION_AUDIO_STATE_CHANGED), - ) - context.registerReceiver( - this, - IntentFilter(ACTION_SCO_AUDIO_STATE_UPDATED), - ) - hasRegisteredReceivers = true - } - } else { - logger.w(TAG, PERMISSION_ERROR_MESSAGE) + context.registerReceiver( + this, + IntentFilter(ACTION_AUDIO_STATE_CHANGED), + ) + context.registerReceiver( + this, + IntentFilter(ACTION_SCO_AUDIO_STATE_UPDATED), + ) + hasRegisteredReceivers = true } } fun stop() { - if (hasPermissions()) { - headsetListener = null - bluetoothAdapter.closeProfileProxy(BluetoothProfile.HEADSET, headsetProxy) - if (hasRegisteredReceivers) { - context.unregisterReceiver(this) - hasRegisteredReceivers = false - } - } else { - logger.w(TAG, PERMISSION_ERROR_MESSAGE) + headsetListener = null + bluetoothAdapter.closeProfileProxy(BluetoothProfile.HEADSET, headsetProxy) + if (hasRegisteredReceivers) { + context.unregisterReceiver(this) + hasRegisteredReceivers = false } } fun activate() { - if (hasPermissions()) { - if (headsetState == Connected || headsetState == AudioActivationError) { - enableBluetoothScoJob.executeBluetoothScoJob() - } else { - logger.w(TAG, "Cannot activate when in the ${headsetState::class.simpleName} state") - } + if (headsetState == Connected || headsetState == AudioActivationError) { + enableBluetoothScoJob.executeBluetoothScoJob() } else { - logger.w(TAG, PERMISSION_ERROR_MESSAGE) + logger.w(TAG, "Cannot activate when in the ${headsetState::class.simpleName} state") } } @@ -262,26 +246,16 @@ internal constructor( } fun hasActivationError(): Boolean { - return if (hasPermissions()) { - headsetState == AudioActivationError - } else { - logger.w(TAG, PERMISSION_ERROR_MESSAGE) - false - } + return headsetState == AudioActivationError } // TODO Remove bluetoothHeadsetName param fun getHeadset(bluetoothHeadsetName: String?): AudioDevice.BluetoothHeadset? { - return if (hasPermissions()) { - if (headsetState != Disconnected) { - val headsetName = bluetoothHeadsetName ?: getHeadsetName() - headsetName?.let { AudioDevice.BluetoothHeadset(it) } - ?: AudioDevice.BluetoothHeadset() - } else { - null - } + return if (headsetState != Disconnected) { + val headsetName = bluetoothHeadsetName ?: getHeadsetName() + headsetName?.let { AudioDevice.BluetoothHeadset(it) } + ?: AudioDevice.BluetoothHeadset() } else { - logger.w(TAG, PERMISSION_ERROR_MESSAGE) null } } @@ -309,6 +283,7 @@ internal constructor( private fun hasActiveHeadsetChanged() = headsetState == AudioActivated && hasConnectedDevice() && !hasActiveHeadset() + @SuppressLint("MissingPermission") private fun getHeadsetName(): String? = headsetProxy?.let { proxy -> proxy.connectedDevices?.let { devices -> @@ -331,6 +306,7 @@ internal constructor( } } + @SuppressLint("MissingPermission") private fun hasActiveHeadset() = headsetProxy?.let { proxy -> proxy.connectedDevices?.let { devices -> @@ -338,6 +314,7 @@ internal constructor( } } ?: false + @SuppressLint("MissingPermission") private fun hasConnectedDevice() = headsetProxy?.let { proxy -> proxy.connectedDevices?.let { devices -> @@ -359,8 +336,6 @@ internal constructor( deviceClass == BluetoothClass.Device.Major.UNCATEGORIZED } ?: false - internal fun hasPermissions() = permissionsRequestStrategy.hasPermissions() - @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) internal sealed class HeadsetState { object Disconnected : HeadsetState() @@ -408,27 +383,4 @@ internal constructor( headsetState = AudioActivationError } } - - internal class DefaultPermissionsCheckStrategy(private val context: Context) : - PermissionsCheckStrategy { - @SuppressLint("NewApi") - override fun hasPermissions(): Boolean { - return if (context.applicationInfo.targetSdkVersion <= android.os.Build.VERSION_CODES.R || - android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.R - ) { - PERMISSION_GRANTED == context.checkPermission( - Manifest.permission.BLUETOOTH, - android.os.Process.myPid(), - android.os.Process.myUid(), - ) - } else { - // for android 12/S or newer - PERMISSION_GRANTED == context.checkPermission( - Manifest.permission.BLUETOOTH_CONNECT, - android.os.Process.myPid(), - android.os.Process.myUid(), - ) - } - } - } } diff --git a/audioswitch/src/test/java/com/twilio/audioswitch/AudioSwitchJavaTest.java b/audioswitch/src/test/java/com/twilio/audioswitch/AudioSwitchJavaTest.java index b2111a5..2a54ea9 100644 --- a/audioswitch/src/test/java/com/twilio/audioswitch/AudioSwitchJavaTest.java +++ b/audioswitch/src/test/java/com/twilio/audioswitch/AudioSwitchJavaTest.java @@ -40,6 +40,7 @@ public void setUp() { getPreferredDeviceList$audioswitch_debug(), getAudioDeviceManager$audioswitch_debug(), getWiredHeadsetReceiver$audioswitch_debug(), + getPermissionsStrategyProxy$audioswitch_debug(), getHeadsetManager$audioswitch_debug()); } @@ -137,6 +138,7 @@ public void shouldAllowChangingThePreferredDeviceList() { preferredDeviceList, getAudioDeviceManager$audioswitch_debug(), getWiredHeadsetReceiver$audioswitch_debug(), + getPermissionsStrategyProxy$audioswitch_debug(), getHeadsetManager$audioswitch_debug()); startAudioSwitch(); diff --git a/audioswitch/src/test/java/com/twilio/audioswitch/AudioSwitchTest.kt b/audioswitch/src/test/java/com/twilio/audioswitch/AudioSwitchTest.kt index 3aa0cd5..16a9c3e 100644 --- a/audioswitch/src/test/java/com/twilio/audioswitch/AudioSwitchTest.kt +++ b/audioswitch/src/test/java/com/twilio/audioswitch/AudioSwitchTest.kt @@ -98,9 +98,10 @@ class AudioSwitchTest : BaseTest() { logger = logger, audioDeviceManager = audioDeviceManager, wiredHeadsetReceiver = wiredHeadsetReceiver, - headsetManager = null, audioFocusChangeListener = defaultAudioFocusChangeListener, preferredDeviceList = preferredDeviceList, + permissionsCheckStrategy = permissionsStrategyProxy, + bluetoothHeadsetManager = null, ) audioSwitch.start(audioDeviceChangeListener) @@ -206,9 +207,10 @@ class AudioSwitchTest : BaseTest() { logger = logger, audioDeviceManager = audioDeviceManager, wiredHeadsetReceiver = wiredHeadsetReceiver, - headsetManager = null, audioFocusChangeListener = defaultAudioFocusChangeListener, preferredDeviceList = preferredDeviceList, + permissionsCheckStrategy = permissionsStrategyProxy, + bluetoothHeadsetManager = null, ) audioSwitch.start(audioDeviceChangeListener) audioSwitch.stop() @@ -224,10 +226,10 @@ class AudioSwitchTest : BaseTest() { bluetoothHeadsetConnectionListener = bluetoothListener, logger = logger, audioDeviceManager = audioDeviceManager, - wiredHeadsetReceiver = wiredHeadsetReceiver, - headsetManager = null, audioFocusChangeListener = defaultAudioFocusChangeListener, preferredDeviceList = preferredDeviceList, + permissionsCheckStrategy = permissionsStrategyProxy, + bluetoothHeadsetManager = null, ) audioSwitch.start(audioDeviceChangeListener) audioSwitch.activate() @@ -448,7 +450,6 @@ class AudioSwitchTest : BaseTest() { logger = logger, audioDeviceManager = audioDeviceManager, wiredHeadsetReceiver = wiredHeadsetReceiver, - headsetManager = null, audioFocusChangeListener = defaultAudioFocusChangeListener, preferredDeviceList = listOf( Speakerphone::class.java, @@ -456,6 +457,8 @@ class AudioSwitchTest : BaseTest() { Earpiece::class.java, Speakerphone::class.java, ), + permissionsCheckStrategy = permissionsStrategyProxy, + bluetoothHeadsetManager = headsetManager, ) } @@ -468,7 +471,6 @@ class AudioSwitchTest : BaseTest() { logger = logger, audioDeviceManager = audioDeviceManager, wiredHeadsetReceiver = wiredHeadsetReceiver, - headsetManager = headsetManager, audioFocusChangeListener = defaultAudioFocusChangeListener, preferredDeviceList = listOf( Earpiece::class.java, @@ -476,7 +478,8 @@ class AudioSwitchTest : BaseTest() { Speakerphone::class.java, AudioDevice.BluetoothHeadset::class.java, ), - + permissionsCheckStrategy = permissionsStrategyProxy, + bluetoothHeadsetManager = headsetManager, ) val secondBluetoothDevice = mock { whenever(mock.name).thenReturn("$DEVICE_NAME 2") @@ -510,9 +513,10 @@ class AudioSwitchTest : BaseTest() { logger = logger, audioDeviceManager = audioDeviceManager, wiredHeadsetReceiver = wiredHeadsetReceiver, - headsetManager = headsetManager, audioFocusChangeListener = defaultAudioFocusChangeListener, preferredDeviceList = preferredDeviceList, + permissionsCheckStrategy = permissionsStrategyProxy, + bluetoothHeadsetManager = headsetManager, ) audioSwitch.run { @@ -535,9 +539,10 @@ class AudioSwitchTest : BaseTest() { logger = logger, audioDeviceManager = audioDeviceManager, wiredHeadsetReceiver = wiredHeadsetReceiver, - headsetManager = headsetManager, audioFocusChangeListener = defaultAudioFocusChangeListener, preferredDeviceList = preferredDeviceList, + permissionsCheckStrategy = permissionsStrategyProxy, + bluetoothHeadsetManager = headsetManager, ) audioSwitch.run { @@ -561,9 +566,10 @@ class AudioSwitchTest : BaseTest() { logger = logger, audioDeviceManager = audioDeviceManager, wiredHeadsetReceiver = wiredHeadsetReceiver, - headsetManager = headsetManager, audioFocusChangeListener = defaultAudioFocusChangeListener, preferredDeviceList = preferredDeviceList, + permissionsCheckStrategy = permissionsStrategyProxy, + bluetoothHeadsetManager = headsetManager, ) audioSwitch.run { @@ -586,9 +592,10 @@ class AudioSwitchTest : BaseTest() { logger = logger, audioDeviceManager = audioDeviceManager, wiredHeadsetReceiver = wiredHeadsetReceiver, - headsetManager = headsetManager, audioFocusChangeListener = defaultAudioFocusChangeListener, preferredDeviceList = preferredDeviceList, + permissionsCheckStrategy = permissionsStrategyProxy, + bluetoothHeadsetManager = headsetManager, ) audioSwitch.run { @@ -622,9 +629,10 @@ class AudioSwitchTest : BaseTest() { logger = logger, audioDeviceManager = audioDeviceManager, wiredHeadsetReceiver = wiredHeadsetReceiver, - headsetManager = headsetManager, audioFocusChangeListener = defaultAudioFocusChangeListener, preferredDeviceList = preferredDeviceList, + permissionsCheckStrategy = permissionsStrategyProxy, + bluetoothHeadsetManager = headsetManager, ) audioSwitch.run { diff --git a/audioswitch/src/test/java/com/twilio/audioswitch/BaseTest.kt b/audioswitch/src/test/java/com/twilio/audioswitch/BaseTest.kt index eaa067a..34e88fe 100644 --- a/audioswitch/src/test/java/com/twilio/audioswitch/BaseTest.kt +++ b/audioswitch/src/test/java/com/twilio/audioswitch/BaseTest.kt @@ -65,7 +65,6 @@ open class BaseTest { bluetoothScoHandler = handler, systemClockWrapper = systemClockWrapper, headsetProxy = headsetProxy, - permissionsRequestStrategy = permissionsStrategyProxy, ) internal var audioSwitch = AudioSwitch( @@ -74,9 +73,10 @@ open class BaseTest { logger = logger, audioDeviceManager = audioDeviceManager, wiredHeadsetReceiver = wiredHeadsetReceiver, - headsetManager = headsetManager, audioFocusChangeListener = defaultAudioFocusChangeListener, preferredDeviceList = preferredDeviceList, + permissionsCheckStrategy = permissionsStrategyProxy, + bluetoothHeadsetManager = headsetManager, ) internal fun assertBluetoothHeadsetTeardown() { diff --git a/audioswitch/src/test/java/com/twilio/audioswitch/bluetooth/BluetoothHeadsetManagerTest.kt b/audioswitch/src/test/java/com/twilio/audioswitch/bluetooth/BluetoothHeadsetManagerTest.kt index 3fcf408..987c2cb 100644 --- a/audioswitch/src/test/java/com/twilio/audioswitch/bluetooth/BluetoothHeadsetManagerTest.kt +++ b/audioswitch/src/test/java/com/twilio/audioswitch/bluetooth/BluetoothHeadsetManagerTest.kt @@ -355,7 +355,6 @@ class BluetoothHeadsetManagerTest : BaseTest() { bluetoothScoHandler = handler, systemClockWrapper = systemClockWrapper, headsetProxy = headsetProxy, - permissionsRequestStrategy = permissionsStrategyProxy, ) headsetManager.headsetState = Connected @@ -476,7 +475,6 @@ class BluetoothHeadsetManagerTest : BaseTest() { handler, systemClockWrapper, headsetProxy = headsetProxy, - permissionsRequestStrategy = permissionsStrategyProxy, ) } }