react-native-webrtc / react-native-callkeep

iOS CallKit framework and Android ConnectionService for React Native
ISC License
925 stars 445 forks source link

Handling Ringning State with selfManaged on Android #812

Open orestesparra opened 1 month ago

orestesparra commented 1 month ago

Bug report

Description

I’m currently using selfManaged in Android. When the phone is receiving an incoming call and is in the RINGING state, my app also receives a call, but the library is unable to manage this scenario properly.

I propose two possible solutions:

Solution 1:

I noticed in the code that there is a function public void onCallStateChanged.

Can I add a new action "RNCallKeepHasRingingCall" and, in the switch case (TelephonyManager.CALL_STATE_RINGING) (TelephonyManager.CALL_STATE_RINGING), include the following line of code?:

RNCallKeepModule.this.sendEventToJS("RNCallKeepHasRingingCall", args);

This would allow me to send an event to JavaScript notifying when the phone is in the RINGING state.

Additionally, I will create another event for the TelephonyManager.CALL_STATE_IDLE case to notify when the phone returns to the IDLE state.

Solution 2:

Create a private boolean property, hasRinging, and update its value in the aforementioned cases in solution 1. Then, I can export the value of this property via a function to JS

Please let me know which approach you would prefer so I can proceed with creating a PR

Regards Orestes

Steps to Reproduce

Versions

- Callkeep: 4.3.14
- React Native: 0.75.2
- iOS: 17
- Android: 34
- Phone model: 

Logs

Paste here