From 79c8386d65767c271ce112d6fa700c69733d18d0 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Tsai Date: Thu, 25 Oct 2012 18:31:37 +0800 Subject: [PATCH] Bug 804983 - WebTelephony API: DOM does not accurately handle an outgoing call. r=bent --- dom/telephony/Telephony.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/dom/telephony/Telephony.cpp b/dom/telephony/Telephony.cpp index 0990b731a5f..edd6e1e61fc 100644 --- a/dom/telephony/Telephony.cpp +++ b/dom/telephony/Telephony.cpp @@ -402,8 +402,10 @@ Telephony::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState, return NS_OK; } - // Didn't know anything about this call before now, must be incoming. - NS_ASSERTION(aCallState == nsIRadioInterfaceLayer::CALL_STATE_INCOMING, + // Didn't know anything about this call before now, could be 'incoming' or + // 'dialing' that was placed by others. + NS_ASSERTION(aCallState == nsIRadioInterfaceLayer::CALL_STATE_INCOMING || + aCallState == nsIRadioInterfaceLayer::CALL_STATE_DIALING, "Serious logic problem here!"); nsRefPtr call = @@ -412,13 +414,15 @@ Telephony::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState, NS_ASSERTION(mCalls.Contains(call), "Should have auto-added new call!"); - // Dispatch incoming event. - nsRefPtr event = CallEvent::Create(call); - NS_ASSERTION(event, "This should never fail!"); + if (aCallState == nsIRadioInterfaceLayer::CALL_STATE_INCOMING) { + // Dispatch incoming event. + nsRefPtr event = CallEvent::Create(call); + NS_ASSERTION(event, "This should never fail!"); - nsresult rv = - event->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("incoming")); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv = + event->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("incoming")); + NS_ENSURE_SUCCESS(rv, rv); + } return NS_OK; }