react-native-webrtc / react-native-incall-manager

Handling media-routes/sensors/events during a audio/video chat on React Native
ISC License
547 stars 191 forks source link

feat: update to new android bluetooth device communication api #224

Closed santhoshvai closed 1 year ago

santhoshvai commented 1 year ago

startBluetoothSco is deprecated in Android T. Instead, android recommends using setCommunicationDevice. This API was available starting Android 31 and has been the preferred way since.

This implementation was taken from Google's Oboe repo.

In this PR, I have made the change so that we use the new API in Android 31 or newer.

This was tested and verified to be correct on Pixel 7 Android 33, OnepPlus Android 33, and Mi2 Android 30.

vanGalilea commented 1 year ago

Also fixes https://github.com/react-native-webrtc/react-native-incall-manager/issues/220 and might be related to https://github.com/react-native-webrtc/react-native-incall-manager/issues/219 https://github.com/react-native-webrtc/react-native-incall-manager/issues/203

santhoshvai commented 1 year ago

cc @saghul for visiblity

zxcpoiu commented 1 year ago

Thanks for the works @santhoshvai and @vanGalilea for the help to confirm :+1: Will look into it asap.

zxcpoiu commented 1 year ago

Looks good, thanks for the PR, will leave it few days before release

vanGalilea commented 1 year ago

@zxcpoiu any plan for a release containing this?

gavrilikhin-d commented 1 year ago

Doesn't work for me, while in webrtc call :(

In logs there is BT state=UNINITIALIZED

 BluetoothManagerService: Sending State Change: TURNING_ON > ON
 InCallManager: --- updateAudioDeviceState: wired headset=false, BT state=UNINITIALIZED
 InCallManager: Device status: available=[EARPIECE, SPEAKER_PHONE], selected=SPEAKER_PHONE, user selected=NONE
 InCallManager: --- updateAudioDeviceState done
zxcpoiu commented 1 year ago

It has been released as 4.1.0.

zxcpoiu commented 1 year ago

@gavrilikhin-d make sure you have bluetooth permission in your menifest, and BLUETOOTH prior to android api 31. BLUETOOTH_CONNECT on api 31+ and later.

you can check https://github.com/zoontek/react-native-permissions for how to request it properly.

gavrilikhin-d commented 1 year ago

@gavrilikhin-d make sure you have bluetooth permission in your menifest, and BLUETOOTH prior to android api 31. BLUETOOTH_CONNECT on api 31+ and later.

you can check https://github.com/zoontek/react-native-permissions for how to request it properly.

Yes, I didn't know that you must explicitly request bluetooth permissions from user