Bug 1223722: Transfer Bluetooth addresses in |BluetoothValue|, r=brsun
authorThomas Zimmermann <tdz@users.sourceforge.net>
Tue, 05 Jan 2016 12:01:33 +0100
changeset 313587 21454026054ea74e8c92a6befee4a98e0d539adc
parent 313586 af66f84f7802c32fb9506c7d776ac1b91cf3fb4f
child 313588 a3eb613f20c97bff735f2a803d803d7fe721d33b
push id5703
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:18:41 +0000
treeherdermozilla-beta@31e373ad5b5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbrsun
bugs1223722
milestone46.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 1223722: Transfer Bluetooth addresses in |BluetoothValue|, r=brsun
dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
dom/bluetooth/bluedroid/BluetoothGattManager.cpp
dom/bluetooth/bluedroid/BluetoothOppManager.cpp
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
dom/bluetooth/bluez/BluetoothA2dpManager.cpp
dom/bluetooth/bluez/BluetoothHfpManager.cpp
dom/bluetooth/bluez/BluetoothOppManager.cpp
dom/bluetooth/common/BluetoothHidManager.cpp
dom/bluetooth/common/BluetoothUtils.cpp
dom/bluetooth/common/BluetoothUtils.h
dom/bluetooth/common/webapi/BluetoothAdapter.cpp
dom/bluetooth/common/webapi/BluetoothAdapter.h
dom/bluetooth/common/webapi/BluetoothDevice.cpp
dom/bluetooth/common/webapi/BluetoothGattServer.cpp
dom/bluetooth/common/webapi/BluetoothManager.cpp
dom/bluetooth/common/webapi/BluetoothPairingListener.cpp
dom/bluetooth/common/webapi/BluetoothPairingListener.h
dom/bluetooth/ipc/BluetoothTypes.ipdlh
--- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
@@ -683,17 +683,17 @@ BluetoothA2dpManager::NotifyConnectionSt
   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), deviceAddressStr, mA2dpConnected);
+    NS_LITERAL_STRING(A2DP_STATUS_CHANGED_ID), mDeviceAddress, mA2dpConnected);
 }
 
 void
 BluetoothA2dpManager::OnGetServiceChannel(const BluetoothAddress& aDeviceAddress,
                                           const BluetoothUuid& aServiceUuid,
                                           int aChannel)
 {
 }
--- a/dom/bluetooth/bluedroid/BluetoothGattManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothGattManager.cpp
@@ -2628,20 +2628,17 @@ public:
 
 private:
   void DistributeSignalDeviceFound(BluetoothTypeOfDevice type)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     InfallibleTArray<BluetoothNamedValue> properties;
 
-    nsAutoString addressStr;
-    AddressToString(mBdAddr, addressStr);
-
-    AppendNamedValue(properties, "Address", addressStr);
+    AppendNamedValue(properties, "Address", mBdAddr);
     AppendNamedValue(properties, "Rssi", mRssi);
     AppendNamedValue(properties, "GattAdv", mAdvData);
     AppendNamedValue(properties, "Type", static_cast<uint32_t>(type));
 
     BluetoothService* bs = BluetoothService::Get();
     NS_ENSURE_TRUE_VOID(bs);
 
     bs->DistributeSignal(NS_LITERAL_STRING("LeDeviceFound"),
@@ -3423,23 +3420,20 @@ BluetoothGattManager::ConnectionNotifica
 
   // Update the connection map based on the connection status
   if (aConnected) {
     server->mConnectionMap.Put(aBdAddr, aConnId);
   } else {
     server->mConnectionMap.Remove(aBdAddr);
   }
 
-  nsAutoString bdAddrStr;
-  AddressToString(aBdAddr, bdAddrStr);
-
   // Notify BluetoothGattServer that connection status changed
   InfallibleTArray<BluetoothNamedValue> props;
   AppendNamedValue(props, "Connected", aConnected);
-  AppendNamedValue(props, "Address", bdAddrStr);
+  AppendNamedValue(props, "Address", aBdAddr);
   bs->DistributeSignal(
     NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
     server->mAppUuid,
     BluetoothValue(props));
 
   // Resolve or reject connect/disconnect peripheral requests
   if (server->mConnectPeripheralRunnable) {
     if (aConnected) {
@@ -3737,25 +3731,22 @@ BluetoothGattManager::RequestReadNotific
       aConnId,
       aTransId,
       GATT_STATUS_REQUEST_NOT_SUPPORTED,
       response,
       new ServerSendResponseResultHandler(server));
     return;
   }
 
-  nsAutoString bdAddrStr;
-  AddressToString(aBdAddr, bdAddrStr);
-
   // Distribute a signal to gattServer
   InfallibleTArray<BluetoothNamedValue> properties;
 
   AppendNamedValue(properties, "TransId", aTransId);
   AppendNamedValue(properties, "AttrHandle", aAttributeHandle);
-  AppendNamedValue(properties, "Address", bdAddrStr);
+  AppendNamedValue(properties, "Address", aBdAddr);
   AppendNamedValue(properties, "NeedResponse", true);
   AppendNamedValue(properties, "Value", nsTArray<uint8_t>());
 
   bs->DistributeSignal(NS_LITERAL_STRING("ReadRequested"),
                        server->mAppUuid,
                        properties);
 }
 
@@ -3794,25 +3785,22 @@ BluetoothGattManager::RequestWriteNotifi
         aTransId,
         GATT_STATUS_REQUEST_NOT_SUPPORTED,
         response,
         new ServerSendResponseResultHandler(server));
     }
     return;
   }
 
-  nsAutoString bdAddrStr;
-  AddressToString(aBdAddr, bdAddrStr);
-
   // Distribute a signal to gattServer
   InfallibleTArray<BluetoothNamedValue> properties;
 
   AppendNamedValue(properties, "TransId", aTransId);
   AppendNamedValue(properties, "AttrHandle", aAttributeHandle);
