Bug 1310020 - Remove DOM/bluetooth and related code. r=jst
authorMichelangelo De Simone <mdesimone@mozilla.com>
Fri, 28 Oct 2016 14:25:23 -0700
changeset 320591 f6bc063709dde28c2b6553280fc38dc1df863ea1
parent 320590 101a5b99a05f48fa9eafb8223a1c5dbc9e26b542
child 320592 27695ca9f8cd0f21aa142a2e4ff3a4891f509fa3
push id83436
push userkwierso@gmail.com
push dateThu, 03 Nov 2016 00:31:38 +0000
treeherdermozilla-inbound@227bccbfea15 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs1310020
milestone52.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 1310020 - Remove DOM/bluetooth and related code. r=jst MozReview-Commit-ID: IEhwzzBgb3x
b2g/app/b2g.js
b2g/installer/package-manifest.in
browser/installer/package-manifest.in
dom/apps/PermissionsTable.jsm
dom/base/DOMException.cpp
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/domerr.msg
dom/base/moz.build
dom/bindings/Bindings.conf
dom/bindings/Exceptions.cpp
dom/bindings/moz.build
dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
dom/bluetooth/bluedroid/BluetoothA2dpManager.h
dom/bluetooth/bluedroid/BluetoothAvrcpManager.cpp
dom/bluetooth/bluedroid/BluetoothAvrcpManager.h
dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp
dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
dom/bluetooth/bluedroid/BluetoothDaemonHidInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonHidInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonSetupInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonSetupInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.h
dom/bluetooth/bluedroid/BluetoothGattManager.cpp
dom/bluetooth/bluedroid/BluetoothGattManager.h
dom/bluetooth/bluedroid/BluetoothHidManager.cpp
dom/bluetooth/bluedroid/BluetoothHidManager.h
dom/bluetooth/bluedroid/BluetoothMapBMessage.cpp
dom/bluetooth/bluedroid/BluetoothMapBMessage.h
dom/bluetooth/bluedroid/BluetoothMapFolder.cpp
dom/bluetooth/bluedroid/BluetoothMapFolder.h
dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp
dom/bluetooth/bluedroid/BluetoothMapSmsManager.h
dom/bluetooth/bluedroid/BluetoothOppManager.cpp
dom/bluetooth/bluedroid/BluetoothOppManager.h
dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
dom/bluetooth/bluedroid/BluetoothPbapManager.h
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
dom/bluetooth/bluedroid/BluetoothSocket.cpp
dom/bluetooth/bluedroid/BluetoothSocket.h
dom/bluetooth/bluedroid/BluetoothSocketMessageWatcher.cpp
dom/bluetooth/bluedroid/BluetoothSocketMessageWatcher.h
dom/bluetooth/bluedroid/hfp-fallback/BluetoothHfpManager.cpp
dom/bluetooth/bluedroid/hfp-fallback/BluetoothHfpManager.h
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h
dom/bluetooth/bluez/BluetoothA2dpManager.cpp
dom/bluetooth/bluez/BluetoothA2dpManager.h
dom/bluetooth/bluez/BluetoothAvrcpManager.cpp
dom/bluetooth/bluez/BluetoothAvrcpManager.h
dom/bluetooth/bluez/BluetoothDBusService.cpp
dom/bluetooth/bluez/BluetoothDBusService.h
dom/bluetooth/bluez/BluetoothHfpManager.cpp
dom/bluetooth/bluez/BluetoothHfpManager.h
dom/bluetooth/bluez/BluetoothHidManager.cpp
dom/bluetooth/bluez/BluetoothHidManager.h
dom/bluetooth/bluez/BluetoothOppManager.cpp
dom/bluetooth/bluez/BluetoothOppManager.h
dom/bluetooth/bluez/BluetoothSocket.cpp
dom/bluetooth/bluez/BluetoothSocket.h
dom/bluetooth/bluez/BluetoothUnixSocketConnector.cpp
dom/bluetooth/bluez/BluetoothUnixSocketConnector.h
dom/bluetooth/common/BluetoothCommon.cpp
dom/bluetooth/common/BluetoothCommon.h
dom/bluetooth/common/BluetoothGattReplyRunnable.cpp
dom/bluetooth/common/BluetoothGattReplyRunnable.h
dom/bluetooth/common/BluetoothGattUUIDName.h
dom/bluetooth/common/BluetoothHashKeys.h
dom/bluetooth/common/BluetoothHfpManagerBase.h
dom/bluetooth/common/BluetoothInterface.cpp
dom/bluetooth/common/BluetoothInterface.h
dom/bluetooth/common/BluetoothProfileController.cpp
dom/bluetooth/common/BluetoothProfileController.h
dom/bluetooth/common/BluetoothProfileManagerBase.h
dom/bluetooth/common/BluetoothReplyRunnable.cpp
dom/bluetooth/common/BluetoothReplyRunnable.h
dom/bluetooth/common/BluetoothRilListener.cpp
dom/bluetooth/common/BluetoothRilListener.h
dom/bluetooth/common/BluetoothService.cpp
dom/bluetooth/common/BluetoothService.h
dom/bluetooth/common/BluetoothSocketObserver.h
dom/bluetooth/common/BluetoothUtils.cpp
dom/bluetooth/common/BluetoothUtils.h
dom/bluetooth/common/BluetoothUuidHelper.cpp
dom/bluetooth/common/BluetoothUuidHelper.h
dom/bluetooth/common/ObexBase.cpp
dom/bluetooth/common/ObexBase.h
dom/bluetooth/common/webapi/BluetoothAdapter.cpp
dom/bluetooth/common/webapi/BluetoothAdapter.h
dom/bluetooth/common/webapi/BluetoothClassOfDevice.cpp
dom/bluetooth/common/webapi/BluetoothClassOfDevice.h
dom/bluetooth/common/webapi/BluetoothDevice.cpp
dom/bluetooth/common/webapi/BluetoothDevice.h
dom/bluetooth/common/webapi/BluetoothDiscoveryHandle.cpp
dom/bluetooth/common/webapi/BluetoothDiscoveryHandle.h
dom/bluetooth/common/webapi/BluetoothGatt.cpp
dom/bluetooth/common/webapi/BluetoothGatt.h
dom/bluetooth/common/webapi/BluetoothGattAttributeEvent.cpp
dom/bluetooth/common/webapi/BluetoothGattAttributeEvent.h
dom/bluetooth/common/webapi/BluetoothGattCharacteristic.cpp
dom/bluetooth/common/webapi/BluetoothGattCharacteristic.h
dom/bluetooth/common/webapi/BluetoothGattDescriptor.cpp
dom/bluetooth/common/webapi/BluetoothGattDescriptor.h
dom/bluetooth/common/webapi/BluetoothGattServer.cpp
dom/bluetooth/common/webapi/BluetoothGattServer.h
dom/bluetooth/common/webapi/BluetoothGattService.cpp
dom/bluetooth/common/webapi/BluetoothGattService.h
dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.cpp
dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.h
dom/bluetooth/common/webapi/BluetoothManager.cpp
dom/bluetooth/common/webapi/BluetoothManager.h
dom/bluetooth/common/webapi/BluetoothMapRequestHandle.cpp
dom/bluetooth/common/webapi/BluetoothMapRequestHandle.h
dom/bluetooth/common/webapi/BluetoothObexAuthHandle.cpp
dom/bluetooth/common/webapi/BluetoothObexAuthHandle.h
dom/bluetooth/common/webapi/BluetoothPairingHandle.cpp
dom/bluetooth/common/webapi/BluetoothPairingHandle.h
dom/bluetooth/common/webapi/BluetoothPairingListener.cpp
dom/bluetooth/common/webapi/BluetoothPairingListener.h
dom/bluetooth/common/webapi/BluetoothPbapRequestHandle.cpp
dom/bluetooth/common/webapi/BluetoothPbapRequestHandle.h
dom/bluetooth/common/webapi/BluetoothUUID.cpp
dom/bluetooth/common/webapi/BluetoothUUID.h
dom/bluetooth/ipc/BluetoothChild.cpp
dom/bluetooth/ipc/BluetoothChild.h
dom/bluetooth/ipc/BluetoothMessageUtils.h
dom/bluetooth/ipc/BluetoothParent.cpp
dom/bluetooth/ipc/BluetoothParent.h
dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
dom/bluetooth/ipc/BluetoothServiceChildProcess.h
dom/bluetooth/ipc/BluetoothTypes.ipdlh
dom/bluetooth/ipc/PBluetooth.ipdl
dom/bluetooth/ipc/PBluetoothRequest.ipdl
dom/bluetooth/moz.build
dom/bluetooth/tests/marionette/head.js
dom/bluetooth/tests/marionette/manifest.ini
dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_discovery.js
dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_enable.js
dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_pair.js
dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_setters.js
dom/bluetooth/tests/marionette/test_dom_BluetoothDevice.js
dom/bluetooth/tests/marionette/test_dom_BluetoothManager.js
dom/browser-element/moz.build
dom/events/test/test_all_synthetic_events.html
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/ipc/moz.build
dom/moz.build
dom/permission/moz.build
dom/permission/tests/mochitest-bt.ini
dom/permission/tests/test_bluetooth.html
dom/webidl/BluetoothAdapter.webidl
dom/webidl/BluetoothAdapterEvent.webidl
dom/webidl/BluetoothAttributeEvent.webidl
dom/webidl/BluetoothClassOfDevice.webidl
dom/webidl/BluetoothDevice.webidl
dom/webidl/BluetoothDeviceEvent.webidl
dom/webidl/BluetoothDiscoveryHandle.webidl
dom/webidl/BluetoothGatt.webidl
dom/webidl/BluetoothGattAttributeEvent.webidl
dom/webidl/BluetoothGattCharacteristic.webidl
dom/webidl/BluetoothGattCharacteristicEvent.webidl
dom/webidl/BluetoothGattDescriptor.webidl
dom/webidl/BluetoothGattServer.webidl
dom/webidl/BluetoothGattService.webidl
dom/webidl/BluetoothLeDeviceEvent.webidl
dom/webidl/BluetoothManager.webidl
dom/webidl/BluetoothMapFolderListingEvent.webidl
dom/webidl/BluetoothMapGetMessageEvent.webidl
dom/webidl/BluetoothMapMessageUpdateEvent.webidl
dom/webidl/BluetoothMapMessagesListingEvent.webidl
dom/webidl/BluetoothMapParameters.webidl
dom/webidl/BluetoothMapRequestHandle.webidl
dom/webidl/BluetoothMapSendMessageEvent.webidl
dom/webidl/BluetoothMapSetMessageStatusEvent.webidl
dom/webidl/BluetoothObexAuthEvent.webidl
dom/webidl/BluetoothObexAuthHandle.webidl
dom/webidl/BluetoothPairingEvent.webidl
dom/webidl/BluetoothPairingHandle.webidl
dom/webidl/BluetoothPairingListener.webidl
dom/webidl/BluetoothPbapParameters.webidl
dom/webidl/BluetoothPbapRequestHandle.webidl
dom/webidl/BluetoothPhonebookPullingEvent.webidl
dom/webidl/BluetoothStatusChangedEvent.webidl
dom/webidl/BluetoothUUID.webidl
dom/webidl/BluetoothVCardListingEvent.webidl
dom/webidl/BluetoothVCardPullingEvent.webidl
dom/webidl/Navigator.webidl
dom/webidl/moz.build
ipc/dbus/moz.build
ipc/moz.build
js/xpconnect/src/moz.build
layout/build/moz.build
layout/build/nsLayoutModule.cpp
layout/build/nsLayoutStatics.cpp
old-configure.in
testing/marionette/harness/marionette/tests/webapi-tests.ini
toolkit/library/moz.build
xpcom/base/ErrorList.h
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -995,23 +995,16 @@ pref("dom.webnotifications.serviceworker
 #endif
 
 // Retain at most 10 processes' layers buffers
 pref("layers.compositor-lru-size", 10);
 
 // In B2G by deafult any AudioChannelAgent is muted when created.
 pref("dom.audiochannel.mutedByDefault", true);
 
-// The app origin of bluetooth app, which is responsible for listening pairing
-// requests.
-pref("dom.bluetooth.app-origin", "app://bluetooth.gaiamobile.org");
-
-// Enable W3C WebBluetooth API and disable B2G only GATT client API.
-pref("dom.bluetooth.webbluetooth.enabled", false);
-
 // Default device name for Presentation API
 pref("dom.presentation.device.name", "Firefox OS");
 
 // Enable notification of performance timing
 pref("dom.performance.enable_notify_performance_timing", true);
 
 // Multi-screen
 pref("b2g.multiscreen.chrome_remote_url", "chrome://b2g/content/shell_remote.html");
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -155,19 +155,16 @@
 @RESPATH@/components/dom_workers.xpt
 #ifdef MOZ_WIDGET_GONK
 @RESPATH@/components/dom_wifi.xpt
 @RESPATH@/components/dom_system_gonk.xpt
 #endif
 #ifdef MOZ_B2G_RIL
 @RESPATH@/components/dom_mobileconnection.xpt
 #endif
-#ifdef MOZ_B2G_BT
-@RESPATH@/components/dom_bluetooth.xpt
-#endif
 @RESPATH@/components/dom_canvas.xpt
 @RESPATH@/components/dom_contacts.xpt
 @RESPATH@/components/dom_core.xpt
 @RESPATH@/components/dom_css.xpt
 @RESPATH@/components/dom_events.xpt
 @RESPATH@/components/dom_geolocation.xpt
 @RESPATH@/components/dom_media.xpt
 @RESPATH@/components/dom_network.xpt
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -179,19 +179,16 @@
 @RESPATH@/components/content_xslt.xpt
 @RESPATH@/components/cookie.xpt
 @RESPATH@/components/directory.xpt
 @RESPATH@/components/docshell.xpt
 @RESPATH@/components/dom.xpt
 @RESPATH@/components/dom_apps.xpt
 @RESPATH@/components/dom_base.xpt
 @RESPATH@/components/dom_system.xpt
-#ifdef MOZ_B2G_BT
-@RESPATH@/components/dom_bluetooth.xpt
-#endif
 @RESPATH@/components/dom_canvas.xpt
 @RESPATH@/components/dom_core.xpt
 @RESPATH@/components/dom_css.xpt
 @RESPATH@/components/dom_events.xpt
 @RESPATH@/components/dom_geolocation.xpt
 @RESPATH@/components/dom_media.xpt
 @RESPATH@/components/dom_network.xpt
 @RESPATH@/components/dom_notification.xpt
--- a/dom/apps/PermissionsTable.jsm
+++ b/dom/apps/PermissionsTable.jsm
@@ -131,21 +131,16 @@ this.PermissionsTable =  { geolocation: 
                              privileged: ALLOW_ACTION,
                              certified: ALLOW_ACTION
                            },
                            "browser:embedded-system-app": {
                              app: DENY_ACTION,
                              privileged: DENY_ACTION,
                              certified: ALLOW_ACTION
                            },
-                           bluetooth: {
-                             app: DENY_ACTION,
-                             privileged: DENY_ACTION,
-                             certified: ALLOW_ACTION
-                           },
                            mobileconnection: {
                              app: DENY_ACTION,
                              privileged: DENY_ACTION,
                              certified: ALLOW_ACTION
                            },
                            mobilenetwork: {
                              app: DENY_ACTION,
                              privileged: ALLOW_ACTION,
--- a/dom/base/DOMException.cpp
+++ b/dom/base/DOMException.cpp
@@ -70,29 +70,16 @@ enum DOM4ErrorTypeCodeMap {
   NotReadableError         = 0,
 
   /* FileHandle API errors */
   FileHandleInactiveError = 0,
 
   /* WebCrypto errors https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#dfn-DataError */
   OperationError           = 0,
 
-  /* Bluetooth API errors */
-  BtFailError              = 0,
-  BtNotReadyError          = 0,
-  BtNoMemError             = 0,
-  BtBusyError              = 0,
-  BtDoneError              = 0,
-  BtUnsupportedError       = 0,
-  BtParmInvalidError       = 0,
-  BtUnhandledError         = 0,
-  BtAuthFailureError       = 0,
-  BtRmtDevDownError        = 0,
-  BtAuthRejectedError      = 0,
-
   /* Push API errors */
   NotAllowedError          = 0,
 };
 
 #define DOM4_MSG_DEF(name, message, nsresult) {(nsresult), name, #name, message},
 #define DOM_MSG_DEF(val, message) {(val), NS_ERROR_GET_CODE(val), #val, message},
 
 static const struct ResultStruct
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -74,19 +74,16 @@
 #include "nsStreamUtils.h"
 #include "nsIAppsService.h"
 #include "mozIApplication.h"
 #include "WidgetUtils.h"
 #include "nsIPresentationService.h"
 
 #include "mozilla/dom/MediaDevices.h"
 #include "MediaManager.h"
-#ifdef MOZ_B2G_BT
-#include "BluetoothManager.h"
-#endif
 
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
 #include "AudioChannelManager.h"
 #endif
 
 #include "nsIDOMGlobalPropertyInitializer.h"
 #include "nsJSUtils.h"
 
@@ -216,19 +213,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPowerManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIccManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInputPortManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConnection)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStorageManager)
 #ifdef MOZ_B2G_RIL
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileConnections)
 #endif
-#ifdef MOZ_B2G_BT
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBluetooth)
-#endif
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioChannelManager)
 #endif
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaDevices)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTimeManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mServiceWorkerContainer)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
@@ -299,22 +293,16 @@ Navigator::Invalidate()
   }
 
 #ifdef MOZ_B2G_RIL
   if (mMobileConnections) {
     mMobileConnections = nullptr;
   }
 #endif
 
-#ifdef MOZ_B2G_BT
-  if (mBluetooth) {
-    mBluetooth = nullptr;
-  }
-#endif
-
   mMediaDevices = nullptr;
 
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   if (mAudioChannelManager) {
     mAudioChannelManager = nullptr;
   }
 #endif
 
@@ -1795,32 +1783,16 @@ Navigator::GetConnection(ErrorResult& aR
       return nullptr;
     }
     mConnection = new network::Connection(mWindow);
   }
 
   return mConnection;
 }
 
-#ifdef MOZ_B2G_BT
-bluetooth::BluetoothManager*
-Navigator::GetMozBluetooth(ErrorResult& aRv)
-{
-  if (!mBluetooth) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
-    mBluetooth = bluetooth::BluetoothManager::Create(mWindow);
-  }
-
-  return mBluetooth;
-}
-#endif //MOZ_B2G_BT
-
 #ifdef MOZ_TIME_MANAGER
 time::TimeManager*
 Navigator::GetMozTime(ErrorResult& aRv)
 {
   if (!mWindow) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -67,22 +67,16 @@ class GamepadServiceTest;
 class NavigatorUserMediaSuccessCallback;
 class NavigatorUserMediaErrorCallback;
 class MozGetUserMediaDevicesSuccessCallback;
 
 namespace network {
 class Connection;
 } // namespace network
 
-#ifdef MOZ_B2G_BT
-namespace bluetooth {
-class BluetoothManager;
-} // namespace bluetooth
-#endif // MOZ_B2G_BT
-
 #ifdef MOZ_B2G_RIL
 class MobileConnectionArray;
 #endif
 
 class PowerManager;
 class IccManager;
 class InputPortManager;
 class DeviceStorageAreaListener;
@@ -230,19 +224,16 @@ public:
   MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv);
 #endif // MOZ_B2G_RIL
 #ifdef MOZ_GAMEPAD
   void GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
   GamepadServiceTest* RequestGamepadServiceTest();
 #endif // MOZ_GAMEPAD
   already_AddRefed<Promise> GetVRDisplays(ErrorResult& aRv);
   void GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const;
-#ifdef MOZ_B2G_BT
-  bluetooth::BluetoothManager* GetMozBluetooth(ErrorResult& aRv);
-#endif // MOZ_B2G_BT
 #ifdef MOZ_TIME_MANAGER
   time::TimeManager* GetMozTime(ErrorResult& aRv);
 #endif // MOZ_TIME_MANAGER
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   system::AudioChannelManager* GetMozAudioChannelManager(ErrorResult& aRv);
 #endif // MOZ_AUDIO_CHANNEL_MANAGER
 
   Presentation* GetPresentation(ErrorResult& aRv);
@@ -321,19 +312,16 @@ private:
   RefPtr<Promise> mBatteryPromise;
   RefPtr<PowerManager> mPowerManager;
   RefPtr<IccManager> mIccManager;
   RefPtr<InputPortManager> mInputPortManager;
   RefPtr<network::Connection> mConnection;
 #ifdef MOZ_B2G_RIL
   RefPtr<MobileConnectionArray> mMobileConnections;
 #endif
-#ifdef MOZ_B2G_BT
-  RefPtr<bluetooth::BluetoothManager> mBluetooth;
-#endif
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   RefPtr<system::AudioChannelManager> mAudioChannelManager;
 #endif
   RefPtr<MediaDevices> mMediaDevices;
   nsTArray<nsWeakPtr> mDeviceStorageStores;
   RefPtr<time::TimeManager> mTimeManager;
   RefPtr<ServiceWorkerContainer> mServiceWorkerContainer;
   nsCOMPtr<nsPIDOMWindowInner> mWindow;
--- a/dom/base/domerr.msg
+++ b/dom/base/domerr.msg
@@ -98,29 +98,16 @@ DOM_MSG_DEF(NS_ERROR_DOM_PROP_ACCESS_DEN
 DOM_MSG_DEF(NS_ERROR_DOM_XPCONNECT_ACCESS_DENIED, "Access to XPConnect service denied")
 DOM_MSG_DEF(NS_ERROR_DOM_BAD_URI, "Access to restricted URI denied")
 DOM_MSG_DEF(NS_ERROR_DOM_RETVAL_UNDEFINED, "Return value is undefined")
 DOM_MSG_DEF(NS_ERROR_DOM_QUOTA_REACHED, "Persistent storage maximum size reached")
 
 DOM4_MSG_DEF(NotFoundError, "File was not found", NS_ERROR_DOM_FILE_NOT_FOUND_ERR)
 DOM4_MSG_DEF(NotReadableError, "File could not be read", NS_ERROR_DOM_FILE_NOT_READABLE_ERR)
 
-/* Non-standard Bluetooth DOM errors. */
-DOM4_MSG_DEF(BtFailError,         "Fail",  NS_ERROR_DOM_BLUETOOTH_FAIL)
-DOM4_MSG_DEF(BtNotReadyError,     "Not ready",  NS_ERROR_DOM_BLUETOOTH_NOT_READY)
-DOM4_MSG_DEF(BtNoMemError,        "No memory",  NS_ERROR_DOM_BLUETOOTH_NOMEM)
-DOM4_MSG_DEF(BtBusyError,         "Device busy with another command",  NS_ERROR_DOM_BLUETOOTH_BUSY)
-DOM4_MSG_DEF(BtDoneError,         "Request already done",  NS_ERROR_DOM_BLUETOOTH_DONE)
-DOM4_MSG_DEF(BtUnsupportedError,  "Unsupported",  NS_ERROR_DOM_BLUETOOTH_UNSUPPORTED)
-DOM4_MSG_DEF(BtParmInvalidError,  "Invalid parameter",  NS_ERROR_DOM_BLUETOOTH_PARM_INVALID)
-DOM4_MSG_DEF(BtUnhandledError,    "Unhandled",  NS_ERROR_DOM_BLUETOOTH_UNHANDLED)
-DOM4_MSG_DEF(BtAuthFailureError,  "Authentication failure",  NS_ERROR_DOM_BLUETOOTH_AUTH_FAILURE)
-DOM4_MSG_DEF(BtRmtDevDownError,   "Remote device down",  NS_ERROR_DOM_BLUETOOTH_RMT_DEV_DOWN)
-DOM4_MSG_DEF(BtAuthRejectedError, "Authentication rejected",  NS_ERROR_DOM_BLUETOOTH_AUTH_REJECTED)
-
 /* Web Animations errors */
 
 DOM4_MSG_DEF(NotSupportedError, "Animation to or from an underlying value is not yet supported.", NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR)
 
 /* common global codes (from nsError.h) */
 
 DOM_MSG_DEF(NS_OK                                  , "Success")
 DOM_MSG_DEF(NS_ERROR_NOT_INITIALIZED               , "Component not initialized")
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -414,18 +414,16 @@ if CONFIG['MOZ_BUILD_APP'] != 'mobile/an
 
 EXTRA_JS_MODULES += [
     'DOMRequestHelper.jsm',
     'IndexedDBHelper.jsm',
 ]
 
 LOCAL_INCLUDES += [
     '../battery',
-    '../bluetooth/common',
-    '../bluetooth/common/webapi',
     '../events',
     '../media',
     '../network',
     '../time',
     '/caps',
     '/docshell/base',
     '/dom/base',
     '/dom/geolocation',
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -102,85 +102,16 @@ DOMInterfaces = {
     'headerFile': 'mozilla/dom/File.h',
 },
 
 'BatteryManager': {
     'nativeType': 'mozilla::dom::battery::BatteryManager',
     'headerFile': 'BatteryManager.h'
 },
 
-'BluetoothAdapter': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothAdapter',
-},
-
-'BluetoothClassOfDevice': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothClassOfDevice',
-},
-
-'BluetoothDevice': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothDevice',
-},
-
-'BluetoothDiscoveryHandle': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothDiscoveryHandle',
-},
-
-'BluetoothGatt': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothGatt',
-},
-
-'BluetoothGattAttributeEvent': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothGattAttributeEvent',
-},
-
-'BluetoothGattCharacteristic': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothGattCharacteristic',
-},
-
-'BluetoothGattDescriptor': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothGattDescriptor',
-},
-
-'BluetoothGattServer': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothGattServer',
-},
-
-'BluetoothGattService': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothGattService',
-},
-
-'BluetoothLeDeviceEvent': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothLeDeviceEvent',
-},
-
-'BluetoothManager': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothManager',
-},
-
-'BluetoothObexAuthHandle': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothObexAuthHandle',
-},
-
-'BluetoothPairingHandle': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothPairingHandle',
-},
-
-'BluetoothPairingListener': {
-    'nativeType':
-      'mozilla::dom::bluetooth::BluetoothPairingListener',
-},
-
-'BluetoothPbapRequestHandle': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothPbapRequestHandle',
-},
-
-'BluetoothMapRequestHandle': {
-    'nativeType': 'mozilla::dom::bluetooth::BluetoothMapRequestHandle',
-},
-
 'BoxObject': {
     'resultNotAddRefed': ['element'],
 },
 
 'Cache': {
     'implicitJSContext': [ 'add', 'addAll' ],
     'nativeType': 'mozilla::dom::cache::Cache',
 },
