Bug 993286 - Patch 3: Add Call.Set() function. r=echou, a=1.4+
authorBen Tian <btian@mozilla.com>
Mon, 21 Apr 2014 18:19:53 +0800
changeset 193096 cd6ad8bd5a84c5f5a81db6b120d6655e2f50e006
parent 193095 0a34f5a81212cda8dd9e265fb27172cf285442eb
child 193097 436884f12e4545eef16ce25cf0c60f5c5da496e5
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechou, 1
bugs993286
milestone30.0a2
Bug 993286 - Patch 3: Add Call.Set() function. r=echou, a=1.4+
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
@@ -316,16 +316,28 @@ NS_IMPL_ISUPPORTS1(BluetoothHfpManager::
  *  Call
  */
 Call::Call()
 {
   Reset();
 }
 
 void
+Call::Set(const nsAString& aNumber, const bool aIsOutgoing)
+{
+  mNumber = aNumber;
+  mDirection = (aIsOutgoing) ? BTHF_CALL_DIRECTION_OUTGOING :
+                               BTHF_CALL_DIRECTION_INCOMING;
+  // Same logic as implementation in ril_worker.js
+  if (aNumber.Length() && aNumber[0] == '+') {
+    mType = BTHF_CALL_ADDRTYPE_INTERNATIONAL;
+  }
+}
+
+void
 Call::Reset()
 {
   mState = nsITelephonyProvider::CALL_STATE_DISCONNECTED;
   mDirection = BTHF_CALL_DIRECTION_OUTGOING;
   mNumber.Truncate();
   mType = BTHF_CALL_ADDRTYPE_UNKNOWN;
 }
 
@@ -1122,24 +1134,18 @@ BluetoothHfpManager::HandleCallStateChan
     mCurrentCallArray.AppendElement(call);
   }
   mCurrentCallArray[aCallIndex].mState = aCallState;
   // Return if SLC is disconnected
   if (!IsConnected()) {
     return;
   }
 
-  mCurrentCallArray[aCallIndex].mNumber = aNumber;
-  mCurrentCallArray[aCallIndex].mDirection = (aIsOutgoing) ?
-                                              BTHF_CALL_DIRECTION_OUTGOING :
-                                              BTHF_CALL_DIRECTION_INCOMING;
-  // Same logic as implementation in ril_worker.js
-  if (aNumber.Length() && aNumber[0] == '+') {
-    mCurrentCallArray[aCallIndex].mType = BTHF_CALL_ADDRTYPE_INTERNATIONAL;
-  }
+  // Update call information besides call state
+  mCurrentCallArray[aCallIndex].Set(aNumber, aIsOutgoing);
 
   // Notify bluedroid of phone state change
   UpdatePhoneCIND(aCallIndex);
 
   switch (aCallState) {
     case nsITelephonyProvider::CALL_STATE_DIALING:
       // We've send Dialer a dialing request and this is the response.
       if (!mDialingRequestProcessed) {
@@ -1187,22 +1193,17 @@ BluetoothHfpManager::GetPhoneType(const 
 
 void
 BluetoothHfpManager::UpdateSecondNumber(const nsAString& aNumber)
 {
   MOZ_ASSERT(mPhoneType == PhoneType::CDMA);
 
   // Always regard second call as incoming call since v1.2 RIL
   // doesn't support outgoing second call in CDMA.
-  mCdmaSecondCall.mDirection = BTHF_CALL_DIRECTION_INCOMING;
-
-  mCdmaSecondCall.mNumber = aNumber;
-  if (aNumber[0] == '+') {
-    mCdmaSecondCall.mType = BTHF_CALL_ADDRTYPE_INTERNATIONAL;
-  }
+  mCdmaSecondCall.Set(aNumber, false);
 
   // FIXME: check CDMA + bluedroid
   //UpdateCIND(CINDType::CALLSETUP, CallSetupState::INCOMING, true);
 }
 
 void
 BluetoothHfpManager::AnswerWaitingCall()
 {
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h
@@ -57,16 +57,17 @@ enum PhoneType {
   NONE, // no connection
   GSM,
   CDMA
 };
 
 class Call {
 public:
   Call();
+  void Set(const nsAString& aNumber, const bool aIsOutgoing);
   void Reset();
   bool IsActive();
 
   uint16_t mState;
   nsString mNumber;
   bthf_call_direction_t mDirection; // 0: outgoing call; 1: incoming call
   bthf_call_addrtype_t mType;
 };