Bug 1061126: Fix constants in Bluedroid HFP manager, r=shuang
authorThomas Zimmermann <tdz@users.sourceforge.net>
Tue, 02 Sep 2014 12:46:07 +0200
changeset 226220 ad902f1fd574941061127da71d3ee2fafc0df79f
parent 226219 518ab7491783ba035ca29c0c80e68a7e87a60af6
child 226221 bae6b0b0a4b5207ef67ddf38de09c9bbcc9fe90a
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshuang
bugs1061126
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1061126: Fix constants in Bluedroid HFP manager, r=shuang This patch replaces the remaining Bluedroid constants from Bluedroid's |BluetoothHfpManager| with Gecko constants.
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
@@ -196,33 +196,33 @@ BluetoothHfpManager::ResetCallArray()
 }
 
 void
 BluetoothHfpManager::Cleanup()
 {
   mReceiveVgsFlag = false;
   mDialingRequestProcessed = true;
 
-  mConnectionState = BTHF_CONNECTION_STATE_DISCONNECTED;
-  mPrevConnectionState = BTHF_CONNECTION_STATE_DISCONNECTED;
+  mConnectionState = HFP_CONNECTION_STATE_DISCONNECTED;
+  mPrevConnectionState = HFP_CONNECTION_STATE_DISCONNECTED;
   mBattChg = 5;
   mService = HFP_NETWORK_STATE_NOT_AVAILABLE;
   mRoam = HFP_SERVICE_TYPE_HOME;
   mSignal = 0;
 
   mController = nullptr;
 }
 
 void
 BluetoothHfpManager::Reset()
 {
   // Phone & Device CIND
   ResetCallArray();
   // Clear Sco state
-  mAudioState = BTHF_AUDIO_STATE_DISCONNECTED;
+  mAudioState = HFP_AUDIO_STATE_DISCONNECTED;
   Cleanup();
 }
 
 bool
 BluetoothHfpManager::Init()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -517,19 +517,19 @@ BluetoothHfpManager::NotifyConnectionSta
   if (aType.EqualsLiteral(BLUETOOTH_HFP_STATUS_CHANGED_ID)) {
     if (IsConnected()) {
       MOZ_ASSERT(mListener);
 
       // Enumerate current calls
       mListener->EnumerateCalls();
 
       OnConnect(EmptyString());
-    } else if (mConnectionState == BTHF_CONNECTION_STATE_DISCONNECTED) {
+    } else if (mConnectionState == HFP_CONNECTION_STATE_DISCONNECTED) {
       mDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
-      if (mPrevConnectionState == BTHF_CONNECTION_STATE_DISCONNECTED) {
+      if (mPrevConnectionState == HFP_CONNECTION_STATE_DISCONNECTED) {
         // 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());
       }
@@ -1109,23 +1109,23 @@ BluetoothHfpManager::DisconnectSco()
                                           new DisconnectAudioResultHandler());
 
   return true;
 }
 
 bool
 BluetoothHfpManager::IsScoConnected()
 {
-  return (mAudioState == BTHF_AUDIO_STATE_CONNECTED);
+  return (mAudioState == HFP_AUDIO_STATE_CONNECTED);
 }
 
 bool
 BluetoothHfpManager::IsConnected()
 {
-  return (mConnectionState == BTHF_CONNECTION_STATE_SLC_CONNECTED);
+  return (mConnectionState == HFP_CONNECTION_STATE_SLC_CONNECTED);
 }
 
 void
 BluetoothHfpManager::OnConnectError()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   mController->NotifyCompletion(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
@@ -1428,23 +1428,28 @@ void BluetoothHfpManager::DialCallNotifi
     newMsg += StringHead(message, message.Length() - 1);
     NotifyDialer(NS_ConvertUTF8toUTF16(newMsg));
   }
 }
 
 void
 BluetoothHfpManager::CnumNotification()
 {
+  static const uint8_t sAddressType[] {
+    [HFP_CALL_ADDRESS_TYPE_UNKNOWN] = 0x81,
+    [HFP_CALL_ADDRESS_TYPE_INTERNATIONAL] = 0x91 // for completeness
+  };
+
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!mMsisdn.IsEmpty()) {
     nsAutoCString message("+CNUM: ,\"");
     message.Append(NS_ConvertUTF16toUTF8(mMsisdn).get());
     message.AppendLiteral("\",");
-    message.AppendInt(BTHF_CALL_ADDRTYPE_UNKNOWN);
+    message.AppendInt(sAddressType[HFP_CALL_ADDRESS_TYPE_UNKNOWN]);
     message.AppendLiteral(",,4");
 
     SendLine(message.get());
   }
 
   SendResponse(HFP_AT_RESPONSE_OK);
 }
 
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h
@@ -165,19 +165,19 @@ private:
     ConvertToBluetoothHandsfreeCallState(int aCallState) const;
 
   void UpdatePhoneCIND(uint32_t aCallIndex);
   void UpdateDeviceCIND();
   void SendCLCC(Call& aCall, int aIndex);
   void SendLine(const char* aMessage);
   void SendResponse(BluetoothHandsfreeAtResponse aResponseCode);
 
-  int mConnectionState;
-  int mPrevConnectionState;
-  int mAudioState;
+  BluetoothHandsfreeConnectionState mConnectionState;
+  BluetoothHandsfreeConnectionState mPrevConnectionState;
+  BluetoothHandsfreeAudioState mAudioState;
   // Device CIND
   int mBattChg;
   BluetoothHandsfreeNetworkState mService;
   BluetoothHandsfreeServiceType mRoam;
   int mSignal;
 
   int mCurrentVgs;
   int mCurrentVgm;