I have a call recording app that reacts to call state changes from a dedicated BroadcastReceiver.
BroadcastReceiver is registered correctly in my manifest, along with the PROCESS_OUTGOING_CALLS
and READ_PHONE_STATE
permissions.
My issue is that for some reason, in some of the calls I get the CALL_STATE_OFFHOOK
state broadcast several minutes after call has already ended.
It seems that the broadcasts are somehow stuck, and then triggered after a while. The 'CALL_STATE_IDLE' subsequent broadcast is received approximately after X time since CALL_STATE_OFFHOOK
broadcast, where X is the time the actual call took.
My logs verify that previous onReceive
calls are not hanging the process or the BroadcastReceiver.
What can be the cause for such behavior?
UPDATE:
I found that this occurs after I turn my Wi-Fi on or off and start a call relatively close to Wi-Fi change.
Is this the cause for the issue or a symptom of the actual issue?
It turned out to be a bug in the Broadcast sending by android (or alternatively some malfunctional receiver). Investigating log cat showed that some system receivers did get broadcasts on time while others (prior to mine) received it after a long time.
This happens frequently whenever Wi-Fi state changes during call start.
What I did was creating an ITelephony
proxy (credit to End call in android programmatically) and monitor its state.
Thanks for the helpers :)