Bug 1159267: Share BlueZ's HFP manager between Bluetooth v1 and v2, r=btian
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 06 May 2015 09:58:04 +0200
changeset 242531 f7fe73c7e071492e16a9cbc4ae52b4e0340ef83e
parent 242530 45ae8fa4b2e65ce896e65955782d12b6b394bf82
child 242532 6f4f0bd2e3afe94f94e55137ba6ba1ae695c49f3
push id28699
push userryanvm@gmail.com
push dateWed, 06 May 2015 20:01:37 +0000
treeherdermozilla-central@b2a742938d64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbtian
bugs1159267
milestone40.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 1159267: Share BlueZ's HFP manager between Bluetooth v1 and v2, r=btian Both implementations mostly differ in coding style and correctness fixes. The last remaining differences are related to different interfaces in Bluetooth v1 and v2.
dom/bluetooth/bluez/BluetoothHfpManager.cpp
--- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp
@@ -437,22 +437,18 @@ BluetoothHfpManager::Reset()
   mIsHsp = false;
   mReceiveVgsFlag = false;
   mController = nullptr;
 }
 
 bool
 BluetoothHfpManager::Init()
 {
-#ifdef MOZ_B2G_BT_API_V2
   // The function must run at b2g process since it would access SettingsService.
   MOZ_ASSERT(IsMainProcess());
-#else
-// Missing in bluetooth1
-#endif
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   NS_ENSURE_TRUE(obs, false);
 
   if (NS_FAILED(obs->AddObserver(this, MOZSETTINGS_CHANGED_ID, false)) ||
       NS_FAILED(obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false))) {
     BT_WARNING("Failed to add observers!");
@@ -592,21 +588,18 @@ void
 BluetoothHfpManager::HandleVolumeChanged(nsISupports* aSubject)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // The string that we're interested in will be a JSON string that looks like:
   //  {"key":"volumeup", "value":10}
   //  {"key":"volumedown", "value":2}
 
-#ifdef MOZ_B2G_BT_API_V2
   RootedDictionary<dom::SettingChangeNotification> setting(nsContentUtils::RootingCx());
-#else
-  RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCx());
-#endif
+
   if (!WrappedJSToDictionary(aSubject, setting)) {
     return;
   }
   if (!setting.mKey.EqualsASCII(AUDIO_VOLUME_BT_SCO_ID)) {
     return;
   }
   if (!setting.mValue.isNumber()) {
     return;
@@ -1110,30 +1103,17 @@ BluetoothHfpManager::ReceiveSocketData(B
           return;
         }
       } else {
         // Ignore requests to activate/deactivate mandatory indicators
       }
     }
 #endif // MOZ_B2G_RIL
   } else {
-#ifdef MOZ_B2G_BT_API_V2
-    nsCString warningMsg;
-    warningMsg.Append(NS_LITERAL_CSTRING("Unsupported AT command: "));
-    warningMsg.Append(msg);
-    warningMsg.Append(NS_LITERAL_CSTRING(", reply with ERROR"));
-    BT_WARNING(warningMsg.get());
-#else
-    nsCString warningMsg;
-    warningMsg.AppendLiteral("Unsupported AT command: ");
-    warningMsg.Append(msg);
-    warningMsg.AppendLiteral(", reply with ERROR");
-    BT_WARNING(warningMsg.get());
-#endif
-
+    BT_WARNING("Unsupported AT command: %s, reply with ERROR", msg.get());
     SendLine("ERROR");
     return;
   }
 
 respond_with_ok:
   // We always respond to remote device with "OK" in general cases.
   SendLine("OK");
 }
@@ -1695,21 +1675,17 @@ BluetoothHfpManager::HandleCallStateChan
         UpdateCIND(CINDType::CALLHELD, CallHeldState::ONHOLD_ACTIVE, aSend);
       }
 
       // -1 is necessary because call 0 is an invalid (padding) call object.
       if (mCurrentCallArray.Length() - 1 ==
           GetNumberOfCalls(nsITelephonyService::CALL_STATE_DISCONNECTED)) {
         // In order to let user hear busy tone via connected Bluetooth headset,
         // we postpone the timing of dropping SCO.
-#ifdef MOZ_B2G_BT_API_V2
         if (!(aError.Equals(NS_LITERAL_STRING("BusyError")))) {
-#else
-        if (!(aError.EqualsLiteral("BusyError"))) {
-#endif
           DisconnectSco();
         } else {
           // Close Sco later since Dialer is still playing busy tone via HF.
           MessageLoop::current()->PostDelayedTask(FROM_HERE,
                                                   new CloseScoTask(),
                                                   sBusyToneInterval);
         }