Bug 953036 - Set HSP flag when BluetoothHfpManager chooses to connect HSP. r=echou, a=1.3+
authorJamin Liu <jaliu@mozilla.com>
Fri, 10 Jan 2014 08:23:13 -0500
changeset 169187 b6915bd4cb49266c37e13785bf004bf2bc958b4e
parent 169186 1105948b00e83a13ac702dd54f1223a6bc1d3709
child 169188 f2fa642b5be5c93f405fea2ac8eb8ec0cf7f5cf3
push id4917
push userryanvm@gmail.com
push dateMon, 13 Jan 2014 15:42:27 +0000
treeherdermozilla-aurora@2d68aecfdef5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechou, 1.3
bugs953036
milestone28.0a2
Bug 953036 - Set HSP flag when BluetoothHfpManager chooses to connect HSP. r=echou, a=1.3+
dom/bluetooth/bluez/BluetoothHfpManager.cpp
dom/bluetooth/bluez/BluetoothHfpManager.h
--- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp
@@ -383,17 +383,17 @@ BluetoothHfpManager::Reset()
   mCCWA = false;
   mCLIP = false;
   mDialingRequestProcessed = true;
 #endif
   mCMEE = false;
   mCMER = false;
   mConnectScoRequest = false;
   mSlcConnected = false;
-  mHspConnected = false;
+  mIsHsp = false;
   mReceiveVgsFlag = false;
 
 #ifdef MOZ_B2G_RIL
   // We disable BSIR by default as it requires OEM implement BT SCO + SPEAKER
   // output audio path in audio driver. OEM can enable BSIR by setting
   // mBSIR=true here.
   //
   // Please see Bug 878728 for more information.
@@ -1623,23 +1623,24 @@ BluetoothHfpManager::OnSocketConnectSucc
    * If the created connection is an inbound connection, close another server
    * socket because currently only one SLC is allowed. After that, we need to
    * make sure that both server socket would be nulled out. As for outbound
    * connections, we do nothing since sockets have been already handled in
    * function Connect().
    */
   if (aSocket == mHandsfreeSocket) {
     MOZ_ASSERT(!mSocket);
+    mIsHsp = false;
     mHandsfreeSocket.swap(mSocket);
 
     mHeadsetSocket->Disconnect();
     mHeadsetSocket = nullptr;
   } else if (aSocket == mHeadsetSocket) {
     MOZ_ASSERT(!mSocket);
-    mHspConnected = true;
+    mIsHsp = true;
     mHeadsetSocket.swap(mSocket);
 
     mHandsfreeSocket->Disconnect();
     mHandsfreeSocket = nullptr;
   }
 
 #ifdef MOZ_B2G_RIL
   // Enumerate current calls
@@ -1724,16 +1725,18 @@ BluetoothHfpManager::OnGetServiceChannel
     nsString hspUuid;
     BluetoothUuidHelper::GetString(BluetoothServiceClass::HEADSET, hspUuid);
 
     if (aServiceUuid.Equals(hspUuid)) {
       OnConnect(NS_LITERAL_STRING(ERR_SERVICE_CHANNEL_NOT_FOUND));
     } else if (NS_FAILED(bs->GetServiceChannel(aDeviceAddress,
                                                hspUuid, this))) {
       OnConnect(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
+    } else {
+      mIsHsp = true;
     }
 
     return;
   }
 
   MOZ_ASSERT(mSocket);
 
   if (!mSocket->Connect(NS_ConvertUTF16toUTF8(aDeviceAddress), aChannel)) {
@@ -1817,17 +1820,17 @@ BluetoothHfpManager::ConnectSco(Bluetoot
       status == SocketConnectionStatus::SOCKET_CONNECTING ||
       (mScoRunnable && (mScoRunnable != aRunnable))) {
     BT_WARNING("SCO connection exists or is being established");
     return false;
   }
 
   // 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) {
+  if (!mSlcConnected && !mIsHsp) {
     mConnectScoRequest = true;
     BT_WARNING("ConnectSco called before Service Level Connection established");
     return false;
   }
 
   mScoSocket->Disconnect();
 
   mScoRunnable = aRunnable;
--- a/dom/bluetooth/bluez/BluetoothHfpManager.h
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.h
@@ -184,17 +184,17 @@ private:
   bool mBSIR;
   bool mCCWA;
   bool mCLIP;
 #endif
   bool mCMEE;
   bool mCMER;
   bool mConnectScoRequest;
   bool mSlcConnected;
-  bool mHspConnected;
+  bool mIsHsp;
 #ifdef MOZ_B2G_RIL
   bool mFirstCKPD;
   int mNetworkSelectionMode;
   PhoneType mPhoneType;
 #endif
   bool mReceiveVgsFlag;
 #ifdef MOZ_B2G_RIL
   bool mDialingRequestProcessed;