Backed out changeset 150544a28405 (bug 1167064) for B2G mochitest failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 08 Jun 2015 15:41:26 -0400
changeset 247817 a208fbe870ff8305ce0b2a9da4a7894ba4034cbf
parent 247816 46debfda9a71b36472b345f5398ae312fcc953e2
child 247818 3b2f55f9839cd24781322aeda63024321b39e108
push id60814
push userkwierso@gmail.com
push dateWed, 10 Jun 2015 02:29:27 +0000
treeherdermozilla-inbound@bc32a90612e5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1167064
milestone41.0a1
backs out150544a284050e4f707faaf6c5e7ac5e68ef5f0e
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
Backed out changeset 150544a28405 (bug 1167064) for B2G mochitest failures.
CLOBBER
dom/base/moz.build
dom/bindings/moz.build
dom/bluetooth/BluetoothUtils.cpp
dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
dom/bluetooth/bluez/BluetoothDBusService.cpp
dom/bluetooth/bluez/BluetoothDBusService.h
dom/bluetooth/moz.build
dom/ipc/moz.build
dom/system/gonk/moz.build
dom/webidl/moz.build
js/xpconnect/src/moz.build
layout/build/moz.build
--- a/CLOBBER
+++ b/CLOBBER
@@ -17,9 +17,9 @@
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
 # Are you updating CLOBBER because you think it's needed for your WebIDL
 # changes to stick? As of bug 928195, this shouldn't be necessary! Please
 # don't change CLOBBER for WebIDL changes any more.
 
-Bug 1167064: Switch to bluetooth APIv2.
+Bug 1165422 - Updated the Android SDK versions
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -431,23 +431,23 @@ LOCAL_INCLUDES += [
     '/layout/style',
     '/layout/svg',
     '/layout/xul',
     '/netwerk/base',
     '/widget',
     '/xpcom/ds',
 ]
 
