From 82aab3bfd58aac8ea25d6dcc8607d7189a3270eb Mon Sep 17 00:00:00 2001 From: Eric Chou Date: Sun, 2 Jun 2013 22:42:43 +0800 Subject: [PATCH] Backed out changeset 736965f66934 --- dom/bluetooth/BluetoothHfpManager.cpp | 52 +++++++++++---------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/dom/bluetooth/BluetoothHfpManager.cpp b/dom/bluetooth/BluetoothHfpManager.cpp index 0ff0fbe69ef..84249dfd64b 100644 --- a/dom/bluetooth/BluetoothHfpManager.cpp +++ b/dom/bluetooth/BluetoothHfpManager.cpp @@ -1282,11 +1282,7 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex, switch (aCallState) { case nsITelephonyProvider::CALL_STATE_HELD: - if (!FindFirstCall(nsIRadioInterfaceLayer::CALL_STATE_CONNECTED)) { - sCINDItems[CINDType::CALLHELD].value = CallHeldState::ONHOLD_NOACTIVE; - } else { - sCINDItems[CINDType::CALLHELD].value = CallHeldState::ONHOLD_ACTIVE; - } + sCINDItems[CINDType::CALLHELD].value = CallHeldState::ONHOLD_ACTIVE; SendCommand("+CIEV: ", CINDType::CALLHELD); break; case nsITelephonyProvider::CALL_STATE_INCOMING: @@ -1344,27 +1340,25 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex, 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(nsIRadioInterfaceLayer::CALL_STATE_CONNECTED) == 1) { - if (FindFirstCall(nsIRadioInterfaceLayer::CALL_STATE_HELD)) { - UpdateCIND(CINDType::CALLHELD, CallHeldState::ONHOLD_ACTIVE, aSend); - } else if (currentCallState == nsIRadioInterfaceLayer::CALL_STATE_HELD) { - UpdateCIND(CINDType::CALLHELD, CallHeldState::NO_CALLHELD, aSend); - } - } break; case nsITelephonyProvider::CALL_STATE_DISCONNECTED: switch (prevCallState) { @@ -1384,19 +1378,13 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex, 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(nsIRadioInterfaceLayer::CALL_STATE_HELD)) { - UpdateCIND(CINDType::CALLHELD, CallHeldState::NO_CALLHELD, aSend); - } else if (!FindFirstCall(nsIRadioInterfaceLayer::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)) {