From 8c617675ade1a060ca9ef556d6310d3e4b8dc7c1 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Tsai Date: Fri, 11 Jan 2013 10:41:53 +0800 Subject: [PATCH] Bug 828160 - B2G RIL: not send duplicate incoming-call messages in some cases of 'waiting call coming' r=allstars.chh --- dom/system/gonk/ril_worker.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index 2c7abcb872b..706742a1e56 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -3023,22 +3023,33 @@ let RIL = { delete newCalls[currentCall.callIndex]; } - if (newCall) { - // Call is still valid. - if (newCall.state != currentCall.state) { - // State has changed. - if (!currentCall.started && newCall.state == CALL_STATE_ACTIVE) { - currentCall.started = new Date().getTime(); - } - currentCall.state = newCall.state; - this._handleChangedCallState(currentCall); - } - } else { + if (!newCall) { // Call is no longer reported by the radio. Remove from our map and // send disconnected state change. delete this.currentCalls[currentCall.callIndex]; this.getFailCauseCode(currentCall); + continue; } + + // Call is still valid. + if (newCall.state == currentCall.state) { + continue; + } + + // State has changed. + if (newCall.state == CALL_STATE_INCOMING && + currentCall.state == CALL_STATE_WAITING) { + // Update the call internally but we don't notify DOM since these two + // states are viewed as the same one there. + currentCall.state = newCall.state; + continue; + } + + if (!currentCall.started && newCall.state == CALL_STATE_ACTIVE) { + currentCall.started = new Date().getTime(); + } + currentCall.state = newCall.state; + this._handleChangedCallState(currentCall); } // Go through any remaining calls that are new to us.