Bug 875677 - Modify the logic of sending 'callheld' indicator to fit HFP 1.6, r=gyeh

According to HFP spec 1.6, we should update callheld status very carefully when
the status of other calls are changed.
This commit is contained in:
Eric Chou 2013-05-31 21:49:42 +08:00
Родитель 134b84c4e7
Коммит e4490cd86d
1 изменённых файлов: 32 добавлений и 20 удалений

Просмотреть файл

@ -1282,7 +1282,11 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
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:
@ -1340,25 +1344,27 @@ 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(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) {
@ -1378,13 +1384,19 @@ 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(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)) {