--- a/dom/bindings/Exceptions.cpp
+++ b/dom/bindings/Exceptions.cpp
@@ -188,17 +188,16 @@ CreateException(JSContext* aCx, nsresult
 {
   // Do we use DOM exceptions for this error code?
   switch (NS_ERROR_GET_MODULE(aRv)) {
   case NS_ERROR_MODULE_DOM:
   case NS_ERROR_MODULE_SVG:
   case NS_ERROR_MODULE_DOM_XPATH:
   case NS_ERROR_MODULE_DOM_INDEXEDDB:
   case NS_ERROR_MODULE_DOM_FILEHANDLE:
-  case NS_ERROR_MODULE_DOM_BLUETOOTH:
   case NS_ERROR_MODULE_DOM_ANIM:
   case NS_ERROR_MODULE_DOM_PUSH:
   case NS_ERROR_MODULE_DOM_MEDIA:
     if (aMessage.IsEmpty()) {
       return DOMException::Create(aRv);
     }
     return DOMException::Create(aRv, aMessage);
   default:
--- a/dom/bindings/moz.build
+++ b/dom/bindings/moz.build
@@ -54,17 +54,16 @@ EXPORTS.mozilla.dom += [
 # Bug 932082 tracks.
 LOCAL_INCLUDES += [
     '!/dist/include/mozilla/dom',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/base',
     '/dom/battery',
-    '/dom/bluetooth/common/webapi',
     '/dom/canvas',
     '/dom/geolocation',
     '/dom/html',
     '/dom/indexedDB',
     '/dom/media/webaudio',
     '/dom/media/webspeech/recognition',
     '/dom/svg',
     '/dom/workers',
deleted file mode 100644
--- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
+++ /dev/null
@@ -1,779 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "base/basictypes.h"
-
-#include "BluetoothA2dpManager.h"
-#include "BluetoothCommon.h"
-#include "BluetoothService.h"
-#include "BluetoothSocket.h"
-#include "BluetoothUtils.h"
-
-#include "mozilla/dom/bluetooth/BluetoothTypes.h"
-#include "mozilla/Services.h"
-#include "mozilla/StaticPtr.h"
-#include "MainThreadUtils.h"
-#include "nsIObserverService.h"
-#include "nsThreadUtils.h"
-
-using namespace mozilla;
-USING_BLUETOOTH_NAMESPACE
-// AVRC_ID op code follows bluedroid avrc_defs.h
-#define AVRC_ID_REWIND  0x48
-#define AVRC_ID_FAST_FOR 0x49
-#define AVRC_KEY_PRESS_STATE  1
-#define AVRC_KEY_RELEASE_STATE  0
-// bluedroid bt_rc.h
-#define AVRC_MAX_ATTR_STR_LEN 255
-
-namespace {
-  StaticRefPtr<BluetoothA2dpManager> sBluetoothA2dpManager;
-  bool sInShutdown = false;
-  static BluetoothA2dpInterface* sBtA2dpInterface;
-} // namespace
-
-const int BluetoothA2dpManager::MAX_NUM_CLIENTS = 1;
-
-NS_IMETHODIMP
-BluetoothA2dpManager::Observe(nsISupports* aSubject,
-                              const char* aTopic,
-                              const char16_t* aData)
-{
-  MOZ_ASSERT(sBluetoothA2dpManager);
-
-  if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
-    HandleShutdown();
-    return NS_OK;
-  }
-
-  MOZ_ASSERT(false, "BluetoothA2dpManager got unexpected topic!");
-  return NS_ERROR_UNEXPECTED;
-}
-
-BluetoothA2dpManager::BluetoothA2dpManager()
-{
-  Reset();
-}
-
-void
-BluetoothA2dpManager::Reset()
-{
-  mA2dpConnected = false;
-  mSinkState = SinkState::SINK_DISCONNECTED;
-  mController = nullptr;
-}
-
-static void
-AvStatusToSinkString(BluetoothA2dpConnectionState aState, nsAString& aString)
-{
-  switch (aState) {
-    case A2DP_CONNECTION_STATE_DISCONNECTED:
-      aString.AssignLiteral("disconnected");
-      break;
-    case A2DP_CONNECTION_STATE_CONNECTING:
-      aString.AssignLiteral("connecting");
-      break;
-    case A2DP_CONNECTION_STATE_CONNECTED:
-      aString.AssignLiteral("connected");
-      break;
-    case A2DP_CONNECTION_STATE_DISCONNECTING:
-      aString.AssignLiteral("disconnecting");
-      break;
-    default:
-      BT_WARNING("Unknown sink state %d", static_cast<int>(aState));
-      return;
-  }
-}
-
-class BluetoothA2dpManager::RegisterModuleResultHandler final
-  : public BluetoothSetupResultHandler
-{
-public:
-  RegisterModuleResultHandler(BluetoothA2dpInterface* aInterface,
-                              BluetoothProfileResultHandler* aRes)
-    : mInterface(aInterface)
-    , mRes(aRes)
-  { }
-
-  void OnError(BluetoothStatus aStatus) override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    BT_WARNING("BluetoothSetupInterface::RegisterModule failed for A2DP: %d",
-               (int)aStatus);
-
-    mInterface->SetNotificationHandler(nullptr);
-
-    if (mRes) {
-      mRes->OnError(NS_ERROR_FAILURE);
-    }
-  }
-
-  void RegisterModule() override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    sBtA2dpInterface = mInterface;
-
-    if (mRes) {
-      mRes->Init();
-    }
-  }
-
-private:
-  BluetoothA2dpInterface* mInterface;
-  RefPtr<BluetoothProfileResultHandler> mRes;
-};
-
-class BluetoothA2dpManager::InitProfileResultHandlerRunnable final
-  : public Runnable
-{
-public:
-  InitProfileResultHandlerRunnable(BluetoothProfileResultHandler* aRes,
-                                   nsresult aRv)
-    : mRes(aRes)
-    , mRv(aRv)
-  {
-    MOZ_ASSERT(mRes);
-  }
-
-  NS_IMETHOD Run() override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    if (NS_SUCCEEDED(mRv)) {
-      mRes->Init();
-    } else {
-      mRes->OnError(mRv);
-    }
-    return NS_OK;
-  }
-
-private:
-  RefPtr<BluetoothProfileResultHandler> mRes;
-  nsresult mRv;
-};
-
-/*
- * This function will be only called when Bluetooth is turning on.
- * It is important to register a2dp callbacks before enable() gets called.
- * It is required to register a2dp callbacks before a2dp media task
- * starts up.
- */
-// static
-void
-BluetoothA2dpManager::InitA2dpInterface(BluetoothProfileResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (sBtA2dpInterface) {
-    BT_LOGR("Bluetooth A2DP interface is already initalized.");
-    RefPtr<Runnable> r =
-      new InitProfileResultHandlerRunnable(aRes, NS_OK);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch A2DP Init runnable");
-    }
-    return;
-  }
-
-  auto btInf = BluetoothInterface::GetInstance();
-
-  if (NS_WARN_IF(!btInf)) {
-    // If there's no Bluetooth interface, we dispatch a runnable
-    // that calls the profile result handler.
-    RefPtr<Runnable> r =
-      new InitProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch A2DP OnError runnable");
-    }
-    return;
-  }
-
-  auto setupInterface = btInf->GetBluetoothSetupInterface();
-
-  if (NS_WARN_IF(!setupInterface)) {
-    // If there's no Setup interface, we dispatch a runnable
-    // that calls the profile result handler.
-    RefPtr<Runnable> r =
-      new InitProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch A2DP OnError runnable");
-    }
-    return;
-  }
-
-  auto a2dpInterface = btInf->GetBluetoothA2dpInterface();
-
-  if (NS_WARN_IF(!a2dpInterface)) {
-    // If there's no A2DP interface, we dispatch a runnable
-    // that calls the profile result handler.
-    RefPtr<Runnable> r =
-      new InitProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch A2DP OnError runnable");
-    }
-    return;
-  }
-
-  // Set notification handler _before_ registering the module. It could
-  // happen that we receive notifications, before the result handler runs.
-  a2dpInterface->SetNotificationHandler(BluetoothA2dpManager::Get());
-
-  setupInterface->RegisterModule(
-    SETUP_SERVICE_ID_A2DP, 0, MAX_NUM_CLIENTS,
-    new RegisterModuleResultHandler(a2dpInterface, aRes));
-}
-
-BluetoothA2dpManager::~BluetoothA2dpManager()
-{ }
-
-void
-BluetoothA2dpManager::Uninit()
-{
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-  NS_ENSURE_TRUE_VOID(obs);
-  if (NS_FAILED(obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID))) {
-    BT_WARNING("Failed to remove shutdown observer!");
-  }
-}
-
-/*
- * Static functions
- */
-
-static BluetoothA2dpManager::SinkState
-StatusStringToSinkState(const nsAString& aStatus)
-{
-  BluetoothA2dpManager::SinkState state =
-    BluetoothA2dpManager::SinkState::SINK_UNKNOWN;
-  if (aStatus.EqualsLiteral("disconnected")) {
-    state = BluetoothA2dpManager::SinkState::SINK_DISCONNECTED;
-  } else if (aStatus.EqualsLiteral("connecting")) {
-    state = BluetoothA2dpManager::SinkState::SINK_CONNECTING;
-  } else if (aStatus.EqualsLiteral("connected")) {
-    state = BluetoothA2dpManager::SinkState::SINK_CONNECTED;
-  } else if (aStatus.EqualsLiteral("playing")) {
-    state = BluetoothA2dpManager::SinkState::SINK_PLAYING;
-  } else {
-    BT_WARNING("Unknown sink state");
-  }
-  return state;
-}
-
-//static
-BluetoothA2dpManager*
-BluetoothA2dpManager::Get()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // If sBluetoothA2dpManager already exists, exit early
-  if (sBluetoothA2dpManager) {
-    return sBluetoothA2dpManager;
-  }
-
-  // If we're in shutdown, don't create a new instance
-  NS_ENSURE_FALSE(sInShutdown, nullptr);
-
-  // Create a new instance and return
-  sBluetoothA2dpManager = new BluetoothA2dpManager();
-
-  return sBluetoothA2dpManager;
-}
-
-class BluetoothA2dpManager::UnregisterModuleResultHandler final
-  : public BluetoothSetupResultHandler
-{
-public:
-  UnregisterModuleResultHandler(BluetoothProfileResultHandler* aRes)
-    : mRes(aRes)
-  { }
-
-  void OnError(BluetoothStatus aStatus) override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    BT_WARNING("BluetoothSetupInterface::UnregisterModule failed for A2DP: %d",
-               (int)aStatus);
-
-    sBtA2dpInterface->SetNotificationHandler(nullptr);
-    sBtA2dpInterface = nullptr;
-
-    sBluetoothA2dpManager->Uninit();
-    sBluetoothA2dpManager = nullptr;
-
-    if (mRes) {
-      mRes->OnError(NS_ERROR_FAILURE);
-    }
-  }
-
-  void UnregisterModule() override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    sBtA2dpInterface->SetNotificationHandler(nullptr);
-    sBtA2dpInterface = nullptr;
-
-    sBluetoothA2dpManager->Uninit();
-    sBluetoothA2dpManager = nullptr;
-
-    if (mRes) {
-      mRes->Deinit();
-    }
-  }
-
-private:
-  RefPtr<BluetoothProfileResultHandler> mRes;
-};
-
-class BluetoothA2dpManager::DeinitProfileResultHandlerRunnable final
-  : public Runnable
-{
-public:
-  DeinitProfileResultHandlerRunnable(BluetoothProfileResultHandler* aRes,
-                                     nsresult aRv)
-    : mRes(aRes)
-    , mRv(aRv)
-  {
-    MOZ_ASSERT(mRes);
-  }
-
-  NS_IMETHOD Run() override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    if (NS_SUCCEEDED(mRv)) {
-      mRes->Deinit();
-    } else {
-      mRes->OnError(mRv);
-    }
-    return NS_OK;
-  }
-
-private:
-  RefPtr<BluetoothProfileResultHandler> mRes;
-  nsresult mRv;
-};
-
-// static
-void
-BluetoothA2dpManager::DeinitA2dpInterface(BluetoothProfileResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!sBtA2dpInterface) {
-    BT_LOGR("Bluetooth A2DP interface has not been initalized.");
-    RefPtr<Runnable> r =
-      new DeinitProfileResultHandlerRunnable(aRes, NS_OK);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch A2DP Deinit runnable");
-    }
-    return;
-  }
-
-  auto btInf = BluetoothInterface::GetInstance();
-
-  if (NS_WARN_IF(!btInf)) {
-    // If there's no backend interface, we dispatch a runnable
-    // that calls the profile result handler.
-    RefPtr<Runnable> r =
-      new DeinitProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch A2DP OnError runnable");
-    }
-    return;
-  }
-
-  auto setupInterface = btInf->GetBluetoothSetupInterface();
-
-  if (NS_WARN_IF(!setupInterface)) {
-    // If there's no Setup interface, we dispatch a runnable
-    // that calls the profile result handler.
-    RefPtr<Runnable> r =
-      new DeinitProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch A2DP OnError runnable");
-    }
-    return;
-  }
-
-  setupInterface->UnregisterModule(
-    SETUP_SERVICE_ID_A2DP,
-    new UnregisterModuleResultHandler(aRes));
-}
-
-void
-BluetoothA2dpManager::HandleShutdown()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  sInShutdown = true;
-  Disconnect(nullptr);
-  sBluetoothA2dpManager = nullptr;
-}
-
-void
-BluetoothA2dpManager::OnConnectError()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  mController->NotifyCompletion(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
-
-  mController = nullptr;
-  mDeviceAddress.Clear();
-}
-
-class BluetoothA2dpManager::ConnectResultHandler final
-  : public BluetoothA2dpResultHandler
-{
-public:
-  void OnError(BluetoothStatus aStatus) override
-  {
-    BT_LOGR("BluetoothA2dpInterface::Connect failed: %d", (int)aStatus);
-
-    NS_ENSURE_TRUE_VOID(sBluetoothA2dpManager);
-    sBluetoothA2dpManager->OnConnectError();
-  }
-};
-
-void
-BluetoothA2dpManager::Connect(const BluetoothAddress& aDeviceAddress,
-                              BluetoothProfileController* aController)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(!aDeviceAddress.IsCleared());
-  MOZ_ASSERT(aController);
-
-  BluetoothService* bs = BluetoothService::Get();
-  if (!bs || sInShutdown) {
-    aController->NotifyCompletion(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
-    return;
-  }
-
-  if (mA2dpConnected) {
-    aController->NotifyCompletion(NS_LITERAL_STRING(ERR_ALREADY_CONNECTED));
-    return;
-  }
-
-  mDeviceAddress = aDeviceAddress;
-  mController = aController;
-
-  if (!sBtA2dpInterface) {
-    BT_LOGR("sBluetoothA2dpInterface is null");
-    aController->NotifyCompletion(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
-    return;
-  }
-
-  sBtA2dpInterface->Connect(mDeviceAddress, new ConnectResultHandler());
-}
-
-void
-BluetoothA2dpManager::OnDisconnectError()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  NS_ENSURE_TRUE_VOID(mController);
-
-  mController->NotifyCompletion(NS_LITERAL_STRING(ERR_DISCONNECTION_FAILED));
-}
-
-class BluetoothA2dpManager::DisconnectResultHandler final
-  : public BluetoothA2dpResultHandler
-{
-public:
-  void OnError(BluetoothStatus aStatus) override
-  {
-    BT_LOGR("BluetoothA2dpInterface::Disconnect failed: %d", (int)aStatus);
-
-    NS_ENSURE_TRUE_VOID(sBluetoothA2dpManager);
-    sBluetoothA2dpManager->OnDisconnectError();
-  }
-};
-
-void
-BluetoothA2dpManager::Disconnect(BluetoothProfileController* aController)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(!mController);
-
-  BluetoothService* bs = BluetoothService::Get();
-  if (!bs) {
-    if (aController) {
-      aController->NotifyCompletion(
-        NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
-    }
-    return;
-  }
-
-  if (!mA2dpConnected) {
-    if (aController) {
-      aController->NotifyCompletion(
-        NS_LITERAL_STRING(ERR_ALREADY_DISCONNECTED));
-    }
-    return;
-  }
-
-  MOZ_ASSERT(!mDeviceAddress.IsCleared());
-
-  mController = aController;
-
-  if (!sBtA2dpInterface) {
-    BT_LOGR("sBluetoothA2dpInterface is null");
-    if (aController) {
-      aController->NotifyCompletion(
-        NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
-    }
-    return;
-  }
-
-  sBtA2dpInterface->Disconnect(mDeviceAddress, new DisconnectResultHandler());
-}
-
-void
-BluetoothA2dpManager::OnConnect(const nsAString& aErrorStr)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  /**
-   * On the one hand, notify the controller that we've done for outbound
-   * connections. On the other hand, we do nothing for inbound connections.
-   */
-  NS_ENSURE_TRUE_VOID(mController);
-
-  RefPtr<BluetoothProfileController> controller = mController.forget();
-  controller->NotifyCompletion(aErrorStr);
-}
-
-void
-BluetoothA2dpManager::OnDisconnect(const nsAString& aErrorStr)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  /**
-   * On the one hand, notify the controller that we've done for outbound
-   * connections. On the other hand, we do nothing for inbound connections.
-   */
-  NS_ENSURE_TRUE_VOID(mController);
-
-  RefPtr<BluetoothProfileController> controller = mController.forget();
-  controller->NotifyCompletion(aErrorStr);
-
-  Reset();
-}
-
-/* HandleSinkPropertyChanged update sink state in A2dp
- *
- * Possible values: "disconnected", "connecting", "connected", "playing"
- *
- * 1. "disconnected" -> "connecting"
- *    Either an incoming or outgoing connection attempt ongoing
- * 2. "connecting" -> "disconnected"
- *    Connection attempt failed
- * 3. "connecting" -> "connected"
- *    Successfully connected
- * 4. "connected" -> "playing"
- *    Audio stream active
- * 5. "playing" -> "connected"
- *    Audio stream suspended
- * 6. "connected" -> "disconnected"
- *    "playing" -> "disconnected"
- *    Disconnected from local or the remote device
- */
-void
-BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(aSignal.value().type() ==
-             BluetoothValue::TArrayOfBluetoothNamedValue);
-
-  BluetoothAddress address;
-  NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(StringToAddress(aSignal.path(), address)));
-
-  /**
-   * Update sink property only if
-   * - mDeviceAddress is empty (A2dp is disconnected), or
-   * - this property change is from the connected sink.
-   */
-  NS_ENSURE_TRUE_VOID(mDeviceAddress.IsCleared() || mDeviceAddress == address);
-
-  const InfallibleTArray<BluetoothNamedValue>& arr =
-    aSignal.value().get_ArrayOfBluetoothNamedValue();
-  MOZ_ASSERT(arr.Length() == 1);
-
-  /**
-   * There are three properties:
-   * - "State": a string
-   * - "Connected": a boolean value
-   * - "Playing": a boolean value
-   *
-   * Note that only "State" is handled in this function.
-   */
-
-  const nsString& name = arr[0].name();
-  NS_ENSURE_TRUE_VOID(name.EqualsLiteral("State"));
-
-  const BluetoothValue& value = arr[0].value();
-  MOZ_ASSERT(value.type() == BluetoothValue::TnsString);
-  SinkState newState = StatusStringToSinkState(value.get_nsString());
-  NS_ENSURE_TRUE_VOID((newState != SinkState::SINK_UNKNOWN) &&
-                      (newState != mSinkState));
-
-  SinkState prevState = mSinkState;
-  mSinkState = newState;
-
-  switch(mSinkState) {
-    case SinkState::SINK_CONNECTING:
-      // case 1: Either an incoming or outgoing connection attempt ongoing
-      MOZ_ASSERT(prevState == SinkState::SINK_DISCONNECTED);
-      break;
-    case SinkState::SINK_PLAYING:
-      // case 4: Audio stream active
-      MOZ_ASSERT(prevState == SinkState::SINK_CONNECTED);
-      break;
-    case SinkState::SINK_CONNECTED:
-      // case 5: Audio stream suspended
-      if (prevState == SinkState::SINK_PLAYING ||
-          prevState == SinkState::SINK_CONNECTED) {
-        break;
-      }
-
-      // case 3: Successfully connected
-      mA2dpConnected = true;
-      mDeviceAddress = address;
-      NotifyConnectionStatusChanged();
-
-      OnConnect(EmptyString());
-      break;
-    case SinkState::SINK_DISCONNECTED:
-      // case 2: Connection attempt failed
-      if (prevState == SinkState::SINK_CONNECTING) {
-        OnConnect(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
-        break;
-      }
-
-      // case 6: Disconnected from the remote device
-      MOZ_ASSERT(prevState == SinkState::SINK_CONNECTED ||
-                 prevState == SinkState::SINK_PLAYING) ;
-
-      mA2dpConnected = false;
-      NotifyConnectionStatusChanged();
-      mDeviceAddress.Clear();
-      OnDisconnect(EmptyString());
-      break;
-    default:
-      break;
-  }
-}
-
-/*
- * Reset connection state to DISCONNECTED to handle backend error. The state
- * change triggers UI status bar update as ordinary bluetooth turn-off sequence.
- */
-void
-BluetoothA2dpManager::HandleBackendError()
-{
-  if (mSinkState != SinkState::SINK_DISCONNECTED) {
-    ConnectionStateNotification(A2DP_CONNECTION_STATE_DISCONNECTED,
-                                mDeviceAddress);
-  }
-}
-
-void
-BluetoothA2dpManager::NotifyConnectionStatusChanged()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // Notify Gecko observers
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-  NS_ENSURE_TRUE_VOID(obs);
-
-  nsAutoString deviceAddressStr;
-  AddressToString(mDeviceAddress, deviceAddressStr);
-
-  if (NS_FAILED(obs->NotifyObservers(this,
-                                     BLUETOOTH_A2DP_STATUS_CHANGED_ID,
-                                     deviceAddressStr.get()))) {
-    BT_WARNING("Failed to notify bluetooth-a2dp-status-changed observsers!");
-  }
-
-  // Dispatch an event of status change
-  DispatchStatusChangedEvent(
-    NS_LITERAL_STRING(A2DP_STATUS_CHANGED_ID), mDeviceAddress, mA2dpConnected);
-}
-
-void
-BluetoothA2dpManager::OnGetServiceChannel(const BluetoothAddress& aDeviceAddress,
-                                          const BluetoothUuid& aServiceUuid,
-                                          int aChannel)
-{
-}
-
-void
-BluetoothA2dpManager::OnUpdateSdpRecords(const BluetoothAddress& aDeviceAddress)
-{
-}
-
-void
-BluetoothA2dpManager::GetAddress(BluetoothAddress& aDeviceAddress)
-{
-  aDeviceAddress = mDeviceAddress;
-}
-
-bool
-BluetoothA2dpManager::IsConnected()
-{
-  return mA2dpConnected;
-}
-
-/*
- * Notifications
- */
-
-void
-BluetoothA2dpManager::ConnectionStateNotification(
-  BluetoothA2dpConnectionState aState, const BluetoothAddress& aBdAddr)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  nsString a2dpState;
-  AvStatusToSinkString(aState, a2dpState);
-
-  InfallibleTArray<BluetoothNamedValue> props;
-  AppendNamedValue(props, "State", a2dpState);
-
-  nsAutoString addressStr;
-  AddressToString(aBdAddr, addressStr);
-
-  HandleSinkPropertyChanged(BluetoothSignal(NS_LITERAL_STRING("AudioSink"),
-                                            addressStr, props));
-}
-
-void
-BluetoothA2dpManager::AudioStateNotification(BluetoothA2dpAudioState aState,
-                                             const BluetoothAddress& aBdAddr)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  nsString a2dpState;
-
-  if (aState == A2DP_AUDIO_STATE_STARTED) {
-    a2dpState = NS_LITERAL_STRING("playing");
-  } else if (aState == A2DP_AUDIO_STATE_STOPPED) {
-    // for avdtp state stop stream
-    a2dpState = NS_LITERAL_STRING("connected");
-  } else if (aState == A2DP_AUDIO_STATE_REMOTE_SUSPEND) {
-    // for avdtp state suspend stream from remote side
-    a2dpState = NS_LITERAL_STRING("connected");
-  }
-
-  InfallibleTArray<BluetoothNamedValue> props;
-  AppendNamedValue(props, "State", a2dpState);
-
-  nsAutoString addressStr;
-  AddressToString(aBdAddr, addressStr);
-
-  HandleSinkPropertyChanged(BluetoothSignal(NS_LITERAL_STRING("AudioSink"),
-                                            addressStr, props));
-}
-
-NS_IMPL_ISUPPORTS(BluetoothA2dpManager, nsIObserver)
deleted file mode 100644
--- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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_bluedroid_BluetoothA2dpManager_h
-#define mozilla_dom_bluetooth_bluedroid_BluetoothA2dpManager_h
-
-#include "BluetoothCommon.h"
-#include "BluetoothInterface.h"
-#include "BluetoothProfileController.h"
-#include "BluetoothProfileManagerBase.h"
-
-BEGIN_BLUETOOTH_NAMESPACE
-class BluetoothA2dpManager : public BluetoothProfileManagerBase
-                           , public BluetoothA2dpNotificationHandler
-{
-public:
-  static const int MAX_NUM_CLIENTS;
-
-  BT_DECL_PROFILE_MGR_BASE
-  virtual void GetName(nsACString& aName)
-  {
-    aName.AssignLiteral("A2DP");
-  }
-
-  enum SinkState {
-    SINK_UNKNOWN,
-    SINK_DISCONNECTED,
-    SINK_CONNECTING,
-    SINK_CONNECTED,
-    SINK_PLAYING,
-  };
-
-  static BluetoothA2dpManager* Get();
-  static void InitA2dpInterface(BluetoothProfileResultHandler* aRes);
-  static void DeinitA2dpInterface(BluetoothProfileResultHandler* aRes);
-
-  void OnConnectError();
-  void OnDisconnectError();
-
-  // A2DP-specific functions
-  void HandleSinkPropertyChanged(const BluetoothSignal& aSignal);
-
-  void HandleBackendError();
-
-protected:
-  virtual ~BluetoothA2dpManager();
-
-private:
-  class ConnectResultHandler;
-  class DeinitProfileResultHandlerRunnable;
-  class DisconnectResultHandler;
-  class InitProfileResultHandlerRunnable;
-  class RegisterModuleResultHandler;
-  class UnregisterModuleResultHandler;
-
-  BluetoothA2dpManager();
-
-  void Uninit();
-  void HandleShutdown();
-  void NotifyConnectionStatusChanged();
-
-  void ConnectionStateNotification(BluetoothA2dpConnectionState aState,
-                                   const BluetoothAddress& aBdAddr) override;
-  void AudioStateNotification(BluetoothA2dpAudioState aState,
-                              const BluetoothAddress& aBdAddr) override;
-
-  BluetoothAddress mDeviceAddress;
-  RefPtr<BluetoothProfileController> mController;
-
-  // A2DP data member
-  bool mA2dpConnected;
-  SinkState mSinkState;
-};
-
-END_BLUETOOTH_NAMESPACE
-
-#endif
deleted file mode 100644
--- a/dom/bluetooth/bluedroid/BluetoothAvrcpManager.cpp
+++ /dev/null
@@ -1,951 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "base/basictypes.h"
-
-#include "BluetoothAvrcpManager.h"
-#include "BluetoothCommon.h"
-#include "BluetoothService.h"
-#include "BluetoothSocket.h"
-#include "BluetoothUtils.h"
-
-#include "mozilla/dom/bluetooth/BluetoothTypes.h"
-#include "mozilla/Services.h"
-#include "mozilla/StaticPtr.h"
-#include "mozilla/UniquePtr.h"
-#include "MainThreadUtils.h"
-#include "nsIObserverService.h"
-#include "nsThreadUtils.h"
-
-using namespace mozilla;
-USING_BLUETOOTH_NAMESPACE
-// AVRC_ID op code follows bluedroid avrc_defs.h
-#define AVRC_ID_REWIND  0x48
-#define AVRC_ID_FAST_FOR 0x49
-#define AVRC_KEY_PRESS_STATE  1
-#define AVRC_KEY_RELEASE_STATE  0
-// bluedroid bt_rc.h
-#define AVRC_MAX_ATTR_STR_LEN 255
-
-namespace {
-  StaticRefPtr<BluetoothAvrcpManager> sBluetoothAvrcpManager;
-  bool sInShutdown = false;
-  static BluetoothAvrcpInterface* sBtAvrcpInterface;
-} // namespace
-
-const int BluetoothAvrcpManager::MAX_NUM_CLIENTS = 1;
-
-/*
- * This function maps attribute id and returns corresponding values
- */
-static void
-ConvertAttributeString(BluetoothAvrcpMediaAttribute aAttrId,
-                       nsAString& aAttrStr)
-{
-  BluetoothAvrcpManager* avrcp = BluetoothAvrcpManager::Get();
-  NS_ENSURE_TRUE_VOID(avrcp);
-
-  switch (aAttrId) {
-    case AVRCP_MEDIA_ATTRIBUTE_TITLE:
-      avrcp->GetTitle(aAttrStr);
-      /*
-       * bluedroid can only send string length AVRC_MAX_ATTR_STR_LEN - 1
-       */
-      if (aAttrStr.Length() >= AVRC_MAX_ATTR_STR_LEN) {
-        aAttrStr.Truncate(AVRC_MAX_ATTR_STR_LEN - 1);
-        BT_WARNING("Truncate media item attribute title, length is over 255");
-      }
-      break;
-    case AVRCP_MEDIA_ATTRIBUTE_ARTIST:
-      avrcp->GetArtist(aAttrStr);
-      if (aAttrStr.Length() >= AVRC_MAX_ATTR_STR_LEN) {
-        aAttrStr.Truncate(AVRC_MAX_ATTR_STR_LEN - 1);
-        BT_WARNING("Truncate media item attribute artist, length is over 255");
-      }
-      break;
-    case AVRCP_MEDIA_ATTRIBUTE_ALBUM:
-      avrcp->GetAlbum(aAttrStr);
-      if (aAttrStr.Length() >= AVRC_MAX_ATTR_STR_LEN) {
-        aAttrStr.Truncate(AVRC_MAX_ATTR_STR_LEN - 1);
-        BT_WARNING("Truncate media item attribute album, length is over 255");
-      }
-      break;
-    case AVRCP_MEDIA_ATTRIBUTE_TRACK_NUM:
-      aAttrStr.AppendInt(avrcp->GetMediaNumber());
-      break;
-    case AVRCP_MEDIA_ATTRIBUTE_NUM_TRACKS:
-      aAttrStr.AppendInt(avrcp->GetTotalMediaNumber());
-      break;
-    case AVRCP_MEDIA_ATTRIBUTE_GENRE:
-      // TODO: we currently don't support genre from music player
-      aAttrStr.Truncate();
-      break;
-    case AVRCP_MEDIA_ATTRIBUTE_PLAYING_TIME:
-      aAttrStr.AppendInt(avrcp->GetDuration());
-      break;
-  }
-}
-
-NS_IMETHODIMP
-BluetoothAvrcpManager::Observe(nsISupports* aSubject,
-                               const char* aTopic,
-                               const char16_t* aData)
-{
-  MOZ_ASSERT(sBluetoothAvrcpManager);
-
-  if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
-    HandleShutdown();
-    return NS_OK;
-  }
-
-  MOZ_ASSERT(false, "BluetoothAvrcpManager got unexpected topic!");
-  return NS_ERROR_UNEXPECTED;
-}
-
-BluetoothAvrcpManager::BluetoothAvrcpManager()
-{
-  Reset();
-}
-
-void
-BluetoothAvrcpManager::Reset()
-{
-  mAvrcpConnected = false;
-  mDuration = 0;
-  mMediaNumber = 0;
-  mTotalMediaCount = 0;
-  mPosition = 0;
-  mPlayStatus = ControlPlayStatus::PLAYSTATUS_STOPPED;
-}
-
-class BluetoothAvrcpManager::RegisterModuleResultHandler final
-  : public BluetoothSetupResultHandler
-{
-public:
-  RegisterModuleResultHandler(BluetoothAvrcpInterface* aInterface,
-                              BluetoothProfileResultHandler* aRes)
-    : mInterface(aInterface)
-    , mRes(aRes)
-  {
-    MOZ_ASSERT(mInterface);
-  }
-
-  void OnError(BluetoothStatus aStatus) override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    BT_WARNING("BluetoothSetupInterface::RegisterModule failed for AVRCP: %d",
-               (int)aStatus);
-
-    mInterface->SetNotificationHandler(nullptr);
-
-    if (mRes) {
-      if (aStatus == STATUS_UNSUPPORTED) {
-        /* Not all versions of Bluedroid support AVRCP. So if the
-         * initialization fails with STATUS_UNSUPPORTED, we still
-         * signal success.
-         */
-        mRes->Init();
-      } else {
-        mRes->OnError(NS_ERROR_FAILURE);
-      }
-    }
-  }
-
-  void RegisterModule() override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    sBtAvrcpInterface = mInterface;
-
-    if (mRes) {
-      mRes->Init();
-    }
-  }
-
-private:
-  BluetoothAvrcpInterface* mInterface;
-  RefPtr<BluetoothProfileResultHandler> mRes;
-};
-
-class BluetoothAvrcpManager::InitProfileResultHandlerRunnable final
-  : public Runnable
-{
-public:
-  InitProfileResultHandlerRunnable(BluetoothProfileResultHandler* aRes,
-                                   nsresult aRv)
-    : mRes(aRes)
-    , mRv(aRv)
-  {
-    MOZ_ASSERT(mRes);
-  }
-
-  NS_IMETHOD Run() override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    if (NS_SUCCEEDED(mRv)) {
-      mRes->Init();
-    } else {
-      mRes->OnError(mRv);
-    }
-    return NS_OK;
-  }
-
-private:
-  RefPtr<BluetoothProfileResultHandler> mRes;
-  nsresult mRv;
-};
-
-/*
- * This function will be only called when Bluetooth is turning on.
- */
-// static
-void
-BluetoothAvrcpManager::InitAvrcpInterface(BluetoothProfileResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (sBtAvrcpInterface) {
-    BT_LOGR("Bluetooth AVRCP interface is already initalized.");
-    RefPtr<Runnable> r =
-      new InitProfileResultHandlerRunnable(aRes, NS_OK);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch AVRCP Init runnable");
-    }
-    return;
-  }
-
-  auto btInf = BluetoothInterface::GetInstance();
-
-  if (NS_WARN_IF(!btInf)) {
-    // If there's no Bluetooth interface, we dispatch a runnable
-    // that calls the profile result handler.
-    RefPtr<Runnable> r =
-      new InitProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch AVRCP OnError runnable");
-    }
-    return;
-  }
-
-  auto setupInterface = btInf->GetBluetoothSetupInterface();
-
-  if (NS_WARN_IF(!setupInterface)) {
-    // If there's no Setup interface, we dispatch a runnable
-    // that calls the profile result handler.
-    RefPtr<Runnable> r =
-      new InitProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch AVRCP OnError runnable");
-    }
-    return;
-  }
-
-  auto avrcpInterface = btInf->GetBluetoothAvrcpInterface();
-
-  if (NS_WARN_IF(!avrcpInterface)) {
-    // If there's no AVRCP interface, we dispatch a runnable
-    // that calls the profile result handler.
-    RefPtr<Runnable> r =
-      new InitProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch AVRCP OnError runnable");
-    }
-    return;
-  }
-
-  // Set notification handler _before_ registering the module. It could
-  // happen that we receive notifications, before the result handler runs.
-  avrcpInterface->SetNotificationHandler(BluetoothAvrcpManager::Get());
-
-  setupInterface->RegisterModule(
-    SETUP_SERVICE_ID_AVRCP, 0, MAX_NUM_CLIENTS,
-    new RegisterModuleResultHandler(avrcpInterface, aRes));
-}
-
-BluetoothAvrcpManager::~BluetoothAvrcpManager()
-{ }
-
-void
-BluetoothAvrcpManager::Uninit()
-{
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-  NS_ENSURE_TRUE_VOID(obs);
-  if (NS_FAILED(obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID))) {
-    BT_WARNING("Failed to remove shutdown observer!");
-  }
-}
-
-/*
- * Static functions
- */
-
-//static
-BluetoothAvrcpManager*
-BluetoothAvrcpManager::Get()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // If sBluetoothAvrcpManager already exists, exit early
-  if (sBluetoothAvrcpManager) {
-    return sBluetoothAvrcpManager;
-  }
-
-  // If we're in shutdown, don't create a new instance
-  NS_ENSURE_FALSE(sInShutdown, nullptr);
-
-  // Create a new instance and return
-  sBluetoothAvrcpManager = new BluetoothAvrcpManager();
-
-  return sBluetoothAvrcpManager;
-}
-
-class BluetoothAvrcpManager::UnregisterModuleResultHandler final
-  : public BluetoothSetupResultHandler
-{
-public:
-  UnregisterModuleResultHandler(BluetoothProfileResultHandler* aRes)
-    : mRes(aRes)
-  { }
-
-  void OnError(BluetoothStatus aStatus) override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    BT_WARNING("BluetoothSetupInterface::UnregisterModule failed for AVRCP: %d",
-               (int)aStatus);
-
-    sBtAvrcpInterface->SetNotificationHandler(nullptr);
-    sBtAvrcpInterface = nullptr;
-
-    sBluetoothAvrcpManager->Uninit();
-    sBluetoothAvrcpManager = nullptr;
-
-    if (mRes) {
-      mRes->OnError(NS_ERROR_FAILURE);
-    }
-  }
-
-  void UnregisterModule() override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    sBtAvrcpInterface->SetNotificationHandler(nullptr);
-    sBtAvrcpInterface = nullptr;
-
-    sBluetoothAvrcpManager->Uninit();
-    sBluetoothAvrcpManager = nullptr;
-
-    if (mRes) {
-      mRes->Deinit();
-    }
-  }
-
-private:
-  RefPtr<BluetoothProfileResultHandler> mRes;
-};
-
-class BluetoothAvrcpManager::DeinitProfileResultHandlerRunnable final
-  : public Runnable
-{
-public:
-  DeinitProfileResultHandlerRunnable(BluetoothProfileResultHandler* aRes,
-                                     nsresult aRv)
-    : mRes(aRes)
-    , mRv(aRv)
-  {
-    MOZ_ASSERT(mRes);
-  }
-
-  NS_IMETHOD Run() override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    if (NS_SUCCEEDED(mRv)) {
-      mRes->Deinit();
-    } else {
-      mRes->OnError(mRv);
-    }
-    return NS_OK;
-  }
-
-private:
-  RefPtr<BluetoothProfileResultHandler> mRes;
-  nsresult mRv;
-};
-
-// static
-void
-BluetoothAvrcpManager::DeinitAvrcpInterface(BluetoothProfileResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!sBtAvrcpInterface) {
-    BT_LOGR("Bluetooth AVRCP interface has not been initalized.");
-    RefPtr<Runnable> r =
-      new DeinitProfileResultHandlerRunnable(aRes, NS_OK);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch AVRCP Deinit runnable");
-    }
-    return;
-  }
-
-  auto btInf = BluetoothInterface::GetInstance();
-
-  if (NS_WARN_IF(!btInf)) {
-    // If there's no backend interface, we dispatch a runnable
-    // that calls the profile result handler.
-    RefPtr<Runnable> r =
-      new DeinitProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch AVRCP OnError runnable");
-    }
-    return;
-  }
-
-  auto setupInterface = btInf->GetBluetoothSetupInterface();
-
-  if (NS_WARN_IF(!setupInterface)) {
-    // If there's no Setup interface, we dispatch a runnable
-    // that calls the profile result handler.
-    RefPtr<Runnable> r =
-      new DeinitProfileResultHandlerRunnable(aRes, NS_ERROR_FAILURE);
-    if (NS_FAILED(NS_DispatchToMainThread(r))) {
-      BT_LOGR("Failed to dispatch AVRCP OnError runnable");
-    }
-    return;
-  }
-
-  setupInterface->UnregisterModule(
-    SETUP_SERVICE_ID_AVRCP,
-    new UnregisterModuleResultHandler(aRes));
-}
-
-void
-BluetoothAvrcpManager::HandleShutdown()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  sInShutdown = true;
-  Disconnect(nullptr);
-  sBluetoothAvrcpManager = nullptr;
-}
-
-class BluetoothAvrcpManager::ConnectRunnable final : public Runnable
-{
-public:
-  ConnectRunnable(BluetoothAvrcpManager* aManager)
-    : mManager(aManager)
-  {
-    MOZ_ASSERT(mManager);
-  }
-  NS_IMETHOD Run() override
-  {
-    mManager->OnConnect(EmptyString());
-    return NS_OK;
-  }
-private:
-  BluetoothAvrcpManager* mManager;
-};
-
-void
-BluetoothAvrcpManager::Connect(const BluetoothAddress& aDeviceAddress,
-                               BluetoothProfileController* aController)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(!aDeviceAddress.IsCleared());
-  MOZ_ASSERT(aController);
-
-  // AVRCP doesn't require connecting. We just set the remote address here.
-  mDeviceAddress = aDeviceAddress;
-  mController = aController;
-  SetConnected(true);
-
-  NS_DispatchToMainThread(new ConnectRunnable(this));
-}
-
-class BluetoothAvrcpManager::DisconnectRunnable final : public Runnable
-{
-public:
-  DisconnectRunnable(BluetoothAvrcpManager* aManager)
-    : mManager(aManager)
-  {
-    MOZ_ASSERT(mManager);
-  }
-  NS_IMETHOD Run() override
-  {
-    mManager->OnDisconnect(EmptyString());
-    return NS_OK;
-  }
-private:
-  BluetoothAvrcpManager* mManager;
-};
-
-void
-BluetoothAvrcpManager::Disconnect(BluetoothProfileController* aController)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(!mController);
-
-  mDeviceAddress.Clear();
-  mController = aController;
-  SetConnected(false);
-
-  NS_DispatchToMainThread(new DisconnectRunnable(this));
-}
-
-void
-BluetoothAvrcpManager::OnConnect(const nsAString& aErrorStr)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  /**
-   * On the one hand, notify the controller that we've done for outbound
-   * connections. On the other hand, we do nothing for inbound connections.
-   */
-  NS_ENSURE_TRUE_VOID(mController);
-
-  RefPtr<BluetoothProfileController> controller = mController.forget();
-  controller->NotifyCompletion(aErrorStr);
-}
-
-void
-BluetoothAvrcpManager::OnDisconnect(const nsAString& aErrorStr)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  /**
-   * On the one hand, notify the controller that we've done for outbound
-   * connections. On the other hand, we do nothing for inbound connections.
-   */
-  NS_ENSURE_TRUE_VOID(mController);
-
-  RefPtr<BluetoothProfileController> controller = mController.forget();
-  controller->NotifyCompletion(aErrorStr);
-
-  Reset();
-}
-
-void
-BluetoothAvrcpManager::OnGetServiceChannel(
-  const BluetoothAddress& aDeviceAddress,
-  const BluetoothUuid& aServiceUuid,
-  int aChannel)
-{ }
-
-void
-BluetoothAvrcpManager::OnUpdateSdpRecords(
-  const BluetoothAddress& aDeviceAddress)
-{ }
-
-void
-BluetoothAvrcpManager::GetAddress(BluetoothAddress& aDeviceAddress)
-{
-  aDeviceAddress = mDeviceAddress;
-}
-
-bool
-BluetoothAvrcpManager::IsConnected()
-{
-  return mAvrcpConnected;
-}
-
-/*
- * In bluedroid stack case, there is no interface to know exactly
- * avrcp connection status. All connection are managed by bluedroid stack.
- */
-void
-BluetoothAvrcpManager::SetConnected(bool aConnected)
-{
-  mAvrcpConnected = aConnected;
-  if (!aConnected) {
-    Reset();
-  }
-}
-
-/*
- * This function only updates meta data in BluetoothAvrcpManager. Send
- * "Get Element Attributes response" in AvrcpGetElementAttrCallback
- */
-void
-BluetoothAvrcpManager::UpdateMetaData(const nsAString& aTitle,
-                                      const nsAString& aArtist,
-                                      const nsAString& aAlbum,
-                                      uint64_t aMediaNumber,
-                                      uint64_t aTotalMediaCount,
-                                      uint32_t aDuration)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  NS_ENSURE_TRUE_VOID(sBtAvrcpInterface);
-
-  // Send track changed and position changed if track num is not the same.
-  // See also AVRCP 1.3 Spec 5.4.2
-  if (mMediaNumber != aMediaNumber &&
-      mTrackChangedNotifyType == AVRCP_NTF_INTERIM) {
-    BluetoothAvrcpNotificationParam param;
-    // convert to network big endian format
-    // since track stores as uint8[8]
-    // 56 = 8 * (AVRCP_UID_SIZE -1)
-    for (int i = 0; i < AVRCP_UID_SIZE; ++i) {
-      param.mTrack[i] = (aMediaNumber >> (56 - 8 * i));
-    }
-    mTrackChangedNotifyType = AVRCP_NTF_CHANGED;
-    sBtAvrcpInterface->RegisterNotificationRsp(AVRCP_EVENT_TRACK_CHANGE,
-                                               AVRCP_NTF_CHANGED,
-                                               param, nullptr);
-    if (mPlayPosChangedNotifyType == AVRCP_NTF_INTERIM) {
-      param.mSongPos = mPosition;
-      // EVENT_PLAYBACK_POS_CHANGED shall be notified if changed current track
-      mPlayPosChangedNotifyType = AVRCP_NTF_CHANGED;
-      sBtAvrcpInterface->RegisterNotificationRsp(AVRCP_EVENT_PLAY_POS_CHANGED,
-                                                 AVRCP_NTF_CHANGED,
-                                                 param, nullptr);
-    }
-  }
-
-  mTitle.Assign(aTitle);
-  mArtist.Assign(aArtist);
-  mAlbum.Assign(aAlbum);
-  mMediaNumber = aMediaNumber;
-  mTotalMediaCount = aTotalMediaCount;
-  mDuration = aDuration;
-}
-
-/*
- * This function is to reply AvrcpGetPlayStatusCallback (play-status-request)
- * from media player application (Gaia side)
- */
-void
-BluetoothAvrcpManager::UpdatePlayStatus(uint32_t aDuration,
-                                        uint32_t aPosition,
-                                        ControlPlayStatus aPlayStatus)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  NS_ENSURE_TRUE_VOID(sBtAvrcpInterface);
-  // always update playstatus first
-  sBtAvrcpInterface->GetPlayStatusRsp(aPlayStatus, aDuration,
-                                      aPosition, nullptr);
-  // when play status changed, send both play status and position
-  if (mPlayStatus != aPlayStatus &&
-      mPlayStatusChangedNotifyType == AVRCP_NTF_INTERIM) {
-    BluetoothAvrcpNotificationParam param;
-    param.mPlayStatus = aPlayStatus;
-    mPlayStatusChangedNotifyType = AVRCP_NTF_CHANGED;
-    sBtAvrcpInterface->RegisterNotificationRsp(AVRCP_EVENT_PLAY_STATUS_CHANGED,
-                                               AVRCP_NTF_CHANGED,
-                                               param, nullptr);
-  }
-
-  if (mPosition != aPosition &&
-      mPlayPosChangedNotifyType == AVRCP_NTF_INTERIM) {
-    BluetoothAvrcpNotificationParam param;
-    param.mSongPos = aPosition;
-    mPlayPosChangedNotifyType = AVRCP_NTF_CHANGED;
-    sBtAvrcpInterface->RegisterNotificationRsp(AVRCP_EVENT_PLAY_POS_CHANGED,
-                                               AVRCP_NTF_CHANGED,
-                                               param, nullptr);
-  }
-
-  mDuration = aDuration;
-  mPosition = aPosition;
-  mPlayStatus = aPlayStatus;
-}
-
-/*
- * This function handles RegisterNotification request from
- * AvrcpRegisterNotificationCallback, which updates current
- * track/status/position status in the INTERRIM response.
- *
- * aParam is only valid when position changed
- */
-void
-BluetoothAvrcpManager::UpdateRegisterNotification(BluetoothAvrcpEvent aEvent,
-                                                  uint32_t aParam)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  NS_ENSURE_TRUE_VOID(sBtAvrcpInterface);
-
-  BluetoothAvrcpNotificationParam param;
-
-  switch (aEvent) {
-    case AVRCP_EVENT_PLAY_STATUS_CHANGED:
-      mPlayStatusChangedNotifyType = AVRCP_NTF_INTERIM;
-      param.mPlayStatus = mPlayStatus;
-      break;
-    case AVRCP_EVENT_TRACK_CHANGE:
-      // In AVRCP 1.3 and 1.4, the identifier parameter of EVENT_TRACK_CHANGED
-      // is different.
-      // AVRCP 1.4: If no track is selected, we shall return 0xFFFFFFFFFFFFFFFF,
-      // otherwise return 0x0 in the INTERRIM response. The expanded text in
-      // version 1.4 is to allow for new UID feature. As for AVRCP 1.3, we shall
-      // return 0xFFFFFFFF. Since PTS enforces to check this part to comply with
-      // the most updated spec.
-      mTrackChangedNotifyType = AVRCP_NTF_INTERIM;
-      // needs to convert to network big endian format since track stores
-      // as uint8[8]. 56 = 8 * (BTRC_UID_SIZE -1).
-      for (int index = 0; index < AVRCP_UID_SIZE; ++index) {
-        // We cannot easily check if a track is selected, so whenever A2DP is
-        // streaming, we assume a track is selected.
-        if (mPlayStatus == ControlPlayStatus::PLAYSTATUS_PLAYING) {
-          param.mTrack[index] = 0x0;
-        } else {
-          param.mTrack[index] = 0xFF;
-        }
-      }
-      break;
-    case AVRCP_EVENT_PLAY_POS_CHANGED:
-      // If no track is selected, return 0xFFFFFFFF in the INTERIM response
-      mPlayPosChangedNotifyType = AVRCP_NTF_INTERIM;
-      if (mPlayStatus == ControlPlayStatus::PLAYSTATUS_PLAYING) {
-        param.mSongPos = mPosition;
-      } else {
-        param.mSongPos = 0xFFFFFFFF;
-      }
-      mPlaybackInterval = aParam;
-      break;
-    case AVRCP_EVENT_APP_SETTINGS_CHANGED:
-      mAppSettingsChangedNotifyType = AVRCP_NTF_INTERIM;
-      param.mNumAttr = 2;
-      param.mIds[0] = AVRCP_PLAYER_ATTRIBUTE_REPEAT;
-      param.mValues[0] = AVRCP_PLAYER_VAL_OFF_REPEAT;
-      param.mIds[1] = AVRCP_PLAYER_ATTRIBUTE_SHUFFLE;
-      param.mValues[1] = AVRCP_PLAYER_VAL_OFF_SHUFFLE;
-      break;
-    default:
-      break;
-  }
-
-  sBtAvrcpInterface->RegisterNotificationRsp(aEvent, AVRCP_NTF_INTERIM,
-                                             param, nullptr);
-}
-
-void
-BluetoothAvrcpManager::GetAlbum(nsAString& aAlbum)
-{
-  aAlbum.Assign(mAlbum);
-}
-
-uint32_t
-BluetoothAvrcpManager::GetDuration()
-{
-  return mDuration;
-}
-
-ControlPlayStatus
-BluetoothAvrcpManager::GetPlayStatus()
-{
-  return mPlayStatus;
-}
-
-uint32_t
-BluetoothAvrcpManager::GetPosition()
-{
-  return mPosition;
-}
-
-uint64_t
-BluetoothAvrcpManager::GetMediaNumber()
-{
-  return mMediaNumber;
-}
-
-uint64_t
-BluetoothAvrcpManager::GetTotalMediaNumber()
-{
-  return mTotalMediaCount;
-}
-
-void
-BluetoothAvrcpManager::GetTitle(nsAString& aTitle)
-{
-  aTitle.Assign(mTitle);
-}
-
-void
-BluetoothAvrcpManager::GetArtist(nsAString& aArtist)
-{
-  aArtist.Assign(mArtist);
-}
-
-/*
- * Notifications
- */
-
-void
-BluetoothAvrcpManager::GetPlayStatusNotification()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  BluetoothService* bs = BluetoothService::Get();
-  if (!bs) {
-    return;
-  }
-
-  bs->DistributeSignal(NS_LITERAL_STRING(REQUEST_MEDIA_PLAYSTATUS_ID),
-                       NS_LITERAL_STRING(KEY_ADAPTER));
-}
-
-/* Player application settings is optional for AVRCP 1.3. B2G
- * currently does not support player-application-setting related
- * functionality.
- */
-void
-BluetoothAvrcpManager::ListPlayerAppAttrNotification()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // TODO: Support AVRCP application-setting-related functions
-}
-
-void
-BluetoothAvrcpManager::ListPlayerAppValuesNotification(
-  BluetoothAvrcpPlayerAttribute aAttrId)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // TODO: Support AVRCP application-setting-related functions
-}
-
-void
-BluetoothAvrcpManager::GetPlayerAppValueNotification(
-  uint8_t aNumAttrs, const BluetoothAvrcpPlayerAttribute* aAttrs)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // TODO: Support AVRCP application-setting-related functions
-}
-
-void
-BluetoothAvrcpManager::GetPlayerAppAttrsTextNotification(
-  uint8_t aNumAttrs, const BluetoothAvrcpPlayerAttribute* aAttrs)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // TODO: Support AVRCP application-setting-related functions
-}
-
-void
-BluetoothAvrcpManager::GetPlayerAppValuesTextNotification(
-  uint8_t aAttrId, uint8_t aNumVals, const uint8_t* aValues)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // TODO: Support AVRCP application-setting-related functions
-}
-
-void
-BluetoothAvrcpManager::SetPlayerAppValueNotification(
-  const BluetoothAvrcpPlayerSettings& aSettings)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // TODO: Support AVRCP application-setting-related functions
-}
-
-/* This method returns element attributes, which are requested from
- * CT. Unlike BlueZ it calls only UpdateMetaData. Bluedroid does not cache
- * meta-data information, but instead uses |GetElementAttrNotifications|
- * and |GetElementAttrRsp| request them.
- */
-void
-BluetoothAvrcpManager::GetElementAttrNotification(
-  uint8_t aNumAttrs, const BluetoothAvrcpMediaAttribute* aAttrs)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  auto attrs = MakeUnique<BluetoothAvrcpElementAttribute[]>(aNumAttrs);
-
-  for (uint8_t i = 0; i < aNumAttrs; ++i) {
-    attrs[i].mId = aAttrs[i];
-    ConvertAttributeString(
-      static_cast<BluetoothAvrcpMediaAttribute>(attrs[i].mId),
-      attrs[i].mValue);
-  }
-
-  MOZ_ASSERT(sBtAvrcpInterface);
-  sBtAvrcpInterface->GetElementAttrRsp(aNumAttrs, attrs.get(), nullptr);
-}
-
-void
-BluetoothAvrcpManager::RegisterNotificationNotification(
-  BluetoothAvrcpEvent aEvent, uint32_t aParam)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  BluetoothAvrcpManager* avrcp = BluetoothAvrcpManager::Get();
-  if (!avrcp) {
-    return;
-  }
-
-  avrcp->UpdateRegisterNotification(aEvent, aParam);
-}
-
-/* This method is used to get CT features from the Feature Bit Mask. If
- * Advanced Control Player bit is set, the CT supports volume sync (absolute
- * volume feature). If Browsing bit is set, AVRCP 1.4 Browse feature will be
- * supported.
- */
-void
-BluetoothAvrcpManager::RemoteFeatureNotification(
-  const BluetoothAddress& aBdAddr, unsigned long aFeatures)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // TODO: Support AVRCP 1.4 absolute volume/browse
-}
-
-/* This method is used to get notifications about volume changes on the
- * remote car kit (if it supports AVRCP 1.4), not notification from phone.
- */
-void
-BluetoothAvrcpManager::VolumeChangeNotification(uint8_t aVolume,
-                                                uint8_t aCType)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // TODO: Support AVRCP 1.4 absolute volume/browse
-}
-
-void
-BluetoothAvrcpManager::PassthroughCmdNotification(uint8_t aId,
-                                                  uint8_t aKeyState)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // Fast-forward and rewind key events won't be generated from bluedroid
-  // stack after ANDROID_VERSION > 18, but via passthrough callback.
-  nsAutoString name;
-  NS_ENSURE_TRUE_VOID(aKeyState == AVRC_KEY_PRESS_STATE ||
-                      aKeyState == AVRC_KEY_RELEASE_STATE);
-  switch (aId) {
-    case AVRC_ID_FAST_FOR:
-      if (aKeyState == AVRC_KEY_PRESS_STATE) {
-        name.AssignLiteral("media-fast-forward-button-press");
-      } else {
-        name.AssignLiteral("media-fast-forward-button-release");
-      }
-      break;
-    case AVRC_ID_REWIND:
-      if (aKeyState == AVRC_KEY_PRESS_STATE) {
-        name.AssignLiteral("media-rewind-button-press");
-      } else {
-        name.AssignLiteral("media-rewind-button-release");
-      }
-      break;
-    default:
-      BT_WARNING("Unable to handle the unknown PassThrough command %d", aId);
-      return;
-  }
-
-  NS_NAMED_LITERAL_STRING(type, "media-button");
-  BroadcastSystemMessage(type, BluetoothValue(name));
-}
-
-NS_IMPL_ISUPPORTS(BluetoothAvrcpManager, nsIObserver)
-
deleted file mode 100644
--- a/dom/bluetooth/bluedroid/BluetoothAvrcpManager.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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_bluedroid_BluetoothAvrcpManager_h
-#define mozilla_dom_bluetooth_bluedroid_BluetoothAvrcpManager_h
-
-#include "BluetoothCommon.h"
-#include "BluetoothInterface.h"
-#include "BluetoothProfileController.h"
-#include "BluetoothProfileManagerBase.h"
-
-BEGIN_BLUETOOTH_NAMESPACE
-class BluetoothAvrcpManager : public BluetoothProfileManagerBase
-                            , public BluetoothAvrcpNotificationHandler
-{
-public:
-  static const int MAX_NUM_CLIENTS;
-
-  BT_DECL_PROFILE_MGR_BASE
-  virtual void GetName(nsACString& aName)
-  {
-    aName.AssignLiteral("AVRCP");
-  }
-
-  enum SinkState {
-    SINK_UNKNOWN,
-    SINK_DISCONNECTED,
-    SINK_CONNECTING,
-    SINK_CONNECTED,
-    SINK_PLAYING,
-  };
-
-  static BluetoothAvrcpManager* Get();
-  static void InitAvrcpInterface(BluetoothProfileResultHandler* aRes);
-  static void DeinitAvrcpInterface(BluetoothProfileResultHandler* aRes);
-
-  void SetConnected(bool aConnected);
-  void UpdateMetaData(const nsAString& aTitle,
-                      const nsAString& aArtist,
-                      const nsAString& aAlbum,
-                      uint64_t aMediaNumber,
-                      uint64_t aTotalMediaCount,
-                      uint32_t aDuration);
-  void UpdatePlayStatus(uint32_t aDuration,
-                        uint32_t aPosition,
-                        ControlPlayStatus aPlayStatus);
-  void UpdateRegisterNotification(BluetoothAvrcpEvent aEvent, uint32_t aParam);
-  void GetAlbum(nsAString& aAlbum);
-  uint32_t GetDuration();
-  ControlPlayStatus GetPlayStatus();
-  uint32_t GetPosition();
-  uint64_t GetMediaNumber();
-  uint64_t GetTotalMediaNumber();
-  void GetTitle(nsAString& aTitle);
-  void GetArtist(nsAString& aArtist);
-  void HandleBackendError();
-
-protected:
-  virtual ~BluetoothAvrcpManager();
-
-private:
-  class ConnectRunnable;
-  class DeinitProfileResultHandlerRunnable;
-  class DisconnectRunnable;
-  class InitProfileResultHandlerRunnable;
-  class RegisterModuleResultHandler;
-  class UnregisterModuleResultHandler;
-
-  BluetoothAvrcpManager();
-
-  void Uninit();
-  void HandleShutdown();
-  void NotifyConnectionStatusChanged();
-
-  void GetPlayStatusNotification() override;
-
-  void ListPlayerAppAttrNotification() override;
-
-  void ListPlayerAppValuesNotification(
-    BluetoothAvrcpPlayerAttribute aAttrId) override;
-
-  void GetPlayerAppValueNotification(
-    uint8_t aNumAttrs,
-    const BluetoothAvrcpPlayerAttribute* aAttrs) override;
-
-  void GetPlayerAppAttrsTextNotification(
-    uint8_t aNumAttrs,
-    const BluetoothAvrcpPlayerAttribute* aAttrs) override;
-
-  void GetPlayerAppValuesTextNotification(
-    uint8_t aAttrId, uint8_t aNumVals, const uint8_t* aValues) override;
-
-  void SetPlayerAppValueNotification(
-    const BluetoothAvrcpPlayerSettings& aSettings) override;
-
-  void GetElementAttrNotification(
-    uint8_t aNumAttrs,
-    const BluetoothAvrcpMediaAttribute* aAttrs) override;
-
-  void RegisterNotificationNotification(
-    BluetoothAvrcpEvent aEvent, uint32_t aParam) override;
-
-  void RemoteFeatureNotification(
-    const BluetoothAddress& aBdAddr, unsigned long aFeatures) override;
-
-  void VolumeChangeNotification(uint8_t aVolume, uint8_t aCType) override;
-
-  void PassthroughCmdNotification(uint8_t aId, uint8_t aKeyState) override;
-
-  BluetoothAddress mDeviceAddress;
-  RefPtr<BluetoothProfileController> mController;
-
-  bool mAvrcpConnected;
-  nsString mAlbum;
-  nsString mArtist;
-  nsString mTitle;
-  uint32_t mDuration;
-  uint64_t mMediaNumber;
-  uint64_t mTotalMediaCount;
-  uint32_t mPosition;
-  /*
-   * mPlaybackInterval specifies the time interval (in seconds) at which
-   * the change in playback position will be notified. If the song is being
-   * forwarded / rewound, a notification will be received whenever the playback
-   * position will change by this value.
-   */
-  uint32_t mPlaybackInterval;
-  ControlPlayStatus mPlayStatus;
-  /*
-   * Notification types: 1. INTERIM 2. CHANGED
-   * 1. The initial response to this Notify command shall be an INTERIM
-   * response with current status.
-   * 2. The following response shall be a CHANGED response with the updated
-   * status.
-   * mPlayStatusChangedNotifType, mTrackChangedNotifType,
-   * mPlayPosChangedNotifType represents current RegisterNotification
-   * notification type.
-   */
-  BluetoothAvrcpNotification mPlayStatusChangedNotifyType;
-  BluetoothAvrcpNotification mTrackChangedNotifyType;
-  BluetoothAvrcpNotification mPlayPosChangedNotifyType;
-  BluetoothAvrcpNotification mAppSettingsChangedNotifyType;
-};
-
-END_BLUETOOTH_NAMESPACE
-
-#endif // mozilla_dom_bluetooth_bluedroid_BluetoothAvrcpManager_h
deleted file mode 100644
--- a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "BluetoothDaemonA2dpInterface.h"
-#include "mozilla/UniquePtr.h"
-#include "mozilla/Unused.h"
-
-BEGIN_BLUETOOTH_NAMESPACE
-
-using namespace mozilla::ipc;
-
-//
-// A2DP module
-//
-
-BluetoothA2dpNotificationHandler*
-  BluetoothDaemonA2dpModule::sNotificationHandler;
-
-void
-BluetoothDaemonA2dpModule::SetNotificationHandler(
-  BluetoothA2dpNotificationHandler* aNotificationHandler)
-{
-  sNotificationHandler = aNotificationHandler;
-}
-
-void
-BluetoothDaemonA2dpModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
-                                     DaemonSocketPDU& aPDU,
-                                     DaemonSocketResultHandler* aRes)
-{
-  static void (BluetoothDaemonA2dpModule::* const HandleOp[])(
-    const DaemonSocketPDUHeader&, DaemonSocketPDU&,
-    DaemonSocketResultHandler*) = {
-    [0] = &BluetoothDaemonA2dpModule::HandleRsp,
-    [1] = &BluetoothDaemonA2dpModule::HandleNtf
-  };
-
-  MOZ_ASSERT(!NS_IsMainThread());
-
-  // negate twice to map bit to 0/1
-  unsigned int isNtf = !!(aHeader.mOpcode & 0x80);
-
-  (this->*(HandleOp[isNtf]))(aHeader, aPDU, aRes);
-}
-
-// Commands
-//
-
-nsresult
-BluetoothDaemonA2dpModule::ConnectCmd(
-  const BluetoothAddress& aRemoteAddr, BluetoothA2dpResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CONNECT,
-                                6); // Address
-
-  nsresult rv = PackPDU(aRemoteAddr, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonA2dpModule::DisconnectCmd(
-  const BluetoothAddress& aRemoteAddr, BluetoothA2dpResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_DISCONNECT,
-                                6); // Address
-
-  nsresult rv = PackPDU(aRemoteAddr, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-// Responses
-//
-
-void
-BluetoothDaemonA2dpModule::ErrorRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothA2dpResultHandler* aRes)
-{
-  ErrorRunnable::Dispatch(
-    aRes, &BluetoothA2dpResultHandler::OnError, UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonA2dpModule::ConnectRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothA2dpResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothA2dpResultHandler::Connect, UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonA2dpModule::DisconnectRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothA2dpResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothA2dpResultHandler::Disconnect, UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonA2dpModule::HandleRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  DaemonSocketResultHandler* aRes)
-{
-  static void (BluetoothDaemonA2dpModule::* const HandleRsp[])(
-    const DaemonSocketPDUHeader&,
-    DaemonSocketPDU&,
-    BluetoothA2dpResultHandler*) = {
-    [OPCODE_ERROR] = &BluetoothDaemonA2dpModule::ErrorRsp,
-    [OPCODE_CONNECT] = &BluetoothDaemonA2dpModule::ConnectRsp,
-    [OPCODE_DISCONNECT] = &BluetoothDaemonA2dpModule::DisconnectRsp
-  };
-
-  MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
-
-  if (NS_WARN_IF(!(aHeader.mOpcode < MOZ_ARRAY_LENGTH(HandleRsp))) ||
-      NS_WARN_IF(!HandleRsp[aHeader.mOpcode])) {
-    return;
-  }
-
-  RefPtr<BluetoothA2dpResultHandler> res =
-    static_cast<BluetoothA2dpResultHandler*>(aRes);
-
-  if (!res) {
-    return; // Return early if no result handler has been set for response
-  }
-
-  (this->*(HandleRsp[aHeader.mOpcode]))(aHeader, aPDU, res);
-}
-
-// Notifications
-//
-
-// Returns the current notification handler to a notification runnable
-class BluetoothDaemonA2dpModule::NotificationHandlerWrapper final
-{
-public:
-  typedef BluetoothA2dpNotificationHandler ObjectType;
-
-  static ObjectType* GetInstance()
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    return sNotificationHandler;
-  }
-};
-
-void
-BluetoothDaemonA2dpModule::ConnectionStateNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ConnectionStateNotification::Dispatch(
-    &BluetoothA2dpNotificationHandler::ConnectionStateNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonA2dpModule::AudioStateNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  AudioStateNotification::Dispatch(
-    &BluetoothA2dpNotificationHandler::AudioStateNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonA2dpModule::AudioConfigNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  AudioConfigNotification::Dispatch(
-    &BluetoothA2dpNotificationHandler::AudioConfigNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonA2dpModule::HandleNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  DaemonSocketResultHandler* aRes)
-{
-  static void (BluetoothDaemonA2dpModule::* const HandleNtf[])(
-    const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {
-    [0] = &BluetoothDaemonA2dpModule::ConnectionStateNtf,
-    [1] = &BluetoothDaemonA2dpModule::AudioStateNtf,
-#if ANDROID_VERSION >= 21
-    [2] = &BluetoothDaemonA2dpModule::AudioConfigNtf
-#endif
-  };
-
-  MOZ_ASSERT(!NS_IsMainThread());
-
-  uint8_t index = aHeader.mOpcode - 0x81;
-
-  if (NS_WARN_IF(!(index < MOZ_ARRAY_LENGTH(HandleNtf))) ||
-      NS_WARN_IF(!HandleNtf[index])) {
-    return;
-  }
-
-  (this->*(HandleNtf[index]))(aHeader, aPDU);
-}
-
-//
-// A2DP interface
-//
-
-BluetoothDaemonA2dpInterface::BluetoothDaemonA2dpInterface(
-  BluetoothDaemonA2dpModule* aModule)
-  : mModule(aModule)
-{ }
-
-BluetoothDaemonA2dpInterface::~BluetoothDaemonA2dpInterface()
-{ }
-
-void
-BluetoothDaemonA2dpInterface::SetNotificationHandler(
-  BluetoothA2dpNotificationHandler* aNotificationHandler)
-{
-  MOZ_ASSERT(mModule);
-
-  mModule->SetNotificationHandler(aNotificationHandler);
-}
-
-/* Connect / Disconnect */
-
-void
-BluetoothDaemonA2dpInterface::Connect(
-  const BluetoothAddress& aBdAddr, BluetoothA2dpResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ConnectCmd(aBdAddr, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonA2dpInterface::Disconnect(
-  const BluetoothAddress& aBdAddr, BluetoothA2dpResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->DisconnectCmd(aBdAddr, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonA2dpInterface::DispatchError(
-  BluetoothA2dpResultHandler* aRes, BluetoothStatus aStatus)
-{
-  DaemonResultRunnable1<BluetoothA2dpResultHandler, void,
-                        BluetoothStatus, BluetoothStatus>::Dispatch(
-    aRes, &BluetoothA2dpResultHandler::OnError,
-    ConstantInitOp1<BluetoothStatus>(aStatus));
-}
-
-void
-BluetoothDaemonA2dpInterface::DispatchError(
-  BluetoothA2dpResultHandler* aRes, nsresult aRv)
-{
-  BluetoothStatus status;
-
-  if (NS_WARN_IF(NS_FAILED(Convert(aRv, status)))) {
-    status = STATUS_FAIL;
-  }
-  DispatchError(aRes, status);
-}
-
-END_BLUETOOTH_NAMESPACE
deleted file mode 100644
--- a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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_bluedroid_BluetoothDaemonA2dpInterface_h
-#define mozilla_dom_bluetooth_bluedroid_BluetoothDaemonA2dpInterface_h
-
-#include "BluetoothDaemonHelpers.h"
-#include "BluetoothInterface.h"
-#include "mozilla/ipc/DaemonRunnables.h"
-
-BEGIN_BLUETOOTH_NAMESPACE
-
-using mozilla::ipc::DaemonSocketPDU;
-using mozilla::ipc::DaemonSocketPDUHeader;
-using mozilla::ipc::DaemonSocketResultHandler;
-
-class BluetoothDaemonA2dpModule
-{
-public:
-  enum {
-    SERVICE_ID = 0x06
-  };
-
-  enum {
-    OPCODE_ERROR = 0x00,
-    OPCODE_CONNECT = 0x01,
-    OPCODE_DISCONNECT = 0x02
-  };
-
-  virtual nsresult Send(DaemonSocketPDU* aPDU,
-                        DaemonSocketResultHandler* aRes) = 0;
-
-  void SetNotificationHandler(
-    BluetoothA2dpNotificationHandler* aNotificationHandler);
-
-  //
-  // Commands
-  //
-
-  nsresult ConnectCmd(const BluetoothAddress& aBdAddr,
-                      BluetoothA2dpResultHandler* aRes);
-  nsresult DisconnectCmd(const BluetoothAddress& aBdAddr,
-                         BluetoothA2dpResultHandler* aRes);
-
-protected:
-  void HandleSvc(const DaemonSocketPDUHeader& aHeader,
-                 DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
-
-  //
-  // Responses
-  //
-
-  typedef mozilla::ipc::DaemonResultRunnable0<
-    BluetoothA2dpResultHandler, void>
-    ResultRunnable;
-
-  typedef mozilla::ipc::DaemonResultRunnable1<
-    BluetoothA2dpResultHandler, void, BluetoothStatus, BluetoothStatus>
-    ErrorRunnable;
-
-  void ErrorRsp(const DaemonSocketPDUHeader& aHeader,
-                DaemonSocketPDU& aPDU,
-                BluetoothA2dpResultHandler* aRes);
-
-  void ConnectRsp(const DaemonSocketPDUHeader& aHeader,
-                  DaemonSocketPDU& aPDU,
-                  BluetoothA2dpResultHandler* aRes);
-
-  void DisconnectRsp(const DaemonSocketPDUHeader& aHeader,
-                     DaemonSocketPDU& aPDU,
-                     BluetoothA2dpResultHandler* aRes);
-
-  void HandleRsp(const DaemonSocketPDUHeader& aHeader,
-                 DaemonSocketPDU& aPDU,
-                 DaemonSocketResultHandler* aRes);
-
-  //
-  // Notifications
-  //
-
-  class NotificationHandlerWrapper;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable2<
-    NotificationHandlerWrapper, void,
-    BluetoothA2dpConnectionState, BluetoothAddress,
-    BluetoothA2dpConnectionState, const BluetoothAddress&>
-    ConnectionStateNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable2<
-    NotificationHandlerWrapper, void,
-    BluetoothA2dpAudioState, BluetoothAddress,
-    BluetoothA2dpAudioState, const BluetoothAddress&>
-    AudioStateNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable3<
-    NotificationHandlerWrapper, void,
-    BluetoothAddress, uint32_t, uint8_t,
-    const BluetoothAddress&, uint32_t, uint8_t>
-    AudioConfigNotification;
-
-  void ConnectionStateNtf(const DaemonSocketPDUHeader& aHeader,
-                          DaemonSocketPDU& aPDU);
-
-  void AudioStateNtf(const DaemonSocketPDUHeader& aHeader,
-                     DaemonSocketPDU& aPDU);
-
-  void AudioConfigNtf(const DaemonSocketPDUHeader& aHeader,
-                      DaemonSocketPDU& aPDU);
-
-  void HandleNtf(const DaemonSocketPDUHeader& aHeader,
-                 DaemonSocketPDU& aPDU,
-                 DaemonSocketResultHandler* aRes);
-
-  static BluetoothA2dpNotificationHandler* sNotificationHandler;
-};
-
-class BluetoothDaemonA2dpInterface final
-  : public BluetoothA2dpInterface
-{
-public:
-  BluetoothDaemonA2dpInterface(BluetoothDaemonA2dpModule* aModule);
-  ~BluetoothDaemonA2dpInterface();
-
-  void SetNotificationHandler(
-    BluetoothA2dpNotificationHandler* aNotificationHandler) override;
-
-  /* Connect / Disconnect */
-
-  void Connect(const BluetoothAddress& aBdAddr,
-               BluetoothA2dpResultHandler* aRes) override;
-  void Disconnect(const BluetoothAddress& aBdAddr,
-                  BluetoothA2dpResultHandler* aRes) override;
-
-private:
-  void DispatchError(BluetoothA2dpResultHandler* aRes,
-                     BluetoothStatus aStatus);
-  void DispatchError(BluetoothA2dpResultHandler* aRes, nsresult aRv);
-
-  BluetoothDaemonA2dpModule* mModule;
-};
-
-END_BLUETOOTH_NAMESPACE
-
-#endif // mozilla_dom_bluetooth_bluedroid_BluetoothDaemonA2dpInterface_h
deleted file mode 100644
--- a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp
+++ /dev/null
@@ -1,976 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "BluetoothDaemonAvrcpInterface.h"
-#include "mozilla/UniquePtr.h"
-#include "mozilla/Unused.h"
-
-BEGIN_BLUETOOTH_NAMESPACE
-
-using namespace mozilla::ipc;
-
-//
-// AVRCP module
-//
-
-BluetoothAvrcpNotificationHandler*
-  BluetoothDaemonAvrcpModule::sNotificationHandler;
-
-void
-BluetoothDaemonAvrcpModule::SetNotificationHandler(
-  BluetoothAvrcpNotificationHandler* aNotificationHandler)
-{
-  sNotificationHandler = aNotificationHandler;
-}
-
-void
-BluetoothDaemonAvrcpModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
-                                      DaemonSocketPDU& aPDU,
-                                      DaemonSocketResultHandler* aRes)
-{
-  static void (BluetoothDaemonAvrcpModule::* const HandleOp[])(
-    const DaemonSocketPDUHeader&, DaemonSocketPDU&,
-    DaemonSocketResultHandler*) = {
-    [0] = &BluetoothDaemonAvrcpModule::HandleRsp,
-    [1] = &BluetoothDaemonAvrcpModule::HandleNtf
-  };
-
-  MOZ_ASSERT(!NS_IsMainThread());
-
-  unsigned int isNtf = !!(aHeader.mOpcode & 0x80);
-
-  (this->*(HandleOp[isNtf]))(aHeader, aPDU, aRes);
-}
-
-// Commands
-//
-
-nsresult
-BluetoothDaemonAvrcpModule::GetPlayStatusRspCmd(
-  ControlPlayStatus aPlayStatus, uint32_t aSongLen, uint32_t aSongPos,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_GET_PLAY_STATUS_RSP,
-                                1 + // Play status
-                                4 + // Duration
-                                4); // Position
-
-  nsresult rv = PackPDU(aPlayStatus, aSongLen, aSongPos, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonAvrcpModule::ListPlayerAppAttrRspCmd(
-  int aNumAttr, const BluetoothAvrcpPlayerAttribute* aPAttrs,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_LIST_PLAYER_APP_ATTR_RSP,
-                                1 + // # Attributes
-                                aNumAttr); // Player attributes
-
-  nsresult rv = PackPDU(
-    PackConversion<int, uint8_t>(aNumAttr),
-    PackArray<BluetoothAvrcpPlayerAttribute>(aPAttrs, aNumAttr), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonAvrcpModule::ListPlayerAppValueRspCmd(
-  int aNumVal, uint8_t* aPVals, BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_LIST_PLAYER_APP_VALUE_RSP,
-                                1 + // # Values
-                                aNumVal); // Player values
-
-  nsresult rv = PackPDU(PackConversion<int, uint8_t>(aNumVal),
-                        PackArray<uint8_t>(aPVals, aNumVal), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonAvrcpModule::GetPlayerAppValueRspCmd(
-  uint8_t aNumAttrs, const uint8_t* aIds, const uint8_t* aValues,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_GET_PLAYER_APP_VALUE_RSP,
-                                1 + // # Pairs
-                                2 * aNumAttrs); // Attribute-value pairs
-
-  nsresult rv = PackPDU(
-    aNumAttrs,
-    BluetoothAvrcpAttributeValuePairs(aIds, aValues, aNumAttrs), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonAvrcpModule::GetPlayerAppAttrTextRspCmd(
-  int aNumAttr, const uint8_t* aIds, const char** aTexts,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_GET_PLAYER_APP_ATTR_TEXT_RSP,
-                                0); // Dynamically allocated
-
-  nsresult rv = PackPDU(
-    PackConversion<int, uint8_t>(aNumAttr),
-    BluetoothAvrcpAttributeTextPairs(aIds, aTexts, aNumAttr), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonAvrcpModule::GetPlayerAppValueTextRspCmd(
-  int aNumVal, const uint8_t* aIds, const char** aTexts,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_GET_PLAYER_APP_VALUE_TEXT_RSP,
-                                0); // Dynamically allocated
-
-  nsresult rv = PackPDU(
-    PackConversion<int, uint8_t>(aNumVal),
-    BluetoothAvrcpAttributeTextPairs(aIds, aTexts, aNumVal), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonAvrcpModule::GetElementAttrRspCmd(
-  uint8_t aNumAttr, const BluetoothAvrcpElementAttribute* aAttr,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_GET_ELEMENT_ATTR_RSP,
-                                0); // Dynamically allocated
-
-  nsresult rv = PackPDU(
-    aNumAttr,
-    PackArray<BluetoothAvrcpElementAttribute>(aAttr, aNumAttr), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonAvrcpModule::SetPlayerAppValueRspCmd(
-  BluetoothAvrcpStatus aRspStatus, BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SET_PLAYER_APP_VALUE_RSP,
-                                1); // Status code
-
-  nsresult rv = PackPDU(aRspStatus, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonAvrcpModule::RegisterNotificationRspCmd(
-  BluetoothAvrcpEvent aEvent, BluetoothAvrcpNotification aType,
-  const BluetoothAvrcpNotificationParam& aParam,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_REGISTER_NOTIFICATION_RSP,
-                                1 + // Event
-                                1 + // Type
-                                1 + // Data length
-                                256); // Maximum data length
-
-  BluetoothAvrcpEventParamPair data(aEvent, aParam);
-  nsresult rv = PackPDU(aEvent, aType, static_cast<uint8_t>(data.GetLength()),
-                        data, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonAvrcpModule::SetVolumeCmd(uint8_t aVolume,
-                                         BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SET_VOLUME,
-                                1); // Volume
-
-  nsresult rv = PackPDU(aVolume, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-// Responses
-//
-
-void
-BluetoothDaemonAvrcpModule::ErrorRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothAvrcpResultHandler* aRes)
-{
-  ErrorRunnable::Dispatch(
-    aRes, &BluetoothAvrcpResultHandler::OnError, UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::GetPlayStatusRspRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothAvrcpResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothAvrcpResultHandler::GetPlayStatusRsp,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::ListPlayerAppAttrRspRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothAvrcpResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothAvrcpResultHandler::ListPlayerAppAttrRsp,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::ListPlayerAppValueRspRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothAvrcpResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothAvrcpResultHandler::ListPlayerAppValueRsp,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::GetPlayerAppValueRspRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothAvrcpResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueRsp,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::GetPlayerAppAttrTextRspRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothAvrcpResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothAvrcpResultHandler::GetPlayerAppAttrTextRsp,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::GetPlayerAppValueTextRspRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothAvrcpResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueTextRsp,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::GetElementAttrRspRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothAvrcpResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothAvrcpResultHandler::GetElementAttrRsp,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::SetPlayerAppValueRspRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothAvrcpResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothAvrcpResultHandler::SetPlayerAppValueRsp,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::RegisterNotificationRspRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothAvrcpResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothAvrcpResultHandler::RegisterNotificationRsp,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::SetVolumeRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothAvrcpResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothAvrcpResultHandler::SetVolume,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::HandleRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  DaemonSocketResultHandler* aRes)
-{
-  static void (BluetoothDaemonAvrcpModule::* const HandleRsp[])(
-    const DaemonSocketPDUHeader&,
-    DaemonSocketPDU&,
-    BluetoothAvrcpResultHandler*) = {
-    [OPCODE_ERROR] =
-      &BluetoothDaemonAvrcpModule::ErrorRsp,
-    [OPCODE_GET_PLAY_STATUS_RSP] =
-      &BluetoothDaemonAvrcpModule::GetPlayStatusRspRsp,
-    [OPCODE_LIST_PLAYER_APP_ATTR_RSP] =
-      &BluetoothDaemonAvrcpModule::ListPlayerAppAttrRspRsp,
-    [OPCODE_LIST_PLAYER_APP_VALUE_RSP] =
-      &BluetoothDaemonAvrcpModule::ListPlayerAppValueRspRsp,
-    [OPCODE_GET_PLAYER_APP_VALUE_RSP] =
-      &BluetoothDaemonAvrcpModule::GetPlayerAppValueRspRsp,
-    [OPCODE_GET_PLAYER_APP_ATTR_TEXT_RSP] =
-      &BluetoothDaemonAvrcpModule::GetPlayerAppAttrTextRspRsp,
-    [OPCODE_GET_PLAYER_APP_VALUE_TEXT_RSP] =
-      &BluetoothDaemonAvrcpModule::GetPlayerAppValueTextRspRsp,
-    [OPCODE_GET_ELEMENT_ATTR_RSP]=
-      &BluetoothDaemonAvrcpModule::GetElementAttrRspRsp,
-    [OPCODE_SET_PLAYER_APP_VALUE_RSP] =
-      &BluetoothDaemonAvrcpModule::SetPlayerAppValueRspRsp,
-    [OPCODE_REGISTER_NOTIFICATION_RSP] =
-      &BluetoothDaemonAvrcpModule::RegisterNotificationRspRsp,
-    [OPCODE_SET_VOLUME] =
-      &BluetoothDaemonAvrcpModule::SetVolumeRsp
-  };
-
-  MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
-
-  if (NS_WARN_IF(!(aHeader.mOpcode < MOZ_ARRAY_LENGTH(HandleRsp))) ||
-      NS_WARN_IF(!HandleRsp[aHeader.mOpcode])) {
-    return;
-  }
-
-  RefPtr<BluetoothAvrcpResultHandler> res =
-    static_cast<BluetoothAvrcpResultHandler*>(aRes);
-
-  if (!res) {
-    return; // Return early if no result handler has been set for response
-  }
-
-  (this->*(HandleRsp[aHeader.mOpcode]))(aHeader, aPDU, res);
-}
-
-// Notifications
-//
-
-// Returns the current notification handler to a notification runnable
-class BluetoothDaemonAvrcpModule::NotificationHandlerWrapper final
-{
-public:
-  typedef BluetoothAvrcpNotificationHandler ObjectType;
-
-  static ObjectType* GetInstance()
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    return sNotificationHandler;
-  }
-};
-
-// Init operator class for RemoteFeatureNotification
-class BluetoothDaemonAvrcpModule::RemoteFeatureInitOp final
-  : private PDUInitOp
-{
-public:
-  RemoteFeatureInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (BluetoothAddress& aArg1, unsigned long& aArg2) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read address */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    /* Read feature */
-    rv = UnpackPDU(
-      pdu,
-      UnpackConversion<BluetoothAvrcpRemoteFeatureBits, unsigned long>(aArg2));
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonAvrcpModule::RemoteFeatureNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  RemoteFeatureNotification::Dispatch(
-    &BluetoothAvrcpNotificationHandler::RemoteFeatureNotification,
-    RemoteFeatureInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::GetPlayStatusNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  GetPlayStatusNotification::Dispatch(
-    &BluetoothAvrcpNotificationHandler::GetPlayStatusNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::ListPlayerAppAttrNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ListPlayerAppAttrNotification::Dispatch(
-    &BluetoothAvrcpNotificationHandler::ListPlayerAppAttrNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::ListPlayerAppValuesNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ListPlayerAppValuesNotification::Dispatch(
-    &BluetoothAvrcpNotificationHandler::ListPlayerAppValuesNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-// Init operator class for GetPlayerAppValueNotification
-class BluetoothDaemonAvrcpModule::GetPlayerAppValueInitOp final
-  : private PDUInitOp
-{
-public:
-  GetPlayerAppValueInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (uint8_t& aArg1,
-               UniquePtr<BluetoothAvrcpPlayerAttribute[]>& aArg2) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read number of attributes */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    /* Read attributes */
-    rv = UnpackPDU(
-      pdu, UnpackArray<BluetoothAvrcpPlayerAttribute>(aArg2, aArg1));
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonAvrcpModule::GetPlayerAppValueNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  GetPlayerAppValueNotification::Dispatch(
-    &BluetoothAvrcpNotificationHandler::GetPlayerAppValueNotification,
-    GetPlayerAppValueInitOp(aPDU));
-}
-
-// Init operator class for GetPlayerAppAttrsTextNotification
-class BluetoothDaemonAvrcpModule::GetPlayerAppAttrsTextInitOp final
-  : private PDUInitOp
-{
-public:
-  GetPlayerAppAttrsTextInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (uint8_t& aArg1,
-               UniquePtr<BluetoothAvrcpPlayerAttribute[]>& aArg2) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read number of attributes */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    /* Read attributes */
-    rv = UnpackPDU(
-      pdu, UnpackArray<BluetoothAvrcpPlayerAttribute>(aArg2, aArg1));
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonAvrcpModule::GetPlayerAppAttrsTextNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  GetPlayerAppAttrsTextNotification::Dispatch(
-    &BluetoothAvrcpNotificationHandler::GetPlayerAppAttrsTextNotification,
-    GetPlayerAppAttrsTextInitOp(aPDU));
-}
-
-// Init operator class for GetPlayerAppValuesTextNotification
-class BluetoothDaemonAvrcpModule::GetPlayerAppValuesTextInitOp final
-  : private PDUInitOp
-{
-public:
-  GetPlayerAppValuesTextInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (uint8_t& aArg1, uint8_t& aArg2,
-               UniquePtr<uint8_t[]>& aArg3) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read attribute */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    /* Read number of values */
-    rv = UnpackPDU(pdu, aArg2);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    /* Read values */
-    rv = UnpackPDU(pdu, UnpackArray<uint8_t>(aArg3, aArg2));
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonAvrcpModule::GetPlayerAppValuesTextNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  GetPlayerAppValuesTextNotification::Dispatch(
-    &BluetoothAvrcpNotificationHandler::GetPlayerAppValuesTextNotification,
-    GetPlayerAppValuesTextInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::SetPlayerAppValueNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  SetPlayerAppValueNotification::Dispatch(
-    &BluetoothAvrcpNotificationHandler::SetPlayerAppValueNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-// Init operator class for GetElementAttrNotification
-class BluetoothDaemonAvrcpModule::GetElementAttrInitOp final
-  : private PDUInitOp
-{
-public:
-  GetElementAttrInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (uint8_t& aArg1,
-               UniquePtr<BluetoothAvrcpMediaAttribute[]>& aArg2) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read number of attributes */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    /* Read attributes */
-    rv = UnpackPDU(
-      pdu, UnpackArray<BluetoothAvrcpMediaAttribute>(aArg2, aArg1));
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonAvrcpModule::GetElementAttrNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  GetElementAttrNotification::Dispatch(
-    &BluetoothAvrcpNotificationHandler::GetElementAttrNotification,
-    GetElementAttrInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::RegisterNotificationNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  RegisterNotificationNotification::Dispatch(
-    &BluetoothAvrcpNotificationHandler::RegisterNotificationNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-#if ANDROID_VERSION >= 19
-void
-BluetoothDaemonAvrcpModule::VolumeChangeNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  VolumeChangeNotification::Dispatch(
-    &BluetoothAvrcpNotificationHandler::VolumeChangeNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonAvrcpModule::PassthroughCmdNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  PassthroughCmdNotification::Dispatch(
-    &BluetoothAvrcpNotificationHandler::PassthroughCmdNotification,
-    UnpackPDUInitOp(aPDU));
-}
-#endif
-
-void
-BluetoothDaemonAvrcpModule::HandleNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  DaemonSocketResultHandler* aRes)
-{
-  static void (BluetoothDaemonAvrcpModule::* const HandleNtf[])(
-    const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {
-#if ANDROID_VERSION >= 19
-    [0] = &BluetoothDaemonAvrcpModule::RemoteFeatureNtf,
-    [1] = &BluetoothDaemonAvrcpModule::GetPlayStatusNtf,
-    [2] = &BluetoothDaemonAvrcpModule::ListPlayerAppAttrNtf,
-    [3] = &BluetoothDaemonAvrcpModule::ListPlayerAppValuesNtf,
-    [4] = &BluetoothDaemonAvrcpModule::GetPlayerAppValueNtf,
-    [5] = &BluetoothDaemonAvrcpModule::GetPlayerAppAttrsTextNtf,
-    [6] = &BluetoothDaemonAvrcpModule::GetPlayerAppValuesTextNtf,
-    [7] = &BluetoothDaemonAvrcpModule::SetPlayerAppValueNtf,
-    [8] = &BluetoothDaemonAvrcpModule::GetElementAttrNtf,
-    [9] = &BluetoothDaemonAvrcpModule::RegisterNotificationNtf,
-    [10] = &BluetoothDaemonAvrcpModule::VolumeChangeNtf,
-    [11] = &BluetoothDaemonAvrcpModule::PassthroughCmdNtf
-#else
-    [0] = &BluetoothDaemonAvrcpModule::GetPlayStatusNtf,
-    [1] = &BluetoothDaemonAvrcpModule::ListPlayerAppAttrNtf,
-    [2] = &BluetoothDaemonAvrcpModule::ListPlayerAppValuesNtf,
-    [3] = &BluetoothDaemonAvrcpModule::GetPlayerAppValueNtf,
-    [4] = &BluetoothDaemonAvrcpModule::GetPlayerAppAttrsTextNtf,
-    [5] = &BluetoothDaemonAvrcpModule::GetPlayerAppValuesTextNtf,
-    [6] = &BluetoothDaemonAvrcpModule::SetPlayerAppValueNtf,
-    [7] = &BluetoothDaemonAvrcpModule::GetElementAttrNtf,
-    [8] = &BluetoothDaemonAvrcpModule::RegisterNotificationNtf
-#endif
-  };
-
-  MOZ_ASSERT(!NS_IsMainThread());
-
-  uint8_t index = aHeader.mOpcode - 0x81;
-
-  if (NS_WARN_IF(!(index < MOZ_ARRAY_LENGTH(HandleNtf))) ||
-      NS_WARN_IF(!HandleNtf[index])) {
-    return;
-  }
-
-  (this->*(HandleNtf[index]))(aHeader, aPDU);
-}
-
-//
-// AVRCP interface
-//
-
-BluetoothDaemonAvrcpInterface::BluetoothDaemonAvrcpInterface(
-  BluetoothDaemonAvrcpModule* aModule)
-  : mModule(aModule)
-{ }
-
-BluetoothDaemonAvrcpInterface::~BluetoothDaemonAvrcpInterface()
-{ }
-
-void
-BluetoothDaemonAvrcpInterface::SetNotificationHandler(
-  BluetoothAvrcpNotificationHandler* aNotificationHandler)
-{
-  MOZ_ASSERT(mModule);
-
-  mModule->SetNotificationHandler(aNotificationHandler);
-}
-
-void
-BluetoothDaemonAvrcpInterface::GetPlayStatusRsp(
-  ControlPlayStatus aPlayStatus, uint32_t aSongLen, uint32_t aSongPos,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->GetPlayStatusRspCmd(aPlayStatus, aSongLen,
-                                             aSongPos, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonAvrcpInterface::ListPlayerAppAttrRsp(
-  int aNumAttr, const BluetoothAvrcpPlayerAttribute* aPAttrs,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ListPlayerAppAttrRspCmd(aNumAttr, aPAttrs, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonAvrcpInterface::ListPlayerAppValueRsp(
-  int aNumVal, uint8_t* aPVals, BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ListPlayerAppValueRspCmd(aNumVal, aPVals, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonAvrcpInterface::GetPlayerAppValueRsp(
-  uint8_t aNumAttrs, const uint8_t* aIds, const uint8_t* aValues,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->GetPlayerAppValueRspCmd(aNumAttrs, aIds,
-                                                 aValues, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonAvrcpInterface::GetPlayerAppAttrTextRsp(
-  int aNumAttr, const uint8_t* aIds, const char** aTexts,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->GetPlayerAppAttrTextRspCmd(aNumAttr, aIds,
-                                                    aTexts, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonAvrcpInterface::GetPlayerAppValueTextRsp(
-  int aNumVal, const uint8_t* aIds, const char** aTexts,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->GetPlayerAppValueTextRspCmd(aNumVal, aIds,
-                                                     aTexts, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonAvrcpInterface::GetElementAttrRsp(
-  uint8_t aNumAttr, const BluetoothAvrcpElementAttribute* aAttr,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->GetElementAttrRspCmd(aNumAttr, aAttr, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonAvrcpInterface::SetPlayerAppValueRsp(
-  BluetoothAvrcpStatus aRspStatus, BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->SetPlayerAppValueRspCmd(aRspStatus, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonAvrcpInterface::RegisterNotificationRsp(
-  BluetoothAvrcpEvent aEvent,
-  BluetoothAvrcpNotification aType,
-  const BluetoothAvrcpNotificationParam& aParam,
-  BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->RegisterNotificationRspCmd(aEvent, aType,
-                                                    aParam, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonAvrcpInterface::SetVolume(
-  uint8_t aVolume, BluetoothAvrcpResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->SetVolumeCmd(aVolume, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonAvrcpInterface::DispatchError(
-  BluetoothAvrcpResultHandler* aRes, BluetoothStatus aStatus)
-{
-  DaemonResultRunnable1<BluetoothAvrcpResultHandler, void,
-                        BluetoothStatus, BluetoothStatus>::Dispatch(
-    aRes, &BluetoothAvrcpResultHandler::OnError,
-    ConstantInitOp1<BluetoothStatus>(aStatus));
-}
-
-void
-BluetoothDaemonAvrcpInterface::DispatchError(
-  BluetoothAvrcpResultHandler* aRes, nsresult aRv)
-{
-  BluetoothStatus status;
-
-  if (NS_WARN_IF(NS_FAILED(Convert(aRv, status)))) {
-    status = STATUS_FAIL;
-  }
-  DispatchError(aRes, status);
-}
-
-END_BLUETOOTH_NAMESPACE
deleted file mode 100644
--- a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.h
+++ /dev/null
@@ -1,350 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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_bluedroid_BluetoothDaemonAvrcpInterface_h
-#define mozilla_dom_bluetooth_bluedroid_BluetoothDaemonAvrcpInterface_h
-
-#include "BluetoothDaemonHelpers.h"
-#include "BluetoothInterface.h"
-#include "mozilla/ipc/DaemonRunnables.h"
-
-BEGIN_BLUETOOTH_NAMESPACE
-
-using mozilla::ipc::DaemonSocketPDU;
-using mozilla::ipc::DaemonSocketPDUHeader;
-using mozilla::ipc::DaemonSocketResultHandler;
-
-class BluetoothDaemonAvrcpModule
-{
-public:
-  enum {
-    SERVICE_ID = 0x08
-  };
-
-  enum {
-    OPCODE_ERROR = 0x00,
-    OPCODE_GET_PLAY_STATUS_RSP = 0x01,
-    OPCODE_LIST_PLAYER_APP_ATTR_RSP = 0x02,
-    OPCODE_LIST_PLAYER_APP_VALUE_RSP = 0x03,
-    OPCODE_GET_PLAYER_APP_VALUE_RSP = 0x04,
-    OPCODE_GET_PLAYER_APP_ATTR_TEXT_RSP = 0x05,
-    OPCODE_GET_PLAYER_APP_VALUE_TEXT_RSP = 0x06,
-    OPCODE_GET_ELEMENT_ATTR_RSP = 0x07,
-    OPCODE_SET_PLAYER_APP_VALUE_RSP = 0x08,
-    OPCODE_REGISTER_NOTIFICATION_RSP = 0x09,
-    OPCODE_SET_VOLUME = 0x0a,
-#if ANDROID_VERSION >= 19
-    OPCODE_REMOTE_FEATURES_NTF = 0x81,
-    OPCODE_GET_PLAY_STATUS_NTF = 0x82,
-    OPCODE_LIST_PLAYER_APP_ATTR_NTF = 0x83,
-    OPCODE_LIST_PLAYER_APP_VALUES_NTF = 0x84,
-    OPCODE_GET_PLAYER_APP_VALUE_NTF = 0x85,
-    OPCODE_GET_PLAYER_APP_ATTRS_TEXT_NTF = 0x86,
-    OPCODE_GET_PLAYER_APP_VALUES_TEXT_NTF = 0x87,
-    OPCODE_SET_PLAYER_APP_VALUE_NTF = 0x88,
-    OPCODE_GET_ELEMENT_ATTR_NTF = 0x89,
-    OPCODE_REGISTER_NOTIFICATION_NTF = 0x8a,
-    OPCODE_VOLUME_CHANGE_NTF = 0x8b,
-    OPCODE_PASSTHROUGH_CMD_NTF = 0x8c
-#else /* defined by BlueZ 5.14 */
-    OPCODE_GET_PLAY_STATUS_NTF = 0x81,
-    OPCODE_LIST_PLAYER_APP_ATTR_NTF = 0x82,
-    OPCODE_LIST_PLAYER_APP_VALUES_NTF = 0x83,
-    OPCODE_GET_PLAYER_APP_VALUE_NTF = 0x84,
-    OPCODE_GET_PLAYER_APP_ATTRS_TEXT_NTF = 0x85,
-    OPCODE_GET_PLAYER_APP_VALUES_TEXT_NTF = 0x86,
-    OPCODE_SET_PLAYER_APP_VALUE_NTF = 0x87,
-    OPCODE_GET_ELEMENT_ATTR_NTF = 0x88,
-    OPCODE_REGISTER_NOTIFICATION_NTF = 0x89
-#endif
-  };
-
-  virtual nsresult Send(DaemonSocketPDU* aPDU,
-                        DaemonSocketResultHandler* aRes) = 0;
-
-  void SetNotificationHandler(
-    BluetoothAvrcpNotificationHandler* aNotificationHandler);
-
-  //
-  // Commands
-  //
-
-  nsresult GetPlayStatusRspCmd(
-    ControlPlayStatus aPlayStatus, uint32_t aSongLen, uint32_t aSongPos,
-    BluetoothAvrcpResultHandler* aRes);
-
-  nsresult ListPlayerAppAttrRspCmd(
-    int aNumAttr, const BluetoothAvrcpPlayerAttribute* aPAttrs,
-    BluetoothAvrcpResultHandler* aRes);
-
-  nsresult ListPlayerAppValueRspCmd(
-    int aNumVal, uint8_t* aPVals, BluetoothAvrcpResultHandler* aRes);
-
-  nsresult GetPlayerAppValueRspCmd(
-    uint8_t aNumAttrs, const uint8_t* aIds, const uint8_t* aValues,
-    BluetoothAvrcpResultHandler* aRes);
-
-  nsresult GetPlayerAppAttrTextRspCmd(
-    int aNumAttr, const uint8_t* aIds, const char** aTexts,
-    BluetoothAvrcpResultHandler* aRes);
-
-  nsresult GetPlayerAppValueTextRspCmd(
-    int aNumVal, const uint8_t* aIds, const char** aTexts,
-    BluetoothAvrcpResultHandler* aRes);
-
-  nsresult GetElementAttrRspCmd(
-    uint8_t aNumAttr, const BluetoothAvrcpElementAttribute* aAttr,
-    BluetoothAvrcpResultHandler* aRes);
-
-  nsresult SetPlayerAppValueRspCmd(
-    BluetoothAvrcpStatus aRspStatus, BluetoothAvrcpResultHandler* aRes);
-
-  nsresult RegisterNotificationRspCmd(
-    BluetoothAvrcpEvent aEvent, BluetoothAvrcpNotification aType,
-    const BluetoothAvrcpNotificationParam& aParam,
-    BluetoothAvrcpResultHandler* aRes);
-
-  nsresult SetVolumeCmd(uint8_t aVolume, BluetoothAvrcpResultHandler* aRes);
-
-protected:
-  void HandleSvc(const DaemonSocketPDUHeader& aHeader,
-                 DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
-
-  //
-  // Responses
-  //
-
-  typedef mozilla::ipc::DaemonResultRunnable0<
-    BluetoothAvrcpResultHandler, void>
-    ResultRunnable;
-
-  typedef mozilla::ipc::DaemonResultRunnable1<
-    BluetoothAvrcpResultHandler, void, BluetoothStatus, BluetoothStatus>
-    ErrorRunnable;
-
-  void ErrorRsp(const DaemonSocketPDUHeader& aHeader,
-                DaemonSocketPDU& aPDU,
-                BluetoothAvrcpResultHandler* aRes);
-
-  void GetPlayStatusRspRsp(const DaemonSocketPDUHeader& aHeader,
-                           DaemonSocketPDU& aPDU,
-                           BluetoothAvrcpResultHandler* aRes);
-
-  void ListPlayerAppAttrRspRsp(const DaemonSocketPDUHeader& aHeader,
-                               DaemonSocketPDU& aPDU,
-                               BluetoothAvrcpResultHandler* aRes);
-
-  void ListPlayerAppValueRspRsp(const DaemonSocketPDUHeader& aHeader,
-                                DaemonSocketPDU& aPDU,
-                                BluetoothAvrcpResultHandler* aRes);
-
-  void GetPlayerAppValueRspRsp(const DaemonSocketPDUHeader& aHeader,
-                               DaemonSocketPDU& aPDU,
-                               BluetoothAvrcpResultHandler* aRes);
-
-  void GetPlayerAppAttrTextRspRsp(const DaemonSocketPDUHeader& aHeader,
-                                  DaemonSocketPDU& aPDU,
-                                  BluetoothAvrcpResultHandler* aRes);
-
-  void GetPlayerAppValueTextRspRsp(const DaemonSocketPDUHeader& aHeader,
-                                   DaemonSocketPDU& aPDU,
-                                   BluetoothAvrcpResultHandler* aRes);
-
-  void GetElementAttrRspRsp(const DaemonSocketPDUHeader& aHeader,
-                            DaemonSocketPDU& aPDU,
-                            BluetoothAvrcpResultHandler* aRes);
-
-  void SetPlayerAppValueRspRsp(const DaemonSocketPDUHeader& aHeader,
-                               DaemonSocketPDU& aPDU,
-                               BluetoothAvrcpResultHandler* aRes);
-
-  void RegisterNotificationRspRsp(const DaemonSocketPDUHeader& aHeader,
-                                  DaemonSocketPDU& aPDU,
-                                  BluetoothAvrcpResultHandler* aRes);
-
-  void SetVolumeRsp(const DaemonSocketPDUHeader& aHeader,
-                    DaemonSocketPDU& aPDU,
-                    BluetoothAvrcpResultHandler* aRes);
-
-  void HandleRsp(const DaemonSocketPDUHeader& aHeader,
-                 DaemonSocketPDU& aPDU,
-                 DaemonSocketResultHandler* aRes);
-
-  //
-  // Notifications
-  //
-
-  class NotificationHandlerWrapper;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable2<
-    NotificationHandlerWrapper, void,
-    BluetoothAddress, unsigned long,
-    const BluetoothAddress&>
-    RemoteFeatureNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable0<
-    NotificationHandlerWrapper, void>
-    GetPlayStatusNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable0<
-    NotificationHandlerWrapper, void>
-    ListPlayerAppAttrNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable1<
-    NotificationHandlerWrapper, void, BluetoothAvrcpPlayerAttribute>
-    ListPlayerAppValuesNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable2<
-    NotificationHandlerWrapper, void, uint8_t,
-    UniquePtr<BluetoothAvrcpPlayerAttribute[]>,
-    uint8_t, const BluetoothAvrcpPlayerAttribute*>
-    GetPlayerAppValueNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable2<
-    NotificationHandlerWrapper, void, uint8_t,
-    UniquePtr<BluetoothAvrcpPlayerAttribute[]>,
-    uint8_t, const BluetoothAvrcpPlayerAttribute*>
-    GetPlayerAppAttrsTextNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable3<
-    NotificationHandlerWrapper, void, uint8_t, uint8_t,
-    UniquePtr<uint8_t[]>, uint8_t, uint8_t, const uint8_t*>
-    GetPlayerAppValuesTextNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable1<
-    NotificationHandlerWrapper, void, BluetoothAvrcpPlayerSettings,
-    const BluetoothAvrcpPlayerSettings&>
-    SetPlayerAppValueNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable2<
-    NotificationHandlerWrapper, void, uint8_t,
-    UniquePtr<BluetoothAvrcpMediaAttribute[]>,
-    uint8_t, const BluetoothAvrcpMediaAttribute*>
-    GetElementAttrNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable2<
-    NotificationHandlerWrapper, void, BluetoothAvrcpEvent, uint32_t>
-    RegisterNotificationNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable2<
-    NotificationHandlerWrapper, void, uint8_t, uint8_t>
-    VolumeChangeNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable2<
-    NotificationHandlerWrapper, void, uint8_t, uint8_t, uint8_t, uint8_t>
-    PassthroughCmdNotification;
-
-  class GetElementAttrInitOp;
-  class GetPlayerAppAttrsTextInitOp;
-  class GetPlayerAppValueInitOp;
-  class GetPlayerAppValuesTextInitOp;
-  class RemoteFeatureInitOp;
-
-  void RemoteFeatureNtf(const DaemonSocketPDUHeader& aHeader,
-                        DaemonSocketPDU& aPDU);
-
-  void GetPlayStatusNtf(const DaemonSocketPDUHeader& aHeader,
-                        DaemonSocketPDU& aPDU);
-
-  void ListPlayerAppAttrNtf(const DaemonSocketPDUHeader& aHeader,
-                            DaemonSocketPDU& aPDU);
-
-  void ListPlayerAppValuesNtf(const DaemonSocketPDUHeader& aHeader,
-                              DaemonSocketPDU& aPDU);
-
-  void GetPlayerAppValueNtf(const DaemonSocketPDUHeader& aHeader,
-                            DaemonSocketPDU& aPDU);
-
-  void GetPlayerAppAttrsTextNtf(const DaemonSocketPDUHeader& aHeader,
-                                DaemonSocketPDU& aPDU);
-
-  void GetPlayerAppValuesTextNtf(const DaemonSocketPDUHeader& aHeader,
-                                 DaemonSocketPDU& aPDU);
-
-  void SetPlayerAppValueNtf(const DaemonSocketPDUHeader& aHeader,
-                            DaemonSocketPDU& aPDU);
-
-  void GetElementAttrNtf(const DaemonSocketPDUHeader& aHeader,
-                         DaemonSocketPDU& aPDU);
-
-  void RegisterNotificationNtf(const DaemonSocketPDUHeader& aHeader,
-                               DaemonSocketPDU& aPDU);
-
-  void VolumeChangeNtf(const DaemonSocketPDUHeader& aHeader,
-                       DaemonSocketPDU& aPDU);
-
-  void PassthroughCmdNtf(const DaemonSocketPDUHeader& aHeader,
-                         DaemonSocketPDU& aPDU);
-
-  void HandleNtf(const DaemonSocketPDUHeader& aHeader,
-                 DaemonSocketPDU& aPDU,
-                 DaemonSocketResultHandler* aRes);
-
-  static BluetoothAvrcpNotificationHandler* sNotificationHandler;
-};
-
-class BluetoothDaemonAvrcpInterface final
-  : public BluetoothAvrcpInterface
-{
-  class CleanupResultHandler;
-  class InitResultHandler;
-
-public:
-  BluetoothDaemonAvrcpInterface(BluetoothDaemonAvrcpModule* aModule);
-  ~BluetoothDaemonAvrcpInterface();
-
-  void SetNotificationHandler(
-    BluetoothAvrcpNotificationHandler* aNotificationHandler) override;
-
-  void GetPlayStatusRsp(ControlPlayStatus aPlayStatus,
-                        uint32_t aSongLen, uint32_t aSongPos,
-                        BluetoothAvrcpResultHandler* aRes) override;
-
-  void ListPlayerAppAttrRsp(int aNumAttr,
-                            const BluetoothAvrcpPlayerAttribute* aPAttrs,
-                            BluetoothAvrcpResultHandler* aRes) override;
-
-  void ListPlayerAppValueRsp(int aNumVal, uint8_t* aPVals,
-                             BluetoothAvrcpResultHandler* aRes) override;
-
-  void GetPlayerAppValueRsp(uint8_t aNumAttrs, const uint8_t* aIds,
-                            const uint8_t* aValues,
-                            BluetoothAvrcpResultHandler* aRes) override;
-
-  void GetPlayerAppAttrTextRsp(int aNumAttr, const uint8_t* aIds,
-                               const char** aTexts,
-                               BluetoothAvrcpResultHandler* aRes) override;
-
-  void GetPlayerAppValueTextRsp(int aNumVal, const uint8_t* aIds,
-                                const char** aTexts,
-                                BluetoothAvrcpResultHandler* aRes) override;
-
-  void GetElementAttrRsp(uint8_t aNumAttr,
-                         const BluetoothAvrcpElementAttribute* aAttr,
-                         BluetoothAvrcpResultHandler* aRes) override;
-
-  void SetPlayerAppValueRsp(BluetoothAvrcpStatus aRspStatus,
-                            BluetoothAvrcpResultHandler* aRes) override;
-
-  void RegisterNotificationRsp(BluetoothAvrcpEvent aEvent,
-                               BluetoothAvrcpNotification aType,
-                               const BluetoothAvrcpNotificationParam& aParam,
-                               BluetoothAvrcpResultHandler* aRes) override;
-
-  void SetVolume(uint8_t aVolume,
-                 BluetoothAvrcpResultHandler* aRes) override;
-
-private:
-  void DispatchError(BluetoothAvrcpResultHandler* aRes,
-                     BluetoothStatus aStatus);
-  void DispatchError(BluetoothAvrcpResultHandler* aRes, nsresult aRv);
-
-  BluetoothDaemonAvrcpModule* mModule;
-};
-
-END_BLUETOOTH_NAMESPACE
-
-#endif // mozilla_dom_bluetooth_bluedroid_BluetoothDaemonAvrcpInterface_h
deleted file mode 100644
--- a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp
+++ /dev/null
@@ -1,1358 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "BluetoothDaemonCoreInterface.h"
-#include "mozilla/UniquePtr.h"
-#include "mozilla/Unused.h"
-
-BEGIN_BLUETOOTH_NAMESPACE
-
-using namespace mozilla::ipc;
-
-//
-// Core module
-//
-
-const int BluetoothDaemonCoreModule::MAX_NUM_CLIENTS = 1;
-
-BluetoothCoreNotificationHandler*
-  BluetoothDaemonCoreModule::sNotificationHandler;
-
-void
-BluetoothDaemonCoreModule::SetNotificationHandler(
-  BluetoothCoreNotificationHandler* aNotificationHandler)
-{
-  sNotificationHandler = aNotificationHandler;
-}
-
-void
-BluetoothDaemonCoreModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
-                                     DaemonSocketPDU& aPDU,
-                                     DaemonSocketResultHandler* aRes)
-{
-  static void (BluetoothDaemonCoreModule::* const HandleOp[])(
-    const DaemonSocketPDUHeader&, DaemonSocketPDU&,
-    DaemonSocketResultHandler*) = {
-    [0] = &BluetoothDaemonCoreModule::HandleRsp,
-    [1] = &BluetoothDaemonCoreModule::HandleNtf
-  };
-
-  MOZ_ASSERT(!NS_IsMainThread());
-
-  (this->*(HandleOp[!!(aHeader.mOpcode & 0x80)]))(aHeader, aPDU, aRes);
-}
-
-// Commands
-//
-
-nsresult
-BluetoothDaemonCoreModule::EnableCmd(BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_ENABLE,
-                                0);
-
-  nsresult rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::DisableCmd(BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_DISABLE,
-                                0);
-
-  nsresult rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::GetAdapterPropertiesCmd(
-  BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_GET_ADAPTER_PROPERTIES,
-                                0);
-
-  nsresult rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::GetAdapterPropertyCmd(
-  BluetoothPropertyType aType, BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_GET_ADAPTER_PROPERTY,
-                                0);
-
-  nsresult rv = PackPDU(aType, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::SetAdapterPropertyCmd(
-  const BluetoothProperty& aProperty, BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SET_ADAPTER_PROPERTY,
-                                0);
-
-  nsresult rv = PackPDU(aProperty, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::GetRemoteDevicePropertiesCmd(
-  const BluetoothAddress& aRemoteAddr, BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_GET_REMOTE_DEVICE_PROPERTIES,
-                                0);
-
-  nsresult rv = PackPDU(aRemoteAddr, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::GetRemoteDevicePropertyCmd(
-  const BluetoothAddress& aRemoteAddr,
-  BluetoothPropertyType aType,
-  BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_GET_REMOTE_DEVICE_PROPERTY,
-                                0);
-
-  nsresult rv = PackPDU(aRemoteAddr, aType, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::SetRemoteDevicePropertyCmd(
-  const BluetoothAddress& aRemoteAddr,
-  const BluetoothProperty& aProperty,
-  BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SET_REMOTE_DEVICE_PROPERTY,
-                                0);
-
-  nsresult rv = PackPDU(aRemoteAddr, aProperty, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::GetRemoteServiceRecordCmd(
-  const BluetoothAddress& aRemoteAddr, const BluetoothUuid& aUuid,
-  BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_GET_REMOTE_SERVICE_RECORD,
-                                0);
-
-  nsresult rv = PackPDU(aRemoteAddr, aUuid, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::GetRemoteServicesCmd(
-  const BluetoothAddress& aRemoteAddr, BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_GET_REMOTE_SERVICES,
-                                0);
-
-  nsresult rv = PackPDU(aRemoteAddr, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::StartDiscoveryCmd(BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_START_DISCOVERY,
-                                0);
-
-  nsresult rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::CancelDiscoveryCmd(BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CANCEL_DISCOVERY,
-                                0);
-
-  nsresult rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::CreateBondCmd(const BluetoothAddress& aBdAddr,
-                                         BluetoothTransport aTransport,
-                                         BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CREATE_BOND,
-                                0);
-
-#if ANDROID_VERSION >= 21
-  nsresult rv = PackPDU(aBdAddr, aTransport, *pdu);
-#else
-  nsresult rv = PackPDU(aBdAddr, *pdu);
-#endif
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::RemoveBondCmd(const BluetoothAddress& aBdAddr,
-                                         BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_REMOVE_BOND,
-                                0);
-
-  nsresult rv = PackPDU(aBdAddr, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::CancelBondCmd(const BluetoothAddress& aBdAddr,
-                                         BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CANCEL_BOND,
-                                0);
-
-  nsresult rv = PackPDU(aBdAddr, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::PinReplyCmd(const BluetoothAddress& aBdAddr,
-                                       bool aAccept,
-                                       const BluetoothPinCode& aPinCode,
-                                       BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_PIN_REPLY,
-                                0);
-
-  nsresult rv = PackPDU(aBdAddr, aAccept, aPinCode, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::SspReplyCmd(const BluetoothAddress& aBdAddr,
-                                       BluetoothSspVariant aVariant,
-                                       bool aAccept, uint32_t aPasskey,
-                                       BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SSP_REPLY,
-                                0);
-
-  nsresult rv = PackPDU(aBdAddr, aVariant, aAccept, aPasskey, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::DutModeConfigureCmd(
-  bool aEnable, BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_DUT_MODE_CONFIGURE,
-                                0);
-
-  nsresult rv = PackPDU(aEnable, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::DutModeSendCmd(uint16_t aOpcode,
-                                          uint8_t* aBuf, uint8_t aLen,
-                                          BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_DUT_MODE_SEND,
-                                0);
-
-  nsresult rv = PackPDU(aOpcode, aLen, PackArray<uint8_t>(aBuf, aLen),
-                        *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-nsresult
-BluetoothDaemonCoreModule::LeTestModeCmd(uint16_t aOpcode,
-                                         uint8_t* aBuf, uint8_t aLen,
-                                         BluetoothCoreResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_LE_TEST_MODE,
-                                0);
-
-  nsresult rv = PackPDU(aOpcode, aLen, PackArray<uint8_t>(aBuf, aLen),
-                        *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return rv;
-}
-
-// Responses
-//
-
-void
-BluetoothDaemonCoreModule::ErrorRsp(const DaemonSocketPDUHeader& aHeader,
-                                    DaemonSocketPDU& aPDU,
-                                    BluetoothCoreResultHandler* aRes)
-{
-  ErrorRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::OnError, UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::EnableRsp(const DaemonSocketPDUHeader& aHeader,
-                                     DaemonSocketPDU& aPDU,
-                                     BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::Enable, UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::DisableRsp(const DaemonSocketPDUHeader& aHeader,
-                                      DaemonSocketPDU& aPDU,
-                                      BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::Disable, UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::GetAdapterPropertiesRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::GetAdapterProperties,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::GetAdapterPropertyRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::GetAdapterProperty,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::SetAdapterPropertyRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::SetAdapterProperty,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::GetRemoteDevicePropertiesRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::GetRemoteDeviceProperties,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::GetRemoteDevicePropertyRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::GetRemoteDeviceProperty,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::SetRemoteDevicePropertyRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::SetRemoteDeviceProperty,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::GetRemoteServiceRecordRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::GetRemoteServiceRecord,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::GetRemoteServicesRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::GetRemoteServices,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::StartDiscoveryRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::StartDiscovery,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::CancelDiscoveryRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::CancelDiscovery,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::CreateBondRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::CreateBond,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::RemoveBondRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::RemoveBond,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::CancelBondRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::CancelBond,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::PinReplyRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::PinReply,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::SspReplyRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::SspReply,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::DutModeConfigureRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::DutModeConfigure,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::DutModeSendRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::DutModeSend,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::LeTestModeRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothCoreResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothCoreResultHandler::LeTestMode,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::HandleRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  DaemonSocketResultHandler* aRes)
-{
-  static void (BluetoothDaemonCoreModule::* const HandleRsp[])(
-    const DaemonSocketPDUHeader&,
-    DaemonSocketPDU&,
-    BluetoothCoreResultHandler*) = {
-    [OPCODE_ERROR] =
-      &BluetoothDaemonCoreModule::ErrorRsp,
-    [OPCODE_ENABLE] =
-      &BluetoothDaemonCoreModule::EnableRsp,
-    [OPCODE_DISABLE] =
-      &BluetoothDaemonCoreModule::DisableRsp,
-    [OPCODE_GET_ADAPTER_PROPERTIES] =
-      &BluetoothDaemonCoreModule::GetAdapterPropertiesRsp,
-    [OPCODE_GET_ADAPTER_PROPERTY] =
-      &BluetoothDaemonCoreModule::GetAdapterPropertyRsp,
-    [OPCODE_SET_ADAPTER_PROPERTY] =
-      &BluetoothDaemonCoreModule::SetAdapterPropertyRsp,
-    [OPCODE_GET_REMOTE_DEVICE_PROPERTIES] =
-      &BluetoothDaemonCoreModule::GetRemoteDevicePropertiesRsp,
-    [OPCODE_GET_REMOTE_DEVICE_PROPERTY] =
-      &BluetoothDaemonCoreModule::GetRemoteDevicePropertyRsp,
-    [OPCODE_SET_REMOTE_DEVICE_PROPERTY] =
-      &BluetoothDaemonCoreModule::SetRemoteDevicePropertyRsp,
-    [OPCODE_GET_REMOTE_SERVICE_RECORD] =
-      &BluetoothDaemonCoreModule::GetRemoteServiceRecordRsp,
-    [OPCODE_GET_REMOTE_SERVICES] =
-      &BluetoothDaemonCoreModule::GetRemoteServicesRsp,
-    [OPCODE_START_DISCOVERY] =
-      &BluetoothDaemonCoreModule::StartDiscoveryRsp,
-    [OPCODE_CANCEL_DISCOVERY] =
-      &BluetoothDaemonCoreModule::CancelDiscoveryRsp,
-    [OPCODE_CREATE_BOND] =
-      &BluetoothDaemonCoreModule::CreateBondRsp,
-    [OPCODE_REMOVE_BOND] =
-      &BluetoothDaemonCoreModule::RemoveBondRsp,
-    [OPCODE_CANCEL_BOND] =
-      &BluetoothDaemonCoreModule::CancelBondRsp,
-    [OPCODE_PIN_REPLY] =
-      &BluetoothDaemonCoreModule::PinReplyRsp,
-    [OPCODE_SSP_REPLY] =
-      &BluetoothDaemonCoreModule::SspReplyRsp,
-    [OPCODE_DUT_MODE_CONFIGURE] =
-      &BluetoothDaemonCoreModule::DutModeConfigureRsp,
-    [OPCODE_DUT_MODE_SEND] =
-      &BluetoothDaemonCoreModule::DutModeSendRsp,
-    [OPCODE_LE_TEST_MODE] =
-      &BluetoothDaemonCoreModule::LeTestModeRsp,
-  };
-
-  MOZ_ASSERT(!NS_IsMainThread());
-
-  if (NS_WARN_IF(!(aHeader.mOpcode < MOZ_ARRAY_LENGTH(HandleRsp))) ||
-      NS_WARN_IF(!HandleRsp[aHeader.mOpcode])) {
-    return;
-  }
-
-  RefPtr<BluetoothCoreResultHandler> res =
-    static_cast<BluetoothCoreResultHandler*>(aRes);
-
-  if (!res) {
-    return; // Return early if no result handler has been set for response
-  }
-
-  (this->*(HandleRsp[aHeader.mOpcode]))(aHeader, aPDU, res);
-}
-
-// Notifications
-//
-
-class BluetoothDaemonCoreModule::NotificationHandlerWrapper final
-{
-public:
-  typedef BluetoothCoreNotificationHandler ObjectType;
-
-  static ObjectType* GetInstance()
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    return sNotificationHandler;
-  }
-};
-
-void
-BluetoothDaemonCoreModule::AdapterStateChangedNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  AdapterStateChangedNotification::Dispatch(
-    &BluetoothCoreNotificationHandler::AdapterStateChangedNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-// Init operator class for AdapterPropertiesNotification
-class BluetoothDaemonCoreModule::AdapterPropertiesInitOp final
-  : private PDUInitOp
-{
-public:
-  AdapterPropertiesInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (BluetoothStatus& aArg1, int& aArg2,
-               UniquePtr<BluetoothProperty[]>& aArg3) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read status */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-        return rv;
-    }
-
-    /* Read number of properties */
-    uint8_t numProperties;
-    rv = UnpackPDU(pdu, numProperties);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    aArg2 = numProperties;
-
-    /* Read properties array */
-    UnpackArray<BluetoothProperty> properties(aArg3, aArg2);
-    rv = UnpackPDU(pdu, properties);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonCoreModule::AdapterPropertiesNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  AdapterPropertiesNotification::Dispatch(
-    &BluetoothCoreNotificationHandler::AdapterPropertiesNotification,
-    AdapterPropertiesInitOp(aPDU));
-}
-
-// Init operator class for RemoteDevicePropertiesNotification
-class BluetoothDaemonCoreModule::RemoteDevicePropertiesInitOp final
-  : private PDUInitOp
-{
-public:
-  RemoteDevicePropertiesInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (BluetoothStatus& aArg1, BluetoothAddress& aArg2, int& aArg3,
-               UniquePtr<BluetoothProperty[]>& aArg4) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read status */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    /* Read address */
-    rv = UnpackPDU(pdu, aArg2);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    /* Read number of properties */
-    uint8_t numProperties;
-    rv = UnpackPDU(pdu, numProperties);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    aArg3 = numProperties;
-
-    /* Read properties array */
-    UnpackArray<BluetoothProperty> properties(aArg4, aArg3);
-    rv = UnpackPDU(pdu, properties);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonCoreModule::RemoteDevicePropertiesNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  RemoteDevicePropertiesNotification::Dispatch(
-    &BluetoothCoreNotificationHandler::RemoteDevicePropertiesNotification,
-    RemoteDevicePropertiesInitOp(aPDU));
-}
-
-// Init operator class for DeviceFoundNotification
-class BluetoothDaemonCoreModule::DeviceFoundInitOp final
-  : private PDUInitOp
-{
-public:
-  DeviceFoundInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (int& aArg1, UniquePtr<BluetoothProperty[]>& aArg2) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read number of properties */
-    uint8_t numProperties;
-    nsresult rv = UnpackPDU(pdu, numProperties);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    aArg1 = numProperties;
-
-    /* Read properties array */
-    UnpackArray<BluetoothProperty> properties(aArg2, aArg1);
-    rv = UnpackPDU(pdu, properties);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonCoreModule::DeviceFoundNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  DeviceFoundNotification::Dispatch(
-    &BluetoothCoreNotificationHandler::DeviceFoundNotification,
-    DeviceFoundInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::DiscoveryStateChangedNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  DiscoveryStateChangedNotification::Dispatch(
-    &BluetoothCoreNotificationHandler::DiscoveryStateChangedNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::PinRequestNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  PinRequestNotification::Dispatch(
-    &BluetoothCoreNotificationHandler::PinRequestNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::SspRequestNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  SspRequestNotification::Dispatch(
-    &BluetoothCoreNotificationHandler::SspRequestNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::BondStateChangedNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  BondStateChangedNotification::Dispatch(
-    &BluetoothCoreNotificationHandler::BondStateChangedNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::AclStateChangedNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  AclStateChangedNotification::Dispatch(
-    &BluetoothCoreNotificationHandler::AclStateChangedNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-// Init operator class for DutModeRecvNotification
-class BluetoothDaemonCoreModule::DutModeRecvInitOp final
-  : private PDUInitOp
-{
-public:
-  DutModeRecvInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (uint16_t& aArg1, UniquePtr<uint8_t[]>& aArg2,
-               uint8_t& aArg3) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read opcode */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    /* Read length */
-    rv = UnpackPDU(pdu, aArg3);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    /* Read data */
-    rv = UnpackPDU(pdu, UnpackArray<uint8_t>(aArg2, aArg3));
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonCoreModule::DutModeRecvNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  DutModeRecvNotification::Dispatch(
-    &BluetoothCoreNotificationHandler::DutModeRecvNotification,
-    DutModeRecvInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::LeTestModeNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  LeTestModeNotification::Dispatch(
-    &BluetoothCoreNotificationHandler::LeTestModeNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonCoreModule::HandleNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  DaemonSocketResultHandler* aRes)
-{
-  static void (BluetoothDaemonCoreModule::* const HandleNtf[])(
-    const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {
-    [0] = &BluetoothDaemonCoreModule::AdapterStateChangedNtf,
-    [1] = &BluetoothDaemonCoreModule::AdapterPropertiesNtf,
-    [2] = &BluetoothDaemonCoreModule::RemoteDevicePropertiesNtf,
-    [3] = &BluetoothDaemonCoreModule::DeviceFoundNtf,
-    [4] = &BluetoothDaemonCoreModule::DiscoveryStateChangedNtf,
-    [5] = &BluetoothDaemonCoreModule::PinRequestNtf,
-    [6] = &BluetoothDaemonCoreModule::SspRequestNtf,
-    [7] = &BluetoothDaemonCoreModule::BondStateChangedNtf,
-    [8] = &BluetoothDaemonCoreModule::AclStateChangedNtf,
-    [9] = &BluetoothDaemonCoreModule::DutModeRecvNtf,
-    [10] = &BluetoothDaemonCoreModule::LeTestModeNtf
-  };
-
-  MOZ_ASSERT(!NS_IsMainThread());
-
-  uint8_t index = aHeader.mOpcode - 0x81;
-
-  if (NS_WARN_IF(!(index < MOZ_ARRAY_LENGTH(HandleNtf))) ||
-      NS_WARN_IF(!HandleNtf[index])) {
-    return;
-  }
-
-    (this->*(HandleNtf[index]))(aHeader, aPDU);
-}
-
-//
-// Core interface
-//
-
-BluetoothDaemonCoreInterface::BluetoothDaemonCoreInterface(
-  BluetoothDaemonCoreModule* aModule)
-  : mModule(aModule)
-{ }
-
-BluetoothDaemonCoreInterface::~BluetoothDaemonCoreInterface()
-{ }
-
-void
-BluetoothDaemonCoreInterface::SetNotificationHandler(
-  BluetoothCoreNotificationHandler* aNotificationHandler)
-{
-  MOZ_ASSERT(mModule);
-
-  mModule->SetNotificationHandler(aNotificationHandler);
-}
-
-/* Enable / Disable */
-
-void
-BluetoothDaemonCoreInterface::Enable(BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->EnableCmd(aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonCoreInterface::Disable(BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->DisableCmd(aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Adapter Properties */
-
-void
-BluetoothDaemonCoreInterface::GetAdapterProperties(
-  BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->GetAdapterPropertiesCmd(aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonCoreInterface::GetAdapterProperty(
-  BluetoothPropertyType aType, BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->GetAdapterPropertyCmd(aType, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonCoreInterface::SetAdapterProperty(
-  const BluetoothProperty& aProperty, BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->SetAdapterPropertyCmd(aProperty, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Remote Device Properties */
-
-void
-BluetoothDaemonCoreInterface::GetRemoteDeviceProperties(
-  const BluetoothAddress& aRemoteAddr, BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->GetRemoteDevicePropertiesCmd(aRemoteAddr, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonCoreInterface::GetRemoteDeviceProperty(
-  const BluetoothAddress& aRemoteAddr, BluetoothPropertyType aType,
-  BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->GetRemoteDevicePropertyCmd(aRemoteAddr, aType, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonCoreInterface::SetRemoteDeviceProperty(
-  const BluetoothAddress& aRemoteAddr, const BluetoothProperty& aProperty,
-  BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->SetRemoteDevicePropertyCmd(aRemoteAddr,
-                                                    aProperty,
-                                                    aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Remote Services */
-
-void
-BluetoothDaemonCoreInterface::GetRemoteServiceRecord(
-  const BluetoothAddress& aRemoteAddr, const BluetoothUuid& aUuid,
-  BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->GetRemoteServiceRecordCmd(aRemoteAddr, aUuid, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonCoreInterface::GetRemoteServices(
-  const BluetoothAddress& aRemoteAddr, BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->GetRemoteServicesCmd(aRemoteAddr, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Discovery */
-
-void
-BluetoothDaemonCoreInterface::StartDiscovery(BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->StartDiscoveryCmd(aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonCoreInterface::CancelDiscovery(BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->CancelDiscoveryCmd(aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Bonds */
-
-void
-BluetoothDaemonCoreInterface::CreateBond(const BluetoothAddress& aBdAddr,
-                                         BluetoothTransport aTransport,
-                                         BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->CreateBondCmd(aBdAddr, aTransport, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonCoreInterface::RemoveBond(const BluetoothAddress& aBdAddr,
-                                         BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->RemoveBondCmd(aBdAddr, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonCoreInterface::CancelBond(
-  const BluetoothAddress& aBdAddr, BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->CancelBondCmd(aBdAddr, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Connection */
-
-void
-BluetoothDaemonCoreInterface::GetConnectionState(
-  const BluetoothAddress& aBdAddr, BluetoothCoreResultHandler* aRes)
-{
-  // NO-OP: no corresponding interface of current BlueZ
-}
-
-/* Authentication */
-
-void
-BluetoothDaemonCoreInterface::PinReply(const BluetoothAddress& aBdAddr,
-                                       bool aAccept,
-                                       const BluetoothPinCode& aPinCode,
-                                       BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->PinReplyCmd(aBdAddr, aAccept, aPinCode, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonCoreInterface::SspReply(const BluetoothAddress& aBdAddr,
-                                       BluetoothSspVariant aVariant,
-                                       bool aAccept, uint32_t aPasskey,
-                                       BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->SspReplyCmd(aBdAddr, aVariant, aAccept, aPasskey,
-                                     aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* DUT Mode */
-
-void
-BluetoothDaemonCoreInterface::DutModeConfigure(
-  bool aEnable, BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->DutModeConfigureCmd(aEnable, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonCoreInterface::DutModeSend(uint16_t aOpcode,
-                                          uint8_t* aBuf,
-                                          uint8_t aLen,
-                                          BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->DutModeSendCmd(aOpcode, aBuf, aLen, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* LE Mode */
-
-void
-BluetoothDaemonCoreInterface::LeTestMode(uint16_t aOpcode,
-                                         uint8_t* aBuf,
-                                         uint8_t aLen,
-                                         BluetoothCoreResultHandler* aRes)
-{
-  nsresult rv = mModule->LeTestModeCmd(aOpcode, aBuf, aLen, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Energy Information */
-
-void
-BluetoothDaemonCoreInterface::ReadEnergyInfo(BluetoothCoreResultHandler* aRes)
-{
-  // NO-OP: no corresponding interface of current BlueZ
-}
-
-void
-BluetoothDaemonCoreInterface::DispatchError(BluetoothCoreResultHandler* aRes,
-                                            BluetoothStatus aStatus)
-{
-  DaemonResultRunnable1<
-    BluetoothCoreResultHandler, void,
-    BluetoothStatus, BluetoothStatus>::Dispatch(
-    aRes, &BluetoothCoreResultHandler::OnError,
-    ConstantInitOp1<BluetoothStatus>(aStatus));
-}
-
-void
-BluetoothDaemonCoreInterface::DispatchError(BluetoothCoreResultHandler* aRes,
-                                            nsresult aRv)
-{
-  BluetoothStatus status;
-
-  if (NS_WARN_IF(NS_FAILED(Convert(aRv, status)))) {
-    status = STATUS_FAIL;
-  }
-  DispatchError(aRes, status);
-}
-
-END_BLUETOOTH_NAMESPACE
deleted file mode 100644
--- a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h
+++ /dev/null
@@ -1,442 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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_bluedroid_BluetoothDaemonCoreInterface_h
-#define mozilla_dom_bluetooth_bluedroid_BluetoothDaemonCoreInterface_h
-
-#include "BluetoothDaemonHelpers.h"
-#include "BluetoothInterface.h"
-#include "mozilla/ipc/DaemonRunnables.h"
-
-BEGIN_BLUETOOTH_NAMESPACE
-
-using mozilla::ipc::DaemonSocketPDU;
-using mozilla::ipc::DaemonSocketPDUHeader;
-using mozilla::ipc::DaemonSocketResultHandler;
-
-class BluetoothDaemonCoreModule
-{
-public:
-  enum {
-    SERVICE_ID = 0x01
-  };
-
-  enum {
-    OPCODE_ERROR = 0x00,
-    OPCODE_ENABLE = 0x01,
-    OPCODE_DISABLE = 0x02,
-    OPCODE_GET_ADAPTER_PROPERTIES = 0x03,
-    OPCODE_GET_ADAPTER_PROPERTY = 0x04,
-    OPCODE_SET_ADAPTER_PROPERTY = 0x05,
-    OPCODE_GET_REMOTE_DEVICE_PROPERTIES = 0x06,
-    OPCODE_GET_REMOTE_DEVICE_PROPERTY = 0x07,
-    OPCODE_SET_REMOTE_DEVICE_PROPERTY = 0x08,
-    OPCODE_GET_REMOTE_SERVICE_RECORD = 0x09,
-    OPCODE_GET_REMOTE_SERVICES = 0x0a,
-    OPCODE_START_DISCOVERY = 0x0b,
-    OPCODE_CANCEL_DISCOVERY = 0x0c,
-    OPCODE_CREATE_BOND = 0x0d,
-    OPCODE_REMOVE_BOND = 0x0e,
-    OPCODE_CANCEL_BOND = 0x0f,
-    OPCODE_PIN_REPLY = 0x10,
-    OPCODE_SSP_REPLY = 0x11,
-    OPCODE_DUT_MODE_CONFIGURE = 0x12,
-    OPCODE_DUT_MODE_SEND = 0x13,
-    OPCODE_LE_TEST_MODE = 0x14,
-    OPCODE_ADAPTER_STATE_CHANGED_NTF = 0x81,
-    OPCODE_ADAPTER_PROPERTIES_NTF = 0x82,
-    OPCODE_REMOTE_DEVICE_PROPERTIES_NTF = 0x83,
-    OPCODE_DEVICE_FOUND_NTF = 0x84,
-    OPCODE_DISCOVERY_STATE_CHANGED_NTF = 0x85,
-    OPCODE_PIN_REQUEST_NTF = 0x86,
-    OPCODE_SSP_REQUEST_NTF = 0x87,
-    OPCODE_BOND_STATE_CHANGED_NTF = 0x88,
-    OPCODE_ACL_STATE_CHANGED_NTF = 0x89,
-    OPCODE_DUT_MODE_RECV_NTF = 0x8a,
-    OPCODE_LE_TEST_MODE_NTF = 0x8b
-  };
-
-  static const int MAX_NUM_CLIENTS;
-
-  virtual nsresult Send(DaemonSocketPDU* aPDU,
-                        DaemonSocketResultHandler* aRes) = 0;
-
-  void SetNotificationHandler(
-    BluetoothCoreNotificationHandler* aNotificationHandler);
-
-  //
-  // Commands
-  //
-
-  nsresult EnableCmd(BluetoothCoreResultHandler* aRes);
-
-  nsresult DisableCmd(BluetoothCoreResultHandler* aRes);
-
-  nsresult GetAdapterPropertiesCmd(BluetoothCoreResultHandler* aRes);
-
-  nsresult GetAdapterPropertyCmd(BluetoothPropertyType aType,
-                                 BluetoothCoreResultHandler* aRes);
-
-  nsresult SetAdapterPropertyCmd(const BluetoothProperty& aProperty,
-                                 BluetoothCoreResultHandler* aRes);
-
-  nsresult GetRemoteDevicePropertiesCmd(const BluetoothAddress& aRemoteAddr,
-                                        BluetoothCoreResultHandler* aRes);
-
-  nsresult GetRemoteDevicePropertyCmd(const BluetoothAddress& aRemoteAddr,
-                                      BluetoothPropertyType aType,
-                                      BluetoothCoreResultHandler* aRes);
-
-  nsresult SetRemoteDevicePropertyCmd(const BluetoothAddress& aRemoteAddr,
-                                      const BluetoothProperty& aProperty,
-                                      BluetoothCoreResultHandler* aRes);
-
-  nsresult GetRemoteServiceRecordCmd(const BluetoothAddress& aRemoteAddr,
-                                     const BluetoothUuid& aUuid,
-                                     BluetoothCoreResultHandler* aRes);
-
-  nsresult GetRemoteServicesCmd(const BluetoothAddress& aRemoteAddr,
-                                BluetoothCoreResultHandler* aRes);
-
-  nsresult StartDiscoveryCmd(BluetoothCoreResultHandler* aRes);
-
-  nsresult CancelDiscoveryCmd(BluetoothCoreResultHandler* aRes);
-
-  nsresult CreateBondCmd(const BluetoothAddress& aBdAddr,
-                         BluetoothTransport aTransport,
-                         BluetoothCoreResultHandler* aRes);
-
-  nsresult RemoveBondCmd(const BluetoothAddress& aBdAddr,
-                         BluetoothCoreResultHandler* aRes);
-
-  nsresult CancelBondCmd(const BluetoothAddress& aBdAddr,
-                         BluetoothCoreResultHandler* aRes);
-
-  nsresult PinReplyCmd(const BluetoothAddress& aBdAddr, bool aAccept,
-                       const BluetoothPinCode& aPinCode,
-                       BluetoothCoreResultHandler* aRes);
-
-  nsresult SspReplyCmd(const BluetoothAddress& aBdAddr,
-                       BluetoothSspVariant aVariant,
-                       bool aAccept, uint32_t aPasskey,
-                       BluetoothCoreResultHandler* aRes);
-
-  nsresult DutModeConfigureCmd(bool aEnable,
-                               BluetoothCoreResultHandler* aRes);
-
-  nsresult DutModeSendCmd(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
-                          BluetoothCoreResultHandler* aRes);
-
-  nsresult LeTestModeCmd(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
-                         BluetoothCoreResultHandler* aRes);
-
-protected:
-  void HandleSvc(const DaemonSocketPDUHeader& aHeader,
-                 DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
-
-private:
-
-  //
-  // Responses
-  //
-
-  typedef mozilla::ipc::DaemonResultRunnable0<
-    BluetoothCoreResultHandler, void>
-    ResultRunnable;
-
-  typedef mozilla::ipc::DaemonResultRunnable1<
-    BluetoothCoreResultHandler, void, BluetoothStatus, BluetoothStatus>
-    ErrorRunnable;
-
-  void ErrorRsp(const DaemonSocketPDUHeader& aHeader,
-                DaemonSocketPDU& aPDU,
-                BluetoothCoreResultHandler* aRes);
-
-  void EnableRsp(const DaemonSocketPDUHeader& aHeader,
-                 DaemonSocketPDU& aPDU,
-                 BluetoothCoreResultHandler* aRes);
-
-  void DisableRsp(const DaemonSocketPDUHeader& aHeader,
-                  DaemonSocketPDU& aPDU,
-                  BluetoothCoreResultHandler* aRes);
-
-  void GetAdapterPropertiesRsp(const DaemonSocketPDUHeader& aHeader,
-                               DaemonSocketPDU& aPDU,
-                               BluetoothCoreResultHandler* aRes);
-
-  void GetAdapterPropertyRsp(const DaemonSocketPDUHeader& aHeader,
-                             DaemonSocketPDU& aPDU,
-                             BluetoothCoreResultHandler* aRes);
-
-  void SetAdapterPropertyRsp(const DaemonSocketPDUHeader& aHeader,
-                             DaemonSocketPDU& aPDU,
-                             BluetoothCoreResultHandler* aRes);
-
-  void GetRemoteDevicePropertiesRsp(const DaemonSocketPDUHeader& aHeader,
-                                    DaemonSocketPDU& aPDU,
-                                    BluetoothCoreResultHandler* aRes);
-
-  void GetRemoteDevicePropertyRsp(const DaemonSocketPDUHeader& aHeader,
-                                  DaemonSocketPDU& aPDU,
-                                  BluetoothCoreResultHandler* aRes);
-
-  void SetRemoteDevicePropertyRsp(const DaemonSocketPDUHeader& aHeader,
-                                  DaemonSocketPDU& aPDU,
-                                  BluetoothCoreResultHandler* aRes);
-  void GetRemoteServiceRecordRsp(const DaemonSocketPDUHeader& aHeader,
-                                 DaemonSocketPDU& aPDU,
-                                 BluetoothCoreResultHandler* aRes);
-  void GetRemoteServicesRsp(const DaemonSocketPDUHeader& aHeader,
-                            DaemonSocketPDU& aPDU,
-                            BluetoothCoreResultHandler* aRes);
-
-  void StartDiscoveryRsp(const DaemonSocketPDUHeader& aHeader,
-                         DaemonSocketPDU& aPDU,
-                         BluetoothCoreResultHandler* aRes);
-  void CancelDiscoveryRsp(const DaemonSocketPDUHeader& aHeader,
-                          DaemonSocketPDU& aPDU,
-                          BluetoothCoreResultHandler* aRes);
-
-  void CreateBondRsp(const DaemonSocketPDUHeader& aHeader,
-                     DaemonSocketPDU& aPDU,
-                     BluetoothCoreResultHandler* aRes);
-  void RemoveBondRsp(const DaemonSocketPDUHeader& aHeader,
-                     DaemonSocketPDU& aPDU,
-                     BluetoothCoreResultHandler* aRes);
-  void CancelBondRsp(const DaemonSocketPDUHeader& aHeader,
-                     DaemonSocketPDU& aPDU,
-                     BluetoothCoreResultHandler* aRes);
-
-  void PinReplyRsp(const DaemonSocketPDUHeader& aHeader,
-                   DaemonSocketPDU& aPDU,
-                   BluetoothCoreResultHandler* aRes);
-  void SspReplyRsp(const DaemonSocketPDUHeader& aHeader,
-                   DaemonSocketPDU& aPDU,
-                   BluetoothCoreResultHandler* aRes);
-
-  void DutModeConfigureRsp(const DaemonSocketPDUHeader& aHeader,
-                           DaemonSocketPDU& aPDU,
-                           BluetoothCoreResultHandler* aRes);
-
-  void DutModeSendRsp(const DaemonSocketPDUHeader& aHeader,
-                      DaemonSocketPDU& aPDU,
-                      BluetoothCoreResultHandler* aRes);
-
-  void LeTestModeRsp(const DaemonSocketPDUHeader& aHeader,
-                     DaemonSocketPDU& aPDU,
-                     BluetoothCoreResultHandler* aRes);
-
-  void HandleRsp(const DaemonSocketPDUHeader& aHeader,
-                 DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
-
-  //
-  // Notifications
-  //
-
-  class NotificationHandlerWrapper;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable1<
-    NotificationHandlerWrapper, void, bool>
-    AdapterStateChangedNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable3<
-    NotificationHandlerWrapper, void, BluetoothStatus, int,
-    UniquePtr<BluetoothProperty[]>, BluetoothStatus, int,
-    const BluetoothProperty*>
-    AdapterPropertiesNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable4<
-    NotificationHandlerWrapper, void, BluetoothStatus, BluetoothAddress, int,
-    UniquePtr<BluetoothProperty[]>, BluetoothStatus,
-    const BluetoothAddress&, int, const BluetoothProperty*>
-    RemoteDevicePropertiesNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable2<
-    NotificationHandlerWrapper, void, int, UniquePtr<BluetoothProperty[]>,
-    int, const BluetoothProperty*>
-    DeviceFoundNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable1<
-    NotificationHandlerWrapper, void, bool>
-    DiscoveryStateChangedNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable3<
-    NotificationHandlerWrapper, void,
-    BluetoothAddress, BluetoothRemoteName, uint32_t,
-    const BluetoothAddress&, const BluetoothRemoteName&>
-    PinRequestNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable5<
-    NotificationHandlerWrapper, void,
-    BluetoothAddress, BluetoothRemoteName, uint32_t, BluetoothSspVariant,
-    uint32_t,
-    const BluetoothAddress&, const BluetoothRemoteName&>
-    SspRequestNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable3<
-    NotificationHandlerWrapper, void, BluetoothStatus, BluetoothAddress,
-    BluetoothBondState, BluetoothStatus, const BluetoothAddress&>
-    BondStateChangedNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable3<
-    NotificationHandlerWrapper, void,
-    BluetoothStatus, BluetoothAddress, BluetoothAclState,
-    BluetoothStatus, const BluetoothAddress&>
-    AclStateChangedNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable3<
-    NotificationHandlerWrapper, void, uint16_t, UniquePtr<uint8_t[]>,
-    uint8_t, uint16_t, const uint8_t*>
-    DutModeRecvNotification;
-
-  typedef mozilla::ipc::DaemonNotificationRunnable2<
-    NotificationHandlerWrapper, void, BluetoothStatus, uint16_t>
-    LeTestModeNotification;
-
-  class AdapterPropertiesInitOp;
-  class DeviceFoundInitOp;
-  class DutModeRecvInitOp;
-  class RemoteDevicePropertiesInitOp;
-
-  void AdapterStateChangedNtf(const DaemonSocketPDUHeader& aHeader,
-                              DaemonSocketPDU& aPDU);
-
-  void AdapterPropertiesNtf(const DaemonSocketPDUHeader& aHeader,
-                            DaemonSocketPDU& aPDU);
-
-  void RemoteDevicePropertiesNtf(const DaemonSocketPDUHeader& aHeader,
-                                 DaemonSocketPDU& aPDU);
-
-  void DeviceFoundNtf(const DaemonSocketPDUHeader& aHeader,
-                      DaemonSocketPDU& aPDU);
-
-  void DiscoveryStateChangedNtf(const DaemonSocketPDUHeader& aHeader,
-                                DaemonSocketPDU& aPDU);
-
-  void PinRequestNtf(const DaemonSocketPDUHeader& aHeader,
-                     DaemonSocketPDU& aPDU);
-
-  void SspRequestNtf(const DaemonSocketPDUHeader& aHeader,
-                     DaemonSocketPDU& aPDU);
-
-  void BondStateChangedNtf(const DaemonSocketPDUHeader& aHeader,
-                           DaemonSocketPDU& aPDU);
-
-  void AclStateChangedNtf(const DaemonSocketPDUHeader& aHeader,
-                          DaemonSocketPDU& aPDU);
-
-  void DutModeRecvNtf(const DaemonSocketPDUHeader& aHeader,
-                      DaemonSocketPDU& aPDU);
-
-  void LeTestModeNtf(const DaemonSocketPDUHeader& aHeader,
-                     DaemonSocketPDU& aPDU);
-
-  void HandleNtf(const DaemonSocketPDUHeader& aHeader,
-                 DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
-
-  static BluetoothCoreNotificationHandler* sNotificationHandler;
-};
-
-class BluetoothDaemonCoreInterface final
-  : public BluetoothCoreInterface
-{
-public:
-  BluetoothDaemonCoreInterface(BluetoothDaemonCoreModule* aModule);
-  ~BluetoothDaemonCoreInterface();
-
-  void SetNotificationHandler(
-    BluetoothCoreNotificationHandler* aNotificationHandler) override;
-
-  /* Enable / Disable */
-
-  void Enable(BluetoothCoreResultHandler* aRes) override;
-  void Disable(BluetoothCoreResultHandler* aRes) override;
-
-  /* Adapter Properties */
-
-  void GetAdapterProperties(BluetoothCoreResultHandler* aRes) override;
-  void GetAdapterProperty(BluetoothPropertyType aType,
-                          BluetoothCoreResultHandler* aRes) override;
-  void SetAdapterProperty(const BluetoothProperty& aProperty,
-                          BluetoothCoreResultHandler* aRes) override;
-
-  /* Remote Device Properties */
-
-  void GetRemoteDeviceProperties(const BluetoothAddress& aRemoteAddr,
-                                 BluetoothCoreResultHandler* aRes) override;
-  void GetRemoteDeviceProperty(const BluetoothAddress& aRemoteAddr,
-                               BluetoothPropertyType aType,
-                               BluetoothCoreResultHandler* aRes) override;
-  void SetRemoteDeviceProperty(const BluetoothAddress& aRemoteAddr,
-                               const BluetoothProperty& aProperty,
-                               BluetoothCoreResultHandler* aRes) override;
-
-  /* Remote Services */
-
-  void GetRemoteServiceRecord(const BluetoothAddress& aRemoteAddr,
-                              const BluetoothUuid& aUuid,
-                              BluetoothCoreResultHandler* aRes) override;
-  void GetRemoteServices(const BluetoothAddress& aRemoteAddr,
-                         BluetoothCoreResultHandler* aRes) override;
-
-  /* Discovery */
-
-  void StartDiscovery(BluetoothCoreResultHandler* aRes) override;
-  void CancelDiscovery(BluetoothCoreResultHandler* aRes) override;
-
-  /* Bonds */
-
-  void CreateBond(const BluetoothAddress& aBdAddr,
-                  BluetoothTransport aTransport,
-                  BluetoothCoreResultHandler* aRes) override;
-  void RemoveBond(const BluetoothAddress& aBdAddr,
-                  BluetoothCoreResultHandler* aRes) override;
-  void CancelBond(const BluetoothAddress& aBdAddr,
-                  BluetoothCoreResultHandler* aRes) override;
-
-  /* Connection */
-
-  void GetConnectionState(const BluetoothAddress& aBdAddr,
-                          BluetoothCoreResultHandler* aRes) override;
-
-  /* Authentication */
-
-  void PinReply(const BluetoothAddress& aBdAddr, bool aAccept,
-                const BluetoothPinCode& aPinCode,
-                BluetoothCoreResultHandler* aRes) override;
-
-  void SspReply(const BluetoothAddress& aBdAddr,
-                BluetoothSspVariant aVariant,
-                bool aAccept, uint32_t aPasskey,
-                BluetoothCoreResultHandler* aRes) override;
-
-  /* DUT Mode */
-
-  void DutModeConfigure(bool aEnable, BluetoothCoreResultHandler* aRes);
-  void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
-                   BluetoothCoreResultHandler* aRes) override;
-
-  /* LE Mode */
-
-  void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
-                  BluetoothCoreResultHandler* aRes) override;
-
-  /* Energy Information */
-
-  void ReadEnergyInfo(BluetoothCoreResultHandler* aRes) override;
-
-private:
-  void DispatchError(BluetoothCoreResultHandler* aRes,
-                     BluetoothStatus aStatus);
-  void DispatchError(BluetoothCoreResultHandler* aRes,
-                     nsresult aRv);
-
-  BluetoothDaemonCoreModule* mModule;
-};
-
-END_BLUETOOTH_NAMESPACE
-
-#endif // mozilla_dom_bluetooth_bluedroid_BluetoothDaemonCoreInterface_h
deleted file mode 100644
--- a/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp
+++ /dev/null
@@ -1,2689 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "BluetoothDaemonGattInterface.h"
-#include "mozilla/UniquePtr.h"
-#include "mozilla/Unused.h"
-
-BEGIN_BLUETOOTH_NAMESPACE
-
-using namespace mozilla::ipc;
-
-//
-// GATT module
-//
-
-BluetoothGattNotificationHandler*
-  BluetoothDaemonGattModule::sNotificationHandler;
-
-void
-BluetoothDaemonGattModule::SetNotificationHandler(
-  BluetoothGattNotificationHandler* aNotificationHandler)
-{
-  sNotificationHandler = aNotificationHandler;
-}
-
-void
-BluetoothDaemonGattModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
-                                     DaemonSocketPDU& aPDU,
-                                     DaemonSocketResultHandler* aRes)
-{
-  static void (BluetoothDaemonGattModule::* const HandleOp[])(
-    const DaemonSocketPDUHeader&, DaemonSocketPDU&,
-    DaemonSocketResultHandler*) = {
-    [0] = &BluetoothDaemonGattModule::HandleRsp,
-    [1] = &BluetoothDaemonGattModule::HandleNtf
-  };
-
-  MOZ_ASSERT(!NS_IsMainThread());
-
-  // Negate twice to map bit to 0/1
-  unsigned long isNtf = !!(aHeader.mOpcode & 0x80);
-
-  (this->*(HandleOp[isNtf]))(aHeader, aPDU, aRes);
-}
-
-// Commands
-//
-
-nsresult
-BluetoothDaemonGattModule::ClientRegisterCmd(
-  const BluetoothUuid& aUuid, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_REGISTER,
-                                16); // Service UUID
-
-  nsresult rv = PackPDU(aUuid, *pdu);
-
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientUnregisterCmd(
-  int aClientIf, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_UNREGISTER,
-                                4); // Client Interface
-
-  nsresult rv = PackPDU(aClientIf, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientScanCmd(
-  int aClientIf, bool aStart, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_SCAN,
-                                4 + // Client Interface
-                                1); // Start
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aClientIf),
-                        PackConversion<bool, uint8_t>(aStart), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientConnectCmd(
-  int aClientIf, const BluetoothAddress& aBdAddr, bool aIsDirect,
-  BluetoothTransport aTransport, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_CONNECT,
-                                4 + // Client Interface
-                                6 + // Remote Address
-                                1 + // Is Direct
-                                4); // Transport
-
-  nsresult rv = PackPDU(
-    PackConversion<int, int32_t>(aClientIf),
-    aBdAddr,
-    PackConversion<bool, uint8_t>(aIsDirect),
-    PackConversion<BluetoothTransport, int32_t>(aTransport), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientDisconnectCmd(
-  int aClientIf, const BluetoothAddress& aBdAddr, int aConnId,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_DISCONNECT,
-                                4 + // Client Interface
-                                6 + // Remote Address
-                                4); // Connection ID
-
-  nsresult rv;
-  rv = PackPDU(PackConversion<int, int32_t>(aClientIf),
-               aBdAddr,
-               PackConversion<int, int32_t>(aConnId), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientListenCmd(
-  int aClientIf, bool aIsStart, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_LISTEN,
-                                4 + // Client Interface
-                                1); // Start
-
-  nsresult rv;
-  rv = PackPDU(PackConversion<int, int32_t>(aClientIf),
-               PackConversion<bool, uint8_t>(aIsStart), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientRefreshCmd(
-  int aClientIf, const BluetoothAddress& aBdAddr,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_REFRESH,
-                                4 + // Client Interface
-                                6); // Remote Address
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aClientIf),
-                        aBdAddr,
-                        *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientSearchServiceCmd(
-  int aConnId, bool aFiltered, const BluetoothUuid& aUuid,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_SEARCH_SERVICE,
-                                4 + // Connection ID
-                                1 + // Filtered
-                                16); // UUID
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aConnId),
-                        PackConversion<bool, uint8_t>(aFiltered),
-                        PackReversed<BluetoothUuid>(aUuid),
-                        *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientGetIncludedServiceCmd(
-  int aConnId, const BluetoothGattServiceId& aServiceId, bool aContinuation,
-  const BluetoothGattServiceId& aStartServiceId,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_GET_INCLUDED_SERVICE,
-                                4 + // Connection ID
-                                18 + // Service ID
-                                1 + // Continuation
-                                18); // Start Service ID
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aConnId), aServiceId,
-                        PackConversion<bool, uint8_t>(aContinuation),
-                        aStartServiceId, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientGetCharacteristicCmd(
-  int aConnId, const BluetoothGattServiceId& aServiceId, bool aContinuation,
-  const BluetoothGattId& aStartCharId,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_GET_CHARACTERISTIC,
-                                4 + // Connection ID
-                                18 + // Service ID
-                                1 + // Continuation
-                                17); // Start Characteristic ID
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aConnId), aServiceId,
-                        PackConversion<bool, uint8_t>(aContinuation),
-                        aStartCharId, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientGetDescriptorCmd(
-  int aConnId, const BluetoothGattServiceId& aServiceId,
-  const BluetoothGattId& aCharId, bool aContinuation,
-  const BluetoothGattId& aStartDescriptorId,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_GET_DESCRIPTOR,
-                                4 + // Connection ID
-                                18 + // Service ID
-                                17 + // Characteristic ID
-                                1 + // Continuation
-                                17); // Start Descriptor ID
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aConnId),
-                        aServiceId, aCharId,
-                        PackConversion<bool, uint8_t>(aContinuation),
-                        aStartDescriptorId, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientReadCharacteristicCmd(
-  int aConnId, const BluetoothGattServiceId& aServiceId,
-  const BluetoothGattId& aCharId, BluetoothGattAuthReq aAuthReq,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_READ_CHARACTERISTIC,
-                                4 + // Connection ID
-                                18 + // Service ID
-                                17 + // Characteristic ID
-                                4); // Authorization
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aConnId), aServiceId,
-                        aCharId, aAuthReq, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientWriteCharacteristicCmd(
-  int aConnId, const BluetoothGattServiceId& aServiceId,
-  const BluetoothGattId& aCharId, BluetoothGattWriteType aWriteType,
-  int aLength, BluetoothGattAuthReq aAuthReq, char* aValue,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_WRITE_CHARACTERISTIC,
-                                0);
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aConnId), aServiceId,
-                        aCharId, aWriteType,
-                        PackConversion<int, int32_t>(aLength), aAuthReq,
-                        PackArray<char>(aValue, aLength), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientReadDescriptorCmd(
-  int aConnId, const BluetoothGattServiceId& aServiceId,
-  const BluetoothGattId& aCharId, const BluetoothGattId& aDescriptorId,
-  BluetoothGattAuthReq aAuthReq, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_READ_DESCRIPTOR,
-                                4 + // Connection ID
-                                18 + // Service ID
-                                17 + // Characteristic ID
-                                17 + // Descriptor ID
-                                4); // Authorization
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aConnId), aServiceId,
-                        aCharId, aDescriptorId, aAuthReq, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientWriteDescriptorCmd(
-  int aConnId, const BluetoothGattServiceId& aServiceId,
-  const BluetoothGattId& aCharId, const BluetoothGattId& aDescriptorId,
-  BluetoothGattWriteType aWriteType, int aLength,
-  BluetoothGattAuthReq aAuthReq, char* aValue,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_WRITE_DESCRIPTOR,
-                                0);
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aConnId), aServiceId,
-                        aCharId, aDescriptorId, aWriteType,
-                        PackConversion<int, int32_t>(aLength), aAuthReq,
-                        PackArray<char>(aValue, aLength), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientExecuteWriteCmd(
-  int aConnId, int aIsExecute, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_EXECUTE_WRITE,
-                                4 + // Connection ID
-                                4); // Execute
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aConnId),
-                        PackConversion<int, int32_t>(aIsExecute), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientRegisterNotificationCmd(
-  int aClientIf, const BluetoothAddress& aBdAddr,
-  const BluetoothGattServiceId& aServiceId, const BluetoothGattId& aCharId,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_REGISTER_NOTIFICATION,
-                                4 + // Client Interface
-                                6 + // Remote Address
-                                18 + // Service ID
-                                17); // Characteristic ID
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aClientIf),
-                        aBdAddr, aServiceId, aCharId, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientDeregisterNotificationCmd(
-  int aClientIf, const BluetoothAddress& aBdAddr,
-  const BluetoothGattServiceId& aServiceId, const BluetoothGattId& aCharId,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_DEREGISTER_NOTIFICATION,
-                                4 + // Client Interface
-                                6 + // Remote Address
-                                18 + // Service ID
-                                17); // Characteristic ID
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aClientIf),
-                        aBdAddr, aServiceId, aCharId, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientReadRemoteRssiCmd(
-  int aClientIf, const BluetoothAddress& aBdAddr,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_READ_REMOTE_RSSI,
-                                4 + // Client Interface
-                                6); // Remote Address
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aClientIf),
-                        aBdAddr, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientGetDeviceTypeCmd(
-  const BluetoothAddress& aBdAddr, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_GET_DEVICE_TYPE,
-                                6); // Remote Address
-
-  nsresult rv = PackPDU(aBdAddr, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientSetAdvDataCmd(
-  int aServerIf, bool aIsScanRsp, bool aIsNameIncluded,
-  bool aIsTxPowerIncluded, int aMinInterval, int aMaxInterval, int aApperance,
-  const nsTArray<uint8_t>& aManufacturerData,
-  const nsTArray<uint8_t>& aServiceData,
-  const nsTArray<BluetoothUuid>& aServiceUuids,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_SET_ADV_DATA,
-                                0);
-
-  uint16_t manufacturerDataByteLen =
-    aManufacturerData.Length() * sizeof(uint8_t);
-  uint16_t serviceDataByteLen = aServiceData.Length() * sizeof(uint8_t);
-  uint16_t serviceUuidsByteLen =
-    aServiceUuids.Length() * sizeof(BluetoothUuid::mUuid);
-  uint8_t* manufacturerData =
-    const_cast<uint8_t*>(aManufacturerData.Elements());
-  uint8_t* serviceData = const_cast<uint8_t*>(aServiceData.Elements());
-  BluetoothUuid* serviceUuids =
-    const_cast<BluetoothUuid*>(aServiceUuids.Elements());
-
-  nsresult rv = PackPDU(
-    PackConversion<int, int32_t>(aServerIf),
-    PackConversion<bool, uint8_t>(aIsScanRsp),
-    PackConversion<bool, uint8_t>(aIsNameIncluded),
-    PackConversion<bool, uint8_t>(aIsTxPowerIncluded),
-    PackConversion<int, int32_t>(aMinInterval),
-    PackConversion<int, int32_t>(aMaxInterval),
-    PackConversion<int, int32_t>(aApperance),
-    manufacturerDataByteLen, serviceDataByteLen, serviceUuidsByteLen,
-    PackArray<uint8_t>(manufacturerData, aManufacturerData.Length()),
-    PackArray<uint8_t>(serviceData, aServiceData.Length()),
-    PackArray<PackReversed<BluetoothUuid>>(
-      serviceUuids, aServiceUuids.Length()),
-    *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ClientTestCommandCmd(
-  int aCommand, const BluetoothGattTestParam& aTestParam,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_CLIENT_TEST_COMMAND,
-                                4 + // Command
-                                6 + // Address
-                                16 + // UUID
-                                2 + // U1
-                                2 + // U2
-                                2 + // U3
-                                2 + // U4
-                                2); // U5
-
-  nsresult rv = PackPDU(
-    PackConversion<int, int32_t>(aCommand),
-    aTestParam.mBdAddr,
-    aTestParam.mU1, aTestParam.mU2, aTestParam.mU3, aTestParam.mU4,
-    aTestParam.mU5, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerRegisterCmd(
-  const BluetoothUuid& aUuid, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_REGISTER,
-                                16); // Uuid
-
-  nsresult rv = PackPDU(aUuid, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerUnregisterCmd(
-  int aServerIf, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_UNREGISTER,
-                                4); // Server Interface
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aServerIf), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerConnectPeripheralCmd(
-  int aServerIf, const BluetoothAddress& aBdAddr, bool aIsDirect,
-  BluetoothTransport aTransport, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_CONNECT_PERIPHERAL,
-                                4 + // Server Interface
-                                6 + // Remote Address
-                                1 + // Is Direct
-                                4); // Transport
-
-  nsresult rv = PackPDU(
-    PackConversion<int, int32_t>(aServerIf),
-    aBdAddr,
-    PackConversion<bool, uint8_t>(aIsDirect),
-    PackConversion<BluetoothTransport, int32_t>(aTransport), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerDisconnectPeripheralCmd(
-  int aServerIf, const BluetoothAddress& aBdAddr, int aConnId,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_DISCONNECT_PERIPHERAL,
-                                4 + // Server Interface
-                                6 + // Remote Address
-                                4); // Connection Id
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aServerIf),
-                        aBdAddr,
-                        PackConversion<int, int32_t>(aConnId), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerAddServiceCmd(
-  int aServerIf, const BluetoothGattServiceId& aServiceId, uint16_t aNumHandles,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_ADD_SERVICE,
-                                4 + // Server Interface
-                                18 + // Service ID
-                                4); // Number of Handles
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aServerIf), aServiceId,
-                        PackConversion<uint16_t, int32_t>(aNumHandles), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerAddIncludedServiceCmd(
-  int aServerIf, const BluetoothAttributeHandle& aServiceHandle,
-  const BluetoothAttributeHandle& aIncludedServiceHandle,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_ADD_INCLUDED_SERVICE,
-                                4 + // Server Interface
-                                4 + // Service Handle
-                                4); // Included Service Handle
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aServerIf),
-                        aServiceHandle, aIncludedServiceHandle, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerAddCharacteristicCmd(
-  int aServerIf, const BluetoothAttributeHandle& aServiceHandle,
-  const BluetoothUuid& aUuid, BluetoothGattCharProp aProperties,
-  BluetoothGattAttrPerm aPermissions, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_ADD_CHARACTERISTIC,
-                                4 + // Server Interface
-                                4 + // Service Handle
-                                16 + // UUID
-                                4 + // Properties
-                                4); // Permissions
-
-  nsresult rv = PackPDU(
-    PackConversion<int, int32_t>(aServerIf), aServiceHandle,
-    PackReversed<BluetoothUuid>(aUuid),
-    PackConversion<BluetoothGattCharProp, int32_t>(aProperties),
-    PackConversion<BluetoothGattAttrPerm, int32_t>(aPermissions), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerAddDescriptorCmd(
-  int aServerIf, const BluetoothAttributeHandle& aServiceHandle,
-  const BluetoothUuid& aUuid, BluetoothGattAttrPerm aPermissions,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_ADD_DESCRIPTOR,
-                                4 + // Server Interface
-                                4 + // Service Handle
-                                16 + // UUID
-                                4); // Permissions
-
-  nsresult rv = PackPDU(
-    PackConversion<int, int32_t>(aServerIf), aServiceHandle,
-    PackReversed<BluetoothUuid>(aUuid),
-    PackConversion<BluetoothGattAttrPerm, int32_t>(aPermissions), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerStartServiceCmd(
-  int aServerIf, const BluetoothAttributeHandle& aServiceHandle,
-  BluetoothTransport aTransport, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_START_SERVICE,
-                                4 + // Server Interface
-                                4 + // Service Handle
-                                4); // Transport
-
-  nsresult rv = PackPDU(
-    PackConversion<int, int32_t>(aServerIf), aServiceHandle,
-    PackConversion<BluetoothTransport, int32_t>(aTransport), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerStopServiceCmd(
-  int aServerIf, const BluetoothAttributeHandle& aServiceHandle,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_STOP_SERVICE,
-                                4 + // Server Interface
-                                4); // Service Handle
-
-  nsresult rv = PackPDU(
-    PackConversion<int, int32_t>(aServerIf), aServiceHandle, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerDeleteServiceCmd(
-  int aServerIf, const BluetoothAttributeHandle& aServiceHandle,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_DELETE_SERVICE,
-                                4 + // Server Interface
-                                4); // Service Handle
-
-  nsresult rv = PackPDU(
-    PackConversion<int, int32_t>(aServerIf), aServiceHandle, *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerSendIndicationCmd(
-  int aServerIf, const BluetoothAttributeHandle& aCharacteristicHandle,
-  int aConnId, int aLength, bool aConfirm,
-  uint8_t* aValue, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_SEND_INDICATION,
-                                0);
-
-  nsresult rv = PackPDU(PackConversion<int, int32_t>(aServerIf),
-                        aCharacteristicHandle,
-                        PackConversion<int, int32_t>(aConnId),
-                        PackConversion<int, int32_t>(aLength),
-                        PackConversion<bool, int32_t>(aConfirm),
-                        PackArray<uint8_t>(aValue, aLength), *pdu);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-nsresult
-BluetoothDaemonGattModule::ServerSendResponseCmd(
-  int aConnId, int aTransId, uint16_t aStatus,
-  const BluetoothGattResponse& aResponse,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  UniquePtr<DaemonSocketPDU> pdu =
-    MakeUnique<DaemonSocketPDU>(SERVICE_ID, OPCODE_SERVER_SEND_RESPONSE,
-                                0);
-
-  nsresult rv = PackPDU(
-    PackConversion<int, int32_t>(aConnId),
-    PackConversion<int, int32_t>(aTransId),
-    PackConversion<BluetoothAttributeHandle, uint16_t>(aResponse.mHandle),
-    aResponse.mOffset,
-    PackConversion<BluetoothGattAuthReq, uint8_t>(aResponse.mAuthReq),
-    PackConversion<uint16_t, int32_t>(aStatus),
-    aResponse.mLength,
-    PackArray<uint8_t>(aResponse.mValue, aResponse.mLength), *pdu);
-
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = Send(pdu.get(), aRes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  Unused << pdu.release();
-  return NS_OK;
-}
-
-// Responses
-//
-
-void
-BluetoothDaemonGattModule::ErrorRsp(
-  const DaemonSocketPDUHeader& aHeader,
-  DaemonSocketPDU& aPDU, BluetoothGattResultHandler* aRes)
-{
-  ErrorRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::OnError, UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientRegisterRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::RegisterClient,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientUnregisterRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::UnregisterClient,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientScanRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::Scan, UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientConnectRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::Connect, UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientDisconnectRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::Disconnect,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientListenRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::Listen, UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientRefreshRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::Refresh, UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientSearchServiceRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::SearchService,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientGetIncludedServiceRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::GetIncludedService,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientGetCharacteristicRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::GetCharacteristic,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientGetDescriptorRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::GetDescriptor,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientReadCharacteristicRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::ReadCharacteristic,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientWriteCharacteristicRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::WriteCharacteristic,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientReadDescriptorRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::ReadDescriptor,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientWriteDescriptorRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::WriteDescriptor,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientExecuteWriteRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::ExecuteWrite,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientRegisterNotificationRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::RegisterNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientDeregisterNotificationRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::DeregisterNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientReadRemoteRssiRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::ReadRemoteRssi,
-    UnpackPDUInitOp(aPDU));
-}
-
-// Init operator class for ClientGetDeviceTypeRsp
-class BluetoothDaemonGattModule::ClientGetDeviceTypeInitOp final
-  : private PDUInitOp
-{
-public:
-  ClientGetDeviceTypeInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (BluetoothTypeOfDevice& aArg1) const
-  {
-    /* Read device type */
-    nsresult rv = UnpackPDU(
-      GetPDU(), UnpackConversion<uint8_t, BluetoothTypeOfDevice>(aArg1));
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonGattModule::ClientGetDeviceTypeRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ClientGetDeviceTypeResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::GetDeviceType,
-    ClientGetDeviceTypeInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientSetAdvDataRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::SetAdvData,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientTestCommandRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::TestCommand,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerRegisterRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::RegisterServer,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerUnregisterRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::UnregisterServer,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerConnectPeripheralRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::ConnectPeripheral,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerDisconnectPeripheralRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::DisconnectPeripheral,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerAddServiceRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::AddService,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerAddIncludedServiceRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::AddIncludedService,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerAddCharacteristicRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::AddCharacteristic,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerAddDescriptorRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::AddDescriptor,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerStartServiceRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::StartService,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerStopServiceRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::StopService,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerDeleteServiceRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::DeleteService,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerSendIndicationRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::SendIndication,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerSendResponseRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  BluetoothGattResultHandler* aRes)
-{
-  ResultRunnable::Dispatch(
-    aRes, &BluetoothGattResultHandler::SendResponse,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::HandleRsp(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  DaemonSocketResultHandler* aRes)
-{
-  static void (BluetoothDaemonGattModule::* const HandleRsp[])(
-    const DaemonSocketPDUHeader&,
-    DaemonSocketPDU&,
-    BluetoothGattResultHandler*) = {
-    [OPCODE_ERROR] =
-      &BluetoothDaemonGattModule::ErrorRsp,
-    [OPCODE_CLIENT_REGISTER] =
-      &BluetoothDaemonGattModule::ClientRegisterRsp,
-    [OPCODE_CLIENT_UNREGISTER] =
-      &BluetoothDaemonGattModule::ClientUnregisterRsp,
-    [OPCODE_CLIENT_SCAN] =
-      &BluetoothDaemonGattModule::ClientScanRsp,
-    [OPCODE_CLIENT_CONNECT] =
-      &BluetoothDaemonGattModule::ClientConnectRsp,
-    [OPCODE_CLIENT_DISCONNECT] =
-      &BluetoothDaemonGattModule::ClientDisconnectRsp,
-    [OPCODE_CLIENT_LISTEN] =
-      &BluetoothDaemonGattModule::ClientListenRsp,
-    [OPCODE_CLIENT_REFRESH] =
-      &BluetoothDaemonGattModule::ClientRefreshRsp,
-    [OPCODE_CLIENT_SEARCH_SERVICE] =
-      &BluetoothDaemonGattModule::ClientSearchServiceRsp,
-    [OPCODE_CLIENT_GET_INCLUDED_SERVICE] =
-      &BluetoothDaemonGattModule::ClientGetIncludedServiceRsp,
-    [OPCODE_CLIENT_GET_CHARACTERISTIC] =
-      &BluetoothDaemonGattModule::ClientGetCharacteristicRsp,
-    [OPCODE_CLIENT_GET_DESCRIPTOR] =
-      &BluetoothDaemonGattModule::ClientGetDescriptorRsp,
-    [OPCODE_CLIENT_READ_CHARACTERISTIC] =
-      &BluetoothDaemonGattModule::ClientReadCharacteristicRsp,
-    [OPCODE_CLIENT_WRITE_CHARACTERISTIC] =
-      &BluetoothDaemonGattModule::ClientWriteCharacteristicRsp,
-    [OPCODE_CLIENT_READ_DESCRIPTOR] =
-      &BluetoothDaemonGattModule::ClientReadDescriptorRsp,
-    [OPCODE_CLIENT_WRITE_DESCRIPTOR] =
-      &BluetoothDaemonGattModule::ClientWriteDescriptorRsp,
-    [OPCODE_CLIENT_EXECUTE_WRITE] =
-      &BluetoothDaemonGattModule::ClientExecuteWriteRsp,
-    [OPCODE_CLIENT_REGISTER_NOTIFICATION] =
-      &BluetoothDaemonGattModule::ClientRegisterNotificationRsp,
-    [OPCODE_CLIENT_DEREGISTER_NOTIFICATION] =
-      &BluetoothDaemonGattModule::ClientDeregisterNotificationRsp,
-    [OPCODE_CLIENT_READ_REMOTE_RSSI] =
-      &BluetoothDaemonGattModule::ClientReadRemoteRssiRsp,
-    [OPCODE_CLIENT_GET_DEVICE_TYPE] =
-      &BluetoothDaemonGattModule::ClientGetDeviceTypeRsp,
-    [OPCODE_CLIENT_SET_ADV_DATA] =
-      &BluetoothDaemonGattModule::ClientSetAdvDataRsp,
-    [OPCODE_CLIENT_TEST_COMMAND] =
-      &BluetoothDaemonGattModule::ClientTestCommandRsp,
-    [OPCODE_SERVER_REGISTER] =
-      &BluetoothDaemonGattModule::ServerRegisterRsp,
-    [OPCODE_SERVER_UNREGISTER] =
-      &BluetoothDaemonGattModule::ServerUnregisterRsp,
-    [OPCODE_SERVER_CONNECT_PERIPHERAL] =
-      &BluetoothDaemonGattModule::ServerConnectPeripheralRsp,
-    [OPCODE_SERVER_DISCONNECT_PERIPHERAL] =
-      &BluetoothDaemonGattModule::ServerDisconnectPeripheralRsp,
-    [OPCODE_SERVER_ADD_SERVICE] =
-      &BluetoothDaemonGattModule::ServerAddServiceRsp,
-    [OPCODE_SERVER_ADD_INCLUDED_SERVICE] =
-      &BluetoothDaemonGattModule::ServerAddIncludedServiceRsp,
-    [OPCODE_SERVER_ADD_CHARACTERISTIC] =
-      &BluetoothDaemonGattModule::ServerAddCharacteristicRsp,
-    [OPCODE_SERVER_ADD_DESCRIPTOR] =
-      &BluetoothDaemonGattModule::ServerAddDescriptorRsp,
-    [OPCODE_SERVER_START_SERVICE] =
-      &BluetoothDaemonGattModule::ServerStartServiceRsp,
-    [OPCODE_SERVER_STOP_SERVICE] =
-      &BluetoothDaemonGattModule::ServerStopServiceRsp,
-    [OPCODE_SERVER_DELETE_SERVICE] =
-      &BluetoothDaemonGattModule::ServerDeleteServiceRsp,
-    [OPCODE_SERVER_SEND_INDICATION] =
-      &BluetoothDaemonGattModule::ServerSendIndicationRsp,
-    [OPCODE_SERVER_SEND_RESPONSE] =
-      &BluetoothDaemonGattModule::ServerSendResponseRsp
-  };
-
-  MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
-
-  if (NS_WARN_IF(!(aHeader.mOpcode < MOZ_ARRAY_LENGTH(HandleRsp))) ||
-      NS_WARN_IF(!HandleRsp[aHeader.mOpcode])) {
-    return;
-  }
-
-  RefPtr<BluetoothGattResultHandler> res =
-    static_cast<BluetoothGattResultHandler*>(aRes);
-
-  if (!res) {
-    return;
-  } // Return early if no result handler has been set for response
-
-  (this->*(HandleRsp[aHeader.mOpcode]))(aHeader, aPDU, res);
-}
-
-// Notifications
-//
-
-// Returns the current notification handler to a notification runnable
-class BluetoothDaemonGattModule::NotificationHandlerWrapper final
-{
-public:
-  typedef BluetoothGattNotificationHandler ObjectType;
-
-  static ObjectType* GetInstance()
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    return sNotificationHandler;
-  }
-};
-
-void
-BluetoothDaemonGattModule::ClientRegisterNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientRegisterNotification::Dispatch(
-    &BluetoothGattNotificationHandler::RegisterClientNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-// Init operator class for ClientScanResultNotification
-class BluetoothDaemonGattModule::ClientScanResultInitOp final
-  : private PDUInitOp
-{
-public:
-  ClientScanResultInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (BluetoothAddress& aArg1,
-               int& aArg2,
-               BluetoothGattAdvData& aArg3) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read address */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read RSSI */
-    rv = UnpackPDU(pdu, aArg2);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read Length */
-    uint16_t length;
-    rv = UnpackPDU(pdu, length);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read Adv Data */
-    rv = UnpackPDU(pdu, UnpackArray<uint8_t>(aArg3.mAdvData, length));
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonGattModule::ClientScanResultNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientScanResultNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ScanResultNotification,
-    ClientScanResultInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientConnectNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientConnectNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ConnectNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientDisconnectNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientDisconnectNotification::Dispatch(
-    &BluetoothGattNotificationHandler::DisconnectNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientSearchCompleteNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientSearchCompleteNotification::Dispatch(
-    &BluetoothGattNotificationHandler::SearchCompleteNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientSearchResultNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientSearchResultNotification::Dispatch(
-    &BluetoothGattNotificationHandler::SearchResultNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientGetCharacteristicNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientGetCharacteristicNotification::Dispatch(
-    &BluetoothGattNotificationHandler::GetCharacteristicNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientGetDescriptorNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientGetDescriptorNotification::Dispatch(
-    &BluetoothGattNotificationHandler::GetDescriptorNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientGetIncludedServiceNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientGetIncludedServiceNotification::Dispatch(
-    &BluetoothGattNotificationHandler::GetIncludedServiceNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientRegisterNotificationNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientRegisterNotificationNotification::Dispatch(
-    &BluetoothGattNotificationHandler::RegisterNotificationNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientNotifyNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientNotifyNotification::Dispatch(
-    &BluetoothGattNotificationHandler::NotifyNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientReadCharacteristicNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientReadCharacteristicNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ReadCharacteristicNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientWriteCharacteristicNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientWriteCharacteristicNotification::Dispatch(
-    &BluetoothGattNotificationHandler::WriteCharacteristicNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientReadDescriptorNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientReadDescriptorNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ReadDescriptorNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientWriteDescriptorNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientWriteDescriptorNotification::Dispatch(
-    &BluetoothGattNotificationHandler::WriteDescriptorNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientExecuteWriteNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientExecuteWriteNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ExecuteWriteNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientReadRemoteRssiNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientReadRemoteRssiNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ReadRemoteRssiNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ClientListenNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ClientListenNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ListenNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerRegisterNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerRegisterNotification::Dispatch(
-    &BluetoothGattNotificationHandler::RegisterServerNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-// Init operator class for ServerConnectionNotification
-class BluetoothDaemonGattModule::ServerConnectionInitOp final
-  : private PDUInitOp
-{
-public:
-  ServerConnectionInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (int& aArg1,
-               int& aArg2,
-               bool& aArg3,
-               BluetoothAddress& aArg4) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read connection ID */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read server interface */
-    rv = UnpackPDU(pdu, aArg2);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read connected */
-    rv = UnpackPDU(pdu, UnpackConversion<int32_t, bool>(aArg3));
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read address */
-    rv = UnpackPDU(pdu, aArg4);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonGattModule::ServerConnectionNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerConnectionNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ConnectionNotification,
-    ServerConnectionInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerServiceAddedNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerServiceAddedNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ServiceAddedNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerIncludedServiceAddedNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerIncludedServiceAddedNotification::Dispatch(
-    &BluetoothGattNotificationHandler::IncludedServiceAddedNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-// Init operator class for ServerCharacteristicAddedNotification
-class BluetoothDaemonGattModule::ServerCharacteristicAddedInitOp final
-  : private PDUInitOp
-{
-public:
-  ServerCharacteristicAddedInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (BluetoothGattStatus& aArg1,
-               int& aArg2,
-               BluetoothUuid& aArg3,
-               BluetoothAttributeHandle& aArg4,
-               BluetoothAttributeHandle& aArg5) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read GATT status */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read server interface */
-    rv = UnpackPDU(pdu, aArg2);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read characteristic UUID */
-    rv = UnpackPDU(pdu, UnpackReversed<BluetoothUuid>(aArg3));
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read service handle */
-    rv = UnpackPDU(pdu, aArg4);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read characteristic handle */
-    rv = UnpackPDU(pdu, aArg5);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonGattModule::ServerCharacteristicAddedNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerCharacteristicAddedNotification::Dispatch(
-    &BluetoothGattNotificationHandler::CharacteristicAddedNotification,
-    ServerCharacteristicAddedInitOp(aPDU));
-}
-
-// Init operator class for ServerDescriptorAddedNotification
-class BluetoothDaemonGattModule::ServerDescriptorAddedInitOp final
-  : private PDUInitOp
-{
-public:
-  ServerDescriptorAddedInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (BluetoothGattStatus& aArg1,
-               int& aArg2,
-               BluetoothUuid& aArg3,
-               BluetoothAttributeHandle& aArg4,
-               BluetoothAttributeHandle& aArg5) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read GATT status */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read server interface */
-    rv = UnpackPDU(pdu, aArg2);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read characteristic UUID */
-    rv = UnpackPDU(pdu, UnpackReversed<BluetoothUuid>(aArg3));
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read service handle */
-    rv = UnpackPDU(pdu, aArg4);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read descriptor handle */
-    rv = UnpackPDU(pdu, aArg5);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-void
-BluetoothDaemonGattModule::ServerDescriptorAddedNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerDescriptorAddedNotification::Dispatch(
-    &BluetoothGattNotificationHandler::DescriptorAddedNotification,
-    ServerDescriptorAddedInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerServiceStartedNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerServiceStartedNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ServiceStartedNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerServiceStoppedNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerServiceStoppedNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ServiceStoppedNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerServiceDeletedNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerServiceDeletedNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ServiceDeletedNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerRequestReadNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerRequestReadNotification::Dispatch(
-    &BluetoothGattNotificationHandler::RequestReadNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-// Init operator class for ServerRequestWriteNotification
-class BluetoothDaemonGattModule::ServerRequestWriteInitOp final
-  : private PDUInitOp
-{
-public:
-  ServerRequestWriteInitOp(DaemonSocketPDU& aPDU)
-    : PDUInitOp(aPDU)
-  { }
-
-  nsresult
-  operator () (int& aArg1,
-               int& aArg2,
-               BluetoothAddress& aArg3,
-               BluetoothAttributeHandle& aArg4,
-               int& aArg5,
-               int& aArg6,
-               UniquePtr<uint8_t[]>& aArg7,
-               bool& aArg8,
-               bool& aArg9) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    /* Read connection ID */
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read trans ID */
-    rv = UnpackPDU(pdu, aArg2);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read address */
-    rv = UnpackPDU(pdu, aArg3);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read attribute handle */
-    rv = UnpackPDU(pdu, aArg4);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read offset */
-    rv = UnpackPDU(pdu, aArg5);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read Length */
-    rv = UnpackPDU(pdu, aArg6);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read value */
-    rv = UnpackPDU(pdu,
-                   UnpackArray<uint8_t>(aArg7, static_cast<size_t>(aArg6)));
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read need response */
-    rv = UnpackPDU(pdu, aArg8);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    /* Read isPrepare */
-    rv = UnpackPDU(pdu, aArg9);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
-void
-BluetoothDaemonGattModule::ServerRequestWriteNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerRequestWriteNotification::Dispatch(
-    &BluetoothGattNotificationHandler::RequestWriteNotification,
-    ServerRequestWriteInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerRequestExecuteWriteNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerRequestExecuteWriteNotification::Dispatch(
-    &BluetoothGattNotificationHandler::RequestExecuteWriteNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::ServerResponseConfirmationNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
-{
-  ServerResponseConfirmationNotification::Dispatch(
-    &BluetoothGattNotificationHandler::ResponseConfirmationNotification,
-    UnpackPDUInitOp(aPDU));
-}
-
-void
-BluetoothDaemonGattModule::HandleNtf(
-  const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
-  DaemonSocketResultHandler* aRes)
-{
-  static void (BluetoothDaemonGattModule::* const HandleNtf[])(
-    const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {
-    [0] = &BluetoothDaemonGattModule::ClientRegisterNtf,
-    [1] = &BluetoothDaemonGattModule::ClientScanResultNtf,
-    [2] = &BluetoothDaemonGattModule::ClientConnectNtf,
-    [3] = &BluetoothDaemonGattModule::ClientDisconnectNtf,
-    [4] = &BluetoothDaemonGattModule::ClientSearchCompleteNtf,
-    [5] = &BluetoothDaemonGattModule::ClientSearchResultNtf,
-    [6] = &BluetoothDaemonGattModule::ClientGetCharacteristicNtf,
-    [7] = &BluetoothDaemonGattModule::ClientGetDescriptorNtf,
-    [8] = &BluetoothDaemonGattModule::ClientGetIncludedServiceNtf,
-    [9] = &BluetoothDaemonGattModule::ClientRegisterNotificationNtf,
-    [10] = &BluetoothDaemonGattModule::ClientNotifyNtf,
-    [11] = &BluetoothDaemonGattModule::ClientReadCharacteristicNtf,
-    [12] = &BluetoothDaemonGattModule::ClientWriteCharacteristicNtf,
-    [13] = &BluetoothDaemonGattModule::ClientReadDescriptorNtf,
-    [14] = &BluetoothDaemonGattModule::ClientWriteDescriptorNtf,
-    [15] = &BluetoothDaemonGattModule::ClientExecuteWriteNtf,
-    [16] = &BluetoothDaemonGattModule::ClientReadRemoteRssiNtf,
-    [17] = &BluetoothDaemonGattModule::ClientListenNtf,
-    [18] = &BluetoothDaemonGattModule::ServerRegisterNtf,
-    [19] = &BluetoothDaemonGattModule::ServerConnectionNtf,
-    [20] = &BluetoothDaemonGattModule::ServerServiceAddedNtf,
-    [21] = &BluetoothDaemonGattModule::ServerIncludedServiceAddedNtf,
-    [22] = &BluetoothDaemonGattModule::ServerCharacteristicAddedNtf,
-    [23] = &BluetoothDaemonGattModule::ServerDescriptorAddedNtf,
-    [24] = &BluetoothDaemonGattModule::ServerServiceStartedNtf,
-    [25] = &BluetoothDaemonGattModule::ServerServiceStoppedNtf,
-    [26] = &BluetoothDaemonGattModule::ServerServiceDeletedNtf,
-    [27] = &BluetoothDaemonGattModule::ServerRequestReadNtf,
-    [28] = &BluetoothDaemonGattModule::ServerRequestWriteNtf,
-    [29] = &BluetoothDaemonGattModule::ServerRequestExecuteWriteNtf,
-    [30] = &BluetoothDaemonGattModule::ServerResponseConfirmationNtf
-  };
-
-  MOZ_ASSERT(!NS_IsMainThread());
-
-  uint8_t index = aHeader.mOpcode - 0x81;
-
-  if (NS_WARN_IF(!(index < MOZ_ARRAY_LENGTH(HandleNtf))) ||
-      NS_WARN_IF(!HandleNtf[index])) {
-    return;
-  }
-
-  (this->*(HandleNtf[index]))(aHeader, aPDU);
-}
-
-//
-// Gatt interface
-//
-
-BluetoothDaemonGattInterface::BluetoothDaemonGattInterface(
-  BluetoothDaemonGattModule* aModule)
-  : mModule(aModule)
-{ }
-
-BluetoothDaemonGattInterface::~BluetoothDaemonGattInterface()
-{ }
-
-void
-BluetoothDaemonGattInterface::SetNotificationHandler(
-  BluetoothGattNotificationHandler* aNotificationHandler)
-{
-  MOZ_ASSERT(mModule);
-
-  mModule->SetNotificationHandler(aNotificationHandler);
-}
-
-/* Register / Unregister */
-void
-BluetoothDaemonGattInterface::RegisterClient(
-  const BluetoothUuid& aUuid, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientRegisterCmd(aUuid, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::UnregisterClient(
-  int aClientIf, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientUnregisterCmd(aClientIf, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Start / Stop LE Scan */
-void
-BluetoothDaemonGattInterface::Scan(
-  int aClientIf, bool aStart, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientScanCmd(aClientIf, aStart, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Connect / Disconnect */
-
-void
-BluetoothDaemonGattInterface::Connect(
-  int aClientIf, const BluetoothAddress& aBdAddr, bool aIsDirect,
-  BluetoothTransport aTransport, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientConnectCmd(
-    aClientIf, aBdAddr, aIsDirect, aTransport, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::Disconnect(
-  int aClientIf, const BluetoothAddress& aBdAddr, int aConnId,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientDisconnectCmd(
-    aClientIf, aBdAddr, aConnId, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Start / Stop advertisements to listen for incoming connections */
-void
-BluetoothDaemonGattInterface::Listen(
-  int aClientIf, bool aIsStart, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientListenCmd(aClientIf, aIsStart, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Clear the attribute cache for a given device*/
-void
-BluetoothDaemonGattInterface::Refresh(
-  int aClientIf, const BluetoothAddress& aBdAddr,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientRefreshCmd(aClientIf, aBdAddr, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Enumerate Attributes */
-void
-BluetoothDaemonGattInterface::SearchService(
-  int aConnId, bool aSearchAll, const BluetoothUuid& aUuid,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientSearchServiceCmd(
-    aConnId, !aSearchAll /* Filtered */, aUuid, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::GetIncludedService(
-  int aConnId, const BluetoothGattServiceId& aServiceId, bool aFirst,
-  const BluetoothGattServiceId& aStartServiceId,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientGetIncludedServiceCmd(
-    aConnId, aServiceId, !aFirst /* Continuation */, aStartServiceId, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::GetCharacteristic(
-  int aConnId, const BluetoothGattServiceId& aServiceId, bool aFirst,
-  const BluetoothGattId& aStartCharId, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientGetCharacteristicCmd(
-    aConnId, aServiceId, !aFirst /* Continuation */, aStartCharId, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::GetDescriptor(
-  int aConnId, const BluetoothGattServiceId& aServiceId,
-  const BluetoothGattId& aCharId, bool aFirst,
-  const BluetoothGattId& aDescriptorId, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientGetDescriptorCmd(
-    aConnId, aServiceId, aCharId, !aFirst /* Continuation */, aDescriptorId,
-    aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Read / Write An Attribute */
-void
-BluetoothDaemonGattInterface::ReadCharacteristic(
-  int aConnId, const BluetoothGattServiceId& aServiceId,
-  const BluetoothGattId& aCharId, BluetoothGattAuthReq aAuthReq,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientReadCharacteristicCmd(
-    aConnId, aServiceId, aCharId, aAuthReq, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::WriteCharacteristic(
-  int aConnId, const BluetoothGattServiceId& aServiceId,
-  const BluetoothGattId& aCharId, BluetoothGattWriteType aWriteType,
-  BluetoothGattAuthReq aAuthReq, const nsTArray<uint8_t>& aValue,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientWriteCharacteristicCmd(
-    aConnId, aServiceId, aCharId, aWriteType,
-    aValue.Length() * sizeof(uint8_t), aAuthReq,
-    reinterpret_cast<char*>(const_cast<uint8_t*>(aValue.Elements())), aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::ReadDescriptor(
-  int aConnId, const BluetoothGattServiceId& aServiceId,
-  const BluetoothGattId& aCharId, const BluetoothGattId& aDescriptorId,
-  BluetoothGattAuthReq aAuthReq, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientReadDescriptorCmd(
-    aConnId, aServiceId, aCharId, aDescriptorId, aAuthReq, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::WriteDescriptor(
-  int aConnId, const BluetoothGattServiceId& aServiceId,
-  const BluetoothGattId& aCharId, const BluetoothGattId& aDescriptorId,
-  BluetoothGattWriteType aWriteType, BluetoothGattAuthReq aAuthReq,
-  const nsTArray<uint8_t>& aValue, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientWriteDescriptorCmd(
-    aConnId, aServiceId, aCharId, aDescriptorId, aWriteType,
-    aValue.Length() * sizeof(uint8_t), aAuthReq,
-    reinterpret_cast<char*>(const_cast<uint8_t*>(aValue.Elements())), aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Execute / Abort Prepared Write*/
-void
-BluetoothDaemonGattInterface::ExecuteWrite(
-  int aConnId, int aIsExecute, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientExecuteWriteCmd(aConnId, aIsExecute, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Register / Deregister Characteristic Notifications or Indications */
-void
-BluetoothDaemonGattInterface::RegisterNotification(
-  int aClientIf, const BluetoothAddress& aBdAddr,
-  const BluetoothGattServiceId& aServiceId, const BluetoothGattId& aCharId,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientRegisterNotificationCmd(
-    aClientIf, aBdAddr, aServiceId, aCharId, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::DeregisterNotification(
-  int aClientIf, const BluetoothAddress& aBdAddr,
-  const BluetoothGattServiceId& aServiceId, const BluetoothGattId& aCharId,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientDeregisterNotificationCmd(
-    aClientIf, aBdAddr, aServiceId, aCharId, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::ReadRemoteRssi(
-  int aClientIf, const BluetoothAddress& aBdAddr,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientReadRemoteRssiCmd(
-    aClientIf, aBdAddr, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::GetDeviceType(
-  const BluetoothAddress& aBdAddr, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientGetDeviceTypeCmd(aBdAddr, aRes);
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::SetAdvData(
-  int aServerIf, bool aIsScanRsp, bool aIsNameIncluded,
-  bool aIsTxPowerIncluded, int aMinInterval, int aMaxInterval, int aApperance,
-  const nsTArray<uint8_t>& aManufacturerData,
-  const nsTArray<uint8_t>& aServiceData,
-  const nsTArray<BluetoothUuid>& aServiceUuids,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientSetAdvDataCmd(
-    aServerIf, aIsScanRsp, aIsNameIncluded, aIsTxPowerIncluded, aMinInterval,
-    aMaxInterval, aApperance, aManufacturerData, aServiceData, aServiceUuids,
-    aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::TestCommand(
-  int aCommand, const BluetoothGattTestParam& aTestParam,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ClientTestCommandCmd(aCommand, aTestParam, aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Register / Unregister */
-void
-BluetoothDaemonGattInterface::RegisterServer(
-  const BluetoothUuid& aUuid, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ServerRegisterCmd(aUuid, aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::UnregisterServer(
-  int aServerIf, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ServerUnregisterCmd(aServerIf, aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Connect / Disconnect */
-void
-BluetoothDaemonGattInterface::ConnectPeripheral(
-  int aServerIf, const BluetoothAddress& aBdAddr, bool aIsDirect, /* auto connect */
-  BluetoothTransport aTransport, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ServerConnectPeripheralCmd(
-    aServerIf, aBdAddr, aIsDirect, aTransport, aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::DisconnectPeripheral(
-  int aServerIf, const BluetoothAddress& aBdAddr, int aConnId,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ServerDisconnectPeripheralCmd(
-    aServerIf, aBdAddr, aConnId, aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Add a services / a characteristic / a descriptor */
-void
-BluetoothDaemonGattInterface::AddService(
-  int aServerIf, const BluetoothGattServiceId& aServiceId, uint16_t aNumHandles,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ServerAddServiceCmd(
-    aServerIf, aServiceId, aNumHandles, aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::AddIncludedService(
-  int aServerIf, const BluetoothAttributeHandle& aServiceHandle,
-  const BluetoothAttributeHandle& aIncludedServiceHandle,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ServerAddIncludedServiceCmd(
-    aServerIf, aServiceHandle, aIncludedServiceHandle, aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::AddCharacteristic(
-  int aServerIf, const BluetoothAttributeHandle& aServiceHandle,
-  const BluetoothUuid& aUuid, BluetoothGattCharProp aProperties,
-  BluetoothGattAttrPerm aPermissions, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ServerAddCharacteristicCmd(
-    aServerIf, aServiceHandle, aUuid, aProperties, aPermissions, aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::AddDescriptor(
-  int aServerIf, const BluetoothAttributeHandle& aServiceHandle,
-  const BluetoothUuid& aUuid, BluetoothGattAttrPerm aPermissions,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ServerAddDescriptorCmd(
-    aServerIf, aServiceHandle, aUuid, aPermissions, aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-/* Start / Stop / Delete a service */
-void
-BluetoothDaemonGattInterface::StartService(
-  int aServerIf, const BluetoothAttributeHandle& aServiceHandle,
-  BluetoothTransport aTransport, BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ServerStartServiceCmd(
-    aServerIf, aServiceHandle, aTransport, aRes);
-
-  if (NS_FAILED(rv)) {
-    DispatchError(aRes, rv);
-  }
-}
-
-void
-BluetoothDaemonGattInterface::StopService(
-  int aServerIf, const BluetoothAttributeHandle& aServiceHandle,
-  BluetoothGattResultHandler* aRes)
-{
-  MOZ_ASSERT(mModule);
-
-  nsresult rv = mModule->ServerStopServiceCmd(aServerIf, aServiceHandle, aRes);
-
-  if (NS_FAILED(rv)) {