Bug 1027506 - [bluedroid] Don't reset call array after HFP link lost. r=echou, a=2.0+
authorShawn Huang <shuang@mozilla.com>
Thu, 26 Jun 2014 09:58:50 +0800
changeset 208458 d62322a3250110bf4843d348be1feb206d2bfa54
parent 208457 6d261c1cbe2571887794f21fcdf17dddb1d94134
child 208459 84b6ad5821389690250f06c6eb71dbcead06dd6a
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechou, 2
bugs1027506
milestone32.0a2
Bug 1027506 - [bluedroid] Don't reset call array after HFP link lost. r=echou, a=2.0+
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
@@ -366,35 +366,41 @@ BluetoothHfpManager::ResetCallArray()
   mCurrentCallArray.AppendElement(call);
 
   if (mPhoneType == PhoneType::CDMA) {
     mCdmaSecondCall.Reset();
   }
 }
 
 void
-BluetoothHfpManager::Reset()
+BluetoothHfpManager::Cleanup()
 {
   mReceiveVgsFlag = false;
   mDialingRequestProcessed = true;
 
   mConnectionState = BTHF_CONNECTION_STATE_DISCONNECTED;
   mPrevConnectionState = BTHF_CONNECTION_STATE_DISCONNECTED;
-  mAudioState = BTHF_AUDIO_STATE_DISCONNECTED;
-
-  // Phone & Device CIND
-  ResetCallArray();
   mBattChg = 5;
   mService = 0;
   mRoam = 0;
   mSignal = 0;
 
   mController = nullptr;
 }
 
+void
+BluetoothHfpManager::Reset()
+{
+  // Phone & Device CIND
+  ResetCallArray();
+  // Clear Sco state
+  mAudioState = BTHF_AUDIO_STATE_DISCONNECTED;
+  Cleanup();
+}
+
 bool
 BluetoothHfpManager::Init()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   NS_ENSURE_TRUE(obs, false);
 
@@ -813,17 +819,17 @@ BluetoothHfpManager::NotifyConnectionSta
         // Bug 979160: This implies the outgoing connection failure.
         // When the outgoing hfp connection fails, state changes to disconnected
         // state. Since bluedroid would not report connecting state, but only
         // report connected/disconnected.
         OnConnect(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
       } else {
         OnDisconnect(EmptyString());
       }
-      Reset();
+      Cleanup();
     }
   }
 }
 
 void
 BluetoothHfpManager::NotifyDialer(const nsAString& aCommand)
 {
   NS_NAMED_LITERAL_STRING(type, "bluetooth-dialer-command");
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h
@@ -131,16 +131,17 @@ private:
   friend class BluetoothHfpManagerObserver;
   friend class GetVolumeTask;
   friend class CloseScoTask;
   friend class RespondToBLDNTask;
   friend class MainThreadTask;
 
   BluetoothHfpManager();
   bool Init();
+  void Cleanup();
 
   void HandleShutdown();
   void HandleVolumeChanged(const nsAString& aData);
   void Notify(const hal::BatteryInformation& aBatteryInfo);
 
   void NotifyConnectionStateChanged(const nsAString& aType);
   void NotifyDialer(const nsAString& aCommand);