-if CONFIG['MOZ_B2G_BT_API_V1']:
+if CONFIG['MOZ_B2G_BT_API_V2']:
     LOCAL_INCLUDES += [
-        '../bluetooth/bluetooth1',
+        '../bluetooth/bluetooth2',
     ]
 else:
     LOCAL_INCLUDES += [
-        '../bluetooth/bluetooth2',
+        '../bluetooth/bluetooth1',
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     LOCAL_INCLUDES += [
         '../fmradio',
         '../system/gonk',
     ]
 
--- a/dom/bindings/moz.build
+++ b/dom/bindings/moz.build
@@ -86,23 +86,23 @@ SOURCES += [
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 if CONFIG['MOZ_AUDIO_CHANNEL_MANAGER']:
     LOCAL_INCLUDES += [
         '/dom/system/gonk',
     ]
 
-if CONFIG['MOZ_B2G_BT_API_V1']:
+if CONFIG['MOZ_B2G_BT_API_V2']:
     LOCAL_INCLUDES += [
-        '/dom/bluetooth/bluetooth1',
+        '/dom/bluetooth/bluetooth2',
     ]
 else:
     LOCAL_INCLUDES += [
-        '/dom/bluetooth/bluetooth2',
+        '/dom/bluetooth/bluetooth1',
     ]
 
 FINAL_LIBRARY = 'xul'
 
 SPHINX_TREES['webidl'] = 'docs'
 SPHINX_PYTHON_PACKAGE_DIRS += ['mozwebidlcodegen']
 
 if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/android', 'xulrunner']:
--- a/dom/bluetooth/BluetoothUtils.cpp
+++ b/dom/bluetooth/BluetoothUtils.cpp
@@ -292,17 +292,17 @@ DispatchReplySuccess(BluetoothReplyRunna
 void
 DispatchReplyError(BluetoothReplyRunnable* aRunnable,
                    const nsAString& aErrorStr)
 {
   MOZ_ASSERT(aRunnable);
   MOZ_ASSERT(!aErrorStr.IsEmpty());
 
   // Reply will be deleted by the runnable after running on main thread
-#ifndef MOZ_B2G_BT_API_V1
+#if MOZ_B2G_BT_API_V2
   BluetoothReply* reply =
     new BluetoothReply(BluetoothReplyError(STATUS_FAIL, nsString(aErrorStr)));
 #else
   BluetoothReply* reply =
     new BluetoothReply(BluetoothReplyError(nsString(aErrorStr)));
 #endif
 
   aRunnable->SetReply(reply); // runnable will delete reply after Run()
@@ -312,17 +312,17 @@ DispatchReplyError(BluetoothReplyRunnabl
 void
 DispatchReplyError(BluetoothReplyRunnable* aRunnable,
                    const enum BluetoothStatus aStatus)
 {
   MOZ_ASSERT(aRunnable);
   MOZ_ASSERT(aStatus != STATUS_SUCCESS);
 
   // Reply will be deleted by the runnable after running on main thread
-#ifndef MOZ_B2G_BT_API_V1
+#if MOZ_B2G_BT_API_V2
   BluetoothReply* reply =
     new BluetoothReply(BluetoothReplyError(aStatus, EmptyString()));
 #else
   BluetoothReply* reply =
     new BluetoothReply(
       BluetoothReplyError(NS_LITERAL_STRING("Internal error")));
 #endif
 
@@ -339,17 +339,17 @@ DispatchStatusChangedEvent(const nsAStri
 
   InfallibleTArray<BluetoothNamedValue> data;
   BT_APPEND_NAMED_VALUE(data, "address", nsString(aAddress));
   BT_APPEND_NAMED_VALUE(data, "status", aStatus);
 
   BluetoothService* bs = BluetoothService::Get();
   NS_ENSURE_TRUE_VOID(bs);
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   bs->DistributeSignal(aType, NS_LITERAL_STRING(KEY_ADAPTER), data);
 #else
   BluetoothSignal signal(nsString(aType), NS_LITERAL_STRING(KEY_ADAPTER), data);
   bs->DistributeSignal(signal);
 #endif
 }
 
 bool
--- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
@@ -1060,17 +1060,17 @@ BluetoothA2dpManager::GetPlayStatusNotif
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
     return;
   }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   bs->DistributeSignal(NS_LITERAL_STRING(REQUEST_MEDIA_PLAYSTATUS_ID),
                        NS_LITERAL_STRING(KEY_ADAPTER));
 #else
   bs->DistributeSignal(
     BluetoothSignal(NS_LITERAL_STRING(REQUEST_MEDIA_PLAYSTATUS_ID),
                     NS_LITERAL_STRING(KEY_ADAPTER),
                     InfallibleTArray<BluetoothNamedValue>()));
 #endif
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ -14,39 +14,39 @@
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.
 */
 
 #include "BluetoothServiceBluedroid.h"
 
 #include "BluetoothA2dpManager.h"
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 #include "BluetoothGattManager.h"
 #else
 // TODO: Support GATT
 #endif
 #include "BluetoothHfpManager.h"
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 #include "BluetoothHidManager.h"
 #else
 // TODO: Support HID
 #endif
 #include "BluetoothOppManager.h"
 #include "BluetoothPbapManager.h"
 #include "BluetoothProfileController.h"
 #include "BluetoothReplyRunnable.h"
 #include "BluetoothUtils.h"
 #include "BluetoothUuid.h"
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
 #include "mozilla/ipc/SocketBase.h"
 #include "mozilla/StaticMutex.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/unused.h"
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 #include "nsDataHashtable.h"
 #endif
 
 #define ENSURE_BLUETOOTH_IS_READY(runnable, result)                    \
   do {                                                                 \
     if (!sBtInterface || !IsEnabled()) {                               \
       DispatchReplyError(runnable,                                     \
         NS_LITERAL_STRING("Bluetooth is not ready"));                  \
@@ -58,17 +58,17 @@
   do {                                                                 \
     if (!sBtInterface || !IsEnabled()) {                               \
       DispatchReplyError(runnable,                                     \
         NS_LITERAL_STRING("Bluetooth is not ready"));                  \
       return;                                                          \
     }                                                                  \
   } while(0)
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 
 #define ENSURE_GATT_MGR_IS_READY_VOID(gatt, runnable)                  \
   do {                                                                 \
     if (!gatt) {                                                       \
       DispatchReplyError(runnable,                                     \
         NS_LITERAL_STRING("GattManager is not ready"));                \
       return;                                                          \
     }                                                                  \
@@ -942,17 +942,17 @@ BluetoothServiceBluedroid::StopInternal(
     BluetoothService::AcknowledgeToggleBt(true);
     BT_LOGR("Error");
   }
 
   return ret;
 }
 #endif
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 nsresult
 BluetoothServiceBluedroid::GetAdaptersInternal(
   BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   /**
    * Wrap BluetoothValue =
@@ -1034,17 +1034,17 @@ public:
   GetRemoteDevicePropertiesResultHandler(const nsAString& aDeviceAddress)
   : mDeviceAddress(aDeviceAddress)
   { }
 
   void OnError(BluetoothStatus aStatus) override
   {
     MOZ_ASSERT(NS_IsMainThread());
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
     BT_WARNING("GetRemoteDeviceProperties(%s) failed: %d",
                NS_ConvertUTF16toUTF8(mDeviceAddress).get(), aStatus);
 
     /* dispatch result after final pending operation */
     if (--sRequestedDeviceCountArray[0] == 0) {
       if (!sGetDeviceRunnableArray.IsEmpty()) {
         DispatchReplyError(sGetDeviceRunnableArray[0],
           NS_LITERAL_STRING("GetRemoteDeviceProperties failed"));
@@ -1078,17 +1078,17 @@ private:
 nsresult
 BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal(
   uint16_t aServiceUuid, BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   BluetoothProfileManagerBase* profile =
     BluetoothUuidHelper::GetBluetoothProfileManager(aServiceUuid);
   if (!profile) {
     DispatchReplyError(aRunnable, NS_LITERAL_STRING(ERR_UNKNOWN_PROFILE));
     return NS_OK;
   }
 
   nsTArray<nsString> deviceAddresses;
@@ -1143,17 +1143,17 @@ BluetoothServiceBluedroid::GetConnectedD
 nsresult
 BluetoothServiceBluedroid::GetPairedDevicePropertiesInternal(
   const nsTArray<nsString>& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   int requestedDeviceCount = aDeviceAddress.Length();
   if (requestedDeviceCount == 0) {
     DispatchReplySuccess(aRunnable);
     return NS_OK;
   }
 #else
   int requestedDeviceCount = aDeviceAddress.Length();
   if (requestedDeviceCount == 0) {
@@ -1177,17 +1177,17 @@ BluetoothServiceBluedroid::GetPairedDevi
 class BluetoothServiceBluedroid::StartDiscoveryResultHandler final
   : public BluetoothResultHandler
 {
 public:
   StartDiscoveryResultHandler(BluetoothReplyRunnable* aRunnable)
   : mRunnable(aRunnable)
   { }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   void OnError(BluetoothStatus aStatus) override
   {
     MOZ_ASSERT(NS_IsMainThread());
     sChangeDiscoveryRunnableArray.RemoveElement(mRunnable);
     DispatchReplyError(mRunnable, aStatus);
   }
 #else
   void StartDiscovery() override
@@ -1209,34 +1209,34 @@ private:
 
 void
 BluetoothServiceBluedroid::StartDiscoveryInternal(
   BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
   ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   sChangeDiscoveryRunnableArray.AppendElement(aRunnable);
 #else
   // Missing in bluetooth1
 #endif
 
   sBtInterface->StartDiscovery(new StartDiscoveryResultHandler(aRunnable));
 }
 
 class BluetoothServiceBluedroid::CancelDiscoveryResultHandler final
   : public BluetoothResultHandler
 {
 public:
   CancelDiscoveryResultHandler(BluetoothReplyRunnable* aRunnable)
   : mRunnable(aRunnable)
   { }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   void OnError(BluetoothStatus aStatus) override
   {
     MOZ_ASSERT(NS_IsMainThread());
     sChangeDiscoveryRunnableArray.RemoveElement(mRunnable);
     DispatchReplyError(mRunnable, aStatus);
   }
 #else
   void CancelDiscovery() override
@@ -1251,17 +1251,17 @@ public:
     ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("StopDiscovery"));
   }
 #endif
 
 private:
   BluetoothReplyRunnable* mRunnable;
 };
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 class BluetoothServiceBluedroid::GetRemoteServicesResultHandler final
   : public BluetoothResultHandler
 {
 public:
   GetRemoteServicesResultHandler(BluetoothReplyRunnable* aRunnable)
   : mRunnable(aRunnable)
   { }
 
@@ -1305,17 +1305,17 @@ BluetoothServiceBluedroid::FetchUuidsInt
 
 void
 BluetoothServiceBluedroid::StopDiscoveryInternal(
   BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
   ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   sChangeDiscoveryRunnableArray.AppendElement(aRunnable);
 #else
   // Missing in bluetooth1
 #endif
 
   sBtInterface->CancelDiscovery(new CancelDiscoveryResultHandler(aRunnable));
 }
 
@@ -1326,17 +1326,17 @@ public:
   SetAdapterPropertyResultHandler(BluetoothReplyRunnable* aRunnable)
   : mRunnable(aRunnable)
   { }
 
   void OnError(BluetoothStatus aStatus) override
   {
     MOZ_ASSERT(NS_IsMainThread());
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
     sSetPropertyRunnableArray.RemoveElement(mRunnable);
     DispatchReplyError(mRunnable, aStatus);
 #else
     ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("SetProperty"));
 #endif
   }
 private:
   BluetoothReplyRunnable* mRunnable;
@@ -1383,17 +1383,17 @@ public:
   CreateBondResultHandler(BluetoothReplyRunnable* aRunnable)
   : mRunnable(aRunnable)
   {
     MOZ_ASSERT(mRunnable);
   }
 
   void OnError(BluetoothStatus aStatus) override
   {
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
     sBondingRunnableArray.RemoveElement(mRunnable);
     DispatchReplyError(mRunnable, aStatus);
 #else
     sBondingRunnableArray.RemoveElement(mRunnable);
     ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("CreatedPairedDevice"));
 #endif
   }
 
@@ -1424,17 +1424,17 @@ public:
   RemoveBondResultHandler(BluetoothReplyRunnable* aRunnable)
   : mRunnable(aRunnable)
   {
     MOZ_ASSERT(mRunnable);
   }
 
   void OnError(BluetoothStatus aStatus) override
   {
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
     sUnbondingRunnableArray.RemoveElement(mRunnable);
     DispatchReplyError(mRunnable, aStatus);
 #else
     sUnbondingRunnableArray.RemoveElement(mRunnable);
     ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("RemoveDevice"));
 #endif
   }
 
@@ -1453,17 +1453,17 @@ BluetoothServiceBluedroid::RemoveDeviceI
   sUnbondingRunnableArray.AppendElement(aRunnable);
 
   sBtInterface->RemoveBond(aDeviceAddress,
                            new RemoveBondResultHandler(aRunnable));
 
   return NS_OK;
 }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 class BluetoothServiceBluedroid::PinReplyResultHandler final
   : public BluetoothResultHandler
 {
 public:
   PinReplyResultHandler(BluetoothReplyRunnable* aRunnable)
   : mRunnable(aRunnable)
   { }
 
@@ -1535,17 +1535,17 @@ BluetoothServiceBluedroid::SetPinCodeInt
 
   sBtInterface->PinReply(aDeviceAddress, true, aPinCode,
     new PinReplyResultHandler(aRunnable));
 
   return true;
 }
 #endif
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 void
 BluetoothServiceBluedroid::SetPasskeyInternal(
   const nsAString& aDeviceAddress, uint32_t aPasskey,
   BluetoothReplyRunnable* aRunnable)
 {
   // Lecagy method used by BlueZ only.
 }
 #else
@@ -1553,17 +1553,17 @@ bool
 BluetoothServiceBluedroid::SetPasskeyInternal(
   const nsAString& aDeviceAddress, uint32_t aPasskey,
   BluetoothReplyRunnable* aRunnable)
 {
   return true;
 }
 #endif
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 class BluetoothServiceBluedroid::SspReplyResultHandler final
   : public BluetoothResultHandler
 {
 public:
   SspReplyResultHandler(BluetoothReplyRunnable* aRunnable)
   : mRunnable(aRunnable)
   { }
 
@@ -1636,17 +1636,17 @@ BluetoothServiceBluedroid::SetPairingCon
 
   sBtInterface->SspReply(aDeviceAddress,
                          SSP_VARIANT_PASSKEY_CONFIRMATION,
                          aConfirm, 0, new SspReplyResultHandler(aRunnable));
   return true;
 }
 #endif
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 // Missing in bluetooth2
 #else
 bool
 BluetoothServiceBluedroid::SetAuthorizationInternal(
   const nsAString& aDeviceAddress, bool aAllow,
   BluetoothReplyRunnable* aRunnable)
 {
   return true;
@@ -1654,17 +1654,17 @@ BluetoothServiceBluedroid::SetAuthorizat
 
 nsresult
 BluetoothServiceBluedroid::PrepareAdapterInternal()
 {
   return NS_OK;
 }
 #endif
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 void
 BluetoothServiceBluedroid::NextBluetoothProfileController()
 #else
 static void
 NextBluetoothProfileController()
 #endif
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -1674,17 +1674,17 @@ NextBluetoothProfileController()
   sControllerArray.RemoveElementAt(0);
 
   // Start the next task if task array is not empty
   if (!sControllerArray.IsEmpty()) {
     sControllerArray[0]->StartSession();
   }
 }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 void
 BluetoothServiceBluedroid::ConnectDisconnect(
   bool aConnect, const nsAString& aDeviceAddress,
   BluetoothReplyRunnable* aRunnable,
   uint16_t aServiceUuid, uint32_t aCod)
 #else
 static void
 ConnectDisconnect(bool aConnect, const nsAString& aDeviceAddress,
@@ -1723,17 +1723,17 @@ BluetoothServiceBluedroid::Connect(const
 void
 BluetoothServiceBluedroid::Disconnect(
   const nsAString& aDeviceAddress, uint16_t aServiceUuid,
   BluetoothReplyRunnable* aRunnable)
 {
   ConnectDisconnect(false, aDeviceAddress, aRunnable, aServiceUuid);
 }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 bool
 BluetoothServiceBluedroid::IsConnected(uint16_t aProfileId)
 {
   return true;
 }
 #else
 void
 BluetoothServiceBluedroid::IsConnected(const uint16_t aServiceUuid,
@@ -1948,17 +1948,17 @@ BluetoothServiceBluedroid::IgnoreWaiting
 {
 }
 
 void
 BluetoothServiceBluedroid::ToggleCalls(BluetoothReplyRunnable* aRunnable)
 {
 }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 // Missing in bluetooth2
 #else
 uint16_t
 BluetoothServiceBluedroid::UuidToServiceClassInt(const BluetoothUuid& mUuid)
 {
   // extract short UUID 0000xxxx-0000-1000-8000-00805f9b34fb
   uint16_t shortUuid;
   memcpy(&shortUuid, mUuid.mUuid + 2, sizeof(uint16_t));
@@ -2057,17 +2057,17 @@ public:
   {
     BT_LOGR("Fail to set: BT_SCAN_MODE_CONNECTABLE");
   }
 };
 
 void
 BluetoothServiceBluedroid::AdapterStateChangedNotification(bool aState)
 {
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   MOZ_ASSERT(NS_IsMainThread());
 
   BT_LOGR("BT_STATE: %d", aState);
 
   sAdapterEnabled = aState;
 
   if (!sAdapterEnabled) {
     static void (* const sDeinitManager[])(BluetoothProfileResultHandler*) = {
@@ -2230,17 +2230,17 @@ BluetoothServiceBluedroid::AdapterStateC
  * BluetoothManager and BluetoothAdapter, do not register observer
  * yet.
  */
 void
 BluetoothServiceBluedroid::AdapterPropertiesNotification(
   BluetoothStatus aStatus, int aNumProperties,
   const BluetoothProperty* aProperties)
 {
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   MOZ_ASSERT(NS_IsMainThread());
 
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
 
   for (int i = 0; i < aNumProperties; i++) {
 
     const BluetoothProperty& p = aProperties[i];
 
@@ -2385,17 +2385,17 @@ BluetoothServiceBluedroid::AdapterProper
  *   (4) as result of GetRemoteDeviceProperties, or
  *   (5) as result of GetRemoteServices.
  */
 void
 BluetoothServiceBluedroid::RemoteDevicePropertiesNotification(
   BluetoothStatus aStatus, const nsAString& aBdAddr,
   int aNumProperties, const BluetoothProperty* aProperties)
 {
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   MOZ_ASSERT(NS_IsMainThread());
 
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
 
   BT_APPEND_NAMED_VALUE(propertiesArray, "Address", nsString(aBdAddr));
 
   for (int i = 0; i < aNumProperties; ++i) {
 
@@ -2591,17 +2591,17 @@ BluetoothServiceBluedroid::RemoteDeviceP
                                    BluetoothValue(props)));
 #endif
 }
 
 void
 BluetoothServiceBluedroid::DeviceFoundNotification(
   int aNumProperties, const BluetoothProperty* aProperties)
 {
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   MOZ_ASSERT(NS_IsMainThread());
 
   BluetoothValue propertyValue;
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
 
   for (int i = 0; i < aNumProperties; i++) {
 
     const BluetoothProperty& p = aProperties[i];
@@ -2679,17 +2679,17 @@ BluetoothServiceBluedroid::DeviceFoundNo
                                    NS_LITERAL_STRING(KEY_ADAPTER),
                                    BluetoothValue(propertiesArray)));
 #endif
 }
 
 void
 BluetoothServiceBluedroid::DiscoveryStateChangedNotification(bool aState)
 {
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   MOZ_ASSERT(NS_IsMainThread());
 
   sAdapterDiscovering = aState;
 
   // Fire PropertyChanged of Discovering
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
   BT_APPEND_NAMED_VALUE(propertiesArray, "Discovering", sAdapterDiscovering);
 
@@ -2722,17 +2722,17 @@ BluetoothServiceBluedroid::DiscoveryStat
 #endif
 }
 
 void
 BluetoothServiceBluedroid::PinRequestNotification(const nsAString& aRemoteBdAddr,
                                                   const nsAString& aBdName,
                                                   uint32_t aCod)
 {
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   MOZ_ASSERT(NS_IsMainThread());
 
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
 
   BT_APPEND_NAMED_VALUE(propertiesArray, "address", nsString(aRemoteBdAddr));
   BT_APPEND_NAMED_VALUE(propertiesArray, "name", nsString(aBdName));
   BT_APPEND_NAMED_VALUE(propertiesArray, "passkey", EmptyString());
   BT_APPEND_NAMED_VALUE(propertiesArray, "type",
@@ -2761,17 +2761,17 @@ BluetoothServiceBluedroid::PinRequestNot
 
 void
 BluetoothServiceBluedroid::SspRequestNotification(
   const nsAString& aRemoteBdAddr, const nsAString& aBdName, uint32_t aCod,
   BluetoothSspVariant aPairingVariant, uint32_t aPassKey)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
   nsAutoString passkey;
   nsAutoString pairingType;
 
   /**
    * Assign pairing request type and passkey based on the pairing variant.
    *
    * passkey value based on pairing request type:
@@ -2821,17 +2821,17 @@ BluetoothServiceBluedroid::SspRequestNot
 #endif
 }
 
 void
 BluetoothServiceBluedroid::BondStateChangedNotification(
   BluetoothStatus aStatus, const nsAString& aRemoteBdAddr,
   BluetoothBondState aState)
 {
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   MOZ_ASSERT(NS_IsMainThread());
 
   if (aState == BOND_STATE_BONDING) {
     // No need to handle bonding state
     return;
   }
 
   BT_LOGR("Bond state: %d status: %d", aState, aStatus);
@@ -3018,17 +3018,17 @@ void
 BluetoothServiceBluedroid::LeTestModeNotification(BluetoothStatus aStatus,
                                                   uint16_t aNumPackets)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // FIXME: This will be implemented in the later patchset
 }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 // TODO: Support EnergyInfoNotification
 #else
 void
 BluetoothServiceBluedroid::EnergyInfoNotification(
   const BluetoothActivityEnergyInfo& aInfo)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -3054,17 +3054,17 @@ BluetoothServiceBluedroid::BackendErrorN
   NS_ENSURE_TRUE_VOID(hfp);
   hfp->HandleBackendError();
   BluetoothA2dpManager* a2dp = BluetoothA2dpManager::Get();
   NS_ENSURE_TRUE_VOID(a2dp);
   a2dp->HandleBackendError();
 
   sIsRestart = true;
   BT_LOGR("Recovery step2: stop bluetooth");
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   StopBluetooth(false, nullptr);
 #else
   StopBluetooth(false);
 #endif
 }
 
 void
 BluetoothServiceBluedroid::CompleteToggleBt(bool aEnabled)
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_bluetooth_bluetoothservicebluedroid_h__
 #define mozilla_dom_bluetooth_bluetoothservicebluedroid_h__
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 
 #include "BluetoothCommon.h"
 #include "BluetoothInterface.h"
 #include "BluetoothService.h"
 
 BEGIN_BLUETOOTH_NAMESPACE
 
 class BluetoothServiceBluedroid : public BluetoothService
--- a/dom/bluetooth/bluez/BluetoothDBusService.cpp
+++ b/dom/bluetooth/bluez/BluetoothDBusService.cpp
@@ -86,17 +86,17 @@ USING_BLUETOOTH_NAMESPACE
 /**
  * To not lock Bluetooth switch button on Settings UI because of any accident,
  * we will force disabling Bluetooth 5 seconds after the user requesting to
  * turn off Bluetooth.
  */
 #define TIMEOUT_FORCE_TO_DISABLE_BT 5
 #define BT_LAZY_THREAD_TIMEOUT_MS 3000
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 // missing on blutooth2
 #else
 // Set Class of Device value bit
 #define SET_AUDIO_BIT(cod) (cod |= 0x200000)
 #define SET_RENDERING_BIT(cod) (cod |= 0x40000)
 #endif
 
 #ifdef MOZ_WIDGET_GONK
@@ -144,17 +144,17 @@ public:
   bool Disable()
   {
     MOZ_ASSERT(!NS_IsMainThread()); // BT thread
 
     if (!IsEnabled()) {
       return true;
     }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
     // TODO: This is the wrong place for handling manager classes
     BluetoothProfileManagerBase* profile;
     profile = BluetoothHfpManager::Get();
     NS_ENSURE_TRUE(profile, false);
     if (profile->IsConnected()) {
       profile->Disconnect(nullptr);
     } else {
       profile->Reset();
@@ -622,17 +622,17 @@ class TryFiringAdapterAddedTask : public
 public:
   void Run() override
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     BluetoothService* bs = BluetoothService::Get();
     NS_ENSURE_TRUE_VOID(bs);
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 // Missing in bluetooth2
 #else
     bs->AdapterAddedReceived();
     bs->TryFiringAdapterAdded();
 #endif
   }
 };
 
@@ -658,17 +658,17 @@ public:
 
     return NS_OK;
   }
 
 private:
   bool mDelay;
 };
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 // Missing in bluetooth2
 #else
 class InternalStopDiscoveryTask : public nsRunnable
 {
   nsresult Run()
   {
     MOZ_ASSERT(NS_IsMainThread());
 
@@ -913,17 +913,17 @@ SinkDisconnectCallback(DBusMessage* aMsg
 }
 
 static bool
 HasAudioService(uint32_t aCodValue)
 {
   return ((aCodValue & 0x200000) == 0x200000);
 }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 static bool
 ContainsIcon(const InfallibleTArray<BluetoothNamedValue>& aProperties)
 {
   for (uint8_t i = 0; i < aProperties.Length(); i++) {
     if (aProperties[i].name().EqualsLiteral("Icon")) {
       return true;
     }
   }
@@ -1777,17 +1777,17 @@ public:
   {
     MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
   }
 
   nsresult Run()
   {
     MOZ_ASSERT(NS_IsMainThread());
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
     BluetoothService* bs = BluetoothService::Get();
     NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
 
     bs->DistributeSignal(NS_LITERAL_STRING(REQUEST_MEDIA_PLAYSTATUS_ID),
                          NS_LITERAL_STRING(KEY_ADAPTER));
 #else
     BluetoothSignal signal(NS_LITERAL_STRING(REQUEST_MEDIA_PLAYSTATUS_ID),
                            NS_LITERAL_STRING(KEY_ADAPTER),
@@ -1881,17 +1881,17 @@ EventFilter(DBusConnection* aConn, DBusM
       // have all of the information to correctly build the device.
       nsAutoString address = NS_ConvertUTF8toUTF16(addr);
       properties.AppendElement(
         BluetoothNamedValue(NS_LITERAL_STRING("Address"), address));
       properties.AppendElement(
         BluetoothNamedValue(NS_LITERAL_STRING("Path"),
                             GetObjectPathFromAddress(signalPath, address)));
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
       if (!ContainsIcon(properties)) {
 #else
       if (FindProperty(properties, "Icon") < 0) {
 #endif
         for (uint32_t i = 0; i < properties.Length(); i++) {
           // It is possible that property Icon missed due to CoD of major
           // class is TOY but service class is "Audio", we need to assign
           // Icon as audio-card. This is for PTS test TC_AG_COD_BV_02_I.
@@ -1903,17 +1903,17 @@ EventFilter(DBusConnection* aConn, DBusM
                 BluetoothNamedValue(NS_LITERAL_STRING("Icon"),
                                     NS_LITERAL_STRING("audio-card")));
             }
             break;
           }
         }
       }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 // Missing in bluetooth2
 #else
       if (FindProperty(properties, "Class") < 0) {
         // Check whether the properties array contains CoD. If it doesn't,
         // fallback to restore CoD value. This usually happens due to NFC
         // directly triggers pairing that makes bluez not update CoD value.
         uint32_t cod = 0;
         int uuidIndex = FindProperty(properties, "UUIDs");
@@ -1982,17 +1982,17 @@ EventFilter(DBusConnection* aConn, DBusM
   } else if (dbus_message_is_signal(aMsg, DBUS_ADAPTER_IFACE,
                                     "PropertyChanged")) {
     ParsePropertyChange(aMsg,
                         v,
                         errorStr,
                         sAdapterProperties,
                         ArrayLength(sAdapterProperties));
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 // Missing in bluetooth2
 #else
     BluetoothNamedValue& property = v.get_ArrayOfBluetoothNamedValue()[0];
     if (property.name().EqualsLiteral("Discovering")) {
       // Special handling when discovery process is stopped by the stack. It
       // does happen when the stack uses Periodic Inquiry instead of Inquiry.
       bool isDiscovering = property.value();
       if (!isDiscovering &&
@@ -2015,17 +2015,17 @@ EventFilter(DBusConnection* aConn, DBusM
     }
 
     BluetoothNamedValue& property = v.get_ArrayOfBluetoothNamedValue()[0];
     if (property.name().EqualsLiteral("Paired")) {
       // Original approach: Broadcast system message of
       // "bluetooth-pairedstatuschanged" from BluetoothService.
       BluetoothValue newValue(v);
       ToLowerCase(newValue.get_ArrayOfBluetoothNamedValue()[0].name());
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
       BluetoothSignal signal(NS_LITERAL_STRING("pairedstatuschanged"),
                              NS_LITERAL_STRING(KEY_LOCAL_AGENT),
                              newValue);
 #else
       BluetoothSignal signal(NS_LITERAL_STRING(PAIRED_STATUS_CHANGED_ID),
                              NS_LITERAL_STRING(KEY_LOCAL_AGENT),
                              newValue);
 #endif
@@ -2289,17 +2289,17 @@ public:
 
     Task* task = new StartDBusConnectionTask(connection);
     DispatchToDBusThread(task);
 
     return NS_OK;
   }
 };
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 nsresult
 BluetoothDBusService::StartInternal(BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(!aRunnable);
 #else
 nsresult
 BluetoothDBusService::StartInternal()
 {
@@ -2424,17 +2424,17 @@ public:
     }
 
     DispatchToDBusThread(new DeleteDBusConnectionTask());
 
     return NS_OK;
   }
 };
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 nsresult
 BluetoothDBusService::StopInternal(BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(!aRunnable);
 #else
 nsresult
 BluetoothDBusService::StopInternal()
 {
@@ -2582,17 +2582,17 @@ public:
 
     unused << handler.forget(); // picked up by callback handler
   }
 
 private:
   nsRefPtr<BluetoothReplyRunnable> mRunnable;
 };
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 nsresult
 BluetoothDBusService::GetAdaptersInternal(BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   /**
    * TODO: implement method GetAdaptersInternal for bluez
    */
@@ -2634,17 +2634,17 @@ OnSendDiscoveryMessageReply(DBusMessage 
   MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
 
   nsAutoString errorStr;
 
   if (!aReply) {
     errorStr.AssignLiteral("SendDiscovery failed");
   }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 // Missing in blueooth2
 #else
   // aData may be a nullptr because we may call StopDiscovery internally when
   // receiving PropertyChanged event of property Discovering from BlueZ.
   //
   // Please see bug 942104 for more details.
   if (!aData) {
     BluetoothSignal signal(NS_LITERAL_STRING(DISCOVERY_STATE_CHANGED_ID),
@@ -2667,17 +2667,17 @@ class SendDiscoveryMessageTask : public 
 {
 public:
   SendDiscoveryMessageTask(const char* aMessageName,
                            BluetoothReplyRunnable* aRunnable)
     : mMessageName(aMessageName)
     , mRunnable(aRunnable)
   {
     MOZ_ASSERT(!mMessageName.IsEmpty());
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
     MOZ_ASSERT(mRunnable);
 #else
     // Missing in bluetooth1
 #endif
   }
 
   void Run() override
   {
@@ -2705,17 +2705,17 @@ private:
 nsresult
 BluetoothDBusService::SendDiscoveryMessage(const char* aMessageName,
                                            BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!sAdapterPath.IsEmpty());
 
   if (!IsReady()) {
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
     NS_NAMED_LITERAL_STRING(errorStr, "Bluetooth service is not ready yet!");
     DispatchBluetoothReply(aRunnable, BluetoothValue(), errorStr);
 #else
     if (aRunnable) {
       NS_NAMED_LITERAL_STRING(errorStr, "Bluetooth service is not ready yet!");
       DispatchBluetoothReply(aRunnable, BluetoothValue(), errorStr);
     }
 #endif
@@ -2905,17 +2905,17 @@ public:
     devicePropertiesArray.AppendElement(
       BluetoothNamedValue(NS_LITERAL_STRING("Path"), mObjectPath));
 
     // It is possible that property Icon missed due to CoD of major
     // class is TOY but service class is "Audio", we need to assign
     // Icon as audio-card. This is for PTS test TC_AG_COD_BV_02_I.
     // As HFP specification defined that
     // service class is "Audio" can be considered as HFP AG.
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
     if (!ContainsIcon(devicePropertiesArray)) {
 #else
     if (FindProperty(devicePropertiesArray, "Icon") < 0) {
 #endif
       for (uint32_t j = 0; j < devicePropertiesArray.Length(); ++j) {
         BluetoothNamedValue& deviceProperty = devicePropertiesArray[j];
         if (deviceProperty.name().EqualsLiteral("Class")) {
           if (HasAudioService(deviceProperty.value().get_uint32_t())) {
@@ -2923,17 +2923,17 @@ public:
               BluetoothNamedValue(NS_LITERAL_STRING("Icon"),
                                   NS_LITERAL_STRING("audio-card")));
           }
           break;
         }
       }
     }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
     // Missing in bluetooth2
 #else
     // Check whether the properties array contains CoD. If it doesn't, fallback to restore
     // CoD value. This usually happens due to NFC directly triggers pairing that
     // makes bluez not update CoD value.
     if (FindProperty(devicePropertiesArray, "Class") < 0) {
       uint32_t cod = 0;
       int uuidIndex = FindProperty(devicePropertiesArray, "UUIDs");
@@ -3106,17 +3106,17 @@ BluetoothDBusService::GetPairedDevicePro
                                                      GetPairedDevicesFilter,
                                                      aRunnable);
   Task* task = new ProcessRemainingDeviceAddressesTask(handler, aRunnable);
   DispatchToDBusThread(task);
 
   return NS_OK;
 }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 nsresult
 BluetoothDBusService::FetchUuidsInternal(const nsAString& aDeviceAddress,
                                          BluetoothReplyRunnable* aRunnable)
 {
   return NS_OK;
 }
 #else
 // missing in bluetooth1
@@ -3491,17 +3491,17 @@ public:
   }
 
 private:
   const nsString mDeviceAddress;
   const nsCString mPinCode;
   nsRefPtr<BluetoothReplyRunnable> mRunnable;
 };
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 void
 BluetoothDBusService::PinReplyInternal(
   const nsAString& aDeviceAddress, bool aAccept,
   const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
 {
   // Legacy interface used by Bluedroid only.
 }
 
@@ -3596,17 +3596,17 @@ public:
   }
 
 private:
   nsString mDeviceAddress;
   uint32_t mPasskey;
   nsRefPtr<BluetoothReplyRunnable> mRunnable;
 };
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 void
 BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress,
                                          uint32_t aPasskey,
                                          BluetoothReplyRunnable* aRunnable)
 {
   Task* task = new SetPasskeyTask(aDeviceAddress,
                                   aPasskey,
                                   aRunnable);
@@ -3622,17 +3622,17 @@ BluetoothDBusService::SetPasskeyInternal
                                   aPasskey,
                                   aRunnable);
   DispatchToDBusThread(task);
 
   return true;
 }
 #endif
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 void
 BluetoothDBusService::SetPairingConfirmationInternal(
                                               const nsAString& aDeviceAddress,
                                               bool aConfirm,
                                               BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -3709,17 +3709,17 @@ BluetoothDBusService::Connect(const nsAS
 void
 BluetoothDBusService::Disconnect(const nsAString& aDeviceAddress,
                                  uint16_t aServiceUuid,
                                  BluetoothReplyRunnable* aRunnable)
 {
   ConnectDisconnect(false, aDeviceAddress, aRunnable, aServiceUuid);
 }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 bool
 BluetoothDBusService::IsConnected(const uint16_t aServiceUuid)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   BluetoothProfileManagerBase* profile =
     BluetoothUuidHelper::GetBluetoothProfileManager(aServiceUuid);
   if (!profile) {
@@ -3782,17 +3782,17 @@ BluetoothDBusService::ToggleCalls(Blueto
 
   DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
 }
 #endif // MOZ_B2G_RIL
 
 class OnUpdateSdpRecordsRunnable : public nsRunnable
 {
 public:
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   OnUpdateSdpRecordsRunnable(const nsAString& aObjectPath,
                              BluetoothProfileManagerBase* aManager)
     : mManager(aManager)
   {
     MOZ_ASSERT(!aObjectPath.IsEmpty());
     MOZ_ASSERT(aManager);
 
     mDeviceAddress = GetAddressFromObjectPath(aObjectPath);
@@ -3813,17 +3813,17 @@ public:
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     mManager->OnUpdateSdpRecords(mDeviceAddress);
 
     return NS_OK;
   }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   // Missing in bluetooth2
 #else
   void
   GetDeviceAddress(nsAString& aRetDeviceAddress)
   {
     aRetDeviceAddress = mDeviceAddress;
   }
 #endif
@@ -4008,17 +4008,17 @@ public:
   }
 
   void Run() override
   {
     MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
     MOZ_ASSERT(sDBusConnection);
     MOZ_ASSERT(!sAdapterPath.IsEmpty());
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
     const nsString objectPath =
       GetObjectPathFromAddress(sAdapterPath, mDeviceAddress);
 
     // I choose to use raw pointer here because this is going to be passed as an
     // argument into SendWithReply() at once.
     OnUpdateSdpRecordsRunnable* callbackRunnable =
       new OnUpdateSdpRecordsRunnable(objectPath, mBluetoothProfileManager);
 
@@ -4050,17 +4050,17 @@ public:
       DBUS_ADAPTER_IFACE,
       "CreateDevice",
       DBUS_TYPE_STRING, &cAddress,
       DBUS_TYPE_INVALID);
 #endif
   }
 
 protected:
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   // Missing in bluetooth2
 #else
   static void CreateDeviceCallback(DBusMessage* aMsg, void* aData)
   {
     MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
 
     nsAutoString errorString;
     OnUpdateSdpRecordsRunnable* r =
@@ -4091,17 +4091,17 @@ protected:
     NS_DispatchToMainThread(r);
   }
 #endif
 
   static void DiscoverServicesCallback(DBusMessage* aMsg, void* aData)
   {
     MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
     nsRefPtr<OnUpdateSdpRecordsRunnable> r(
       static_cast<OnUpdateSdpRecordsRunnable*>(aData));
     NS_DispatchToMainThread(r);
 #else
     nsAutoString errorStr;
 
     if (IsDBusMessageError(aMsg, nullptr, errorStr)) {
       BT_LOGR("%s", NS_ConvertUTF16toUTF8(errorStr).get());
@@ -4119,17 +4119,17 @@ private:
 };
 
 bool
 BluetoothDBusService::UpdateSdpRecords(const nsAString& aDeviceAddress,
                                        BluetoothProfileManagerBase* aManager)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   Task* task = new UpdateSdpRecordsTask(aDeviceAddress, aManager);
   DispatchToDBusThread(task);
 #else
   DispatchToDBusThread(new UpdateSdpRecordsTask(aDeviceAddress, aManager));
 #endif
 
   return true;
 }
@@ -4374,17 +4374,17 @@ BluetoothDBusService::SendMetaData(const
                            NS_LITERAL_STRING(ERR_AVRCP_IS_DISCONNECTED));
     return;
   }
 
   nsAutoString prevTitle, prevAlbum;
   a2dp->GetTitle(prevTitle);
   a2dp->GetAlbum(prevAlbum);
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   uint64_t mediaNumber = static_cast<uint64_t>(aMediaNumber);
   if (mediaNumber != a2dp->GetMediaNumber() ||
       !aTitle.Equals(prevTitle) ||
       !aAlbum.Equals(prevAlbum)) {
     UpdateNotification(ControlEventId::EVENT_TRACK_CHANGED, aMediaNumber);
   }
 #else
   if (aMediaNumber < 0 || (uint64_t)aMediaNumber != a2dp->GetMediaNumber() ||
@@ -4685,17 +4685,17 @@ BluetoothDBusService::UpdateNotification
 
   nsAutoString deviceAddress;
   a2dp->GetAddress(deviceAddress);
 
   Task* task = new UpdateNotificationTask(deviceAddress, aEventId, aData);
   DispatchToDBusThread(task);
 }
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
 void
 BluetoothDBusService::StartLeScanInternal(
   const nsTArray<nsString>& aServiceUuids,
   BluetoothReplyRunnable* aRunnable)
 {
 }
 
 void
--- a/dom/bluetooth/bluez/BluetoothDBusService.h
+++ b/dom/bluetooth/bluez/BluetoothDBusService.h
@@ -42,17 +42,17 @@ public:
     EVENT_UNKNOWN
   };
 
   BluetoothDBusService();
   ~BluetoothDBusService();
 
   bool IsReady();
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   virtual nsresult StartInternal(BluetoothReplyRunnable* aRunnable) override;
 
   virtual nsresult StopInternal(BluetoothReplyRunnable* aRunnable) override;
 
   virtual nsresult
   GetAdaptersInternal(BluetoothReplyRunnable* aRunnable) override;
 
   virtual nsresult
@@ -104,17 +104,17 @@ public:
   CreatePairedDeviceInternal(const nsAString& aDeviceAddress,
                              int aTimeout,
                              BluetoothReplyRunnable* aRunnable) override;
 
   virtual nsresult
   RemoveDeviceInternal(const nsAString& aDeviceObjectPath,
                        BluetoothReplyRunnable* aRunnable) override;
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   virtual void
   PinReplyInternal(const nsAString& aDeviceAddress,
                    bool aAccept,
                    const nsAString& aPinCode,
                    BluetoothReplyRunnable* aRunnable);
 
   virtual void
   SspReplyInternal(const nsAString& aDeviceAddress,
@@ -148,17 +148,17 @@ public:
 #endif
 
   virtual void
   Connect(const nsAString& aDeviceAddress,
           uint32_t aCod,
           uint16_t aServiceUuid,
           BluetoothReplyRunnable* aRunnable) override;
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   virtual bool
   IsConnected(uint16_t aServiceUuid) override;
 #else
   virtual void
   IsConnected(const uint16_t aServiceUuid,
               BluetoothReplyRunnable* aRunnable) override;
 #endif
 
@@ -228,17 +228,17 @@ public:
   virtual nsresult
   SendSinkMessage(const nsAString& aDeviceAddresses,
                   const nsAString& aMessage) override;
 
   virtual nsresult
   SendInputMessage(const nsAString& aDeviceAddresses,
                    const nsAString& aMessage) override;
 
-#ifndef MOZ_B2G_BT_API_V1
+#ifdef MOZ_B2G_BT_API_V2
   virtual void
   StartLeScanInternal(const nsTArray<nsString>& aServiceUuids,
                       BluetoothReplyRunnable* aRunnable) override;
 
   virtual void
   StopLeScanInternal(const nsAString& aAppUuid,
                      BluetoothReplyRunnable* aRunnable) override;
 
--- a/dom/bluetooth/moz.build
+++ b/dom/bluetooth/moz.build
@@ -19,35 +19,17 @@ if CONFIG['MOZ_B2G_BT']:
         'ObexBase.cpp'
     ]
 
     if CONFIG['MOZ_B2G_RIL']:
         SOURCES += [
             'BluetoothRilListener.cpp'
         ]
 
-    if CONFIG['MOZ_B2G_BT_API_V1']:
-        SOURCES += [
-            'bluetooth1/BluetoothAdapter.cpp',
-            'bluetooth1/BluetoothDevice.cpp',
-            'bluetooth1/BluetoothManager.cpp',
-            'bluetooth1/BluetoothProfileController.cpp',
-            'bluetooth1/BluetoothPropertyContainer.cpp',
-            'bluetooth1/BluetoothReplyRunnable.cpp',
-            'bluetooth1/BluetoothService.cpp',
-            'bluetooth1/ipc/BluetoothChild.cpp',
-            'bluetooth1/ipc/BluetoothParent.cpp',
-            'bluetooth1/ipc/BluetoothServiceChildProcess.cpp',
-        ]
-        LOCAL_INCLUDES += [
-            'bluetooth1',
-            'bluetooth1/ipc',
-        ]
-        DEFINES['MOZ_B2G_BT_API_V1'] = True
-    else:
+    if CONFIG['MOZ_B2G_BT_API_V2']:
         SOURCES += [
             'bluetooth2/BluetoothAdapter.cpp',
             'bluetooth2/BluetoothClassOfDevice.cpp',
             'bluetooth2/BluetoothDevice.cpp',
             'bluetooth2/BluetoothDiscoveryHandle.cpp',
             'bluetooth2/BluetoothGatt.cpp',
             'bluetooth2/BluetoothGattCharacteristic.cpp',
             'bluetooth2/BluetoothGattDescriptor.cpp',
@@ -62,16 +44,34 @@ if CONFIG['MOZ_B2G_BT']:
             'bluetooth2/ipc/BluetoothChild.cpp',
             'bluetooth2/ipc/BluetoothParent.cpp',
             'bluetooth2/ipc/BluetoothServiceChildProcess.cpp',
         ]
         LOCAL_INCLUDES += [
             'bluetooth2',
             'bluetooth2/ipc',
         ]
+        DEFINES['MOZ_B2G_BT_API_V2'] = True
+    else:
+        SOURCES += [
+            'bluetooth1/BluetoothAdapter.cpp',
+            'bluetooth1/BluetoothDevice.cpp',
+            'bluetooth1/BluetoothManager.cpp',
+            'bluetooth1/BluetoothProfileController.cpp',
+            'bluetooth1/BluetoothPropertyContainer.cpp',
+            'bluetooth1/BluetoothReplyRunnable.cpp',
+            'bluetooth1/BluetoothService.cpp',
+            'bluetooth1/ipc/BluetoothChild.cpp',
+            'bluetooth1/ipc/BluetoothParent.cpp',
+            'bluetooth1/ipc/BluetoothServiceChildProcess.cpp',
+        ]
+        LOCAL_INCLUDES += [
+            'bluetooth1',
+            'bluetooth1/ipc',
+        ]
 
     #
     # Bluetooth backends
     #
 
     if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
         if CONFIG['MOZ_B2G_BT_BLUEZ']:
             CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
@@ -125,17 +125,17 @@ if CONFIG['MOZ_B2G_BT']:
                 ]
             else:
                 SOURCES += [
                     'bluedroid/hfp-fallback/BluetoothHfpManager.cpp',
                 ]
                 LOCAL_INCLUDES += [
                     'bluedroid/hfp-fallback',
                 ]
-            if not CONFIG['MOZ_B2G_BT_API_V1']:
+            if CONFIG['MOZ_B2G_BT_API_V2']:
                 SOURCES += [
                     'bluedroid/BluetoothGattManager.cpp',
                 ]
 
             DEFINES['MOZ_B2G_BT_BLUEDROID'] = True
             if CONFIG['MOZ_B2G_BT_DAEMON']:
                 DEFINES['MOZ_B2G_BT_DAEMON'] = True
     elif CONFIG['MOZ_ENABLE_DBUS']:
@@ -158,31 +158,17 @@ if CONFIG['MOZ_B2G_BT']:
 #
 # Exported interfaces
 #
 
 EXPORTS.mozilla.dom.bluetooth += [
   'BluetoothCommon.h'
 ]
 
-if CONFIG['MOZ_B2G_BT_API_V1']:
-    EXPORTS.mozilla.dom.bluetooth.ipc += [
-        'bluetooth1/ipc/BluetoothMessageUtils.h',
-    ]
-    EXPORTS.mozilla.dom.bluetooth += [
-        'bluetooth1/BluetoothAdapter.h',
-        'bluetooth1/BluetoothDevice.h',
-        'bluetooth1/BluetoothManager.h',
-    ]
-    IPDL_SOURCES += [
-        'bluetooth1/ipc/BluetoothTypes.ipdlh',
-        'bluetooth1/ipc/PBluetooth.ipdl',
-        'bluetooth1/ipc/PBluetoothRequest.ipdl',
-    ]
-else:
+if CONFIG['MOZ_B2G_BT_API_V2']:
     EXPORTS.mozilla.dom.bluetooth.ipc += [
         'bluetooth2/ipc/BluetoothMessageUtils.h',
     ]
     EXPORTS.mozilla.dom.bluetooth += [
         'bluetooth2/BluetoothAdapter.h',
         'bluetooth2/BluetoothClassOfDevice.h',
         'bluetooth2/BluetoothDevice.h',
         'bluetooth2/BluetoothDiscoveryHandle.h',
@@ -195,16 +181,30 @@ else:
         'bluetooth2/BluetoothPairingHandle.h',
         'bluetooth2/BluetoothPairingListener.h',
     ]
     IPDL_SOURCES += [
         'bluetooth2/ipc/BluetoothTypes.ipdlh',
         'bluetooth2/ipc/PBluetooth.ipdl',
         'bluetooth2/ipc/PBluetoothRequest.ipdl',
     ]
+else:
+    EXPORTS.mozilla.dom.bluetooth.ipc += [
+        'bluetooth1/ipc/BluetoothMessageUtils.h',
+    ]
+    EXPORTS.mozilla.dom.bluetooth += [
+        'bluetooth1/BluetoothAdapter.h',
+        'bluetooth1/BluetoothDevice.h',
+        'bluetooth1/BluetoothManager.h',
+    ]
+    IPDL_SOURCES += [
+        'bluetooth1/ipc/BluetoothTypes.ipdlh',
+        'bluetooth1/ipc/PBluetooth.ipdl',
+        'bluetooth1/ipc/PBluetoothRequest.ipdl',
+    ]
 
 FAIL_ON_WARNINGS = True
 
 LOCAL_INCLUDES += [
     '../base',
     '../network',
     '../system/gonk',
 ]
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -157,26 +157,26 @@ if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_
 DEFINES['BIN_SUFFIX'] = '"%s"' % CONFIG['BIN_SUFFIX']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gonk', 'qt'):
     DEFINES['MOZ_ENABLE_FREETYPE'] = True
 
 if CONFIG['MOZ_TOOLKIT_SEARCH']:
     DEFINES['MOZ_TOOLKIT_SEARCH'] = True
 
-if CONFIG['MOZ_B2G_BT_API_V1']:
+if CONFIG['MOZ_B2G_BT_API_V2']:
+    LOCAL_INCLUDES += [
+        '/dom/bluetooth/bluetooth2',
+        '/dom/bluetooth/bluetooth2/ipc',
+    ]
+else:
     LOCAL_INCLUDES += [
         '/dom/bluetooth/bluetooth1',
         '/dom/bluetooth/bluetooth1/ipc',
     ]
-else:
-    LOCAL_INCLUDES += [
-        '/dom/bluetooth/bluetooth2',
-        '/dom/bluetooth/bluetooth2/ipc',
-    ]
 
 JAR_MANIFESTS += ['jar.mn']
 
 BROWSER_CHROME_MANIFESTS += ['tests/browser.ini']
 MOCHITEST_CHROME_MANIFESTS += ['tests/chrome.ini']
 MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
 
 CXXFLAGS += CONFIG['TK_CFLAGS']
--- a/dom/system/gonk/moz.build
+++ b/dom/system/gonk/moz.build
@@ -120,18 +120,18 @@ include('/ipc/chromium/chromium-config.m
 
 LOCAL_INCLUDES += [
     '/dom/base',
     '/dom/bluetooth',
     '/dom/geolocation',
     '/dom/wifi',
 ]
 
-if CONFIG['MOZ_B2G_BT_API_V1']:
+if CONFIG['MOZ_B2G_BT_API_V2']:
+    LOCAL_INCLUDES += [
+        '/dom/bluetooth/bluetooth2',
+    ]
+else:
     LOCAL_INCLUDES += [
         '/dom/bluetooth/bluetooth1',
     ]
-else:
-    LOCAL_INCLUDES += [
-        '/dom/bluetooth/bluetooth2',
-    ]
 
 FINAL_LIBRARY = 'xul'
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -641,37 +641,37 @@ WEBIDL_FILES += [
 ]
 
 # We only expose our prefable test interfaces in debug builds, just to be on
 # the safe side.
 if CONFIG['MOZ_DEBUG']:
     WEBIDL_FILES += ['TestInterfaceJS.webidl', 'TestInterfaceJSDictionaries.webidl']
 
 if CONFIG['MOZ_B2G_BT']:
-    if CONFIG['MOZ_B2G_BT_API_V1']:
-        WEBIDL_FILES += [
-            'BluetoothAdapter.webidl',
-            'BluetoothDevice.webidl',
-            'BluetoothManager.webidl',
-        ]
-    else:
+    if CONFIG['MOZ_B2G_BT_API_V2']:
         WEBIDL_FILES += [
             'BluetoothAdapter2.webidl',
             'BluetoothClassOfDevice.webidl',
             'BluetoothDevice2.webidl',
             'BluetoothDiscoveryHandle.webidl',
             'BluetoothGatt.webidl',
             'BluetoothGattCharacteristic.webidl',
             'BluetoothGattDescriptor.webidl',
             'BluetoothGattService.webidl',
             'BluetoothLeDeviceEvent.webidl',
             'BluetoothManager2.webidl',
             'BluetoothPairingHandle.webidl',
             'BluetoothPairingListener.webidl',
         ]
+    else:
+        WEBIDL_FILES += [
+            'BluetoothAdapter.webidl',
+            'BluetoothDevice.webidl',
+            'BluetoothManager.webidl',
+        ]
 
 if CONFIG['MOZ_SIMPLEPUSH']:
     WEBIDL_FILES += [
         'SimplePushManager.webidl'
     ]
 else:
     WEBIDL_FILES += [
         'PushEvent.webidl',
@@ -792,27 +792,27 @@ if CONFIG['MOZ_WEBSPEECH']:
 if CONFIG['MOZ_GAMEPAD']:
     GENERATED_EVENTS_WEBIDL_FILES += [
         'GamepadAxisMoveEvent.webidl',
         'GamepadButtonEvent.webidl',
         'GamepadEvent.webidl',
     ]
 
 if CONFIG['MOZ_B2G_BT']:
-    if CONFIG['MOZ_B2G_BT_API_V1']:
-        GENERATED_EVENTS_WEBIDL_FILES += [
-            'BluetoothDiscoveryStateChangedEvent.webidl',
-        ]
-    else:
+    if CONFIG['MOZ_B2G_BT_API_V2']:
         GENERATED_EVENTS_WEBIDL_FILES += [
             'BluetoothAdapterEvent.webidl',
             'BluetoothAttributeEvent.webidl',
             'BluetoothGattCharacteristicEvent.webidl',
             'BluetoothPairingEvent.webidl',
         ]
+    else:
+        GENERATED_EVENTS_WEBIDL_FILES += [
+            'BluetoothDiscoveryStateChangedEvent.webidl',
+        ]
 
     GENERATED_EVENTS_WEBIDL_FILES += [
         'BluetoothDeviceEvent.webidl',
         'BluetoothStatusChangedEvent.webidl',
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     GENERATED_EVENTS_WEBIDL_FILES += [
--- a/js/xpconnect/src/moz.build
+++ b/js/xpconnect/src/moz.build
@@ -68,16 +68,16 @@ LOCAL_INCLUDES += [
     '/layout/style',
     '/xpcom/reflect/xptinfo',
 ]
 
 if CONFIG['MOZ_B2G_BT']:
     LOCAL_INCLUDES += [
         '/dom/bluetooth',
     ]
-    if CONFIG['MOZ_B2G_BT_API_V1']:
+    if CONFIG['MOZ_B2G_BT_API_V2']:
+        LOCAL_INCLUDES += [
+            '/dom/bluetooth/bluetooth2',
+        ]
+    else:
         LOCAL_INCLUDES += [
             '/dom/bluetooth/bluetooth1',
         ]
-    else:
-        LOCAL_INCLUDES += [
-            '/dom/bluetooth/bluetooth2',
-        ]
--- a/layout/build/moz.build
+++ b/layout/build/moz.build
@@ -103,23 +103,23 @@ if CONFIG['MOZ_B2G_FM']:
     LOCAL_INCLUDES += [
         '/dom/fmradio',
     ]
 
 if CONFIG['MOZ_B2G_BT']:
     LOCAL_INCLUDES += [
         '/dom/bluetooth',
     ]
-    if CONFIG['MOZ_B2G_BT_API_V1']:
+    if CONFIG['MOZ_B2G_BT_API_V2']:
         LOCAL_INCLUDES += [
-            '/dom/bluetooth/bluetooth1',
+            '/dom/bluetooth/bluetooth2',
         ]
     else:
         LOCAL_INCLUDES += [
-            '/dom/bluetooth/bluetooth2',
+            '/dom/bluetooth/bluetooth1',
         ]
 
 if CONFIG['MOZ_WEBSPEECH']:
     LOCAL_INCLUDES += [
         '/dom/media/webspeech/synth',
     ]
 
 if CONFIG['MOZ_WEBSPEECH_POCKETSPHINX']: