twilio / audioswitch

An Android audio management library for real-time communication apps.
Apache License 2.0
163 stars 50 forks source link

Getting ring on speaker when we are working on another app and Bluetooth is connected in our app #83

Closed Monika-Paliwal closed 3 years ago

Monika-Paliwal commented 3 years ago

Describe the bug I am facing one issue that is when a call comes on the Android device when it connected with Bluetooth, then the call rings on Bluetooth only, and on the mobile phone, it's ringing on speaker when Bluetooth already attached with the device.

To Reproduce Steps to reproduce the behavior:

  1. During the ring, if we are on another app and our app is in the background if users click on the Notification push ringtone gets interrupted, sometimes it rings on Bluetooth and sometimes on the device speaker.
  2. The ring volume is increase and decrease some time on the speaker in the same scenarios when Bluetooth is connected.

Expected behavior When a wired headset or Bluetooth is connected it should ring on Bluetooth every time when the app is in the background or we are on another app.

Actual behavior After Bluetooth is Connected, the ring is only coming on the speaker.

Android Device

Device: Samsung A30 5F API Version: 29 Version 10

Audio switch version: 1.0.1

Alton09 commented 3 years ago

Hi @Monika-Paliwal . Are you using the Android Voice SDK to trigger this push notification voice call? Or is this a phone call from the system? Also, can you please share your app logcat logs with the AS/ filter applied while reproducing this issue? Thanks!

Monika-Paliwal commented 3 years ago

Hello, @Alton09 We are using Twilio video SDK and it's call on our app not on the phone call from the system. here are the logs for that issue 2021-02-04 16:18:00.354 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: message received msg=211, ext1=0, ext2=0 2021-02-04 16:18:00.354 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: unrecognized message: (211, 0, 0) 2021-02-04 16:18:00.354 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: callback application 2021-02-04 16:18:00.354 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: back from callback 2021-02-04 16:18:00.366 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: message received msg=6, ext1=0, ext2=0 2021-02-04 16:18:00.366 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: unrecognized message: (6, 0, 0) 2021-02-04 16:18:00.366 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: callback application 2021-02-04 16:18:00.366 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: back from callback 2021-02-04 16:18:00.368 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:00.370 18081-18081/com.taskhuman.insights.debug V/MediaPlayer-JNI: getCurrentPosition: 0 (msec) 2021-02-04 16:18:00.539 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: message received msg=211, ext1=0, ext2=0 2021-02-04 16:18:00.540 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: unrecognized message: (211, 0, 0) 2021-02-04 16:18:00.540 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: callback application 2021-02-04 16:18:00.540 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: back from callback 2021-02-04 16:18:00.540 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: message received msg=211, ext1=0, ext2=0 2021-02-04 16:18:00.540 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: unrecognized message: (211, 0, 0) 2021-02-04 16:18:00.540 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: callback application 2021-02-04 16:18:00.540 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: back from callback 2021-02-04 16:18:00.573 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_IDLE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:00.638 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:05.677 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:06.147 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:06.368 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_IDLE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:06.455 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:11.477 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:11.911 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:12.132 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_IDLE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:12.208 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:13.548 18081-18081/com.taskhuman.insights.debug V/MediaPlayer-JNI: stop 2021-02-04 16:18:13.548 18081-18081/com.taskhuman.insights.debug V/MediaPlayerNative: stop 2021-02-04 16:18:13.551 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: message received msg=8, ext1=0, ext2=0 2021-02-04 16:18:13.551 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: unrecognized message: (8, 0, 0) 2021-02-04 16:18:13.551 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: callback application 2021-02-04 16:18:13.551 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: back from callback 2021-02-04 16:18:13.552 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: message received msg=211, ext1=0, ext2=0 2021-02-04 16:18:13.553 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: unrecognized message: (211, 0, 0) 2021-02-04 16:18:13.553 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: callback application 2021-02-04 16:18:13.553 18081-18099/com.taskhuman.insights.debug V/MediaPlayerNative: back from callback 2021-02-04 16:18:13.561 18081-18081/com.taskhuman.insights.debug V/MediaPlayer: resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false 2021-02-04 16:18:13.562 18081-18081/com.taskhuman.insights.debug V/MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null 2021-02-04 16:18:13.562 18081-18081/com.taskhuman.insights.debug V/MediaPlayer-JNI: release 2021-02-04 16:18:13.564 18081-18081/com.taskhuman.insights.debug V/MediaPlayerNative: setListener 2021-02-04 16:18:13.564 18081-18081/com.taskhuman.insights.debug V/MediaPlayerNative: disconnect 2021-02-04 16:18:13.603 18081-18081/com.taskhuman.insights.debug V/MediaPlayerNative: destructor 2021-02-04 16:18:13.604 18081-18081/com.taskhuman.insights.debug V/MediaPlayerNative: disconnect 2021-02-04 16:18:13.636 18081-18081/com.taskhuman.insights.debug W/MediaPlayer: mediaplayer went away with unhandled events 2021-02-04 16:18:13.636 18081-18081/com.taskhuman.insights.debug W/MediaPlayer: mediaplayer went away with unhandled events 2021-02-04 16:18:13.666 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: appVersion: 3.17.1 2021-02-04 16:18:13.666 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: deviceType: android 2021-02-04 16:18:13.667 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: releaseType: dev 2021-02-04 16:18:13.667 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: timeOffset: 19800000 2021-02-04 16:18:13.667 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: timeZone: IST 2021-02-04 16:18:13.667 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: deviceModel: samsung SM-A305F 2021-02-04 16:18:13.667 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: userType: 1 2021-02-04 16:18:13.668 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: callId=ca7101d392bea09a1612435632848&actualRingTime=60&callUniqueId=c2afdb08abf9fb1ada14d32d1fc97cb7aa700300 2021-02-04 16:18:13.668 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: --> END POST (108-byte body) 2021-02-04 16:18:14.005 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept 2021-02-04 16:18:14.006 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: Access-Control-Allow-Origin: * 2021-02-04 16:18:14.006 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: Content-Type: application/json; charset=utf-8 2021-02-04 16:18:14.006 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: Date: Thu, 04 Feb 2021 10:48:14 GMT 2021-02-04 16:18:14.006 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: ETag: W/"18b-sXQ3dzKAfJIhUU+gY8FTbTXeEZI" 2021-02-04 16:18:14.007 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: Server: nginx/1.10.3 (Ubuntu) 2021-02-04 16:18:14.007 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: X-Powered-By: Express 2021-02-04 16:18:14.007 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: Content-Length: 395 2021-02-04 16:18:14.008 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: Connection: keep-alive 2021-02-04 16:18:14.016 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: {"success":true,"notificationLog":{"notificationType":5,"callType":1,"actualRingTime":60,"callUniqueId":"c2afdb08abf9fb1ada14d32d1fc97cb7aa700300","lastUpdatedBy":205,"_id":"601bd0b1551a2326762e4b59","callId":"ca7101d392bea09a1612435632848","ringInitiated":"1612435633644","createdAt":"2021-02-04T10:47:13.648Z","updatedAt":"2021-02-04T10:47:14.194Z","__v":0,"remainingSeconds":60,"timeDiff":0}} 2021-02-04 16:18:14.016 18081-21432/com.taskhuman.insights.debug I/okhttp.OkHttpClient: <-- END HTTP (395-byte body) 2021-02-04 16:18:14.026 18081-21432/com.taskhuman.insights.debug W/.insights.debu: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) 2021-02-04 16:18:14.037 18081-18081/com.taskhuman.insights.debug D/Utils: updateActualRingTime API call successful 2021-02-04 16:18:14.071 18081-18131/com.taskhuman.insights.debug D/TransportRuntime.SQLiteEventStore: Storing event with priority=DEFAULT, name=FIREPERF for destination cct 2021-02-04 16:18:14.091 18081-28326/com.taskhuman.insights.debug D/TaH: From: 484942056710 2021-02-04 16:18:14.098 18081-28326/com.taskhuman.insights.debug D/Push 1: Note message received through push 1 2021-02-04 16:18:17.244 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:17.701 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:17.879 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_IDLE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:17.947 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:18.803 18081-18097/com.taskhuman.insights.debug V/MediaPlayer-JNI: native_finalize 2021-02-04 16:18:18.804 18081-18097/com.taskhuman.insights.debug V/MediaPlayer-JNI: release 2021-02-04 16:18:22.976 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:23.435 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:23.617 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_IDLE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:23.678 18081-18099/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:28.704 18081-18100/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:29.126 18081-18100/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:29.305 18081-18100/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_IDLE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:29.368 18081-18100/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:34.410 18081-18100/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:34.885 18081-18100/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:35.102 18081-18100/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_IDLE for client com.samsung.adaptivebrightnessgo API Level 2 2021-02-04 16:18:35.164 18081-18100/com.taskhuman.insights.debug I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client com.samsung.adaptivebrightnessgo API Level 2

Alton09 commented 3 years ago

Thanks for the information @Monika-Paliwal . I'm not seeing any logs related to AudioSwitch. Can you please enable them and send them again? Thanks!

Monika-Paliwal commented 3 years ago

@Alton09 I am getting the ring fluctuation issue when i was initiated the call and call is in ringing screen that time the ring is fluctuating in device and bluetooth device on click on the push notification.

2021-02-18 17:35:27.170 27870-27870/com.taskhuman.insights.debug D/AS/AudioSwitch: AudioSwitch(1.1.1) 2021-02-18 17:35:27.170 27870-27870/com.taskhuman.insights.debug D/AS/AudioSwitch: Preferred device list = [BluetoothHeadset, WiredHeadset, Speakerphone, Earpiece] 2021-02-18 17:35:27.332 27870-27870/com.taskhuman.insights.debug D/AS/AudioSwitch: Available AudioDevice list updated: [Speakerphone(name=Speakerphone), Earpiece(name=Earpiece)] 2021-02-18 17:35:27.332 27870-27870/com.taskhuman.insights.debug D/AS/AudioSwitch: Current user selected AudioDevice = null 2021-02-18 17:35:28.694 27870-27870/com.taskhuman.insights.debug D/AS/AudioSwitch: Available AudioDevice list updated: [BluetoothHeadset(name=boAt Rockerz 400), Speakerphone(name=Speakerphone), Earpiece(name=Earpiece)] 2021-02-18 17:35:28.694 27870-27870/com.taskhuman.insights.debug D/AS/AudioSwitch: Current user selected AudioDevice = null 2021-02-18 17:35:28.842 27870-27870/com.taskhuman.insights.debug D/AudioManager: dispatching onAudioFocusChange(1) to android.media.AudioManager@ebaa6acom.twilio.audioswitch.AudioSwitch$1@a400b5b 2021-02-18 17:35:29.517 27870-27870/com.taskhuman.insights.debug D/AS/AudioSwitch: Available AudioDevice list updated: [BluetoothHeadset(name=boAt Rockerz 400), Speakerphone(name=Speakerphone), Earpiece(name=Earpiece)] 2021-02-18 17:35:29.518 27870-27870/com.taskhuman.insights.debug D/AS/AudioSwitch: Current user selected AudioDevice = null

Monika-Paliwal commented 3 years ago

@Alton09 Can you please look into the logs and let me know.

Alton09 commented 3 years ago

Hi @Monika-Paliwal. Thank you for sharing the logs. What exactly does your app use to initiate an in-app phone call? i.e. Twilio Voice SDK, some other SDK, etc. It's hard to troubleshoot and reproduce this issue on our end without knowing what this dependency is, and if it is interacting with the Android framework to manage audio devices and audio focus.

Also, is this issue only occurring a Samsung A30 5F? Or does the issue occur on other devices as well. Thanks!

Monika-Paliwal commented 3 years ago

Hey @Alton09 Firstly the call is initiated on phone call and We are using Twilio Video SDK. And it's reproducing in all samsung devices. Can you please flow the above mentioned steps it will be helpful to reproduce the exact issue.

Alton09 commented 3 years ago

Thanks for the clarification @Monika-Paliwal. I'll try to spend some time on this issue soon and report my findings. FYI this issue sounds similar to #85, so it might be helpful for you to keep an eye on it as well.

Alton09 commented 3 years ago

@Monika-Paliwal Have you tried the recommendation that I added in #85?

Alton09 commented 3 years ago

Closing this one due to inactivity.