Merge m-i and m-c
authorPhil Ringnalda <philringnalda@gmail.com>
Sun, 02 Jun 2013 12:06:39 -0700
changeset 133736 198e38876f7e06d49be862710f76881f79abf1d7
parent 133734 2d5a92daf4f1f042e659670b6dfc49c3f1be06b8 (current diff)
parent 133735 6edffc15e2dc25df697f6cc41941b2ed3194de8a (diff)
child 133737 5103d37775cebe0b201da4ddc22f1084ce5c5d8e
child 133806 1ee64bcc673cee097010b3605c1d04fab29c15a1
child 133849 94cae09bda18a513c06c7445d390f20943814b69
child 134126 76629dcc62991228708181a74c1214e0ed2d97dc
child 155428 2c6006ba259cc5351e8a19327189830190e91326
push id28880
push userphilringnalda@gmail.com
push dateSun, 02 Jun 2013 19:07:03 +0000
treeherdermozilla-inbound@198e38876f7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone24.0a1
first release with
nightly linux32
198e38876f7e / 24.0a1 / 20130603031140 / files
nightly linux64
198e38876f7e / 24.0a1 / 20130603031140 / files
nightly mac
198e38876f7e / 24.0a1 / 20130603031140 / files
nightly win32
198e38876f7e / 24.0a1 / 20130603031140 / files
nightly win64
198e38876f7e / 24.0a1 / 20130603031140 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge m-i and m-c
--- a/dom/bluetooth/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/BluetoothHfpManager.cpp
@@ -1277,17 +1277,21 @@ BluetoothHfpManager::HandleCallStateChan
   }
   mCurrentCallArray[aCallIndex].mNumber = aNumber;
 
   nsRefPtr<nsRunnable> sendRingTask;
   nsString address;
 
   switch (aCallState) {
     case nsITelephonyProvider::CALL_STATE_HELD:
-      sCINDItems[CINDType::CALLHELD].value = CallHeldState::ONHOLD_ACTIVE;
+      if (!FindFirstCall(nsITelephonyProvider::CALL_STATE_CONNECTED)) {
+        sCINDItems[CINDType::CALLHELD].value = CallHeldState::ONHOLD_NOACTIVE;
+      } else {
+        sCINDItems[CINDType::CALLHELD].value = CallHeldState::ONHOLD_ACTIVE;
+      }
       SendCommand("+CIEV: ", CINDType::CALLHELD);
       break;
     case nsITelephonyProvider::CALL_STATE_INCOMING:
       if (FindFirstCall(nsITelephonyProvider::CALL_STATE_CONNECTED)) {
         if (mCCWA) {
           nsAutoCString ccwaMsg("+CCWA: \"");
           ccwaMsg.Append(NS_ConvertUTF16toUTF8(aNumber));
           ccwaMsg.AppendLiteral("\",");
@@ -1335,35 +1339,37 @@ BluetoothHfpManager::HandleCallStateChan
           // Incoming call, no break
           sStopSendingRingFlag = true;
           ConnectSco();
         case nsITelephonyProvider::CALL_STATE_ALERTING:
           // Outgoing call
           UpdateCIND(CINDType::CALL, CallState::IN_PROGRESS, aSend);
           UpdateCIND(CINDType::CALLSETUP, CallSetupState::NO_CALLSETUP, aSend);
           break;
-        case nsITelephonyProvider::CALL_STATE_HELD:
-          // Besides checking if there is still held calls, another thing we
-          // need to consider is the state change when receiving AT+CHLD=2.
-          // Assume that there is one active call(c1) and one call on hold(c2).
-          // We got AT+CHLD=2, which swaps active/held position. The first
-          // action would be c2 -> ACTIVE, then c1 -> HELD. When we get the
-          // CallStateChanged event of c2 becoming ACTIVE, we enter here.
-          // However we can't send callheld=0 at this time because we should
-          // see c2 -> ACTIVE + c1 -> HELD as one operation. That's the reason
-          // why I added the GetNumberOfCalls() condition check.
-          if (!FindFirstCall(nsITelephonyProvider::CALL_STATE_HELD) &&
-              GetNumberOfCalls(
-                nsITelephonyProvider::CALL_STATE_CONNECTED) == 1) {
-            UpdateCIND(CINDType::CALLHELD, CallHeldState::NO_CALLHELD, aSend);
-          }
-          break;
         default:
           NS_WARNING("Not handling state changed");
       }
+
+      // = Handle callheld separately =
+      // Besides checking if there is still held calls, another thing we
+      // need to consider is the state change when receiving AT+CHLD=2.
+      // Assume that there is one active call(c1) and one call on hold(c2).
+      // We got AT+CHLD=2, which swaps active/held position. The first
+      // action would be c2 -> ACTIVE, then c1 -> HELD. When we get the
+      // CallStateChanged event of c2 becoming ACTIVE, we enter here.
+      // However we can't send callheld=0 at this time because we should
+      // see c2 -> ACTIVE + c1 -> HELD as one operation. That's the reason
+      // why I added the GetNumberOfCalls() condition check.
+      if (GetNumberOfCalls(nsITelephonyProvider::CALL_STATE_CONNECTED) == 1) {
+        if (FindFirstCall(nsITelephonyProvider::CALL_STATE_HELD)) {
+          UpdateCIND(CINDType::CALLHELD, CallHeldState::ONHOLD_ACTIVE, aSend);
+        } else if (prevCallState == nsITelephonyProvider::CALL_STATE_HELD) {
+          UpdateCIND(CINDType::CALLHELD, CallHeldState::NO_CALLHELD, aSend);
+        }
+      }
       break;
     case nsITelephonyProvider::CALL_STATE_DISCONNECTED:
       switch (prevCallState) {
         case nsITelephonyProvider::CALL_STATE_INCOMING:
         case nsITelephonyProvider::CALL_STATE_BUSY:
           // Incoming call, no break
           sStopSendingRingFlag = true;
         case nsITelephonyProvider::CALL_STATE_DIALING:
@@ -1373,23 +1379,29 @@ BluetoothHfpManager::HandleCallStateChan
           break;
         case nsITelephonyProvider::CALL_STATE_CONNECTED:
           // No call is ongoing
           if (sCINDItems[CINDType::CALLHELD].value ==
               CallHeldState::NO_CALLHELD) {
             UpdateCIND(CINDType::CALL, CallState::NO_CALL, aSend);
           }
           break;
-        case nsITelephonyProvider::CALL_STATE_HELD:
-          UpdateCIND(CINDType::CALLHELD, CallHeldState::NO_CALLHELD, aSend);
-          break;
         default:
           NS_WARNING("Not handling state changed");
       }
 
+      // Handle held calls separately
+      if (!FindFirstCall(nsITelephonyProvider::CALL_STATE_HELD)) {
+        UpdateCIND(CINDType::CALLHELD, CallHeldState::NO_CALLHELD, aSend);
+      } else if (!FindFirstCall(nsITelephonyProvider::CALL_STATE_CONNECTED)) {
+        UpdateCIND(CINDType::CALLHELD, CallHeldState::ONHOLD_NOACTIVE, aSend);
+      } else {
+        UpdateCIND(CINDType::CALLHELD, CallHeldState::ONHOLD_ACTIVE, aSend);
+      }
+
       // -1 is necessary because call 0 is an invalid (padding) call object.
       if (mCurrentCallArray.Length() - 1 ==
           GetNumberOfCalls(nsITelephonyProvider::CALL_STATE_DISCONNECTED)) {
         // There is no call, close Sco and clear mCurrentCallArray
         DisconnectSco();
         ResetCallArray();
       }
       break;