Bug 1147736 - Part 2: Bypass NotifyError. r=aknow
☠☠ backed out by ec6f7f1add4b ☠ ☠
authorBen Hsu <driftersprt@gmail.com>
Mon, 27 Apr 2015 23:28:00 -0400
changeset 242539 a78ad976faf317828b6cb268dced774e863b6b80
parent 242538 5a0f9070dd9441a39d5d759f19e88303d768ad6d
child 242540 95e956a2ddb926fc79a61d80bad4a26035f354b0
push id28699
push userryanvm@gmail.com
push dateWed, 06 May 2015 20:01:37 +0000
treeherdermozilla-central@b2a742938d64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaknow
bugs1147736
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1147736 - Part 2: Bypass NotifyError. r=aknow
dom/telephony/Telephony.cpp
dom/telephony/TelephonyCall.cpp
dom/telephony/gonk/TelephonyService.js
--- a/dom/telephony/Telephony.cpp
+++ b/dom/telephony/Telephony.cpp
@@ -372,20 +372,24 @@ Telephony::HandleCallInfo(nsITelephonyCa
     call->UpdateSwitchable(isSwitchable);
     call->UpdateMergeable(isMergeable);
 
     nsAutoString number;
     aInfo->GetNumber(number);
     nsRefPtr<TelephonyCallId> id = call->Id();
     id->UpdateNumber(number);
 
+    nsAutoString disconnectedReason;
+    aInfo->GetDisconnectedReason(disconnectedReason);
+
     // State changed.
     if (call->CallState() != callState) {
       if (callState == nsITelephonyService::CALL_STATE_DISCONNECTED) {
-        call->ChangeStateInternal(callState, true);
+        call->UpdateDisconnectedReason(disconnectedReason);
+        call->ChangeState(nsITelephonyService::CALL_STATE_DISCONNECTED);
         return NS_OK;
       }
 
       // We don't fire the statechange event on a call in conference here.
       // Instead, the event will be fired later in
       // TelephonyCallGroup::ChangeState(). Thus the sequence of firing the
       // statechange events is guaranteed: first on TelephonyCallGroup then on
       // individual TelephonyCall objects.
--- a/dom/telephony/TelephonyCall.cpp
+++ b/dom/telephony/TelephonyCall.cpp
@@ -129,17 +129,16 @@ TelephonyCall::ChangeStateInternal(uint1
   if (aCallState == nsITelephonyService::CALL_STATE_DISCONNECTED) {
     NS_ASSERTION(mLive, "Should be live!");
     mLive = false;
     if (mGroup) {
       mGroup->RemoveCall(this);
     } else {
       mTelephony->RemoveCall(this);
     }
-    UpdateDisconnectedReason(NS_LITERAL_STRING("NormalCallClearingError"));
   } else if (!mLive) {
     mLive = true;
     if (mGroup) {
       mGroup->AddCall(this);
     } else {
       mTelephony->AddCall(this);
     }
   }
@@ -206,26 +205,33 @@ TelephonyCall::NotifyError(const nsAStri
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to dispatch error event!");
   }
 }
 
 void
 TelephonyCall::UpdateDisconnectedReason(const nsAString& aDisconnectedReason)
 {
-  NS_ASSERTION(Substring(aDisconnectedReason, aDisconnectedReason.Length() - 5).EqualsLiteral("Error"),
+  NS_ASSERTION(Substring(aDisconnectedReason,
+                         aDisconnectedReason.Length() - 5).EqualsLiteral("Error"),
                "Disconnected reason should end with 'Error'");
 
-  if (mDisconnectedReason.IsNull()) {
-    // There is no 'Error' suffix in the corresponding enum. We should skip
-    // that part for comparison.
-    CONVERT_STRING_TO_NULLABLE_ENUM(
-        Substring(aDisconnectedReason, 0, aDisconnectedReason.Length() - 5),
-        TelephonyCallDisconnectedReason,
-        mDisconnectedReason);
+  if (!mDisconnectedReason.IsNull()) {
+    return;
+  }
+
+  // There is no 'Error' suffix in the corresponding enum. We should skip
+  // that part for comparison.
+  CONVERT_STRING_TO_NULLABLE_ENUM(
+      Substring(aDisconnectedReason, 0, aDisconnectedReason.Length() - 5),
+      TelephonyCallDisconnectedReason,
+      mDisconnectedReason);
+
+  if (!aDisconnectedReason.EqualsLiteral("NormalCallClearingError")) {
+    NotifyError(aDisconnectedReason);
   }
 }
 
 void
 TelephonyCall::ChangeGroup(TelephonyCallGroup* aGroup)
 {
   mGroup = aGroup;
 
--- a/dom/telephony/gonk/TelephonyService.js
+++ b/dom/telephony/gonk/TelephonyService.js
@@ -1445,20 +1445,16 @@ TelephonyService.prototype = {
     this._cdmaCallWaitingNumber = null;
   },
 
   /**
    * Disconnect calls by updating their states. Sometimes, it may cause other
    * calls being disconnected as well.
    *
    * @return Array a list of calls we need to fire callStateChange
-   *
-   * TODO: The list currently doesn't contain calls that we fire notifyError
-   * for them. However, after Bug 1147736, notifyError is replaced by
-   * callStateChanged and those calls should be included in the list.
    */
   _disconnectCalls: function(aClientId, aCalls,
                              aFailCause = RIL.GECKO_CALL_ERROR_NORMAL_CALL_CLEARING) {
     if (DEBUG) debug("_disconnectCalls: " + JSON.stringify(aCalls));
 
     // Child cannot live without parent. Let's find all the calls that need to
     // be disconnected.
     let disconnectedCalls = aCalls.slice();
@@ -1472,32 +1468,26 @@ TelephonyService.prototype = {
 
     // Store unique value in the list.
     disconnectedCalls = [...Set(disconnectedCalls)];
 
     let callsForStateChanged = [];
 
     disconnectedCalls.forEach(call => {
       call.state = nsITelephonyService.CALL_STATE_DISCONNECTED;
-      call.failCause = aFailCause;
+      call.disconnectedReason = aFailCause;
 
       if (call.parentId) {
         let parentCall = this._currentCalls[aClientId][call.parentId];
         delete parentCall.childId;
       }
 
       this._notifyCallEnded(call);
 
-      if (call.hangUpLocal || !call.failCause ||
-          call.failCause === RIL.GECKO_CALL_ERROR_NORMAL_CALL_CLEARING) {
-        callsForStateChanged.push(call);
-      } else {
-        this._notifyAllListeners("notifyError",
-                                 [aClientId, call.callIndex, call.failCause]);
-      }
+      callsForStateChanged.push(call);
 
       delete this._currentCalls[aClientId][call.callIndex];
     });
 
     return callsForStateChanged;
   },
 
   /**