diff --git a/dom/bluetooth/bluez/BluetoothHfpManager.cpp b/dom/bluetooth/bluez/BluetoothHfpManager.cpp index 41475e29250..814b562c4b3 100644 --- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp +++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp @@ -384,6 +384,7 @@ BluetoothHfpManager::Reset() mCMER = false; mConnectScoRequest = false; mSlcConnected = false; + mHspConnected = false; mReceiveVgsFlag = false; #ifdef MOZ_B2G_RIL @@ -1617,6 +1618,7 @@ BluetoothHfpManager::OnSocketConnectSuccess(BluetoothSocket* aSocket) mHeadsetSocket = nullptr; } else if (aSocket == mHeadsetSocket) { MOZ_ASSERT(!mSocket); + mHspConnected = true; mHeadsetSocket.swap(mSocket); mHandsfreeSocket->Disconnect(); @@ -1802,9 +1804,9 @@ BluetoothHfpManager::ConnectSco(BluetoothReplyRunnable* aRunnable) return false; } - // Make sure Service Level Connection established before we start to - // set up SCO (synchronous connection). - if (!mSlcConnected) { + // If we are not using HSP, we have to make sure Service Level Connection + // established before we start to set up SCO (synchronous connection). + if (!mSlcConnected && !mHspConnected) { mConnectScoRequest = true; BT_WARNING("ConnectSco called before Service Level Connection established"); return false; diff --git a/dom/bluetooth/bluez/BluetoothHfpManager.h b/dom/bluetooth/bluez/BluetoothHfpManager.h index 2e01783861a..91f78c6cd99 100644 --- a/dom/bluetooth/bluez/BluetoothHfpManager.h +++ b/dom/bluetooth/bluez/BluetoothHfpManager.h @@ -102,8 +102,9 @@ public: * This function set up a Synchronous Connection (SCO) link for HFP. * Service Level Connection (SLC) should be established before SCO setup * process. - * If SLC haven't been established, this function will return false and send a - * request to set up SCO ater HfpManager receive AT+CMER. + * If SLC haven't been established, this function will return false and + * send a request to set up SCO ater HfpManager receive AT+CMER, unless we are + * connecting HSP socket rather than HFP socket. * * @param aRunnable Indicate a BluetoothReplyRunnable to execute this * function. The default value is nullpter @@ -188,6 +189,7 @@ private: bool mCMER; bool mConnectScoRequest; bool mSlcConnected; + bool mHspConnected; #ifdef MOZ_B2G_RIL bool mFirstCKPD; int mNetworkSelectionMode;