Fixed issue with store/fetch settings prior to RN initialization, plus other things
This PR isn't necessarily meant to be merged as is, because I've made a few secondary changes, and I want to discuss a few issues.
Fix issue with fetchStoredSettings in self managed mode
The primary fix I've got here, addresses an issue that happens primarily with self managed mode, where call keep is activated before react native has initializsed the RNCallKeepModule class, meaning that there's no react context present, and as such we have no reference to Context at all.
This causes a null reference exception when we try to fetchStoredSettings.
I've lifted this logic into it's own class, and have it rely on Context instead of ReactContext. It doesn't need a ReactContext to function, and I can then initialize the RNCallKeepSettings class from my MainApplication as needed:
val settings = JavaOnlyMap()
settings.putString("alertTitle", "Permissions required")
settings.putString("alertDescription", "This application needs to access your phone accounts")
settings.putString("cancelButton", "Cancel")
settings.putString("okButton", "OK")
settings.putString("imageName", "iconmask")
settings.putBoolean("selfManaged", true)
RNCallKeepSettings.getInstance(this).settings = settings;
Added more ACTION_REJECT actions
I've added ACTION_REJECT_NEW_CALL and ACTION_REJECT_RINGING_CALL - these are needed to tell apart if a call is being rejected by android or the user. If the user has a ringing call on the native dialer, Android calls onReject() on VoiceConnection.
If the user has a ringing call in (this) calling app, it instead calls onCreateIncomingConnectionFailed on VoiceConnectionService.
These two signals the same issue, but in two different scenarios.
Added logic for manually registering phone account
This is specific to my self managed app, but it should be best practice. When an incoming notification is received, I don't want to wait for RN to start up as this can take seconds. I instead invoke the telecomManager directly from the Firebase Service. For this i need to register this before RN starts, and as such I've added this method phoneAccountRegistered to RNCallKeepModule, and a few tests where I bail out of methods if _handle != null
This is perhaps a bit brutal, so this is where we should probably talk a bit about how we can address this.
Lastly, I've made a very barebones implementation of getCalls on Android I needed this for debugging on my own app, but it's somewhat incomplete 🤷♂️