-  AppendNamedValue(properties, "Address", bdAddrStr);
+  AppendNamedValue(properties, "Address", aBdAddr);
   AppendNamedValue(properties, "NeedResponse", aNeedResponse);
 
   nsTArray<uint8_t> value;
   value.AppendElements(aValue, aLength);
   AppendNamedValue(properties, "Value", value);
 
   bs->DistributeSignal(NS_LITERAL_STRING("WriteRequested"),
                        server->mAppUuid,
--- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
@@ -1415,81 +1415,69 @@ BluetoothOppManager::SendObexData(Unique
 
 void
 BluetoothOppManager::FileTransferComplete()
 {
   if (mSendTransferCompleteFlag) {
     return;
   }
 
-  nsAutoString deviceAddressStr;
-  AddressToString(mDeviceAddress, deviceAddressStr);
-
   NS_NAMED_LITERAL_STRING(type, "bluetooth-opp-transfer-complete");
   InfallibleTArray<BluetoothNamedValue> parameters;
 
-  AppendNamedValue(parameters, "address", deviceAddressStr);
+  AppendNamedValue(parameters, "address", mDeviceAddress);
   AppendNamedValue(parameters, "success", mSuccessFlag);
   AppendNamedValue(parameters, "received", mIsServer);
   AppendNamedValue(parameters, "fileName", mFileName);
   AppendNamedValue(parameters, "fileLength", mSentFileLength);
   AppendNamedValue(parameters, "contentType", mContentType);
 
   BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
 
   mSendTransferCompleteFlag = true;
 }
 
 void
 BluetoothOppManager::StartFileTransfer()
 {
-  nsAutoString deviceAddressStr;
-  AddressToString(mDeviceAddress, deviceAddressStr);
-
   NS_NAMED_LITERAL_STRING(type, "bluetooth-opp-transfer-start");
   InfallibleTArray<BluetoothNamedValue> parameters;
 
-  AppendNamedValue(parameters, "address", deviceAddressStr);
+  AppendNamedValue(parameters, "address", mDeviceAddress);
   AppendNamedValue(parameters, "received", mIsServer);
   AppendNamedValue(parameters, "fileName", mFileName);
   AppendNamedValue(parameters, "fileLength", mFileLength);
   AppendNamedValue(parameters, "contentType", mContentType);
 
   BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
 
   mSendTransferCompleteFlag = false;
 }
 
 void
 BluetoothOppManager::UpdateProgress()
 {
-  nsAutoString deviceAddressStr;
-  AddressToString(mDeviceAddress, deviceAddressStr);
-
   NS_NAMED_LITERAL_STRING(type, "bluetooth-opp-update-progress");
   InfallibleTArray<BluetoothNamedValue> parameters;
 
-  AppendNamedValue(parameters, "address", deviceAddressStr);
+  AppendNamedValue(parameters, "address", mDeviceAddress);
   AppendNamedValue(parameters, "received", mIsServer);
   AppendNamedValue(parameters, "processedLength", mSentFileLength);
   AppendNamedValue(parameters, "fileLength", mFileLength);
 
   BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
 }
 
 void
 BluetoothOppManager::ReceivingFileConfirmation()
 {
-  nsAutoString deviceAddressStr;
-  AddressToString(mDeviceAddress, deviceAddressStr);
-
   NS_NAMED_LITERAL_STRING(type, "bluetooth-opp-receiving-file-confirmation");
   InfallibleTArray<BluetoothNamedValue> parameters;
 
-  AppendNamedValue(parameters, "address", deviceAddressStr);
+  AppendNamedValue(parameters, "address", mDeviceAddress);
   AppendNamedValue(parameters, "fileName", mFileName);
   AppendNamedValue(parameters, "fileLength", mFileLength);
   AppendNamedValue(parameters, "contentType", mContentType);
 
   BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
 }
 
 void
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ -779,36 +779,25 @@ BluetoothServiceBluedroid::GetAdaptersIn
    *     |
    *     |__ BluetoothNamedValue =
    *     |     {"Adapter", BluetoothValue = BluetoothNamedValue[]}
    *     ...
    */
   InfallibleTArray<BluetoothNamedValue> adaptersProperties;
   uint32_t numAdapters = 1; // Bluedroid supports single adapter only
 
-  nsAutoString bdAddressStr;
-  AddressToString(mBdAddress, bdAddressStr);
-
-  nsTArray<nsString> bondedAddresses;
-
-  for (uint32_t i = 0; i < mBondedAddresses.Length(); ++i) {
-    nsAutoString bondedAddressStr;
-    AddressToString(mBondedAddresses[i], bondedAddressStr);
-    bondedAddresses.AppendElement(bondedAddressStr);
-  }
-
   for (uint32_t i = 0; i < numAdapters; i++) {
     InfallibleTArray<BluetoothNamedValue> properties;
 
     AppendNamedValue(properties, "State", mEnabled);
-    AppendNamedValue(properties, "Address", bdAddressStr);
+    AppendNamedValue(properties, "Address", mBdAddress);
     AppendNamedValue(properties, "Name", mBdName);
     AppendNamedValue(properties, "Discoverable", mDiscoverable);
     AppendNamedValue(properties, "Discovering", mDiscovering);
-    AppendNamedValue(properties, "PairedDevices", bondedAddresses);
+    AppendNamedValue(properties, "PairedDevices", mBondedAddresses);
 
     AppendNamedValue(adaptersProperties, "Adapter",
                      BluetoothValue(properties));
   }
 
   DispatchReplySuccess(aRunnable, adaptersProperties);
   return NS_OK;
 }
@@ -2011,22 +2000,19 @@ BluetoothServiceBluedroid::AdapterStateC
     // Return error if BluetoothService is unavailable
     BluetoothService* bs = BluetoothService::Get();
     NS_ENSURE_TRUE_VOID(bs);
 
     // Cleanup static adapter properties and notify adapter.
     mBdAddress.Clear();
     mBdName.Truncate();
 
-    nsAutoString bdAddressStr;
-    AddressToString(mBdAddress, bdAddressStr);
-
     InfallibleTArray<BluetoothNamedValue> props;
     AppendNamedValue(props, "Name", mBdName);
-    AppendNamedValue(props, "Address", bdAddressStr);
+    AppendNamedValue(props, "Address", mBdAddress);
     if (mDiscoverable) {
       mDiscoverable = false;
       AppendNamedValue(props, "Discoverable", false);
     }
     if (mDiscovering) {
       mDiscovering = false;
       AppendNamedValue(props, "Discovering", false);
     }
@@ -2115,20 +2101,17 @@ BluetoothServiceBluedroid::AdapterProper
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
 
   for (int i = 0; i < aNumProperties; i++) {
 
     const BluetoothProperty& p = aProperties[i];
 
     if (p.mType == PROPERTY_BDADDR) {
       mBdAddress = p.mBdAddress;
-      nsAutoString addressStr;
-      AddressToString(mBdAddress, addressStr);
-
-      AppendNamedValue(propertiesArray, "Address", addressStr);
+      AppendNamedValue(propertiesArray, "Address", mBdAddress);
 
     } else if (p.mType == PROPERTY_BDNAME) {
       mBdName = p.mString;
       AppendNamedValue(propertiesArray, "Name", mBdName);
 
     } else if (p.mType == PROPERTY_ADAPTER_SCAN_MODE) {
 
       // If BT is not enabled, Bluetooth scan mode should be non-discoverable
@@ -2144,25 +2127,17 @@ BluetoothServiceBluedroid::AdapterProper
       // event after bond completed.
       BT_LOGD("Adapter property: BONDED_DEVICES. Count: %d",
               p.mBdAddressArray.Length());
 
       // Whenever reloading paired devices, force refresh
       mBondedAddresses.Clear();
       mBondedAddresses.AppendElements(p.mBdAddressArray);
 
-      nsTArray<nsString> bondedAddresses;
-
-      for (unsigned int j = 0; j < p.mBdAddressArray.Length(); ++j) {
-        nsAutoString addressStr;
-        AddressToString(p.mBdAddressArray[j], addressStr);
-        bondedAddresses.AppendElement(addressStr);
-      }
-
-      AppendNamedValue(propertiesArray, "PairedDevices", bondedAddresses);
+      AppendNamedValue(propertiesArray, "PairedDevices", mBondedAddresses);
     } else if (p.mType == PROPERTY_UNKNOWN) {
       /* Bug 1065999: working around unknown properties */
     } else {
       BT_LOGD("Unhandled adapter property type: %d", p.mType);
       continue;
     }
   }
 
@@ -2192,20 +2167,17 @@ void
 BluetoothServiceBluedroid::RemoteDevicePropertiesNotification(
   BluetoothStatus aStatus, const BluetoothAddress& aBdAddr,
   int aNumProperties, const BluetoothProperty* aProperties)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
 
-  nsAutoString bdAddrStr;
-  AddressToString(aBdAddr, bdAddrStr);
-
-  AppendNamedValue(propertiesArray, "Address", bdAddrStr);
+  AppendNamedValue(propertiesArray, "Address", aBdAddr);
 
   for (int i = 0; i < aNumProperties; ++i) {
 
     const BluetoothProperty& p = aProperties[i];
 
     if (p.mType == PROPERTY_BDNAME) {
       AppendNamedValue(propertiesArray, "Name", p.mString);
 
@@ -2288,16 +2260,18 @@ BluetoothServiceBluedroid::RemoteDeviceP
   //  (3) send any pending Bluetooth replies.
   //
   // |DispatchReplySuccess| creates its own internal runnable, which is
   // always run after we completed the current method. This means that we
   // can exchange |DispatchReplySuccess| with other operations without
   // changing the order of (1,2) and (3).
 
   // Update to registered BluetoothDevice objects
+  nsAutoString bdAddrStr;
+  AddressToString(aBdAddr, bdAddrStr);
   BluetoothSignal signal(NS_LITERAL_STRING("PropertyChanged"),
                          bdAddrStr, propertiesArray);
 
   // FetchUuids task
   if (!mFetchUuidsRunnables.IsEmpty()) {
     // propertiesArray contains Address and Uuids only
     DispatchReplySuccess(mFetchUuidsRunnables[0],
                          propertiesArray[1].value()); /* Uuids */
@@ -2339,19 +2313,17 @@ BluetoothServiceBluedroid::DeviceFoundNo
   BluetoothAddress bdAddr;
   nsString bdName;
 
   for (int i = 0; i < aNumProperties; i++) {
 
     const BluetoothProperty& p = aProperties[i];
 
     if (p.mType == PROPERTY_BDADDR) {
-      nsAutoString addressStr;
-      AddressToString(p.mBdAddress, addressStr);
-      AppendNamedValue(propertiesArray, "Address", addressStr);
+      AppendNamedValue(propertiesArray, "Address", p.mBdAddress);
       bdAddr = p.mBdAddress;
     } else if (p.mType == PROPERTY_BDNAME) {
       AppendNamedValue(propertiesArray, "Name", p.mString);
       bdName = p.mString;
     } else if (p.mType == PROPERTY_CLASS_OF_DEVICE) {
       AppendNamedValue(propertiesArray, "Cod", p.mUint32);
 
     } else if (p.mType == PROPERTY_UUIDS) {
@@ -2416,30 +2388,27 @@ BluetoothServiceBluedroid::PinRequestNot
   uint32_t aCod)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
 
   // If |aBdName| is empty, get device name from |mDeviceNameMap|;
   // Otherwise update <address, name> mapping with |aBdName|
-  nsAutoString bdAddr;
-  AddressToString(aRemoteBdAddr, bdAddr);
-
   nsAutoString bdName;
   RemoteNameToString(aBdName, bdName);
 
   if (bdName.IsEmpty()) {
     mDeviceNameMap.Get(aRemoteBdAddr, &bdName);
   } else {
     mDeviceNameMap.Remove(aRemoteBdAddr);
     mDeviceNameMap.Put(aRemoteBdAddr, bdName);
   }
 
-  AppendNamedValue(propertiesArray, "address", bdAddr);
+  AppendNamedValue(propertiesArray, "address", aRemoteBdAddr);
   AppendNamedValue(propertiesArray, "name", bdName);
   AppendNamedValue(propertiesArray, "passkey", EmptyString());
   AppendNamedValue(propertiesArray, "type",
                    NS_LITERAL_STRING(PAIRING_REQ_TYPE_ENTERPINCODE));
 
   DistributeSignal(NS_LITERAL_STRING("PairingRequest"),
                    NS_LITERAL_STRING(KEY_PAIRING_LISTENER),
                    BluetoothValue(propertiesArray));
@@ -2451,19 +2420,16 @@ BluetoothServiceBluedroid::SspRequestNot
   uint32_t aCod, BluetoothSspVariant aPairingVariant, uint32_t aPassKey)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
 
   // If |aBdName| is empty, get device name from |mDeviceNameMap|;
   // Otherwise update <address, name> mapping with |aBdName|
-  nsAutoString bdAddr;
-  AddressToString(aRemoteBdAddr, bdAddr);
-
   nsAutoString bdName;
   RemoteNameToString(aBdName, bdName);
 
   if (bdName.IsEmpty()) {
     mDeviceNameMap.Get(aRemoteBdAddr, &bdName);
   } else {
     mDeviceNameMap.Remove(aRemoteBdAddr);
     mDeviceNameMap.Put(aRemoteBdAddr, bdName);
@@ -2491,17 +2457,17 @@ BluetoothServiceBluedroid::SspRequestNot
     case SSP_VARIANT_CONSENT:
       pairingType.AssignLiteral(PAIRING_REQ_TYPE_CONSENT);
       break;
     default:
       BT_WARNING("Unhandled SSP Bonding Variant: %d", aPairingVariant);
       return;
   }
 
-  AppendNamedValue(propertiesArray, "address", bdAddr);
+  AppendNamedValue(propertiesArray, "address", aRemoteBdAddr);
   AppendNamedValue(propertiesArray, "name", bdName);
   AppendNamedValue(propertiesArray, "passkey", passkey);
   AppendNamedValue(propertiesArray, "type", pairingType);
 
   DistributeSignal(NS_LITERAL_STRING("PairingRequest"),
                    NS_LITERAL_STRING(KEY_PAIRING_LISTENER),
                    BluetoothValue(propertiesArray));
 }
@@ -2539,19 +2505,16 @@ BluetoothServiceBluedroid::BondStateChan
       DispatchReplyError(mRemoveBondRunnables[0], aStatus);
       mRemoveBondRunnables.RemoveElementAt(0);
     }
 
     return;
   }
 
   // Query pairing device name from hash table
-  nsAutoString remoteBdAddr;
-  AddressToString(aRemoteBdAddr, remoteBdAddr);
-
   nsString remotebdName;
   mDeviceNameMap.Get(aRemoteBdAddr, &remotebdName);
 
   // Update bonded address array and append pairing device name
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
   if (!bonded) {
     mBondedAddresses.RemoveElement(aRemoteBdAddr);
   } else {
@@ -2562,23 +2525,25 @@ BluetoothServiceBluedroid::BondStateChan
     // We don't assert |!remotebdName.IsEmpty()| since empty string is also
     // valid, according to Bluetooth Core Spec. v3.0 - Sec. 6.22:
     // "a valid Bluetooth name is a UTF-8 encoding string which is up to 248
     // bytes in length."
     AppendNamedValue(propertiesArray, "Name", remotebdName);
   }
 
   // Notify device of attribute changed
+  nsAutoString remoteBdAddr;
+  AddressToString(aRemoteBdAddr, remoteBdAddr);
   AppendNamedValue(propertiesArray, "Paired", bonded);
   DistributeSignal(NS_LITERAL_STRING("PropertyChanged"),
                    remoteBdAddr,
                    BluetoothValue(propertiesArray));
 
   // Notify adapter of device paired/unpaired
-  InsertNamedValue(propertiesArray, 0, "Address", remoteBdAddr);
+  InsertNamedValue(propertiesArray, 0, "Address", aRemoteBdAddr);
   DistributeSignal(bonded ? NS_LITERAL_STRING(DEVICE_PAIRED_ID)
                           : NS_LITERAL_STRING(DEVICE_UNPAIRED_ID),
                    NS_LITERAL_STRING(KEY_ADAPTER),
                    BluetoothValue(propertiesArray));
 
   // Resolve existing pair/unpair promise
   if (bonded && !mCreateBondRunnables.IsEmpty()) {
     DispatchReplySuccess(mCreateBondRunnables[0]);
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
@@ -619,17 +619,17 @@ BluetoothHfpManager::NotifyConnectionSta
   } else if (aType.EqualsLiteral(BLUETOOTH_SCO_STATUS_CHANGED_ID)) {
     status = IsScoConnected();
     eventName.AssignLiteral(SCO_STATUS_CHANGED_ID);
   } else {
     MOZ_ASSERT(false);
     return;
   }
 
-  DispatchStatusChangedEvent(eventName, deviceAddressStr, status);
+  DispatchStatusChangedEvent(eventName, mDeviceAddress, status);
 
   // Notify profile controller
   if (aType.EqualsLiteral(BLUETOOTH_HFP_STATUS_CHANGED_ID)) {
     if (IsConnected()) {
       MOZ_ASSERT(mListener);
 
       // Enumerate current calls
       mListener->EnumerateCalls();
--- a/dom/bluetooth/bluez/BluetoothA2dpManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothA2dpManager.cpp
@@ -361,17 +361,17 @@ BluetoothA2dpManager::NotifyConnectionSt
   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), deviceAddressStr, mA2dpConnected);
+    NS_LITERAL_STRING(A2DP_STATUS_CHANGED_ID), mDeviceAddress, mA2dpConnected);
 }
 
 void
 BluetoothA2dpManager::OnGetServiceChannel(const BluetoothAddress& aDeviceAddress,
                                           const BluetoothUuid& aServiceUuid,
                                           int aChannel)
 {
 }
--- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp
@@ -542,17 +542,17 @@ BluetoothHfpManager::NotifyConnectionSta
   } else if (aType.EqualsLiteral(BLUETOOTH_SCO_STATUS_CHANGED_ID)) {
     status = IsScoConnected();
     eventName.AssignLiteral(SCO_STATUS_CHANGED_ID);
   } else {
     MOZ_ASSERT(false);
     return;
   }
 
-  DispatchStatusChangedEvent(eventName, deviceAddressStr, status);
+  DispatchStatusChangedEvent(eventName, mDeviceAddress, status);
 }
 
 #ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::NotifyDialer(const nsAString& aCommand)
 {
   nsString type, name;
   BluetoothValue v;
--- a/dom/bluetooth/bluez/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothOppManager.cpp
@@ -1378,26 +1378,23 @@ BluetoothOppManager::SendObexData(Unique
 
 void
 BluetoothOppManager::FileTransferComplete()
 {
   if (mSendTransferCompleteFlag) {
     return;
   }
 
-  nsAutoString connectedDeviceAddressStr;
-  AddressToString(mConnectedDeviceAddress, connectedDeviceAddressStr);
-
   nsString type, name;
   BluetoothValue v;
   InfallibleTArray<BluetoothNamedValue> parameters;
   type.AssignLiteral("bluetooth-opp-transfer-complete");
 
   name.AssignLiteral("address");
-  v = connectedDeviceAddressStr;
+  v = mConnectedDeviceAddress;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   name.AssignLiteral("success");
   v = mSuccessFlag;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   name.AssignLiteral("received");
   v = mIsServer;
@@ -1421,26 +1418,23 @@ BluetoothOppManager::FileTransferComplet
   }
 
   mSendTransferCompleteFlag = true;
 }
 
 void
 BluetoothOppManager::StartFileTransfer()
 {
-  nsAutoString connectedDeviceAddressStr;
-  AddressToString(mConnectedDeviceAddress, connectedDeviceAddressStr);
-
   nsString type, name;
   BluetoothValue v;
   InfallibleTArray<BluetoothNamedValue> parameters;
   type.AssignLiteral("bluetooth-opp-transfer-start");
 
   name.AssignLiteral("address");
-  v = connectedDeviceAddressStr;
+  v = mConnectedDeviceAddress;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   name.AssignLiteral("received");
   v = mIsServer;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   name.AssignLiteral("fileName");
   v = mFileName;
@@ -1460,26 +1454,23 @@ BluetoothOppManager::StartFileTransfer()
   }
 
   mSendTransferCompleteFlag = false;
 }
 
 void
 BluetoothOppManager::UpdateProgress()
 {
-  nsAutoString connectedDeviceAddressStr;
-  AddressToString(mConnectedDeviceAddress, connectedDeviceAddressStr);
-
   nsString type, name;
   BluetoothValue v;
   InfallibleTArray<BluetoothNamedValue> parameters;
   type.AssignLiteral("bluetooth-opp-update-progress");
 
   name.AssignLiteral("address");
-  v = connectedDeviceAddressStr;
+  v = mConnectedDeviceAddress;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   name.AssignLiteral("received");
   v = mIsServer;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   name.AssignLiteral("processedLength");
   v = mSentFileLength;
@@ -1493,26 +1484,23 @@ BluetoothOppManager::UpdateProgress()
     BT_WARNING("Failed to broadcast [bluetooth-opp-update-progress]");
     return;
   }
 }
 
 void
 BluetoothOppManager::ReceivingFileConfirmation()
 {
-  nsAutoString connectedDeviceAddressStr;
-  AddressToString(mConnectedDeviceAddress, connectedDeviceAddressStr);
-
   nsString type, name;
   BluetoothValue v;
   InfallibleTArray<BluetoothNamedValue> parameters;
   type.AssignLiteral("bluetooth-opp-receiving-file-confirmation");
 
   name.AssignLiteral("address");
-  v = connectedDeviceAddressStr;
+  v = mConnectedDeviceAddress;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   name.AssignLiteral("fileName");
   v = mFileName;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   name.AssignLiteral("fileLength");
   v = mFileLength;
--- a/dom/bluetooth/common/BluetoothHidManager.cpp
+++ b/dom/bluetooth/common/BluetoothHidManager.cpp
@@ -242,24 +242,21 @@ BluetoothHidManager::HandleInputProperty
   }
 }
 
 void
 BluetoothHidManager::NotifyStatusChanged()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  nsAutoString deviceAddressStr;
