react-native-webrtc / react-native-callkeep

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

PhoneAccount.isEnabled called on null object #179

Open jagould2012 opened 4 years ago

jagould2012 commented 4 years ago

Bug report

Description

https://github.com/react-native-webrtc/react-native-callkeep/commit/6c18fdf5c7f183d8befb960bf6e1f79a86c9e2e8

I think this still has an issue. getPhoneAccount(handle) can return null, even when telecomManager is not null, causing isEnabled to be called on a null object.

Should be:

return isConnectionServiceAvailable() && telecomManager != null && telecomManager.getPhoneAccount(handle) != null && telecomManager.getPhoneAccount(handle).isEnabled();

Steps to Reproduce

Try to call setup on a device that has ConnectionService, but not PhoneAccount (any tablet with SDK > 23)

hasPhoneAccount cannot be used gracefully to detect this configuration as it crashes itself. supportConnectionService returns true on these devices.

Versions

- Callkeep: 3.0.12
- React Native: 0.61.5
- iOS: N/A
- Android: Any with SDK > 23

Logs

jagould2012 commented 4 years ago

As a work around, I'm using the react-native-device-info module to detect phones, but not a great solution as I think there may be devices that come back as Handset that still might cause this issue


if(await RNCallKeep.supportConnectionService() && getDeviceType() == 'Handset')
{
    //setup CallKeep
}