Bug 993286 - Patch 3/3: Add Call.Set() function, r=echou, a=1.4+
authorBen Tian <btian@mozilla.com>
Mon, 21 Apr 2014 18:19:53 +0800
changeset 179890 3e77a85ed5fbaf2ff296c261a9be4066fb4f7194
parent 179889 601899fbbbad15653560fe204c4eb6e3ade1faab
child 179891 ba77e640578d6725a1496b160c4e0610c81e2a26
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersechou, 1.4
bugs993286
milestone31.0a1
Bug 993286 - Patch 3/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;
 }
 
@@ -1124,24 +1136,18 @@ BluetoothHfpManager::HandleCallStateChan
   }
   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) {
@@ -1189,22 +1195,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;
 };