-  AddressToString(mDeviceAddress, deviceAddressStr);
-
   NS_NAMED_LITERAL_STRING(type, BLUETOOTH_HID_STATUS_CHANGED_ID);
   InfallibleTArray<BluetoothNamedValue> parameters;
 
   AppendNamedValue(parameters, "connected", mConnected);
-  AppendNamedValue(parameters, "address", deviceAddressStr);
+  AppendNamedValue(parameters, "address", mDeviceAddress);
 
   BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
 }
 
 void
 BluetoothHidManager::OnGetServiceChannel(
   const BluetoothAddress& aDeviceAddress,
   const BluetoothUuid& aServiceUuid,
--- a/dom/bluetooth/common/BluetoothUtils.cpp
+++ b/dom/bluetooth/common/BluetoothUtils.cpp
@@ -512,17 +512,28 @@ SetJsObject(JSContext* aContext,
   const nsTArray<BluetoothNamedValue>& arr =
     aValue.get_ArrayOfBluetoothNamedValue();
 
   for (uint32_t i = 0; i < arr.Length(); i++) {
     JS::Rooted<JS::Value> val(aContext);
     const BluetoothValue& v = arr[i].value();
 
     switch(v.type()) {
-       case BluetoothValue::TnsString: {
+       case BluetoothValue::TBluetoothAddress: {
+        nsAutoString addressStr;
+        AddressToString(v.get_BluetoothAddress(), addressStr);
+
+        JSString* jsData = JS_NewUCStringCopyN(aContext,
+                                               addressStr.BeginReading(),
+                                               addressStr.Length());
+        NS_ENSURE_TRUE(jsData, false);
+        val.setString(jsData);
+        break;
+      }
+      case BluetoothValue::TnsString: {
         JSString* jsData = JS_NewUCStringCopyN(aContext,
                                      v.get_nsString().BeginReading(),
                                      v.get_nsString().Length());
         NS_ENSURE_TRUE(jsData, false);
         val.setString(jsData);
         break;
       }
       case BluetoothValue::Tuint32_t:
@@ -668,23 +679,23 @@ DispatchReplyError(BluetoothReplyRunnabl
     new BluetoothReply(BluetoothReplyError(aStatus, EmptyString()));
 
   aRunnable->SetReply(reply);
   NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(aRunnable)));
 }
 
 void
 DispatchStatusChangedEvent(const nsAString& aType,
-                           const nsAString& aAddress,
+                           const BluetoothAddress& aAddress,
                            bool aStatus)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   InfallibleTArray<BluetoothNamedValue> data;
-  AppendNamedValue(data, "address", nsString(aAddress));
+  AppendNamedValue(data, "address", aAddress);
   AppendNamedValue(data, "status", aStatus);
 
   BluetoothService* bs = BluetoothService::Get();
   NS_ENSURE_TRUE_VOID(bs);
 
   bs->DistributeSignal(aType, NS_LITERAL_STRING(KEY_ADAPTER), data);
 }
 
--- a/dom/bluetooth/common/BluetoothUtils.h
+++ b/dom/bluetooth/common/BluetoothUtils.h
@@ -308,17 +308,17 @@ DispatchReplyError(BluetoothReplyRunnabl
  * @param aStatus    the error status to reply failed request.
  */
 void
 DispatchReplyError(BluetoothReplyRunnable* aRunnable,
                    const enum BluetoothStatus aStatus);
 
 void
 DispatchStatusChangedEvent(const nsAString& aType,
-                           const nsAString& aDeviceAddress,
+                           const BluetoothAddress& aDeviceAddress,
                            bool aStatus);
 
 //
 // BluetoothNamedValue manipulation
 //
 
 /**
  * Wrap literal name and value into a BluetoothNamedValue and
--- a/dom/bluetooth/common/webapi/BluetoothAdapter.cpp
+++ b/dom/bluetooth/common/webapi/BluetoothAdapter.cpp
@@ -401,34 +401,41 @@ BluetoothAdapter::GetGattServer()
 
   return mGattServer;
 }
 
 void
 BluetoothAdapter::GetPairedDeviceProperties(
   const nsTArray<nsString>& aDeviceAddresses)
 {
-  BluetoothService* bs = BluetoothService::Get();
-  NS_ENSURE_TRUE_VOID(bs);
-
   nsTArray<BluetoothAddress> deviceAddresses;
   deviceAddresses.SetLength(aDeviceAddresses.Length());
 
   for (size_t i = 0; i < deviceAddresses.Length(); ++i) {
     auto rv = StringToAddress(aDeviceAddresses[i], deviceAddresses[i]);
     if (NS_FAILED(rv)) {
       BT_WARNING("GetPairedDeviceProperties failed");
       return;
     }
   }
 
+  GetPairedDeviceProperties(deviceAddresses);
+}
+
+void
+BluetoothAdapter::GetPairedDeviceProperties(
+  const nsTArray<BluetoothAddress>& aDeviceAddresses)
+{
+  BluetoothService* bs = BluetoothService::Get();
+  NS_ENSURE_TRUE_VOID(bs);
+
   RefPtr<BluetoothVoidReplyRunnable> results =
     new BluetoothVoidReplyRunnable(nullptr);
 
-  auto rv = bs->GetPairedDevicePropertiesInternal(deviceAddresses, results);
+  auto rv = bs->GetPairedDevicePropertiesInternal(aDeviceAddresses, results);
   if (NS_FAILED(rv)) {
     BT_WARNING("GetPairedDeviceProperties failed");
     return;
   }
 }
 
 void
 BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue)
@@ -446,31 +453,34 @@ BluetoothAdapter::SetPropertyByValue(con
       if (mGattServer) {
         mGattServer->Invalidate();
         mGattServer = nullptr;
       }
     }
   } else if (name.EqualsLiteral("Name")) {
     mName = value.get_nsString();
   } else if (name.EqualsLiteral("Address")) {
-    mAddress = value.get_nsString();
+    AddressToString(value.get_BluetoothAddress(), mAddress);
   } else if (name.EqualsLiteral("Discoverable")) {
     mDiscoverable = value.get_bool();
   } else if (name.EqualsLiteral("Discovering")) {
     mDiscovering = value.get_bool();
     if (!mDiscovering) {
       // Reset discovery handle in use to nullptr
       SetDiscoveryHandleInUse(nullptr);
     }
   } else if (name.EqualsLiteral("PairedDevices")) {
-    const InfallibleTArray<nsString>& pairedDeviceAddresses
-      = value.get_ArrayOfnsString();
+    const InfallibleTArray<BluetoothAddress>& pairedDeviceAddresses
+      = value.get_ArrayOfBluetoothAddress();
 
     for (uint32_t i = 0; i < pairedDeviceAddresses.Length(); i++) {
-      if (mDevices.Contains(pairedDeviceAddresses[i])) {
+      nsString pairedDeviceAddressStr;
+      AddressToString(pairedDeviceAddresses[i], pairedDeviceAddressStr);
+
+      if (mDevices.Contains(pairedDeviceAddressStr)) {
         // Existing paired devices handle 'PropertyChanged' signal
         // in BluetoothDevice::Notify()
         continue;
       }
 
       InfallibleTArray<BluetoothNamedValue> props;
       AppendNamedValue(props, "Address", pairedDeviceAddresses[i]);
       AppendNamedValue(props, "Paired", true);
@@ -530,25 +540,25 @@ BluetoothAdapter::Notify(const Bluetooth
   } else if (aData.name().EqualsLiteral(HFP_STATUS_CHANGED_ID) ||
              aData.name().EqualsLiteral(SCO_STATUS_CHANGED_ID) ||
              aData.name().EqualsLiteral(A2DP_STATUS_CHANGED_ID)) {
     MOZ_ASSERT(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
     const InfallibleTArray<BluetoothNamedValue>& arr =
       v.get_ArrayOfBluetoothNamedValue();
 
     MOZ_ASSERT(arr.Length() == 2 &&
-               arr[0].value().type() == BluetoothValue::TnsString &&
+               arr[0].value().type() == BluetoothValue::TBluetoothAddress &&
                arr[1].value().type() == BluetoothValue::Tbool);
-    nsString address = arr[0].value().get_nsString();
+    BluetoothAddress address = arr[0].value().get_BluetoothAddress();
     bool status = arr[1].value().get_bool();
 
     BluetoothStatusChangedEventInit init;
     init.mBubbles = false;
     init.mCancelable = false;
-    init.mAddress = address;
+    AddressToString(address, init.mAddress);
     init.mStatus = status;
     RefPtr<BluetoothStatusChangedEvent> event =
       BluetoothStatusChangedEvent::Constructor(this, aData.name(), init);
     DispatchTrustedEvent(event);
   } else if (aData.name().EqualsLiteral(PAIRING_ABORTED_ID) ||
              aData.name().EqualsLiteral(REQUEST_MEDIA_PLAYSTATUS_ID)) {
     DispatchEmptyEvent(aData.name());
   } else if (aData.name().EqualsLiteral(OBEX_PASSWORD_REQ_ID)) {
@@ -1023,19 +1033,22 @@ BluetoothAdapter::IsAdapterAttributeChan
   switch(aType) {
     case BluetoothAdapterAttribute::State:
       MOZ_ASSERT(aValue.type() == BluetoothValue::Tbool);
       return aValue.get_bool() ? mState != BluetoothAdapterState::Enabled
                                : mState != BluetoothAdapterState::Disabled;
     case BluetoothAdapterAttribute::Name:
       MOZ_ASSERT(aValue.type() == BluetoothValue::TnsString);
       return !mName.Equals(aValue.get_nsString());
-    case BluetoothAdapterAttribute::Address:
-      MOZ_ASSERT(aValue.type() == BluetoothValue::TnsString);
-      return !mAddress.Equals(aValue.get_nsString());
+    case BluetoothAdapterAttribute::Address: {
+        MOZ_ASSERT(aValue.type() == BluetoothValue::TBluetoothAddress);
+        BluetoothAddress address;
+        StringToAddress(mAddress, address);
+        return address != aValue.get_BluetoothAddress();
+      }
     case BluetoothAdapterAttribute::Discoverable:
       MOZ_ASSERT(aValue.type() == BluetoothValue::Tbool);
       return mDiscoverable != aValue.get_bool();
     case BluetoothAdapterAttribute::Discovering:
       MOZ_ASSERT(aValue.type() == BluetoothValue::Tbool);
       return mDiscovering != aValue.get_bool();
     default:
       BT_WARNING("Type %d is not handled", uint32_t(aType));
@@ -1202,24 +1215,26 @@ BluetoothAdapter::HandleDevicePaired(con
   }
 
   MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
 
   const InfallibleTArray<BluetoothNamedValue>& arr =
     aValue.get_ArrayOfBluetoothNamedValue();
 
   MOZ_ASSERT(arr.Length() == 3 &&
-             arr[0].value().type() == BluetoothValue::TnsString && // Address
+             arr[0].value().type() == BluetoothValue::TBluetoothAddress && // Address
              arr[1].value().type() == BluetoothValue::TnsString && // Name
              arr[2].value().type() == BluetoothValue::Tbool);      // Paired
-  MOZ_ASSERT(!arr[0].value().get_nsString().IsEmpty() &&
+  MOZ_ASSERT(!arr[0].value().get_BluetoothAddress().IsCleared() &&
              arr[2].value().get_bool());
 
   // Append the paired device if it doesn't exist in adapter's devices array
-  size_t index = mDevices.IndexOf(arr[0].value().get_nsString());
+  nsString addressStr;
+  AddressToString(arr[0].value().get_BluetoothAddress(), addressStr);
+  size_t index = mDevices.IndexOf(addressStr);
   if (index == mDevices.NoIndex) {
     index = mDevices.Length(); // the new device's index
     mDevices.AppendElement(
       BluetoothDevice::Create(GetOwner(), aValue));
   }
 
   // Notify application of paired device
   BluetoothDeviceEventInit init;
@@ -1235,23 +1250,24 @@ BluetoothAdapter::HandleDeviceUnpaired(c
   }
 
   MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
 
   const InfallibleTArray<BluetoothNamedValue>& arr =
     aValue.get_ArrayOfBluetoothNamedValue();
 
   MOZ_ASSERT(arr.Length() == 2 &&
-             arr[0].value().type() == BluetoothValue::TnsString && // Address
-             arr[1].value().type() == BluetoothValue::Tbool);      // Paired
-  MOZ_ASSERT(!arr[0].value().get_nsString().IsEmpty() &&
+             arr[0].value().type() == BluetoothValue::TBluetoothAddress && // Address
+             arr[1].value().type() == BluetoothValue::Tbool);              // Paired
+  MOZ_ASSERT(!arr[0].value().get_BluetoothAddress().IsCleared() &&
              !arr[1].value().get_bool());
 
   // Remove the device with the same address
-  nsString deviceAddress = arr[0].value().get_nsString();
+  nsString deviceAddress;
+  AddressToString(arr[0].value().get_BluetoothAddress(), deviceAddress);
   mDevices.RemoveElement(deviceAddress);
 
   // Notify application of unpaired device
   BluetoothDeviceEventInit init;
   init.mAddress = deviceAddress;
   DispatchDeviceEvent(NS_LITERAL_STRING(DEVICE_UNPAIRED_ID), init);
 }
 
--- a/dom/bluetooth/common/webapi/BluetoothAdapter.h
+++ b/dom/bluetooth/common/webapi/BluetoothAdapter.h
@@ -188,16 +188,19 @@ public:
   {
      return GetOwner();
   }
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
   virtual void DisconnectFromOwner() override;
 
+  void GetPairedDeviceProperties(
+    const nsTArray<BluetoothAddress>& aDeviceAddresses);
+
   /**
    * Set this adapter's discovery handle in use (mDiscoveryHandleInUse).
    *
    * |mDiscoveryHandleInUse| is set to the latest discovery handle when adapter
    * just starts discovery, and is reset to nullptr when discovery is stopped
    * by some adapter.
    *
    * @param aDiscoveryHandle [in] Discovery handle to set.
--- a/dom/bluetooth/common/webapi/BluetoothDevice.cpp
+++ b/dom/bluetooth/common/webapi/BluetoothDevice.cpp
@@ -143,17 +143,17 @@ BluetoothDevice::ConvertUint32ToDeviceTy
 void
 BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue)
 {
   const nsString& name = aValue.name();
   const BluetoothValue& value = aValue.value();
   if (name.EqualsLiteral("Name")) {
     mName = value.get_nsString();
   } else if (name.EqualsLiteral("Address")) {
-    mAddress = value.get_nsString();
+    AddressToString(value.get_BluetoothAddress(), mAddress);
   } else if (name.EqualsLiteral("Cod")) {
     mCod->Update(value.get_uint32_t());
   } else if (name.EqualsLiteral("Paired")) {
     mPaired = value.get_bool();
   } else if (name.EqualsLiteral("UUIDs")) {
     // We assume the received uuids array is sorted without duplicate items.
     // If it's not, we require additional processing before assigning it
     // directly.
--- a/dom/bluetooth/common/webapi/BluetoothGattServer.cpp
+++ b/dom/bluetooth/common/webapi/BluetoothGattServer.cpp
@@ -84,21 +84,21 @@ void BluetoothGattServer::HandleConnecti
   const BluetoothValue& aValue)
 {
   MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
   const InfallibleTArray<BluetoothNamedValue>& arr =
     aValue.get_ArrayOfBluetoothNamedValue();
 
   MOZ_ASSERT(arr.Length() == 2 &&
              arr[0].value().type() == BluetoothValue::Tbool &&
-             arr[1].value().type() == BluetoothValue::TnsString);
+             arr[1].value().type() == BluetoothValue::TBluetoothAddress);
 
   BluetoothStatusChangedEventInit init;
   init.mStatus = arr[0].value().get_bool();
-  init.mAddress = arr[1].value().get_nsString();
+  AddressToString(arr[1].value().get_BluetoothAddress(), init.mAddress);
 
   RefPtr<BluetoothStatusChangedEvent> event =
     BluetoothStatusChangedEvent::Constructor(
       this, NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID), init);
 
   DispatchTrustedEvent(event);
 }
 
@@ -185,24 +185,25 @@ BluetoothGattServer::HandleReadWriteRequ
 {
   MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
   const InfallibleTArray<BluetoothNamedValue>& arr =
     aValue.get_ArrayOfBluetoothNamedValue();
 
   MOZ_ASSERT(arr.Length() == 5 &&
     arr[0].value().type() == BluetoothValue::Tint32_t &&
     arr[1].value().type() == BluetoothValue::TBluetoothAttributeHandle &&
-    arr[2].value().type() == BluetoothValue::TnsString &&
+    arr[2].value().type() == BluetoothValue::TBluetoothAddress &&
     arr[3].value().type() == BluetoothValue::Tbool &&
     arr[4].value().type() == BluetoothValue::TArrayOfuint8_t);
 
   int32_t requestId = arr[0].value().get_int32_t();
   BluetoothAttributeHandle handle =
     arr[1].value().get_BluetoothAttributeHandle();
-  nsString address = arr[2].value().get_nsString();
+  nsString address;
+  AddressToString(arr[2].value().get_BluetoothAddress(), address);
   bool needResponse = arr[3].value().get_bool();
   nsTArray<uint8_t> value;
   value = arr[4].value().get_ArrayOfuint8_t();
 
   // Find the target characteristic or descriptor from the given handle
   RefPtr<BluetoothGattCharacteristic> characteristic = nullptr;
   RefPtr<BluetoothGattDescriptor> descriptor = nullptr;
   for (uint32_t i = 0; i < mServices.Length(); i++) {
--- a/dom/bluetooth/common/webapi/BluetoothManager.cpp
+++ b/dom/bluetooth/common/webapi/BluetoothManager.cpp
@@ -191,21 +191,22 @@ BluetoothManager::HandleAdapterAdded(con
   BluetoothAdapterEventInit init;
   init.mAdapter = mAdapters.LastElement();
   DispatchAdapterEvent(NS_LITERAL_STRING("adapteradded"), init);
 }
 
 void
 BluetoothManager::HandleAdapterRemoved(const BluetoothValue& aValue)
 {
-  MOZ_ASSERT(aValue.type() == BluetoothValue::TnsString);
+  MOZ_ASSERT(aValue.type() == BluetoothValue::TBluetoothAddress);
   MOZ_ASSERT(DefaultAdapterExists());
 
   // Remove the adapter of given address from adapters array
-  nsString addressToRemove = aValue.get_nsString();
+  nsString addressToRemove;
+  AddressToString(aValue.get_BluetoothAddress(), addressToRemove);
 
   uint32_t i;
   for (i = 0; i < mAdapters.Length(); i++) {
     nsString address;
     mAdapters[i]->GetAddress(address);
     if (address.Equals(addressToRemove)) {
       mAdapters.RemoveElementAt(i);
       break;
--- a/dom/bluetooth/common/webapi/BluetoothPairingListener.cpp
+++ b/dom/bluetooth/common/webapi/BluetoothPairingListener.cpp
@@ -44,25 +44,29 @@ BluetoothPairingListener::Create(nsPIDOM
 BluetoothPairingListener::~BluetoothPairingListener()
 {
   UnregisterBluetoothSignalHandler(NS_LITERAL_STRING(KEY_PAIRING_LISTENER),
                                    this);
 }
 
 void
 BluetoothPairingListener::DispatchPairingEvent(const nsAString& aName,
-                                               const nsAString& aAddress,
+                                               const BluetoothAddress& aAddress,
                                                const nsAString& aPasskey,
                                                const nsAString& aType)
 {
-  MOZ_ASSERT(!aName.IsEmpty() && !aAddress.IsEmpty() && !aType.IsEmpty());
+  MOZ_ASSERT(!aAddress.IsCleared());
+  MOZ_ASSERT(!aName.IsEmpty() && !aType.IsEmpty());
+
+  nsString addressStr;
+  AddressToString(aAddress, addressStr);
 
   RefPtr<BluetoothPairingHandle> handle =
     BluetoothPairingHandle::Create(GetOwner(),
-                                   aAddress,
+                                   addressStr,
                                    aType,
                                    aPasskey);
 
   BluetoothPairingEventInit init;
   init.mDeviceName = aName;
   init.mHandle = handle;
 
   RefPtr<BluetoothPairingEvent> event =
@@ -82,22 +86,22 @@ BluetoothPairingListener::Notify(const B
   if (aData.name().EqualsLiteral("PairingRequest")) {
 
     MOZ_ASSERT(value.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
 
     const InfallibleTArray<BluetoothNamedValue>& arr =
       value.get_ArrayOfBluetoothNamedValue();
 
     MOZ_ASSERT(arr.Length() == 4 &&
-               arr[0].value().type() == BluetoothValue::TnsString && // address
+               arr[0].value().type() == BluetoothValue::TBluetoothAddress && // address
                arr[1].value().type() == BluetoothValue::TnsString && // name
                arr[2].value().type() == BluetoothValue::TnsString && // passkey
                arr[3].value().type() == BluetoothValue::TnsString);  // type
 
-    nsString address = arr[0].value().get_nsString();
+    BluetoothAddress address = arr[0].value().get_BluetoothAddress();
     nsString name = arr[1].value().get_nsString();
     nsString passkey = arr[2].value().get_nsString();
     nsString type = arr[3].value().get_nsString();
 
     // Notify pairing listener of pairing requests
     DispatchPairingEvent(name, address, passkey, type);
   } else {
     BT_WARNING("Not handling pairing listener signal: %s",
--- a/dom/bluetooth/common/webapi/BluetoothPairingListener.h
+++ b/dom/bluetooth/common/webapi/BluetoothPairingListener.h
@@ -20,17 +20,17 @@ class BluetoothPairingListener final : p
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   static already_AddRefed<BluetoothPairingListener>
     Create(nsPIDOMWindow* aWindow);
 
   void DispatchPairingEvent(const nsAString& aName,
-                            const nsAString& aAddress,
+                            const BluetoothAddress& aAddress,
                             const nsAString& aPasskey,
                             const nsAString& aType);
 
   void Notify(const BluetoothSignal& aParam); // BluetoothSignalObserver
 
   nsPIDOMWindow* GetParentObject() const
   {
     return GetOwner();
--- a/dom/bluetooth/ipc/BluetoothTypes.ipdlh
+++ b/dom/bluetooth/ipc/BluetoothTypes.ipdlh
@@ -1,14 +1,16 @@
 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
 /* vim: set ts=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/. */
 
+using mozilla::dom::bluetooth::BluetoothAddress
+  from "mozilla/dom/bluetooth/BluetoothCommon.h";
 using mozilla::dom::bluetooth::BluetoothAttributeHandle
   from "mozilla/dom/bluetooth/BluetoothCommon.h";
 using mozilla::dom::bluetooth::BluetoothGattAttrPerm
   from "mozilla/dom/bluetooth/BluetoothCommon.h";
 using mozilla::dom::bluetooth::BluetoothGattCharAttribute
   from "mozilla/dom/bluetooth/BluetoothCommon.h";
 using mozilla::dom::bluetooth::BluetoothGattCharProp
   from "mozilla/dom/bluetooth/BluetoothCommon.h";
@@ -47,16 +49,18 @@ union BluetoothValue
   uint8_t[];
   uint32_t[];
   BluetoothNamedValue[];
   BluetoothGattId;
   BluetoothGattId[];
   BluetoothGattServiceId;
   BluetoothGattServiceId[];
   BluetoothGattCharAttribute[];
+  BluetoothAddress;
+  BluetoothAddress[];
   BluetoothAttributeHandle;
   BluetoothUuid;
 };
 
 /**
  * Key-value pair for dicts returned by the bluetooth backend. Used for things
  * like property updates, where the property will have a name and a type.
  */