Bug 915628 - [Bluetooth] Define new log levels and add logs in profile controller, r=echou
authorBen Tian <btian@mozilla.com>
Sat, 14 Sep 2013 06:51:00 +0800
changeset 147172 e63b6d17fbfd966d2ad77c2d4cd8dbaf1efbf2e8
parent 147171 13e8f5eb231e8d65c055aa9ce52727a3b176e3ef
child 147173 fd8ca2b2cbdb91f3af8f77145076aaee04a86d4a
child 147185 1e43abeecacebce2079dcb8df3c4b3ac83017799
push id1005
push userechou@mozilla.com
push dateSat, 14 Sep 2013 08:57:27 +0000
treeherderb2g-inbound@e63b6d17fbfd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechou
bugs915628
milestone26.0a1
Bug 915628 - [Bluetooth] Define new log levels and add logs in profile controller, r=echou
dom/bluetooth/BluetoothA2dpManager.cpp
dom/bluetooth/BluetoothA2dpManager.h
dom/bluetooth/BluetoothAdapter.cpp
dom/bluetooth/BluetoothCommon.h
dom/bluetooth/BluetoothDevice.cpp
dom/bluetooth/BluetoothHfpManager.cpp
dom/bluetooth/BluetoothHfpManager.h
dom/bluetooth/BluetoothHidManager.cpp
dom/bluetooth/BluetoothHidManager.h
dom/bluetooth/BluetoothManager.cpp
dom/bluetooth/BluetoothOppManager.cpp
dom/bluetooth/BluetoothOppManager.h
dom/bluetooth/BluetoothProfileController.cpp
dom/bluetooth/BluetoothProfileManagerBase.h
dom/bluetooth/BluetoothPropertyContainer.cpp
dom/bluetooth/BluetoothReplyRunnable.cpp
dom/bluetooth/BluetoothRilListener.cpp
dom/bluetooth/BluetoothService.cpp
dom/bluetooth/BluetoothSocket.cpp
dom/bluetooth/BluetoothUnixSocketConnector.cpp
dom/bluetooth/BluetoothUtils.cpp
dom/bluetooth/gonk/BluetoothGonkService.cpp
dom/bluetooth/ipc/BluetoothParent.cpp
dom/bluetooth/linux/BluetoothDBusService.cpp
dom/bluetooth/linux/BluetoothDBusService.h
--- a/dom/bluetooth/BluetoothA2dpManager.cpp
+++ b/dom/bluetooth/BluetoothA2dpManager.cpp
@@ -320,33 +320,35 @@ BluetoothA2dpManager::HandleSinkProperty
       NotifyConnectionStatusChanged();
       mDeviceAddress.Truncate();
 
       // case 7 only
       if (prevState == SinkState::SINK_DISCONNECTING) {
         OnDisconnect(EmptyString());
       }
       break;
+    default:
+      break;
   }
 }
 
 void
 BluetoothA2dpManager::NotifyConnectionStatusChanged()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // Notify Gecko observers
   nsCOMPtr<nsIObserverService> obs =
     do_GetService("@mozilla.org/observer-service;1");
   NS_ENSURE_TRUE_VOID(obs);
 
   if (NS_FAILED(obs->NotifyObservers(this,
                                      BLUETOOTH_A2DP_STATUS_CHANGED_ID,
                                      mDeviceAddress.get()))) {
-    NS_WARNING("Failed to notify bluetooth-a2dp-status-changed observsers!");
+    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
--- a/dom/bluetooth/BluetoothA2dpManager.h
+++ b/dom/bluetooth/BluetoothA2dpManager.h
@@ -39,20 +39,25 @@ public:
   virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE;
   virtual bool IsConnected() MOZ_OVERRIDE;
   virtual void Connect(const nsAString& aDeviceAddress,
                        BluetoothProfileController* aController) MOZ_OVERRIDE;
   virtual void Disconnect(BluetoothProfileController* aController) MOZ_OVERRIDE;
   virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE;
   virtual void OnDisconnect(const nsAString& aErrorStr) MOZ_OVERRIDE;
 
-  // A2DP member functions
+  virtual void GetName(nsACString& aName)
+  {
+    aName.AssignLiteral("A2DP");
+  }
+
+  // A2DP-specific functions
   void HandleSinkPropertyChanged(const BluetoothSignal& aSignal);
 
-  // AVRCP member functions
+  // AVRCP-specific functions
   void SetAvrcpConnected(bool aConnected);
   bool IsAvrcpConnected();
   void UpdateMetaData(const nsAString& aTitle,
                       const nsAString& aArtist,
                       const nsAString& aAlbum,
                       uint32_t aMediaNumber,
                       uint32_t aTotalMediaCount,
                       uint32_t aDuration);
--- a/dom/bluetooth/BluetoothAdapter.cpp
+++ b/dom/bluetooth/BluetoothAdapter.cpp
@@ -68,52 +68,52 @@ public:
   }
 
   virtual bool ParseSuccessfulReply(JS::Value* aValue)
   {
     *aValue = JSVAL_VOID;
 
     const BluetoothValue& v = mReply->get_BluetoothReplySuccess().value();
     if (v.type() != BluetoothValue::TArrayOfBluetoothNamedValue) {
-      NS_WARNING("Not a BluetoothNamedValue array!");
+      BT_WARNING("Not a BluetoothNamedValue array!");
       SetError(NS_LITERAL_STRING("BluetoothReplyTypeError"));
       return false;
     }
 
     const InfallibleTArray<BluetoothNamedValue>& values =
       v.get_ArrayOfBluetoothNamedValue();
 
     nsTArray<nsRefPtr<BluetoothDevice> > devices;
     JSObject* JsDevices;
     for (uint32_t i = 0; i < values.Length(); i++) {
       const BluetoothValue properties = values[i].value();
       if (properties.type() != BluetoothValue::TArrayOfBluetoothNamedValue) {
-        NS_WARNING("Not a BluetoothNamedValue array!");
+        BT_WARNING("Not a BluetoothNamedValue array!");
         SetError(NS_LITERAL_STRING("BluetoothReplyTypeError"));
         return false;
       }
       nsRefPtr<BluetoothDevice> d =
         BluetoothDevice::Create(mAdapterPtr->GetOwner(),
                                 mAdapterPtr->GetPath(),
                                 properties);
       devices.AppendElement(d);
     }
 
     nsresult rv;
     nsIScriptContext* sc = mAdapterPtr->GetContextForEventHandlers(&rv);
     if (!sc) {
-      NS_WARNING("Cannot create script context!");
+      BT_WARNING("Cannot create script context!");
       SetError(NS_LITERAL_STRING("BluetoothScriptContextError"));
       return false;
     }
 
     AutoPushJSContext cx(sc->GetNativeContext());
     rv = nsTArrayToJSArray(cx, devices, &JsDevices);
     if (!JsDevices) {
-      NS_WARNING("Cannot create JS array!");
+      BT_WARNING("Cannot create JS array!");
       SetError(NS_LITERAL_STRING("BluetoothError"));
       return false;
     }
 
     aValue->setObject(*JsDevices);
     return true;
   }
 
@@ -137,17 +137,17 @@ public:
   }
 
   virtual bool ParseSuccessfulReply(JS::Value* aValue)
   {
     *aValue = JSVAL_VOID;
 
     const BluetoothValue& v = mReply->get_BluetoothReplySuccess().value();
     if (v.type() != BluetoothValue::Tbool) {
-      NS_WARNING("Not a boolean!");
+      BT_WARNING("Not a boolean!");
       SetError(NS_LITERAL_STRING("BluetoothReplyTypeError"));
       return false;
     }
 
     aValue->setBoolean(v.get_bool());
     return true;
   }
 
@@ -247,17 +247,17 @@ BluetoothAdapter::SetPropertyByValue(con
     mUuids = value.get_ArrayOfnsString();
     nsresult rv;
     nsIScriptContext* sc = GetContextForEventHandlers(&rv);
     NS_ENSURE_SUCCESS_VOID(rv);
 
     AutoPushJSContext cx(sc->GetNativeContext());
     JS::Rooted<JSObject*> uuids(cx);
     if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, uuids.address()))) {
-      NS_WARNING("Cannot set JS UUIDs object!");
+      BT_WARNING("Cannot set JS UUIDs object!");
       return;
     }
     mJsUuids = uuids;
     Root();
   } else if (name.EqualsLiteral("Devices")) {
     mDeviceAddresses = value.get_ArrayOfnsString();
 
     uint32_t length = mDeviceAddresses.Length();
@@ -268,27 +268,27 @@ BluetoothAdapter::SetPropertyByValue(con
     nsresult rv;
     nsIScriptContext* sc = GetContextForEventHandlers(&rv);
     NS_ENSURE_SUCCESS_VOID(rv);
 
     AutoPushJSContext cx(sc->GetNativeContext());
     JS::Rooted<JSObject*> deviceAddresses(cx);
     if (NS_FAILED(nsTArrayToJSArray(cx, mDeviceAddresses,
                                     deviceAddresses.address()))) {
-      NS_WARNING("Cannot set JS Devices object!");
+      BT_WARNING("Cannot set JS Devices object!");
       return;
     }
     mJsDeviceAddresses = deviceAddresses;
     Root();
   } else {
 #ifdef DEBUG
     nsCString warningMsg;
     warningMsg.AssignLiteral("Not handling adapter property: ");
     warningMsg.Append(NS_ConvertUTF16toUTF8(name));
-    NS_WARNING(warningMsg.get());
+    BT_WARNING(warningMsg.get());
 #endif
   }
 }
 
 // static
 already_AddRefed<BluetoothAdapter>
 BluetoothAdapter::Create(nsPIDOMWindow* aWindow, const BluetoothValue& aValue)
 {
@@ -299,17 +299,17 @@ BluetoothAdapter::Create(nsPIDOMWindow* 
   return adapter.forget();
 }
 
 void
 BluetoothAdapter::Notify(const BluetoothSignal& aData)
 {
   InfallibleTArray<BluetoothNamedValue> arr;
 
-  BT_LOG("[A] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
+  BT_LOGD("[A] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
 
   BluetoothValue v = aData.value();
   if (aData.name().EqualsLiteral("DeviceFound")) {
     nsRefPtr<BluetoothDevice> device = BluetoothDevice::Create(GetOwner(), mPath, aData.value());
     nsCOMPtr<nsIDOMEvent> event;
     NS_NewDOMBluetoothDeviceEvent(getter_AddRefs(event), this, nullptr, nullptr);
 
     nsCOMPtr<nsIDOMBluetoothDeviceEvent> e = do_QueryInterface(event);
@@ -354,17 +354,17 @@ BluetoothAdapter::Notify(const Bluetooth
     NS_ENSURE_SUCCESS_VOID(rv);
 
     DispatchTrustedEvent(event);
   } else {
 #ifdef DEBUG
     nsCString warningMsg;
     warningMsg.AssignLiteral("Not handling adapter signal: ");
     warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
-    NS_WARNING(warningMsg.get());
+    BT_WARNING(warningMsg.get());
 #endif
   }
 }
 
 already_AddRefed<DOMRequest>
 BluetoothAdapter::StartStopDiscovery(bool aStart, ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
@@ -384,17 +384,17 @@ BluetoothAdapter::StartStopDiscovery(boo
   }
   nsresult rv;
   if (aStart) {
     rv = bs->StartDiscoveryInternal(results);
   } else {
     rv = bs->StopDiscoveryInternal(results);
   }
   if (NS_FAILED(rv)) {
-    NS_WARNING("Start/Stop Discovery failed!");
+    BT_WARNING("Start/Stop Discovery failed!");
     aRv.Throw(rv);
     return nullptr;
   }
 
   // mDiscovering is not set here, we'll get a Property update from our external
   // protocol to tell us that it's been set.
 
   return request.forget();
@@ -411,30 +411,30 @@ BluetoothAdapter::StopDiscovery(ErrorRes
 {
   return StartStopDiscovery(false, aRv);
 }
 
 JS::Value
 BluetoothAdapter::GetDevices(JSContext* aContext, ErrorResult& aRv)
 {
   if (!mJsDeviceAddresses) {
-    NS_WARNING("Devices not yet set!\n");
+    BT_WARNING("Devices not yet set!\n");
     aRv.Throw(NS_ERROR_FAILURE);
     return JS::NullValue();
   }
 
   JS::ExposeObjectToActiveJS(mJsDeviceAddresses);
   return JS::ObjectValue(*mJsDeviceAddresses);
 }
 
 JS::Value
 BluetoothAdapter::GetUuids(JSContext* aContext, ErrorResult& aRv)
 {
   if (!mJsUuids) {
-    NS_WARNING("UUIDs not yet set!\n");
+    BT_WARNING("UUIDs not yet set!\n");
     aRv.Throw(NS_ERROR_FAILURE);
     return JS::NullValue();
   }
 
   JS::ExposeObjectToActiveJS(mJsUuids);
   return JS::ObjectValue(*mJsUuids);
 }
 
@@ -554,17 +554,17 @@ BluetoothAdapter::PairUnpair(bool aPair,
   if (aPair) {
     rv = bs->CreatePairedDeviceInternal(addr,
                                         kCreatePairedDeviceTimeout,
                                         results);
   } else {
     rv = bs->RemoveDeviceInternal(addr, results);
   }
   if (NS_FAILED(rv)) {
-    NS_WARNING("Pair/Unpair failed!");
+    BT_WARNING("Pair/Unpair failed!");
     aRv.Throw(rv);
     return nullptr;
   }
 
   return request.forget();
 }
 
 already_AddRefed<DOMRequest>
@@ -594,17 +594,17 @@ BluetoothAdapter::SetPinCode(const nsASt
     new BluetoothVoidReplyRunnable(request);
 
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
   if (!bs->SetPinCodeInternal(aDeviceAddress, aPinCode, results)) {
-    NS_WARNING("SetPinCode failed!");
+    BT_WARNING("SetPinCode failed!");
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   return request.forget();
 }
 
 already_AddRefed<DOMRequest>
@@ -622,17 +622,17 @@ BluetoothAdapter::SetPasskey(const nsASt
     new BluetoothVoidReplyRunnable(request);
 
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
   if (bs->SetPasskeyInternal(aDeviceAddress, aPasskey, results)) {
-    NS_WARNING("SetPasskeyInternal failed!");
+    BT_WARNING("SetPasskeyInternal failed!");
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   return request.forget();
 }
 
 already_AddRefed<DOMRequest>
@@ -652,17 +652,17 @@ BluetoothAdapter::SetPairingConfirmation
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
   if (!bs->SetPairingConfirmationInternal(aDeviceAddress,
                                           aConfirmation,
                                           results)) {
-    NS_WARNING("SetPairingConfirmation failed!");
+    BT_WARNING("SetPairingConfirmation failed!");
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   return request.forget();
 }
 
 already_AddRefed<DOMRequest>
@@ -742,17 +742,17 @@ BluetoothAdapter::SendFile(const nsAStri
 
   nsRefPtr<DOMRequest> request = new DOMRequest(win);
   nsRefPtr<BluetoothVoidReplyRunnable> results =
     new BluetoothVoidReplyRunnable(request);
 
   BlobChild* actor =
     ContentChild::GetSingleton()->GetOrCreateActorForBlob(aBlob);
   if (!actor) {
-    NS_WARNING("Can't create actor");
+    BT_WARNING("Can't create actor");
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
--- a/dom/bluetooth/BluetoothCommon.h
+++ b/dom/bluetooth/BluetoothCommon.h
@@ -3,44 +3,59 @@
 /* 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_bluetoothcommon_h__
 #define mozilla_dom_bluetooth_bluetoothcommon_h__
 
 #include "mozilla/Observer.h"
+#include "nsPrintfCString.h"
 #include "nsStringGlue.h"
 #include "nsTArray.h"
 
 extern bool gBluetoothDebugFlag;
 
 #define SWITCH_BT_DEBUG(V) (gBluetoothDebugFlag = V)
 
 #undef BT_LOG
 #if defined(MOZ_WIDGET_GONK)
 #include <android/log.h>
-#define BT_LOG(args...)                                              \
+/**
+ * Prints 'D'EBUG build logs, which show in DEBUG build only when
+ * developer setting 'Bluetooth output in adb' is enabled.
+ */
+#define BT_LOGD(args...)                                             \
   do {                                                               \
     if (gBluetoothDebugFlag) {                                       \
       __android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth", args); \
     }                                                                \
   } while(0)
 
+/**
+ * Prints 'R'ELEASE build logs, which show in both RELEASE and DEBUG builds.
+ */
+#define BT_LOGR(args...)                                             \
+  __android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth", args)      \
+
+/**
+ * Prints DEBUG build warnings, which show in DEBUG build only.
+ */
 #define BT_WARNING(args...)                                          \
-  __android_log_print(ANDROID_LOG_WARN, "GeckoBluetooth", args)
+  NS_WARNING(nsPrintfCString(args).get())                            \
 
 #else
-#define BT_LOG(args, ...)                                            \
+#define BT_LOGD(args, ...)                                           \
   do {                                                               \
     if (gBluetoothDebugFlag) {                                       \
       printf(args, ##__VA_ARGS__);                                   \
     }                                                                \
   } while(0)
 
+#define BT_LOGR(args, ...) printf(args, ##__VA_ARGS__)
 #define BT_WARNING(args, ...) printf(args, ##__VA_ARGS__)
 #endif
 
 #define BEGIN_BLUETOOTH_NAMESPACE \
   namespace mozilla { namespace dom { namespace bluetooth {
 #define END_BLUETOOTH_NAMESPACE \
   } /* namespace bluetooth */ } /* namespace dom */ } /* namespace mozilla */
 #define USING_BLUETOOTH_NAMESPACE \
--- a/dom/bluetooth/BluetoothDevice.cpp
+++ b/dom/bluetooth/BluetoothDevice.cpp
@@ -125,41 +125,41 @@ BluetoothDevice::SetPropertyByValue(cons
     nsresult rv;
     nsIScriptContext* sc = GetContextForEventHandlers(&rv);
     NS_ENSURE_SUCCESS_VOID(rv);
 
     AutoPushJSContext cx(sc->GetNativeContext());
 
     JS::Rooted<JSObject*> uuids(cx);
     if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, uuids.address()))) {
-      NS_WARNING("Cannot set JS UUIDs object!");
+      BT_WARNING("Cannot set JS UUIDs object!");
       return;
     }
     mJsUuids = uuids;
     Root();
   } else if (name.EqualsLiteral("Services")) {
     mServices = value.get_ArrayOfnsString();
     nsresult rv;
     nsIScriptContext* sc = GetContextForEventHandlers(&rv);
     NS_ENSURE_SUCCESS_VOID(rv);
 
     AutoPushJSContext cx(sc->GetNativeContext());
 
     JS::Rooted<JSObject*> services(cx);
     if (NS_FAILED(nsTArrayToJSArray(cx, mServices, services.address()))) {
-      NS_WARNING("Cannot set JS Services object!");
+      BT_WARNING("Cannot set JS Services object!");
       return;
     }
     mJsServices = services;
     Root();
   } else {
     nsCString warningMsg;
     warningMsg.AssignLiteral("Not handling device property: ");
     warningMsg.Append(NS_ConvertUTF16toUTF8(name));
-    NS_WARNING(warningMsg.get());
+    BT_WARNING(warningMsg.get());
   }
 }
 
 // static
 already_AddRefed<BluetoothDevice>
 BluetoothDevice::Create(nsPIDOMWindow* aWindow,
                         const nsAString& aAdapterPath,
                         const BluetoothValue& aValue)
@@ -170,56 +170,56 @@ BluetoothDevice::Create(nsPIDOMWindow* a
   nsRefPtr<BluetoothDevice> device =
     new BluetoothDevice(aWindow, aAdapterPath, aValue);
   return device.forget();
 }
 
 void
 BluetoothDevice::Notify(const BluetoothSignal& aData)
 {
-  BT_LOG("[D] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
+  BT_LOGD("[D] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
 
   BluetoothValue v = aData.value();
   if (aData.name().EqualsLiteral("PropertyChanged")) {
     NS_ASSERTION(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue,
                  "PropertyChanged: Invalid value type");
     const InfallibleTArray<BluetoothNamedValue>& arr =
       v.get_ArrayOfBluetoothNamedValue();
 
     NS_ASSERTION(arr.Length() == 1,
                  "Got more than one property in a change message!");
     SetPropertyByValue(arr[0]);
   } else {
 #ifdef DEBUG
     nsCString warningMsg;
     warningMsg.AssignLiteral("Not handling device signal: ");
     warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
-    NS_WARNING(warningMsg.get());
+    BT_WARNING(warningMsg.get());
 #endif
   }
 }
 
 JS::Value
 BluetoothDevice::GetUuids(JSContext* aCx, ErrorResult& aRv)
 {
   if (!mJsUuids) {
-    NS_WARNING("UUIDs not yet set!\n");
+    BT_WARNING("UUIDs not yet set!");
     aRv.Throw(NS_ERROR_FAILURE);
     return JS::NullValue();
   }
 
   JS::ExposeObjectToActiveJS(mJsUuids);
   return JS::ObjectValue(*mJsUuids);
 }
 
 JS::Value
 BluetoothDevice::GetServices(JSContext* aCx, ErrorResult& aRv)
 {
   if (!mJsServices) {
-    NS_WARNING("Services not yet set!\n");
+    BT_WARNING("Services not yet set!");
     aRv.Throw(NS_ERROR_FAILURE);
     return JS::Value(JSVAL_NULL);
   }
 
   JS::ExposeObjectToActiveJS(mJsServices);
   return JS::ObjectValue(*mJsServices);
 }
 
--- a/dom/bluetooth/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/BluetoothHfpManager.cpp
@@ -166,30 +166,30 @@ public:
   Handle(const nsAString& aName, const JS::Value& aResult)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     JSContext *cx = nsContentUtils::GetCurrentJSContext();
     NS_ENSURE_TRUE(cx, NS_OK);
 
     if (!aResult.isNumber()) {
-      NS_WARNING("'" AUDIO_VOLUME_BT_SCO_ID "' is not a number!");
+      BT_WARNING("'" AUDIO_VOLUME_BT_SCO_ID "' is not a number!");
       return NS_OK;
     }
 
     BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
     hfp->mCurrentVgs = aResult.toNumber();
 
     return NS_OK;
   }
 
   NS_IMETHOD
   HandleError(const nsAString& aName)
   {
-    NS_WARNING("Unable to get value for '" AUDIO_VOLUME_BT_SCO_ID "'");
+    BT_WARNING("Unable to get value for '" AUDIO_VOLUME_BT_SCO_ID "'");
     return NS_OK;
   }
 };
 
 NS_IMPL_ISUPPORTS1(BluetoothHfpManager::GetVolumeTask,
                    nsISettingsServiceCallback);
 
 NS_IMETHODIMP
@@ -250,17 +250,17 @@ public:
     MOZ_ASSERT(NS_IsMainThread());
 
     // Stop sending RING indicator
     if (sStopSendingRingFlag) {
       return;
     }
 
     if (!sBluetoothHfpManager) {
-      NS_WARNING("BluetoothHfpManager no longer exists, cannot send ring!");
+      BT_WARNING("BluetoothHfpManager no longer exists, cannot send ring!");
       return;
     }
 
     nsAutoCString ringMsg("RING");
     sBluetoothHfpManager->SendLine(ringMsg.get());
 
     if (!mNumber.IsEmpty()) {
       nsAutoCString clipMsg("+CLIP: \"");
@@ -370,17 +370,17 @@ BluetoothHfpManager::Init()
     BT_WARNING("Failed to add observers!");
     return false;
   }
 
   hal::RegisterBatteryObserver(this);
 
   mListener = new BluetoothRilListener();
   if (!mListener->StartListening()) {
-    NS_WARNING("Failed to start listening RIL");
+    BT_WARNING("Failed to start listening RIL");
     return false;
   }
 
   nsCOMPtr<nsISettingsService> settings =
     do_GetService("@mozilla.org/settingsService;1");
   NS_ENSURE_TRUE(settings, false);
 
   nsCOMPtr<nsISettingsServiceLock> settingsLock;
@@ -400,17 +400,17 @@ BluetoothHfpManager::Init()
   mScoSocketStatus = mScoSocket->GetConnectionStatus();
   ListenSco();
   return true;
 }
 
 BluetoothHfpManager::~BluetoothHfpManager()
 {
   if (!mListener->StopListening()) {
-    NS_WARNING("Failed to stop listening RIL");
+    BT_WARNING("Failed to stop listening RIL");
   }
   mListener = nullptr;
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   NS_ENSURE_TRUE_VOID(obs);
 
   if (NS_FAILED(obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) ||
       NS_FAILED(obs->RemoveObserver(this, MOZSETTINGS_CHANGED_ID))) {
@@ -449,17 +449,17 @@ BluetoothHfpManager::NotifyConnectionSta
 
   // Notify Gecko observers
   nsCOMPtr<nsIObserverService> obs =
     do_GetService("@mozilla.org/observer-service;1");
   NS_ENSURE_TRUE_VOID(obs);
 
   if (NS_FAILED(obs->NotifyObservers(this, NS_ConvertUTF16toUTF8(aType).get(),
                                      mDeviceAddress.get()))) {
-    NS_WARNING("Failed to notify observsers!");
+    BT_WARNING("Failed to notify observsers!");
   }
 
   // Dispatch an event of status change
   bool status;
   nsAutoString eventName;
   if (aType.EqualsLiteral(BLUETOOTH_HFP_STATUS_CHANGED_ID)) {
     status = IsConnected();
     eventName.AssignLiteral(HFP_STATUS_CHANGED_ID);
@@ -482,17 +482,17 @@ BluetoothHfpManager::NotifyDialer(const 
   InfallibleTArray<BluetoothNamedValue> parameters;
   type.AssignLiteral("bluetooth-dialer-command");
 
   name.AssignLiteral("command");
   v = nsString(aCommand);
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   if (!BroadcastSystemMessage(type, parameters)) {
-    NS_WARNING("Failed to broadcast system message to dialer");
+    BT_WARNING("Failed to broadcast system message to dialer");
   }
 }
 
 void
 BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -561,17 +561,17 @@ BluetoothHfpManager::HandleVoiceConnecti
     service = true;
   }
   UpdateCIND(CINDType::SERVICE, service);
 
   uint8_t signal;
   JS::Value value;
   voiceInfo->GetRelSignalStrength(&value);
   if (!value.isNumber()) {
-    NS_WARNING("Failed to get relSignalStrength in BluetoothHfpManager");
+    BT_WARNING("Failed to get relSignalStrength in BluetoothHfpManager");
     return;
   }
   signal = ceil(value.toNumber() / 20.0);
   UpdateCIND(CINDType::SIGNAL, signal);
 
   /**
    * Possible return values for mode are:
    * - null (unknown): set mNetworkSelectionMode to 0 (auto)
@@ -595,17 +595,17 @@ BluetoothHfpManager::HandleVoiceConnecti
   // or numeric; long alphanumeric format can be upto 16 characters long and
   // short format up to 8 characters (refer GSM MoU SE.13 [9])..."
   // However, we found that the operator name may sometimes be longer than 16
   // characters. After discussion, we decided to fix this here but not in RIL
   // or modem.
   //
   // Please see Bug 871366 for more information.
   if (mOperatorName.Length() > 16) {
-    NS_WARNING("The operator name was longer than 16 characters. We cut it.");
+    BT_WARNING("The operator name was longer than 16 characters. We cut it.");
     mOperatorName.Left(mOperatorName, 16);
   }
 }
 
 void
 BluetoothHfpManager::HandleIccInfoChanged()
 {
   nsCOMPtr<nsIIccProvider> icc =
@@ -665,45 +665,45 @@ BluetoothHfpManager::ReceiveSocketData(B
   } else if (msg.Find("AT+CMER=") != -1) {
     /**
      * SLC establishment is done when AT+CMER has been received.
      * Do nothing but respond with "OK".
      */
     ParseAtCommand(msg, 8, atCommandValues);
 
     if (atCommandValues.Length() < 4) {
-      NS_WARNING("Could't get the value of command [AT+CMER=]");
+      BT_WARNING("Could't get the value of command [AT+CMER=]");
       goto respond_with_ok;
     }
 
     if (!atCommandValues[0].EqualsLiteral("3") ||
         !atCommandValues[1].EqualsLiteral("0") ||
         !atCommandValues[2].EqualsLiteral("0")) {
-      NS_WARNING("Wrong value of CMER");
+      BT_WARNING("Wrong value of CMER");
       goto respond_with_ok;
     }
 
     mCMER = atCommandValues[3].EqualsLiteral("1");
   } else if (msg.Find("AT+CMEE=") != -1) {
     ParseAtCommand(msg, 8, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
-      NS_WARNING("Could't get the value of command [AT+CMEE=]");
+      BT_WARNING("Could't get the value of command [AT+CMEE=]");
       goto respond_with_ok;
     }
 
     // AT+CMEE = 0: +CME ERROR shall not be used
     // AT+CMEE = 1: use numeric <err>
     // AT+CMEE = 2: use verbose <err>
     mCMEE = !atCommandValues[0].EqualsLiteral("0");
   } else if (msg.Find("AT+COPS=") != -1) {
     ParseAtCommand(msg, 8, atCommandValues);
 
     if (atCommandValues.Length() != 2) {
-      NS_WARNING("Could't get the value of command [AT+COPS=]");
+      BT_WARNING("Could't get the value of command [AT+COPS=]");
       goto respond_with_ok;
     }
 
     // Handsfree only support AT+COPS=3,0
     if (!atCommandValues[0].EqualsLiteral("3") ||
         !atCommandValues[1].EqualsLiteral("0")) {
       if (mCMEE) {
         SendCommand("+CME ERROR: ", BluetoothCmeError::OPERATION_NOT_SUPPORTED);
@@ -718,49 +718,49 @@ BluetoothHfpManager::ReceiveSocketData(B
     message.AppendLiteral(",0,\"");
     message.Append(NS_ConvertUTF16toUTF8(mOperatorName));
     message.AppendLiteral("\"");
     SendLine(message.get());
   } else if (msg.Find("AT+VTS=") != -1) {
     ParseAtCommand(msg, 7, atCommandValues);
 
     if (atCommandValues.Length() != 1) {
-      NS_WARNING("Couldn't get the value of command [AT+VTS=]");
+      BT_WARNING("Couldn't get the value of command [AT+VTS=]");
       goto respond_with_ok;
     }
 
     if (IsValidDtmf(atCommandValues[0].get()[0])) {
       nsAutoCString message("VTS=");
       message += atCommandValues[0].get()[0];
       NotifyDialer(NS_ConvertUTF8toUTF16(message));
     }
   } else if (msg.Find("AT+VGM=") != -1) {
     ParseAtCommand(msg, 7, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
-      NS_WARNING("Couldn't get the value of command [AT+VGM]");
+      BT_WARNING("Couldn't get the value of command [AT+VGM]");
       goto respond_with_ok;
     }
 
     nsresult rv;
     int vgm = atCommandValues[0].ToInteger(&rv);
     if (NS_FAILED(rv)) {
-      NS_WARNING("Failed to extract microphone volume from bluetooth headset!");
+      BT_WARNING("Failed to extract microphone volume from bluetooth headset!");
       goto respond_with_ok;
     }
 
     NS_ASSERTION(vgm >= 0 && vgm <= 15, "Received invalid VGM value");
     mCurrentVgm = vgm;
   } else if (msg.Find("AT+CHLD=?") != -1) {
     SendLine("+CHLD: (0,1,2)");
   } else if (msg.Find("AT+CHLD=") != -1) {
     ParseAtCommand(msg, 8, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
-      NS_WARNING("Could't get the value of command [AT+CHLD=]");
+      BT_WARNING("Could't get the value of command [AT+CHLD=]");
       goto respond_with_ok;
     }
 
     /**
      * The following three cases are supported:
      * AT+CHLD=0 - Releases all held calls or sets User Determined User Busy
      *             (UDUB) for a waiting call
      * AT+CHLD=1 - Releases active calls and accepts the other (held or
@@ -771,53 +771,53 @@ BluetoothHfpManager::ReceiveSocketData(B
      * The following cases are NOT supported yet:
      * AT+CHLD=1<idx>, AT+CHLD=2<idx>, AT+CHLD=3, AT+CHLD=4
      * Please see 4.33.2 in Bluetooth hands-free profile 1.6 for more
      * information.
      */
     char chld = atCommandValues[0][0];
     bool valid = true;
     if (atCommandValues[0].Length() > 1) {
-      NS_WARNING("No index should be included in command [AT+CHLD]");
+      BT_WARNING("No index should be included in command [AT+CHLD]");
       valid = false;
     } else if (chld == '3' || chld == '4') {
-      NS_WARNING("The value of command [AT+CHLD] is not supported");
+      BT_WARNING("The value of command [AT+CHLD] is not supported");
       valid = false;
     } else if (chld == '0') {
       // We need to rename these dialer commands for better readability
       // and expandability.
       // See bug 884190 for more information.
       NotifyDialer(NS_LITERAL_STRING("CHLD=0"));
     } else if (chld == '1') {
       NotifyDialer(NS_LITERAL_STRING("CHLD=1"));
     } else if (chld == '2') {
       NotifyDialer(NS_LITERAL_STRING("CHLD=2"));
     } else {
-      NS_WARNING("Wrong value of command [AT+CHLD]");
+      BT_WARNING("Wrong value of command [AT+CHLD]");
       valid = false;
     }
 
     if (!valid) {
       SendLine("ERROR");
       return;
     }
   } else if (msg.Find("AT+VGS=") != -1) {
     // Adjust volume by headset
     mReceiveVgsFlag = true;
     ParseAtCommand(msg, 7, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
-      NS_WARNING("Could't get the value of command [AT+VGS=]");
+      BT_WARNING("Could't get the value of command [AT+VGS=]");
       goto respond_with_ok;
     }
 
     nsresult rv;
     int newVgs = atCommandValues[0].ToInteger(&rv);
     if (NS_FAILED(rv)) {
-      NS_WARNING("Failed to extract volume value from bluetooth headset!");
+      BT_WARNING("Failed to extract volume value from bluetooth headset!");
       goto respond_with_ok;
     }
 
     if (newVgs == mCurrentVgs) {
       goto respond_with_ok;
     }
 
     NS_ASSERTION(newVgs >= 0 && newVgs <= 15, "Received invalid VGS value");
@@ -850,36 +850,36 @@ BluetoothHfpManager::ReceiveSocketData(B
   } else if (msg.Find("AT+CHUP") != -1) {
     NotifyDialer(NS_LITERAL_STRING("CHUP"));
   } else if (msg.Find("AT+CLCC") != -1) {
     SendCommand("+CLCC: ");
   } else if (msg.Find("ATD") != -1) {
     nsAutoCString message(msg), newMsg;
     int end = message.FindChar(';');
     if (end < 0) {
-      NS_WARNING("Could't get the value of command [ATD]");
+      BT_WARNING("Could't get the value of command [ATD]");
       goto respond_with_ok;
     }
 
     newMsg += nsDependentCSubstring(message, 0, end);
     NotifyDialer(NS_ConvertUTF8toUTF16(newMsg));
   } else if (msg.Find("AT+CLIP=") != -1) {
     ParseAtCommand(msg, 8, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
-      NS_WARNING("Could't get the value of command [AT+CLIP=]");
+      BT_WARNING("Could't get the value of command [AT+CLIP=]");
       goto respond_with_ok;
     }
 
     mCLIP = atCommandValues[0].EqualsLiteral("1");
   } else if (msg.Find("AT+CCWA=") != -1) {
     ParseAtCommand(msg, 8, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
-      NS_WARNING("Could't get the value of command [AT+CCWA=]");
+      BT_WARNING("Could't get the value of command [AT+CCWA=]");
       goto respond_with_ok;
     }
 
     mCCWA = atCommandValues[0].EqualsLiteral("1");
   } else if (msg.Find("AT+CKPD") != -1) {
     if (!sStopSendingRingFlag) {
       // Bluetooth HSP spec 4.2.2
       // There is an incoming call, notify Dialer to pick up the phone call
@@ -902,17 +902,17 @@ BluetoothHfpManager::ReceiveSocketData(B
           DisconnectSco();
         }
       } else {
         // Three conditions have to be matched to come in here:
         // (1) Not sending RING indicator
         // (2) A SCO link exists
         // (3) This is the very first AT+CKPD=200 of this session
         // It is the case of Figure 4.3, Bluetooth HSP spec. Do nothing.
-        NS_WARNING("AT+CKPD=200: Do nothing");
+        BT_WARNING("AT+CKPD=200: Do nothing");
       }
     }
 
     mFirstCKPD = false;
   } else if (msg.Find("AT+CNUM") != -1) {
     if (!mMsisdn.IsEmpty()) {
       nsAutoCString message("+CNUM: ,\"");
       message.Append(NS_ConvertUTF16toUTF8(mMsisdn).get());
@@ -951,17 +951,17 @@ BluetoothHfpManager::ReceiveSocketData(B
         // Ignore requests to activate/deactivate mandatory indicators
       }
     }
   } else {
     nsCString warningMsg;
     warningMsg.Append(NS_LITERAL_CSTRING("Unsupported AT command: "));
     warningMsg.Append(msg);
     warningMsg.Append(NS_LITERAL_CSTRING(", reply with ERROR"));
-    NS_WARNING(warningMsg.get());
+    BT_WARNING(warningMsg.get());
 
     SendLine("ERROR");
     return;
   }
 
 respond_with_ok:
   // We always respond to remote device with "OK" in general cases.
   SendLine("OK");
@@ -1021,44 +1021,44 @@ BluetoothHfpManager::Connect(const nsASt
 }
 
 bool
 BluetoothHfpManager::Listen()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (sInShutdown) {
-    NS_WARNING("Listen called while in shutdown!");
+    BT_WARNING("Listen called while in shutdown!");
     return false;
   }
 
   if (mSocket) {
-    NS_WARNING("mSocket exists. Failed to listen.");
+    BT_WARNING("mSocket exists. Failed to listen.");
     return false;
   }
 
   if (!mHandsfreeSocket) {
     mHandsfreeSocket =
       new BluetoothSocket(this, BluetoothSocketType::RFCOMM, true, true);
 
     if (!mHandsfreeSocket->Listen(
           BluetoothReservedChannels::CHANNEL_HANDSFREE_AG)) {
-      NS_WARNING("[HFP] Can't listen on RFCOMM socket!");
+      BT_WARNING("[HFP] Can't listen on RFCOMM socket!");
       mHandsfreeSocket = nullptr;
       return false;
     }
   }
 
   if (!mHeadsetSocket) {
     mHeadsetSocket =
       new BluetoothSocket(this, BluetoothSocketType::RFCOMM, true, true);
 
     if (!mHeadsetSocket->Listen(
           BluetoothReservedChannels::CHANNEL_HEADSET_AG)) {
-      NS_WARNING("[HSP] Can't listen on RFCOMM socket!");
+      BT_WARNING("[HSP] Can't listen on RFCOMM socket!");
       mHandsfreeSocket->Disconnect();
       mHandsfreeSocket = nullptr;
       mHeadsetSocket = nullptr;
       return false;
     }
   }
 
   return true;
@@ -1096,31 +1096,31 @@ BluetoothHfpManager::SendLine(const char
 
   return mSocket->SendSocketData(msg);
 }
 
 bool
 BluetoothHfpManager::SendCommand(const char* aCommand, uint32_t aValue)
 {
   if (!IsConnected()) {
-    NS_WARNING("Trying to SendCommand() without a SLC");
+    BT_WARNING("Trying to SendCommand() without a SLC");
     return false;
   }
 
   nsAutoCString message;
   message += aCommand;
 
   if (!strcmp(aCommand, "+CIEV: ")) {
     if (!mCMER || !sCINDItems[aValue].activated) {
       // Indicator status update is disabled
       return true;
     }
 
     if ((aValue < 1) || (aValue > ArrayLength(sCINDItems) - 1)) {
-      NS_WARNING("unexpected CINDType for CIEV command");
+      BT_WARNING("unexpected CINDType for CIEV command");
       return false;
     }
 
     message.AppendInt(aValue);
     message.AppendLiteral(",");
     message.AppendInt(sCINDItems[aValue].value);
   } else if (!strcmp(aCommand, "+CIND: ")) {
     if (!aValue) {
@@ -1178,17 +1178,17 @@ BluetoothHfpManager::SendCommand(const c
         case nsITelephonyProvider::CALL_STATE_INCOMING:
           if (!FindFirstCall(nsITelephonyProvider::CALL_STATE_CONNECTED)) {
             message.AppendInt(4);
           } else {
             message.AppendInt(5);
           }
           break;
         default:
-          NS_WARNING("Not handling call status for CLCC");
+          BT_WARNING("Not handling call status for CLCC");
           break;
       }
       message.AppendLiteral(",0,0,\"");
       message.Append(NS_ConvertUTF16toUTF8(call.mNumber));
       message.AppendLiteral("\",");
       message.AppendInt(call.mType);
 
       rv &= SendLine(message.get());
@@ -1338,17 +1338,17 @@ BluetoothHfpManager::HandleCallStateChan
           ConnectSco();
         case nsITelephonyProvider::CALL_STATE_DIALING:
         case nsITelephonyProvider::CALL_STATE_ALERTING:
           // Outgoing call
           UpdateCIND(CINDType::CALL, CallState::IN_PROGRESS, aSend);
           UpdateCIND(CINDType::CALLSETUP, CallSetupState::NO_CALLSETUP, aSend);
           break;
         default:
-          NS_WARNING("Not handling state changed");
+          BT_WARNING("Not handling state changed");
       }
 
       // = Handle callheld separately =
       // Besides checking if there is still held calls, another thing we
       // need to consider is the state change when receiving AT+CHLD=2.
       // Assume that there is one active call(c1) and one call on hold(c2).
       // We got AT+CHLD=2, which swaps active/held position. The first
       // action would be c2 -> ACTIVE, then c1 -> HELD. When we get the
@@ -1377,17 +1377,17 @@ BluetoothHfpManager::HandleCallStateChan
         case nsITelephonyProvider::CALL_STATE_CONNECTED:
           // No call is ongoing
           if (sCINDItems[CINDType::CALLHELD].value ==
               CallHeldState::NO_CALLHELD) {
             UpdateCIND(CINDType::CALL, CallState::NO_CALL, aSend);
           }
           break;
         default:
-          NS_WARNING("Not handling state changed");
+          BT_WARNING("Not handling state changed");
       }
 
       // Handle held calls separately
       if (!FindFirstCall(nsITelephonyProvider::CALL_STATE_HELD)) {
         UpdateCIND(CINDType::CALLHELD, CallHeldState::NO_CALLHELD, aSend);
       } else if (!FindFirstCall(nsITelephonyProvider::CALL_STATE_CONNECTED)) {
         UpdateCIND(CINDType::CALLHELD, CallHeldState::ONHOLD_NOACTIVE, aSend);
       } else {
@@ -1407,17 +1407,17 @@ BluetoothHfpManager::HandleCallStateChan
                                                   new CloseScoTask(),
                                                   sBusyToneInterval);
         }
 
         ResetCallArray();
       }
       break;
     default:
-      NS_WARNING("Not handling state changed");
+      BT_WARNING("Not handling state changed");
       break;
   }
 }
 
 void
 BluetoothHfpManager::OnSocketConnectSuccess(BluetoothSocket* aSocket)
 {
   MOZ_ASSERT(aSocket);
@@ -1616,30 +1616,30 @@ BluetoothHfpManager::GetAddress(nsAStrin
 }
 
 bool
 BluetoothHfpManager::ConnectSco(BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (sInShutdown) {
-    NS_WARNING("ConnecteSco called while in shutdown!");
+    BT_WARNING("ConnecteSco called while in shutdown!");
     return false;
   }
 
   if (!IsConnected()) {
-    NS_WARNING("BluetoothHfpManager is not connected");
+    BT_WARNING("BluetoothHfpManager is not connected");
     return false;
   }
 
   SocketConnectionStatus status = mScoSocket->GetConnectionStatus();
   if (status == SocketConnectionStatus::SOCKET_CONNECTED ||
       status == SocketConnectionStatus::SOCKET_CONNECTING ||
       (mScoRunnable && (mScoRunnable != aRunnable))) {
-    NS_WARNING("SCO connection exists or is being established");
+    BT_WARNING("SCO connection exists or is being established");
     return false;
   }
 
   mScoSocket->Disconnect();
 
   mScoRunnable = aRunnable;
 
   BluetoothService* bs = BluetoothService::Get();
@@ -1649,50 +1649,50 @@ BluetoothHfpManager::ConnectSco(Bluetoot
   mScoSocketStatus = mSocket->GetConnectionStatus();
   return NS_SUCCEEDED(rv);
 }
 
 bool
 BluetoothHfpManager::DisconnectSco()
 {
   if (!IsConnected()) {
-    NS_WARNING("BluetoothHfpManager is not connected");
+    BT_WARNING("BluetoothHfpManager is not connected");
     return false;
   }
 
   SocketConnectionStatus status = mScoSocket->GetConnectionStatus();
   if (status != SOCKET_CONNECTED && status != SOCKET_CONNECTING) {
-    NS_WARNING("No SCO exists");
+    BT_WARNING("No SCO exists");
     return false;
   }
 
   mScoSocket->Disconnect();
   return true;
 }
 
 bool
 BluetoothHfpManager::ListenSco()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (sInShutdown) {
-    NS_WARNING("ListenSco called while in shutdown!");
+    BT_WARNING("ListenSco called while in shutdown!");
     return false;
   }
 
   if (mScoSocket->GetConnectionStatus() ==
       SocketConnectionStatus::SOCKET_LISTENING) {
-    NS_WARNING("SCO socket has been already listening");
+    BT_WARNING("SCO socket has been already listening");
     return false;
   }
 
   mScoSocket->Disconnect();
 
   if (!mScoSocket->Listen(-1)) {
-    NS_WARNING("Can't listen on SCO socket!");
+    BT_WARNING("Can't listen on SCO socket!");
     return false;
   }
 
   mScoSocketStatus = mScoSocket->GetConnectionStatus();
   return true;
 }
 
 bool
--- a/dom/bluetooth/BluetoothHfpManager.h
+++ b/dom/bluetooth/BluetoothHfpManager.h
@@ -76,16 +76,21 @@ public:
   virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE;
   virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE;
   virtual void Connect(const nsAString& aDeviceAddress,
                        BluetoothProfileController* aController) MOZ_OVERRIDE;
   virtual void Disconnect(BluetoothProfileController* aController) MOZ_OVERRIDE;
   virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE;
   virtual void OnDisconnect(const nsAString& AErrorStr) MOZ_OVERRIDE;
 
+  virtual void GetName(nsACString& aName)
+  {
+    aName.AssignLiteral("HFP/HSP");
+  }
+
   bool Listen();
   bool ConnectSco(BluetoothReplyRunnable* aRunnable = nullptr);
   bool DisconnectSco();
   bool ListenSco();
 
   /**
    * @param aSend A boolean indicates whether we need to notify headset or not
    */
--- a/dom/bluetooth/BluetoothHidManager.cpp
+++ b/dom/bluetooth/BluetoothHidManager.cpp
@@ -231,17 +231,17 @@ BluetoothHidManager::NotifyStatusChanged
   parameters.AppendElement(
     BluetoothNamedValue(NS_LITERAL_STRING("connected"), v));
 
   v = mDeviceAddress;
   parameters.AppendElement(
     BluetoothNamedValue(NS_LITERAL_STRING("address"), v));
 
   if (!BroadcastSystemMessage(type, parameters)) {
-    NS_WARNING("Failed to broadcast system message to settings");
+    BT_WARNING("Failed to broadcast system message to settings");
     return;
   }
 }
 
 void
 BluetoothHidManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
                                          const nsAString& aServiceUuid,
                                          int aChannel)
--- a/dom/bluetooth/BluetoothHidManager.h
+++ b/dom/bluetooth/BluetoothHidManager.h
@@ -32,16 +32,22 @@ public:
   virtual bool IsConnected() MOZ_OVERRIDE;
   virtual void Connect(const nsAString& aDeviceAddress,
                        BluetoothProfileController* aController) MOZ_OVERRIDE;
   virtual void Disconnect(BluetoothProfileController* aController)
                           MOZ_OVERRIDE;
   virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE;
   virtual void OnDisconnect(const nsAString& aErrorStr) MOZ_OVERRIDE;
 
+  virtual void GetName(nsACString& aName)
+  {
+    aName.AssignLiteral("HID");
+  }
+
+  // HID-specific functions
   void HandleInputPropertyChanged(const BluetoothSignal& aSignal);
 
 private:
   BluetoothHidManager();
   bool Init();
   void Cleanup();
   void HandleShutdown();
 
--- a/dom/bluetooth/BluetoothManager.cpp
+++ b/dom/bluetooth/BluetoothManager.cpp
@@ -43,40 +43,40 @@ public:
 
   bool
   ParseSuccessfulReply(JS::Value* aValue)
   {
     *aValue = JSVAL_VOID;
 
     const BluetoothValue& v = mReply->get_BluetoothReplySuccess().value();
     if (v.type() != BluetoothValue::TArrayOfBluetoothNamedValue) {
-      NS_WARNING("Not a BluetoothNamedValue array!");
+      BT_WARNING("Not a BluetoothNamedValue array!");
       SetError(NS_LITERAL_STRING("BluetoothReplyTypeError"));
       return false;
     }
 
     const InfallibleTArray<BluetoothNamedValue>& values =
       v.get_ArrayOfBluetoothNamedValue();
     nsRefPtr<BluetoothAdapter> adapter =
       BluetoothAdapter::Create(mManagerPtr->GetOwner(), values);
 
     nsresult rv;
     nsIScriptContext* sc = mManagerPtr->GetContextForEventHandlers(&rv);
     if (!sc) {
-      NS_WARNING("Cannot create script context!");
+      BT_WARNING("Cannot create script context!");
       SetError(NS_LITERAL_STRING("BluetoothScriptContextError"));
       return false;
     }
 
     AutoPushJSContext cx(sc->GetNativeContext());
 
     JS::Rooted<JSObject*> global(cx, sc->GetWindowProxy());
     rv = nsContentUtils::WrapNative(cx, global, adapter, aValue);
     if (NS_FAILED(rv)) {
-      NS_WARNING("Cannot create native object!");
+      BT_WARNING("Cannot create native object!");
       SetError(NS_LITERAL_STRING("BluetoothNativeObjectError"));
       return false;
     }
 
     return true;
   }
 
   void
@@ -115,17 +115,17 @@ BluetoothManager::~BluetoothManager()
 void
 BluetoothManager::SetPropertyByValue(const BluetoothNamedValue& aValue)
 {
 #ifdef DEBUG
     const nsString& name = aValue.name();
     nsCString warningMsg;
     warningMsg.AssignLiteral("Not handling manager property: ");
     warningMsg.Append(NS_ConvertUTF16toUTF8(name));
-    NS_WARNING(warningMsg.get());
+    BT_WARNING(warningMsg.get());
 #endif
 }
 
 bool
 BluetoothManager::GetEnabled(ErrorResult& aRv)
 {
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
@@ -192,30 +192,30 @@ BluetoothManager::CheckPermission(nsPIDO
   NS_ENSURE_SUCCESS(rv, false);
 
   return permission == nsIPermissionManager::ALLOW_ACTION;
 }
 
 void
 BluetoothManager::Notify(const BluetoothSignal& aData)
 {
-  BT_LOG("[M] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
+  BT_LOGD("[M] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
 
   if (aData.name().EqualsLiteral("AdapterAdded")) {
     DispatchTrustedEvent(NS_LITERAL_STRING("adapteradded"));
   } else if (aData.name().EqualsLiteral("Enabled")) {
     DispatchTrustedEvent(NS_LITERAL_STRING("enabled"));
   } else if (aData.name().EqualsLiteral("Disabled")) {
     DispatchTrustedEvent(NS_LITERAL_STRING("disabled"));
   } else {
 #ifdef DEBUG
     nsCString warningMsg;
     warningMsg.AssignLiteral("Not handling manager signal: ");
     warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
-    NS_WARNING(warningMsg.get());
+    BT_WARNING(warningMsg.get());
 #endif
   }
 }
 
 bool
 BluetoothManager::IsConnected(uint16_t aProfileId, ErrorResult& aRv)
 {
   BluetoothService* bs = BluetoothService::Get();
--- a/dom/bluetooth/BluetoothOppManager.cpp
+++ b/dom/bluetooth/BluetoothOppManager.cpp
@@ -108,27 +108,27 @@ public:
 
     uint32_t numRead;
     nsAutoArrayPtr<char> buf(new char[mAvailablePacketSize]);
 
     // function inputstream->Read() only works on non-main thread
     nsresult rv = mInputStream->Read(buf, mAvailablePacketSize, &numRead);
     if (NS_FAILED(rv)) {
       // Needs error handling here
-      NS_WARNING("Failed to read from input stream");
+      BT_WARNING("Failed to read from input stream");
       return NS_ERROR_FAILURE;
     }
 
     if (numRead > 0) {
       sBluetoothOppManager->CheckPutFinal(numRead);
 
       nsRefPtr<SendSocketDataTask> task =
         new SendSocketDataTask((uint8_t*)buf.forget(), numRead);
       if (NS_FAILED(NS_DispatchToMainThread(task))) {
-        NS_WARNING("Failed to dispatch to main thread!");
+        BT_WARNING("Failed to dispatch to main thread!");
         return NS_ERROR_FAILURE;
       }
     }
 
     return NS_OK;
   };
 
 private:
@@ -303,37 +303,37 @@ BluetoothOppManager::HandleShutdown()
 }
 
 bool
 BluetoothOppManager::Listen()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mSocket) {
-    NS_WARNING("mSocket exists. Failed to listen.");
+    BT_WARNING("mSocket exists. Failed to listen.");
     return false;
   }
 
   if (!mRfcommSocket) {
     mRfcommSocket =
       new BluetoothSocket(this, BluetoothSocketType::RFCOMM, true, true);
 
     if (!mRfcommSocket->Listen(BluetoothReservedChannels::CHANNEL_OPUSH)) {
-      NS_WARNING("[OPP] Can't listen on RFCOMM socket!");
+      BT_WARNING("[OPP] Can't listen on RFCOMM socket!");
       mRfcommSocket = nullptr;
       return false;
     }
   }
 
   if (!mL2capSocket) {
     mL2capSocket =
       new BluetoothSocket(this, BluetoothSocketType::EL2CAP, true, true);
 
     if (!mL2capSocket->Listen(BluetoothReservedChannels::CHANNEL_OPUSH_L2CAP)) {
-      NS_WARNING("[OPP] Can't listen on L2CAP socket!");
+      BT_WARNING("[OPP] Can't listen on L2CAP socket!");
       mRfcommSocket->Disconnect();
       mRfcommSocket = nullptr;
       mL2capSocket = nullptr;
       return false;
     }
   }
 
   return true;
@@ -445,17 +445,17 @@ BluetoothOppManager::AfterOppConnected()
   mWaitingForConfirmationFlag = true;
   AfterFirstPut();
   // Get a mount lock to prevent the sdcard from being shared with
   // the PC while we're doing a OPP file transfer. After OPP transaction
   // were done, the mount lock will be freed.
   if (!AcquireSdcardMountLock()) {
     // If we fail to get a mount lock, abort this transaction
     // Directly sending disconnect-request is better than abort-request
-    NS_WARNING("BluetoothOPPManager couldn't get a mount lock!");
+    BT_WARNING("BluetoothOPPManager couldn't get a mount lock!");
     Disconnect(nullptr);
   }
 }
 
 void
 BluetoothOppManager::AfterOppDisconnected()
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -575,44 +575,44 @@ BluetoothOppManager::ExtractPacketHeader
 
 bool
 BluetoothOppManager::ExtractBlobHeaders()
 {
   RetrieveSentFileName();
 
   nsresult rv = mBlob->GetType(mContentType);
   if (NS_FAILED(rv)) {
-    NS_WARNING("Can't get content type");
+    BT_WARNING("Can't get content type");
     SendDisconnectRequest();
     return false;
   }
 
   uint64_t fileLength;
   rv = mBlob->GetSize(&fileLength);
   if (NS_FAILED(rv)) {
-    NS_WARNING("Can't get file size");
+    BT_WARNING("Can't get file size");
     SendDisconnectRequest();
     return false;
   }
 
   // Currently we keep the size of files which were sent/received via
   // Bluetooth not exceed UINT32_MAX because the Length header in OBEX
   // is only 4-byte long. Although it is possible to transfer a file
   // larger than UINT32_MAX, it needs to parse another OBEX Header
   // and I would like to leave it as a feature.
   if (fileLength > (uint64_t)UINT32_MAX) {
-    NS_WARNING("The file size is too large for now");
+    BT_WARNING("The file size is too large for now");
     SendDisconnectRequest();
     return false;
   }
 
   mFileLength = fileLength;
   rv = NS_NewThread(getter_AddRefs(mReadFileThread));
   if (NS_FAILED(rv)) {
-    NS_WARNING("Can't create thread");
+    BT_WARNING("Can't create thread");
     SendDisconnectRequest();
     return false;
   }
 
   return true;
 }
 
 void
@@ -824,20 +824,20 @@ BluetoothOppManager::ServerDataHandler(U
       mSuccessFlag = true;
       FileTransferComplete();
       NotifyAboutFileChange();
     }
   } else if (opCode == ObexRequestCode::Get ||
              opCode == ObexRequestCode::GetFinal ||
              opCode == ObexRequestCode::SetPath) {
     ReplyError(ObexResponseCode::BadRequest);
-    NS_WARNING("Unsupported ObexRequestCode");
+    BT_WARNING("Unsupported ObexRequestCode");
   } else {
     ReplyError(ObexResponseCode::NotImplemented);
-    NS_WARNING("Unrecognized ObexRequestCode");
+    BT_WARNING("Unrecognized ObexRequestCode");
   }
 }
 
 void
 BluetoothOppManager::ClearQueue()
 {
   mCurrentBlobIndex = -1;
   mBlob = nullptr;
@@ -873,17 +873,17 @@ BluetoothOppManager::ClientDataHandler(U
         mLastCommand == ObexRequestCode::Abort ||
         mLastCommand == ObexRequestCode::PutFinal) {
       SendDisconnectRequest();
     }
     nsAutoCString str;
     str += "[OPP] 0x";
     str.AppendInt(mLastCommand, 16);
     str += " failed";
-    NS_WARNING(str.get());
+    BT_WARNING(str.get());
     FileTransferComplete();
     return;
   }
 
   if (mLastCommand == ObexRequestCode::PutFinal) {
     mSuccessFlag = true;
     FileTransferComplete();
 
@@ -937,31 +937,31 @@ BluetoothOppManager::ClientDataHandler(U
       UpdateProgress();
       mUpdateProgressCounter = mSentFileLength / kUpdateProgressBase + 1;
     }
 
     nsresult rv;
     if (!mInputStream) {
       rv = mBlob->GetInternalStream(getter_AddRefs(mInputStream));
       if (NS_FAILED(rv)) {
-        NS_WARNING("Can't get internal stream of blob");
+        BT_WARNING("Can't get internal stream of blob");
         SendDisconnectRequest();
         return;
       }
     }
 
     nsRefPtr<ReadFileTask> task = new ReadFileTask(mInputStream,
                                                    mRemoteMaxPacketLength);
     rv = mReadFileThread->Dispatch(task, NS_DISPATCH_NORMAL);
     if (NS_FAILED(rv)) {
-      NS_WARNING("Cannot dispatch read file task!");
+      BT_WARNING("Cannot dispatch read file task!");
       SendDisconnectRequest();
     }
   } else {
-    NS_WARNING("Unhandled ObexRequestCode");
+    BT_WARNING("Unhandled ObexRequestCode");
   }
 }
 
 // Virtual function of class SocketConsumer
 void
 BluetoothOppManager::ReceiveSocketData(BluetoothSocket* aSocket,
                                        nsAutoPtr<UnixSocketRawData>& aMessage)
 {
@@ -1024,17 +1024,17 @@ BluetoothOppManager::SendPutHeaderReques
 void
 BluetoothOppManager::SendPutRequest(uint8_t* aFileBody,
                                     int aFileBodyLength)
 {
   int packetLeftSpace = mRemoteMaxPacketLength - kPutRequestHeaderSize;
 
   if (!mConnected) return;
   if (aFileBodyLength > packetLeftSpace) {
-    NS_WARNING("Not allowed such a small MaxPacketLength value");
+    BT_WARNING("Not allowed such a small MaxPacketLength value");
     return;
   }
 
   // Section 3.3.3 "Put", IrOBEX 1.2
   // [opcode:1][length:2][Headers:var]
   uint8_t* req = new uint8_t[mRemoteMaxPacketLength];
 
   int index = 3;
@@ -1229,17 +1229,17 @@ BluetoothOppManager::FileTransferComplet
   v = mSentFileLength;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   name.AssignLiteral("contentType");
   v = mContentType;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   if (!BroadcastSystemMessage(type, parameters)) {
-    NS_WARNING("Failed to broadcast [bluetooth-opp-transfer-complete]");
+    BT_WARNING("Failed to broadcast [bluetooth-opp-transfer-complete]");
     return;
   }
 
   mSendTransferCompleteFlag = true;
 }
 
 void
 BluetoothOppManager::StartFileTransfer()
@@ -1265,17 +1265,17 @@ BluetoothOppManager::StartFileTransfer()
   v = mFileLength;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   name.AssignLiteral("contentType");
   v = mContentType;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   if (!BroadcastSystemMessage(type, parameters)) {
-    NS_WARNING("Failed to broadcast [bluetooth-opp-transfer-start]");
+    BT_WARNING("Failed to broadcast [bluetooth-opp-transfer-start]");
     return;
   }
 }
 
 void
 BluetoothOppManager::UpdateProgress()
 {
   nsString type, name;
@@ -1295,17 +1295,17 @@ BluetoothOppManager::UpdateProgress()
   v = mSentFileLength;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   name.AssignLiteral("fileLength");
   v = mFileLength;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   if (!BroadcastSystemMessage(type, parameters)) {
-    NS_WARNING("Failed to broadcast [bluetooth-opp-update-progress]");
+    BT_WARNING("Failed to broadcast [bluetooth-opp-update-progress]");
     return;
   }
 }
 
 void
 BluetoothOppManager::ReceivingFileConfirmation()
 {
   nsString type, name;
@@ -1325,17 +1325,17 @@ BluetoothOppManager::ReceivingFileConfir
   v = mFileLength;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   name.AssignLiteral("contentType");
   v = mContentType;
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   if (!BroadcastSystemMessage(type, parameters)) {
-    NS_WARNING("Failed to send [bluetooth-opp-receiving-file-confirmation]");
+    BT_WARNING("Failed to send [bluetooth-opp-receiving-file-confirmation]");
     return;
   }
 }
 
 void
 BluetoothOppManager::NotifyAboutFileChange()
 {
   NS_NAMED_LITERAL_STRING(data, "modified");
--- a/dom/bluetooth/BluetoothOppManager.h
+++ b/dom/bluetooth/BluetoothOppManager.h
@@ -73,16 +73,21 @@ public:
   // The following functions are inherited from BluetoothProfileManagerBase
   virtual void OnGetServiceChannel(const nsAString& aDeviceAddress,
                                    const nsAString& aServiceUuid,
                                    int aChannel) MOZ_OVERRIDE;
   virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE;
   virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE;
   virtual bool IsConnected() MOZ_OVERRIDE;
 
+  virtual void GetName(nsACString& aName)
+  {
+    aName.AssignLiteral("OPP");
+  }
+
   /*
    * If an application wants to send a file, first, it needs to
    * call Connect() to create a valid RFCOMM connection. After
    * that, call SendFile()/StopSendingFile() to control file-sharing
    * process. During the file transfering process, the application
    * will receive several system messages which contain the processed
    * percentage of file. At the end, the application will get another
    * system message indicating that the process is complete, then it can
--- a/dom/bluetooth/BluetoothProfileController.cpp
+++ b/dom/bluetooth/BluetoothProfileController.cpp
@@ -12,16 +12,24 @@
 #include "BluetoothHidManager.h"
 #include "BluetoothOppManager.h"
 
 #include "BluetoothUtils.h"
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
 
 USING_BLUETOOTH_NAMESPACE
 
+#define BT_LOGR_PROFILE(mgr, args...)                 \
+  do {                                                \
+    nsCString name;                                   \
+    mgr->GetName(name);                               \
+    BT_LOGR("%s: [%s] %s", __FUNCTION__, name.get(),  \
+      nsPrintfCString(args).get());                   \
+  } while(0)
+
 BluetoothProfileController::BluetoothProfileController(
                                    const nsAString& aDeviceAddress,
                                    BluetoothReplyRunnable* aRunnable,
                                    BluetoothProfileControllerCallback aCallback)
   : mCallback(aCallback)
   , mDeviceAddress(aDeviceAddress)
   , mRunnable(aRunnable)
   , mSuccess(false)
@@ -115,17 +123,16 @@ BluetoothProfileController::Connect(uint
 
   mCod = aCod;
 
   /**
    * Connect to HFP/HSP first. Then, connect A2DP if Rendering bit is set.
    * It's almost impossible to send file to a remote device which is an Audio
    * device or a Rendering device, so we won't connect OPP in that case.
    */
-  BluetoothProfileManagerBase* profile;
   if (hasAudio) {
     AddProfile(BluetoothHfpManager::Get());
   }
   if (hasRendering) {
     AddProfile(BluetoothA2dpManager::Get());
   }
   if (hasObjectTransfer && !hasAudio && !hasRendering) {
     AddProfile(BluetoothOppManager::Get());
@@ -139,16 +146,17 @@ BluetoothProfileController::Connect(uint
 
 void
 BluetoothProfileController::ConnectNext()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (++mProfilesIndex < mProfiles.Length()) {
     MOZ_ASSERT(!mDeviceAddress.IsEmpty());
+    BT_LOGR_PROFILE(mProfiles[mProfilesIndex], "");
 
     mProfiles[mProfilesIndex]->Connect(mDeviceAddress, this);
     return;
   }
 
   MOZ_ASSERT(mRunnable && mCallback);
 
   // The action has been completed, so the dom request is replied and then
@@ -161,16 +169,18 @@ BluetoothProfileController::ConnectNext(
   }
   mCallback();
 }
 
 void
 BluetoothProfileController::OnConnect(const nsAString& aErrorStr)
 {
   MOZ_ASSERT(NS_IsMainThread());
+  BT_LOGR_PROFILE(mProfiles[mProfilesIndex], "<%s>",
+    NS_ConvertUTF16toUTF8(aErrorStr).get());
 
   if (!aErrorStr.IsEmpty()) {
     BT_WARNING(NS_ConvertUTF16toUTF8(aErrorStr).get());
   } else {
     mSuccess = true;
   }
 
   ConnectNext();
@@ -198,16 +208,18 @@ BluetoothProfileController::Disconnect(B
 }
 
 void
 BluetoothProfileController::DisconnectNext()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (++mProfilesIndex < mProfiles.Length()) {
+    BT_LOGR_PROFILE(mProfiles[mProfilesIndex], "");
+
     mProfiles[mProfilesIndex]->Disconnect(this);
     return;
   }
 
   MOZ_ASSERT(mRunnable && mCallback);
 
   // The action has been completed, so the dom request is replied and then
   // the callback is invoked
@@ -219,18 +231,19 @@ BluetoothProfileController::DisconnectNe
   }
   mCallback();
 }
 
 void
 BluetoothProfileController::OnDisconnect(const nsAString& aErrorStr)
 {
   MOZ_ASSERT(NS_IsMainThread());
+  BT_LOGR_PROFILE(mProfiles[mProfilesIndex], "<%s>",
+    NS_ConvertUTF16toUTF8(aErrorStr).get());
 
   if (!aErrorStr.IsEmpty()) {
     BT_WARNING(NS_ConvertUTF16toUTF8(aErrorStr).get());
   } else {
     mSuccess = true;
   }
 
   DisconnectNext();
 }
-
--- a/dom/bluetooth/BluetoothProfileManagerBase.h
+++ b/dom/bluetooth/BluetoothProfileManagerBase.h
@@ -58,13 +58,18 @@ public:
   virtual void Disconnect(BluetoothProfileController* aController) = 0;
 
   /**
    * If it establishes/releases a connection successfully, the error string
    * will be empty. Otherwise, the error string shows the failure reason.
    */
   virtual void OnConnect(const nsAString& aErrorStr) = 0;
   virtual void OnDisconnect(const nsAString& aErrorStr) = 0;
+
+  /**
+   * Returns string of profile name
+   */
+  virtual void GetName(nsACString& aName) = 0;
 };
 
 END_BLUETOOTH_NAMESPACE
 
 #endif  //#ifndef mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__
--- a/dom/bluetooth/BluetoothPropertyContainer.cpp
+++ b/dom/bluetooth/BluetoothPropertyContainer.cpp
@@ -36,17 +36,17 @@ BluetoothPropertyContainer::SetProperty(
                                         ErrorResult& aRv)
 {
   nsRefPtr<mozilla::dom::DOMRequest> request = new DOMRequest(aOwner);
   nsRefPtr<BluetoothReplyRunnable> task =
     new BluetoothVoidReplyRunnable(request);
 
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
-    NS_WARNING("Bluetooth service not available!");
+    BT_WARNING("Bluetooth service not available!");
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsresult rv = bs->SetProperty(mObjectType, aProperty, task);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
--- a/dom/bluetooth/BluetoothReplyRunnable.cpp
+++ b/dom/bluetooth/BluetoothReplyRunnable.cpp
@@ -68,17 +68,17 @@ BluetoothReplyRunnable::Run()
     if (!ParseSuccessfulReply(&v)) {
       rv = FireErrorString();
     } else {
       rv = FireReply(v);
     }
   }
 
   if (NS_FAILED(rv)) {
-    NS_WARNING("Could not fire DOMRequest!");
+    BT_WARNING("Could not fire DOMRequest!");
   }
 
   ReleaseMembers();
   MOZ_ASSERT(!mDOMRequest,
              "mDOMRequest still alive! Deriving class should call "
              "BluetoothReplyRunnable::ReleaseMembers()!");
 
   return rv;
--- a/dom/bluetooth/BluetoothRilListener.cpp
+++ b/dom/bluetooth/BluetoothRilListener.cpp
@@ -187,20 +187,20 @@ TelephonyListener::NotifyError(int32_t a
     // In order to not miss any related call state transition.
     // It's possible that 3G network signal lost for unknown reason.
     // If a call is released abnormally, NotifyError() will be called,
     // instead of CallStateChanged(). We need to reset the call array state
     // via setting CALL_STATE_DISCONNECTED
     hfp->HandleCallStateChanged(aCallIndex,
                                 nsITelephonyProvider::CALL_STATE_DISCONNECTED,
                                 aError, EmptyString(), false, true);
-    NS_WARNING("Reset the call state due to call transition ends abnormally");
+    BT_WARNING("Reset the call state due to call transition ends abnormally");
   }
 
-  NS_WARNING(NS_ConvertUTF16toUTF8(aError).get());
+  BT_WARNING(NS_ConvertUTF16toUTF8(aError).get());
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TelephonyListener::ConferenceCallStateChanged(uint16_t aCallState)
 {
   return NS_OK;
 }
--- a/dom/bluetooth/BluetoothService.cpp
+++ b/dom/bluetooth/BluetoothService.cpp
@@ -181,48 +181,48 @@ public:
      * When two values are the same, we don't switch on/off bluetooth
      * but we still do ToggleBtAck task. One special case happens at startup
      * stage. At startup, the initialization of BluetoothService still has to
      * be done even if mEnabled is equal to the status of Bluetooth firmware.
      *
      * Please see bug 892392 for more information.
      */
     if (!mIsStartup && mEnabled == gBluetoothService->IsEnabledInternal()) {
-      NS_WARNING("Bluetooth has already been enabled/disabled before.");
+      BT_WARNING("Bluetooth has already been enabled/disabled before.");
     } else {
       // Switch on/off bluetooth
       if (mEnabled) {
         if (NS_FAILED(gBluetoothService->StartInternal())) {
-          NS_WARNING("Bluetooth service failed to start!");
+          BT_WARNING("Bluetooth service failed to start!");
           mEnabled = !mEnabled;
         }
       } else {
         if (NS_FAILED(gBluetoothService->StopInternal())) {
-          NS_WARNING("Bluetooth service failed to stop!");
+          BT_WARNING("Bluetooth service failed to stop!");
           mEnabled = !mEnabled;
         }
       }
     }
 
     // This is requested in Bug 836516. With settings this property, WLAN
     // firmware could be aware of Bluetooth has been turned on/off, so that the
     // mecahnism of handling coexistence of WIFI and Bluetooth could be started.
     //
     // In the future, we may have our own way instead of setting a system
     // property to let firmware developers be able to sense that Bluetooth has
     // been toggled.
 #if defined(MOZ_WIDGET_GONK)
     if (property_set(PROP_BLUETOOTH_ENABLED, mEnabled ? "true" : "false") != 0) {
-      NS_WARNING("Failed to set bluetooth enabled property");
+      BT_WARNING("Failed to set bluetooth enabled property");
     }
 #endif
 
     nsCOMPtr<nsIRunnable> ackTask = new BluetoothService::ToggleBtAck(mEnabled);
     if (NS_FAILED(NS_DispatchToMainThread(ackTask))) {
-      NS_WARNING("Failed to dispatch to main thread!");
+      BT_WARNING("Failed to dispatch to main thread!");
     }
 
     return NS_OK;
   }
 
 private:
   bool mEnabled;
   bool mIsStartup;
@@ -233,32 +233,32 @@ class BluetoothService::StartupTask : pu
 public:
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD Handle(const nsAString& aName, const JS::Value& aResult)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     if (!aResult.isBoolean()) {
-      NS_WARNING("Setting for '" BLUETOOTH_ENABLED_SETTING "' is not a boolean!");
+      BT_WARNING("Setting for '" BLUETOOTH_ENABLED_SETTING "' is not a boolean!");
       return NS_OK;
     }
 
     // It is theoretically possible to shut down before the first settings check
     // has completed (though extremely unlikely).
     if (gBluetoothService) {
       return gBluetoothService->HandleStartupSettingsCheck(aResult.toBoolean());
     }
 
     return NS_OK;
   }
 
   NS_IMETHOD HandleError(const nsAString& aName)
   {
-    NS_WARNING("Unable to get value for '" BLUETOOTH_ENABLED_SETTING "'");
+    BT_WARNING("Unable to get value for '" BLUETOOTH_ENABLED_SETTING "'");
     return NS_OK;
   }
 };
 
 NS_IMPL_ISUPPORTS1(BluetoothService::StartupTask, nsISettingsServiceCallback);
 
 NS_IMPL_ISUPPORTS1(BluetoothService, nsIObserver)
 
@@ -302,66 +302,66 @@ BluetoothService::Create()
   }
 #endif
 
 #if defined(MOZ_BLUETOOTH_GONK)
   return new BluetoothGonkService();
 #elif defined(MOZ_BLUETOOTH_DBUS)
   return new BluetoothDBusService();
 #endif
-  NS_WARNING("No platform support for bluetooth!");
+  BT_WARNING("No platform support for bluetooth!");
   return nullptr;
 }
 
 bool
 BluetoothService::Init()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   NS_ENSURE_TRUE(obs, false);
 
   if (NS_FAILED(obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
                                  false))) {
-    NS_WARNING("Failed to add shutdown observer!");
+    BT_WARNING("Failed to add shutdown observer!");
     return false;
   }
 
   // Only the main process should observe bluetooth settings changes.
   if (IsMainProcess() &&
       NS_FAILED(obs->AddObserver(this, MOZSETTINGS_CHANGED_ID, false))) {
-    NS_WARNING("Failed to add settings change observer!");
+    BT_WARNING("Failed to add settings change observer!");
     return false;
   }
 
   return true;
 }
 
 void
 BluetoothService::Cleanup()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   if (obs &&
       (NS_FAILED(obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) ||
        NS_FAILED(obs->RemoveObserver(this, MOZSETTINGS_CHANGED_ID)))) {
-    NS_WARNING("Can't unregister observers!");
+    BT_WARNING("Can't unregister observers!");
   }
 }
 
 void
 BluetoothService::RegisterBluetoothSignalHandler(
                                               const nsAString& aNodeName,
                                               BluetoothSignalObserver* aHandler)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aHandler);
 
-  BT_LOG("[S] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aNodeName).get());
+  BT_LOGD("[S] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aNodeName).get());
 
   BluetoothSignalObserverList* ol;
   if (!mBluetoothSignalObserverTable.Get(aNodeName, &ol)) {
     ol = new BluetoothSignalObserverList();
     mBluetoothSignalObserverTable.Put(aNodeName, ol);
   }
 
   ol->AddObserver(aHandler);
@@ -370,31 +370,31 @@ BluetoothService::RegisterBluetoothSigna
 void
 BluetoothService::UnregisterBluetoothSignalHandler(
                                               const nsAString& aNodeName,
                                               BluetoothSignalObserver* aHandler)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aHandler);
 
-  BT_LOG("[S] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aNodeName).get());
+  BT_LOGD("[S] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aNodeName).get());
 
   BluetoothSignalObserverList* ol;
   if (mBluetoothSignalObserverTable.Get(aNodeName, &ol)) {
     ol->RemoveObserver(aHandler);
     // We shouldn't have duplicate instances in the ObserverList, but there's
     // no appropriate way to do duplication check while registering, so
     // assertions are added here.
     MOZ_ASSERT(!ol->RemoveObserver(aHandler));
     if (ol->Length() == 0) {
       mBluetoothSignalObserverTable.Remove(aNodeName);
     }
   }
   else {
-    NS_WARNING("Node was never registered!");
+    BT_WARNING("Node was never registered!");
   }
 }
 
 PLDHashOperator
 RemoveAllSignalHandlers(const nsAString& aKey,
                         nsAutoPtr<BluetoothSignalObserverList>& aData,
                         void* aUserArg)
 {
@@ -429,17 +429,17 @@ BluetoothService::DistributeSignal(const
     return;
   }
 
   BluetoothSignalObserverList* ol;
   if (!mBluetoothSignalObserverTable.Get(aSignal.path(), &ol)) {
 #if DEBUG
     nsAutoCString msg("No observer registered for path ");
     msg.Append(NS_ConvertUTF16toUTF8(aSignal.path()));
-    NS_WARNING(msg.get());
+    BT_WARNING(msg.get());
 #endif
     return;
   }
   MOZ_ASSERT(ol->Length());
   ol->Broadcast(aSignal);
 }
 
 nsresult
@@ -524,17 +524,17 @@ BluetoothService::SetEnabled(bool aEnabl
       RemoveObserversExceptBluetoothManager, nullptr);
   }
 
   /**
    * mEnabled: real status of bluetooth
    * aEnabled: expected status of bluetooth
    */
   if (mEnabled == aEnabled) {
-    NS_WARNING("Bluetooth has already been enabled/disabled before\
+    BT_WARNING("Bluetooth has already been enabled/disabled before\
                 or the toggling is failed.");
   }
 
   mEnabled = aEnabled;
 
   gToggleInProgress = false;
 }
 
@@ -730,17 +730,17 @@ BluetoothService::Get()
 
   // If we already exist, exit early
   if (gBluetoothService) {
     return gBluetoothService;
   }
 
   // If we're in shutdown, don't create a new instance
   if (gInShutdown) {
-    NS_WARNING("BluetoothService can't be created during shutdown");
+    BT_WARNING("BluetoothService can't be created during shutdown");
     return nullptr;
   }
 
   // Create new instance, register, return
   nsRefPtr<BluetoothService> service = BluetoothService::Create();
   NS_ENSURE_TRUE(service, nullptr);
 
   if (!service->Init()) {
@@ -779,21 +779,21 @@ BluetoothService::Notify(const Bluetooth
 {
   nsString type = NS_LITERAL_STRING("bluetooth-pairing-request");
 
   AutoSafeJSContext cx;
   JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
   NS_ENSURE_TRUE_VOID(obj);
 
   if (!SetJsObject(cx, aData.value(), obj)) {
-    NS_WARNING("Failed to set properties of system message!");
+    BT_WARNING("Failed to set properties of system message!");
     return;
   }
 
-  BT_LOG("[S] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
+  BT_LOGD("[S] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
 
   if (aData.name().EqualsLiteral("RequestConfirmation")) {
     MOZ_ASSERT(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 4,
       "RequestConfirmation: Wrong length of parameters");
   } else if (aData.name().EqualsLiteral("RequestPinCode")) {
     MOZ_ASSERT(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 3,
       "RequestPinCode: Wrong length of parameters");
   } else if (aData.name().EqualsLiteral("RequestPasskey")) {
@@ -806,17 +806,17 @@ BluetoothService::Notify(const Bluetooth
   } else if (aData.name().EqualsLiteral(PAIRED_STATUS_CHANGED_ID)) {
     MOZ_ASSERT(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 1,
       "pairedstatuschanged: Wrong length of parameters");
     type.AssignLiteral("bluetooth-pairedstatuschanged");
   } else {
     nsCString warningMsg;
     warningMsg.AssignLiteral("Not handling service signal: ");
     warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
-    NS_WARNING(warningMsg.get());
+    BT_WARNING(warningMsg.get());
     return;
   }
 
   nsCOMPtr<nsISystemMessagesInternal> systemMessenger =
     do_GetService("@mozilla.org/system-message-internal;1");
   NS_ENSURE_TRUE_VOID(systemMessenger);
 
   systemMessenger->BroadcastMessage(type,
--- a/dom/bluetooth/BluetoothSocket.cpp
+++ b/dom/bluetooth/BluetoothSocket.cpp
@@ -32,17 +32,17 @@ BluetoothSocket::Connect(const nsACStrin
   MOZ_ASSERT(!aDeviceAddress.IsEmpty());
 
   nsAutoPtr<BluetoothUnixSocketConnector> c(
     new BluetoothUnixSocketConnector(mType, aChannel, mAuth, mEncrypt));
 
   if (!ConnectSocket(c.forget(), aDeviceAddress.BeginReading())) {
     nsAutoString addr;
     GetAddress(addr);
-    BT_LOG("%s failed. Current connected device address: %s",
+    BT_LOGD("%s failed. Current connected device address: %s",
            __FUNCTION__, NS_ConvertUTF16toUTF8(addr).get());
     return false;
   }
 
   return true;
 }
 
 bool
@@ -51,17 +51,17 @@ BluetoothSocket::Listen(int aChannel)
   MOZ_ASSERT(NS_IsMainThread());
 
   nsAutoPtr<BluetoothUnixSocketConnector> c(
     new BluetoothUnixSocketConnector(mType, aChannel, mAuth, mEncrypt));
 
   if (!ListenSocket(c.forget())) {
     nsAutoString addr;
     GetAddress(addr);
-    BT_LOG("%s failed. Current connected device address: %s",
+    BT_LOGD("%s failed. Current connected device address: %s",
            __FUNCTION__, NS_ConvertUTF16toUTF8(addr).get());
     return false;
   }
 
   return true;
 }
 
 void
--- a/dom/bluetooth/BluetoothUnixSocketConnector.cpp
+++ b/dom/bluetooth/BluetoothUnixSocketConnector.cpp
@@ -94,32 +94,32 @@ BluetoothUnixSocketConnector::SetUp(int 
     break;
   default:
     MOZ_CRASH("Unknown socket type!");
   }
 
   if (lm) {
     if (mType == BluetoothSocketType::RFCOMM) {
       if (setsockopt(aFd, SOL_RFCOMM, RFCOMM_LM, &lm, sizeof(lm))) {
-        NS_WARNING("setsockopt(RFCOMM_LM) failed, throwing");
+        BT_WARNING("setsockopt(RFCOMM_LM) failed, throwing");
         return false;
       }
     } else if (mType == BluetoothSocketType::L2CAP ||
                mType == BluetoothSocketType::EL2CAP) {
       if (setsockopt(aFd, SOL_L2CAP, L2CAP_LM, &lm, sizeof(lm))) {
-        NS_WARNING("setsockopt(L2CAP_LM) failed, throwing");
+        BT_WARNING("setsockopt(L2CAP_LM) failed, throwing");
         return false;
       }
     }
   }
 
   if (mType == BluetoothSocketType::RFCOMM) {
     sndbuf = RFCOMM_SO_SNDBUF;
     if (setsockopt(aFd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf))) {
-      NS_WARNING("setsockopt(SO_SNDBUF) failed, throwing");
+      BT_WARNING("setsockopt(SO_SNDBUF) failed, throwing");
       return false;
     }
   }
 
   /* Setting L2CAP socket options */
   if (mType == BluetoothSocketType::L2CAP ||
       mType == BluetoothSocketType::EL2CAP) {
     struct l2cap_options opts;
@@ -141,23 +141,23 @@ BluetoothUnixSocketConnector::SetUp(int 
 
       err = setsockopt(aFd, SOL_L2CAP, L2CAP_OPTIONS, &opts, optlen);
     }
 
     /* Set larger SNDBUF & RCVBUF for EL2CAP connections */
     if (mType == BluetoothSocketType::EL2CAP) {
       sndbuf = L2CAP_SO_SNDBUF;
       if (setsockopt(aFd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf))) {
-        NS_WARNING("setsockopt(SO_SNDBUF) failed, throwing");
+        BT_WARNING("setsockopt(SO_SNDBUF) failed, throwing");
         return false;
       }
 
       rcvbuf = L2CAP_SO_RCVBUF;
       if (setsockopt(aFd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf))) {
-        NS_WARNING("setsockopt(SO_RCVBUF) failed, throwing");
+        BT_WARNING("setsockopt(SO_RCVBUF) failed, throwing");
         return false;
       }
     }
   }
 
   return true;
 }
 
@@ -180,22 +180,22 @@ BluetoothUnixSocketConnector::Create()
   case BluetoothSocketType::EL2CAP:
     fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_L2CAP);
     break;
   default:
     MOZ_CRASH();
   }
 
   if (fd < 0) {
-    NS_WARNING("Could not open bluetooth socket!");
+    BT_WARNING("Could not open bluetooth socket!");
     return -1;
   }
 
   if (!SetUp(fd)) {
-    NS_WARNING("Could not set up socket!");
+    BT_WARNING("Could not set up socket!");
     return -1;
   }
 
   return fd;
 }
 
 bool
 BluetoothUnixSocketConnector::CreateAddr(bool aIsServer,
@@ -203,17 +203,17 @@ BluetoothUnixSocketConnector::CreateAddr
                                          sockaddr_any& aAddr,
                                          const char* aAddress)
 {
   // Set to BDADDR_ANY, if it's not a server, we'll reset.
   bdaddr_t bd_address_obj = {{0, 0, 0, 0, 0, 0}};
 
   if (!aIsServer && aAddress && strlen(aAddress) > 0) {
     if (get_bdaddr(aAddress, &bd_address_obj)) {
-      NS_WARNING("Can't get bluetooth address!");
+      BT_WARNING("Can't get bluetooth address!");
       return false;
     }
   }
 
   // Initialize
   memset(&aAddr, 0, sizeof(aAddr));
 
   switch (mType) {
@@ -234,17 +234,17 @@ BluetoothUnixSocketConnector::CreateAddr
     break;
   case BluetoothSocketType::SCO:
     struct sockaddr_sco addr_sco;
     aAddrSize = sizeof(addr_sco);
     aAddr.sco.sco_family = AF_BLUETOOTH;
     memcpy(&aAddr.sco.sco_bdaddr, &bd_address_obj, sizeof(bd_address_obj));
     break;
   default:
-    NS_WARNING("Socket type unknown!");
+    BT_WARNING("Socket type unknown!");
     return false;
   }
   return true;
 }
 
 void
 BluetoothUnixSocketConnector::GetSocketAddr(const sockaddr_any& aAddr,
                                             nsAString& aAddrStr)
--- a/dom/bluetooth/BluetoothUtils.cpp
+++ b/dom/bluetooth/BluetoothUtils.cpp
@@ -24,17 +24,17 @@ BEGIN_BLUETOOTH_NAMESPACE
 bool
 SetJsObject(JSContext* aContext,
             const BluetoothValue& aValue,
             JS::Handle<JSObject*> aObj)
 {
   MOZ_ASSERT(aContext && aObj);
 
   if (aValue.type() != BluetoothValue::TArrayOfBluetoothNamedValue) {
-    NS_WARNING("SetJsObject: Invalid parameter type");
+    BT_WARNING("SetJsObject: Invalid parameter type");
     return false;
   }
 
   const nsTArray<BluetoothNamedValue>& arr =
     aValue.get_ArrayOfBluetoothNamedValue();
 
   for (uint32_t i = 0; i < arr.Length(); i++) {
     JS::Rooted<JS::Value> val(aContext);
@@ -51,24 +51,24 @@ SetJsObject(JSContext* aContext,
       }
       case BluetoothValue::Tuint32_t:
         val = INT_TO_JSVAL(v.get_uint32_t());
         break;
       case BluetoothValue::Tbool:
         val = BOOLEAN_TO_JSVAL(v.get_bool());
         break;
       default:
-        NS_WARNING("SetJsObject: Parameter is not handled");
+        BT_WARNING("SetJsObject: Parameter is not handled");
         break;
     }
 
     if (!JS_SetProperty(aContext, aObj,
                         NS_ConvertUTF16toUTF8(arr[i].name()).get(),
                         val)) {
-      NS_WARNING("Failed to set property");
+      BT_WARNING("Failed to set property");
       return false;
     }
   }
 
   return true;
 }
 
 nsString
@@ -107,22 +107,22 @@ BroadcastSystemMessage(const nsAString& 
                        const InfallibleTArray<BluetoothNamedValue>& aData)
 {
   mozilla::AutoSafeJSContext cx;
   NS_ASSERTION(!::JS_IsExceptionPending(cx),
       "Shouldn't get here when an exception is pending!");
 
   JS::RootedObject obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
   if (!obj) {
-    NS_WARNING("Failed to new JSObject for system message!");
+    BT_WARNING("Failed to new JSObject for system message!");
     return false;
   }
 
   if (!SetJsObject(cx, aData, obj)) {
-    NS_WARNING("Failed to set properties of system message!");
+    BT_WARNING("Failed to set properties of system message!");
     return false;
   }
 
   nsCOMPtr<nsISystemMessagesInternal> systemMessenger =
     do_GetService("@mozilla.org/system-message-internal;1");
   NS_ENSURE_TRUE(systemMessenger, false);
 
   systemMessenger->BroadcastMessage(aType,
@@ -144,17 +144,17 @@ DispatchBluetoothReply(BluetoothReplyRun
     reply = new BluetoothReply(BluetoothReplyError(err));
   } else {
     MOZ_ASSERT(aValue.type() != BluetoothValue::T__None);
     reply = new BluetoothReply(BluetoothReplySuccess(aValue));
   }
 
   aRunnable->SetReply(reply);
   if (NS_FAILED(NS_DispatchToMainThread(aRunnable))) {
-    NS_WARNING("Failed to dispatch to main thread!");
+    BT_WARNING("Failed to dispatch to main thread!");
   }
 }
 
 void
 ParseAtCommand(const nsACString& aAtCommand, const int aStart,
                nsTArray<nsCString>& aRetValues)
 {
   int length = aAtCommand.Length();
--- a/dom/bluetooth/gonk/BluetoothGonkService.cpp
+++ b/dom/bluetooth/gonk/BluetoothGonkService.cpp
@@ -94,28 +94,29 @@ StartStopGonkBluetooth(bool aShouldEnabl
     return NS_OK;
   }
   if (aShouldEnable) {
     result = (sBluedroidFunctions.bt_enable() == 0) ? true : false;
     if (sBluedroidFunctions.bt_is_enabled() < 0) {
       // if isEnabled < 0, this means we brought up the firmware, but something
       // went wrong with bluetoothd. Post a warning message, but try to proceed
       // with firmware unloading if that was requested, so we can retry later.
-      NS_WARNING("Bluetooth firmware up, but cannot connect to HCI socket! Check bluetoothd and try stopping/starting bluetooth again.");
+      BT_WARNING("Bluetooth firmware up, but cannot connect to HCI socket! "
+        "Check bluetoothd and try stopping/starting bluetooth again.");
       // Just disable now, return an error.
       if (sBluedroidFunctions.bt_disable() != 0) {
-        NS_WARNING("Problem shutting down bluetooth after error in bringup!");
+        BT_WARNING("Problem shutting down bluetooth after error in bringup!");
       }
       return NS_ERROR_FAILURE;
     }
   } else {
     result = (sBluedroidFunctions.bt_disable() == 0) ? true : false;
   }
   if (!result) {
-    NS_WARNING("Could not set gonk bluetooth firmware!");
+    BT_WARNING("Could not set gonk bluetooth firmware!");
     return NS_ERROR_FAILURE;
   }
   
   return NS_OK;
 }
 
 nsresult
 BluetoothGonkService::StartInternal()
--- a/dom/bluetooth/ipc/BluetoothParent.cpp
+++ b/dom/bluetooth/ipc/BluetoothParent.cpp
@@ -43,17 +43,17 @@ public:
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_ASSERT(mReply);
 
     if (mRequest) {
       // Must do this first because Send__delete__ will delete mRequest.
       mRequest->RequestComplete();
 
       if (!mRequest->Send__delete__(mRequest, *mReply)) {
-        NS_WARNING("Failed to send response to child process!");
+        BT_WARNING("Failed to send response to child process!");
         return NS_ERROR_FAILURE;
       }
     }
 
     ReleaseMembers();
     return NS_OK;
   }
 
--- a/dom/bluetooth/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/linux/BluetoothDBusService.cpp
@@ -30,17 +30,16 @@
 
 #include <cstdio>
 #include <dbus/dbus.h>
 
 #include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 #include "nsDebug.h"
 #include "nsDataHashtable.h"
-#include "nsPrintfCString.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
 #include "mozilla/Hal.h"
 #include "mozilla/ipc/UnixSocket.h"
 #include "mozilla/ipc/DBusThread.h"
 #include "mozilla/ipc/DBusUtils.h"
 #include "mozilla/ipc/RawDBusConnection.h"
 #include "mozilla/Mutex.h"
@@ -165,17 +164,16 @@ static const char* sBluetoothDBusSignals
   "type='signal',interface='org.bluez.HealthDevice'",
   "type='signal',interface='org.bluez.AudioSink'",
   "type='signal',interface='org.bluez.Control'"
 };
 
 /**
  * DBus Connection held for the BluetoothCommandThread to use. Should never be
  * used by any other thread.
- *
  */
 static nsRefPtr<RawDBusConnection> gThreadConnection;
 static nsDataHashtable<nsStringHashKey, DBusMessage* >* sPairingReqTable;
 static nsTArray<uint32_t> sAuthorizedServiceClass;
 static nsString sAdapterPath;
 static Atomic<int32_t> sIsPairing(0);
 static int sConnectedDeviceCount = 0;
 static StaticAutoPtr<Monitor> sStopBluetoothMonitor;
@@ -201,17 +199,17 @@ GetConnectedDevicesFilter(const Bluetoot
   return true;
 }
 
 static bool
 GetPairedDevicesFilter(const BluetoothValue& aValue)
 {
   // Check property 'Paired' and only paired device will be returned
   if (aValue.type() != BluetoothValue::TArrayOfBluetoothNamedValue) {
-    NS_WARNING("Not a BluetoothNamedValue array!");
+    BT_WARNING("Not a BluetoothNamedValue array!");
     return false;
   }
 
   const InfallibleTArray<BluetoothNamedValue>& deviceProperties =
     aValue.get_ArrayOfBluetoothNamedValue();
   uint32_t length = deviceProperties.Length();
   for (uint32_t p = 0; p < length; ++p) {
     if (deviceProperties[p].name().EqualsLiteral("Paired")) {
@@ -364,40 +362,16 @@ IsDBusMessageError(DBusMessage* aMsg, DB
       aErrorStr = NS_ConvertUTF8toUTF16(error_msg);
       return true;
     }
   }
   return false;
 }
 
 static void
-UnpackIntMessage(DBusMessage* aMsg, DBusError* aErr,
-                 BluetoothValue& aValue, nsAString& aErrorStr)
-{
-  MOZ_ASSERT(aMsg);
-
-  DBusError err;
-  dbus_error_init(&err);
-  if (!IsDBusMessageError(aMsg, aErr, aErrorStr)) {
-    MOZ_ASSERT(dbus_message_get_type(aMsg) == DBUS_MESSAGE_TYPE_METHOD_RETURN,
-               "Got dbus callback that's not a METHOD_RETURN!");
-    int i;
-    if (!dbus_message_get_args(aMsg, &err, DBUS_TYPE_INT32,
-                               &i, DBUS_TYPE_INVALID)) {
-      if (dbus_error_is_set(&err)) {
-        aErrorStr = NS_ConvertUTF8toUTF16(err.message);
-        LOG_AND_FREE_DBUS_ERROR(&err);
-      }
-    } else {
-      aValue = (uint32_t)i;
-    }
-  }
-}
-
-static void
 UnpackObjectPathMessage(DBusMessage* aMsg, DBusError* aErr,
                         BluetoothValue& aValue, nsAString& aErrorStr)
 {
   DBusError err;
   dbus_error_init(&err);
   if (!IsDBusMessageError(aMsg, aErr, aErrorStr)) {
     MOZ_ASSERT(dbus_message_get_type(aMsg) == DBUS_MESSAGE_TYPE_METHOD_RETURN,
                "Got dbus callback that's not a METHOD_RETURN!");
@@ -417,23 +391,23 @@ UnpackObjectPathMessage(DBusMessage* aMs
 
 class PrepareProfileManagersRunnable : public nsRunnable
 {
 public:
   nsresult Run()
   {
     BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
     if (!hfp || !hfp->Listen()) {
-      NS_WARNING("Failed to start listening for BluetoothHfpManager!");
+      BT_WARNING("Failed to start listening for BluetoothHfpManager!");
       return NS_ERROR_FAILURE;
     }
 
     BluetoothOppManager* opp = BluetoothOppManager::Get();
     if (!opp || !opp->Listen()) {
-      NS_WARNING("Failed to start listening for BluetoothOppManager!");
+      BT_WARNING("Failed to start listening for BluetoothOppManager!");
       return NS_ERROR_FAILURE;
     }
 
     BluetoothA2dpManager* a2dp = BluetoothA2dpManager::Get();
     NS_ENSURE_TRUE(a2dp, NS_ERROR_FAILURE);
     a2dp->ResetA2dp();
     a2dp->ResetAvrcp();
 
@@ -646,19 +620,19 @@ GetProperty(DBusMessageIter aIter, Prope
    */
   bool convert = false;
   if (propertyName.EqualsLiteral("Connected") &&
       receivedType == DBUS_TYPE_ARRAY) {
     convert = true;
   }
 
   if ((receivedType != expectedType) && !convert) {
-    NS_WARNING(nsPrintfCString("Iterator not type we expect! Property name: %s,
-      Property Type Expected: %d, Property Type Received: %d",
-      NS_ConvertUTF16toUTF8(propertyName).get(), expectedType, receivedType).get());
+    BT_WARNING("Iterator not type we expect! Property name: %s,"
+      "Property Type Expected: %d, Property Type Received: %d",
+      NS_ConvertUTF16toUTF8(propertyName).get(), expectedType, receivedType);
     return false;
   }
 
   BluetoothValue propertyValue;
   switch (receivedType) {
     case DBUS_TYPE_STRING:
     case DBUS_TYPE_OBJECT_PATH:
       const char* c;
@@ -737,17 +711,17 @@ ParseProperties(DBusMessageIter* aIter,
   do {
     MOZ_ASSERT(dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY,
                "Trying to parse a property from sth. that's not an dict!");
     dbus_message_iter_recurse(&dict, &dict_entry);
 
     if (!GetProperty(dict_entry, aPropertyTypes, aPropertyTypeLen, &prop_index,
                      props)) {
       aErrorStr.AssignLiteral("Can't Create Property!");
-      NS_WARNING("Can't create property!");
+      BT_WARNING("Can't create property!");
       return;
     }
   } while (dbus_message_iter_next(&dict));
 
   aValue = props;
 }
 
 static bool
@@ -797,23 +771,23 @@ ParsePropertyChange(DBusMessage* aMsg, B
 {
   DBusMessageIter iter;
   DBusError err;
   int prop_index = -1;
   InfallibleTArray<BluetoothNamedValue> props;
 
   dbus_error_init(&err);
   if (!dbus_message_iter_init(aMsg, &iter)) {
-    NS_WARNING("Can't create iterator!");
+    BT_WARNING("Can't create iterator!");
     return;
   }
 
   if (!GetProperty(iter, aPropertyTypes, aPropertyTypeLen,
                    &prop_index, props)) {
-    NS_WARNING("Can't get property!");
+    BT_WARNING("Can't get property!");
     aErrorStr.AssignLiteral("Can't get property!");
     return;
   }
   aValue = props;
 }
 
 class AppendDeviceNameReplyHandler: public DBusReplyHandler
 {
@@ -934,17 +908,17 @@ AgentEventFilter(DBusConnection *conn, D
     BT_WARNING("%s: agent handler not interested (not a method call).\n",
                __FUNCTION__);
     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
   }
 
   DBusError err;
   dbus_error_init(&err);
 
-  BT_LOG("%s: %s, %s", __FUNCTION__,
+  BT_LOGD("%s: %s, %s", __FUNCTION__,
                        dbus_message_get_path(msg),
                        dbus_message_get_member(msg));
 
   nsString signalPath = NS_ConvertUTF8toUTF16(dbus_message_get_path(msg));
   nsString signalName = NS_ConvertUTF8toUTF16(dbus_message_get_member(msg));
   nsString errorStr;
   BluetoothValue v;
   InfallibleTArray<BluetoothNamedValue> parameters;
@@ -986,17 +960,17 @@ AgentEventFilter(DBusConnection *conn, D
     NS_ConvertUTF8toUTF16 uuidStr(uuid);
     BluetoothServiceClass serviceClass =
       BluetoothUuidHelper::GetBluetoothServiceClass(uuidStr);
     if (serviceClass == BluetoothServiceClass::UNKNOWN) {
       errorStr.AssignLiteral("Failed to get service class");
       goto handle_error;
     }
 
-    DBusMessage* reply;
+    DBusMessage* reply = nullptr;
     int i;
     int length = sAuthorizedServiceClass.Length();
     for (i = 0; i < length; i++) {
       if (serviceClass == sAuthorizedServiceClass[i]) {
         reply = dbus_message_new_method_return(msg);
         break;
       }
     }
@@ -1194,17 +1168,17 @@ public:
 
     // TODO/qdot: This needs to be held for the life of the bluetooth connection
     // so we could clean it up. For right now though, we can throw it away.
     nsTArray<uint32_t> handles;
 
     ExtractHandles(aReply, handles);
 
     if(!RegisterAgent(&sAgentVTable)) {
-      NS_WARNING("Failed to register agent");
+      BT_WARNING("Failed to register agent");
     }
   }
 
 private:
   void ExtractHandles(DBusMessage *aMessage, nsTArray<uint32_t>& aOutHandles)
   {
     DBusError error;
     int length;
@@ -1375,17 +1349,17 @@ EventFilter(DBusConnection* aConn, DBusM
 
   DBusError err;
   dbus_error_init(&err);
 
   nsAutoString signalPath;
   nsAutoString signalName;
   nsAutoString signalInterface;
 
-  BT_LOG("%s: %s, %s, %s", __FUNCTION__,
+  BT_LOGD("%s: %s, %s, %s", __FUNCTION__,
                           dbus_message_get_interface(aMsg),
                           dbus_message_get_path(aMsg),
                           dbus_message_get_member(aMsg));
 
   signalInterface = NS_ConvertUTF8toUTF16(dbus_message_get_interface(aMsg));
   signalPath = NS_ConvertUTF8toUTF16(dbus_message_get_path(aMsg));
   signalName = NS_ConvertUTF8toUTF16(dbus_message_get_member(aMsg));
   nsString errorStr;
@@ -1401,17 +1375,17 @@ EventFilter(DBusConnection* aConn, DBusM
   } else if (signalInterface.EqualsLiteral(DBUS_DEVICE_IFACE)){
     signalPath = GetAddressFromObjectPath(signalPath);
   }
 
   if (dbus_message_is_signal(aMsg, DBUS_ADAPTER_IFACE, "DeviceFound")) {
     DBusMessageIter iter;
 
     if (!dbus_message_iter_init(aMsg, &iter)) {
-      NS_WARNING("Can't create iterator!");
+      BT_WARNING("Can't create iterator!");
       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
     }
 
     const char* addr;
     dbus_message_iter_get_basic(&iter, &addr);
 
     if (!dbus_message_iter_next(&iter)) {
       errorStr.AssignLiteral("Unexpected message struct in msg DeviceFound");
@@ -1578,17 +1552,17 @@ EventFilter(DBusConnection* aConn, DBusM
                         sInputProperties,
                         ArrayLength(sInputProperties));
   } else {
     errorStr = NS_ConvertUTF8toUTF16(dbus_message_get_member(aMsg));
     errorStr.AppendLiteral(" Signal not handled!");
   }
 
   if (!errorStr.IsEmpty()) {
-    NS_WARNING(NS_ConvertUTF16toUTF8(errorStr).get());
+    BT_WARNING(NS_ConvertUTF16toUTF8(errorStr).get());
     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
   }
 
   BluetoothSignal signal(signalName, signalPath, v);
   nsRefPtr<nsRunnable> task;
   if (signalInterface.EqualsLiteral(DBUS_SINK_IFACE)) {
     task = new SinkPropertyChangedHandler(signal);
   } else if (signalInterface.EqualsLiteral(DBUS_CTL_IFACE)) {
@@ -1628,47 +1602,47 @@ GetDefaultAdapterPath(BluetoothValue& aV
 
   return aError.IsEmpty();
 }
 
 bool
 BluetoothDBusService::IsReady()
 {
   if (!IsEnabled() || !mConnection || !gThreadConnection || IsToggling()) {
-    NS_WARNING("Bluetooth service is not ready yet!");
+    BT_WARNING("Bluetooth service is not ready yet!");
     return false;
   }
   return true;
 }
 
 nsresult
 BluetoothDBusService::StartInternal()
 {
   // This could block. It should never be run on the main thread.
   MOZ_ASSERT(!NS_IsMainThread());
 
   if (!StartDBus()) {
-    NS_WARNING("Cannot start DBus thread!");
+    BT_WARNING("Cannot start DBus thread!");
     return NS_ERROR_FAILURE;
   }
 
   if (mConnection) {
     return NS_OK;
   }
 
   if (NS_FAILED(EstablishDBusConnection())) {
-    NS_WARNING("Cannot start Main Thread DBus connection!");
+    BT_WARNING("Cannot start Main Thread DBus connection!");
     StopDBus();
     return NS_ERROR_FAILURE;
   }
 
   gThreadConnection = new RawDBusConnection();
 
   if (NS_FAILED(gThreadConnection->EstablishDBusConnection())) {
-    NS_WARNING("Cannot start Sync Thread DBus connection!");
+    BT_WARNING("Cannot start Sync Thread DBus connection!");
     StopDBus();
     return NS_ERROR_FAILURE;
   }
 
   DBusError err;
   dbus_error_init(&err);
 
   // Set which messages will be processed by this dbus connection.
@@ -1682,34 +1656,34 @@ BluetoothDBusService::StartInternal()
     if (dbus_error_is_set(&err)) {
       LOG_AND_FREE_DBUS_ERROR(&err);
     }
   }
 
   // Add a filter for all incoming messages_base
   if (!dbus_connection_add_filter(mConnection, EventFilter,
                                   NULL, NULL)) {
-    NS_WARNING("Cannot create DBus Event Filter for DBus Thread!");
+    BT_WARNING("Cannot create DBus Event Filter for DBus Thread!");
     return NS_ERROR_FAILURE;
   }
 
   if (!sPairingReqTable) {
     sPairingReqTable = new nsDataHashtable<nsStringHashKey, DBusMessage* >;
   }
 
   BluetoothValue v;
   nsAutoString replyError;
   if (!GetDefaultAdapterPath(v, replyError)) {
     // Adapter path is not ready yet
     // Let's do PrepareAdapterRunnable when we receive signal 'AdapterAdded'
   } else {
     // Adapter path has been ready. let's do PrepareAdapterRunnable now
     nsRefPtr<PrepareAdapterRunnable> b = new PrepareAdapterRunnable(v.get_nsString());
     if (NS_FAILED(NS_DispatchToMainThread(b))) {
-      NS_WARNING("Failed to dispatch to main thread!");
+      BT_WARNING("Failed to dispatch to main thread!");
     }
   }
 
   return NS_OK;
 }
 
 PLDHashOperator
 UnrefDBusMessages(const nsAString& key, DBusMessage* value, void* arg)
@@ -2271,25 +2245,25 @@ BluetoothDBusService::SetProperty(Blueto
   /* Compose the command */
   DBusMessage* msg = dbus_message_new_method_call(
                                       "org.bluez",
                                       NS_ConvertUTF16toUTF8(sAdapterPath).get(),
                                       interface,
                                       "SetProperty");
 
   if (!msg) {
-    NS_WARNING("Could not allocate D-Bus message object!");
+    BT_WARNING("Could not allocate D-Bus message object!");
     return NS_ERROR_FAILURE;
   }
 
   nsCString intermediatePropName(NS_ConvertUTF16toUTF8(aValue.name()));
   const char* propName = intermediatePropName.get();
   if (!dbus_message_append_args(msg, DBUS_TYPE_STRING, &propName,
                                 DBUS_TYPE_INVALID)) {
-    NS_WARNING("Couldn't append arguments to dbus message!");
+    BT_WARNING("Couldn't append arguments to dbus message!");
     return NS_ERROR_FAILURE;
   }
 
   int type;
   int tmp_int;
   void* val;
   nsCString str;
   if (aValue.value().type() == BluetoothValue::Tuint32_t) {
@@ -2301,42 +2275,42 @@ BluetoothDBusService::SetProperty(Blueto
     const char* tempStr = str.get();
     val = &tempStr;
     type = DBUS_TYPE_STRING;
   } else if (aValue.value().type() == BluetoothValue::Tbool) {
     tmp_int = aValue.value().get_bool() ? 1 : 0;
     val = &(tmp_int);
     type = DBUS_TYPE_BOOLEAN;
   } else {
-    NS_WARNING("Property type not handled!");
+    BT_WARNING("Property type not handled!");
     dbus_message_unref(msg);
     return NS_ERROR_FAILURE;
   }
 
   DBusMessageIter value_iter, iter;
   dbus_message_iter_init_append(msg, &iter);
   char var_type[2] = {(char)type, '\0'};
   if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
                                         var_type, &value_iter) ||
       !dbus_message_iter_append_basic(&value_iter, type, val) ||
       !dbus_message_iter_close_container(&iter, &value_iter)) {
-    NS_WARNING("Could not append argument to method call!");
+    BT_WARNING("Could not append argument to method call!");
     dbus_message_unref(msg);
     return NS_ERROR_FAILURE;
   }
 
   nsRefPtr<BluetoothReplyRunnable> runnable = aRunnable;
 
   // msg is unref'd as part of dbus_func_send_async
   if (!dbus_func_send_async(mConnection,
                             msg,
                             1000,
                             GetVoidCallback,
                             (void*)aRunnable)) {
-    NS_WARNING("Could not start async function!");
+    BT_WARNING("Could not start async function!");
     return NS_ERROR_FAILURE;
   }
   runnable.forget();
   return NS_OK;
 }
 
 bool
 BluetoothDBusService::GetDevicePath(const nsAString& aAdapterPath,
@@ -2408,17 +2382,17 @@ BluetoothDBusService::CreatePairedDevice
                                   NS_ConvertUTF16toUTF8(sAdapterPath).get(),
                                   DBUS_ADAPTER_IFACE,
                                   "CreatePairedDevice",
                                   DBUS_TYPE_STRING, &deviceAddress,
                                   DBUS_TYPE_OBJECT_PATH, &deviceAgentPath,
                                   DBUS_TYPE_STRING, &capabilities,
                                   DBUS_TYPE_INVALID);
   if (!ret) {
-    NS_WARNING("Could not start async function!");
+    BT_WARNING("Could not start async function!");
     return NS_ERROR_FAILURE;
   }
 
   runnable.forget();
   return NS_OK;
 }
 
 static void
@@ -2672,17 +2646,17 @@ BluetoothDBusService::Disconnect(const n
 bool
 BluetoothDBusService::IsConnected(const uint16_t aServiceUuid)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   BluetoothProfileManagerBase* profile =
     BluetoothUuidHelper::GetBluetoothProfileManager(aServiceUuid);
   if (!profile) {
-    NS_WARNING(ERR_UNKNOWN_PROFILE);
+    BT_WARNING(ERR_UNKNOWN_PROFILE);
     return false;
   }
 
   NS_ENSURE_TRUE(profile, false);
   return profile->IsConnected();
 }
 
 class OnUpdateSdpRecordsRunnable : public nsRunnable
--- a/dom/bluetooth/linux/BluetoothDBusService.h
+++ b/dom/bluetooth/linux/BluetoothDBusService.h
@@ -1,16 +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/. */
 
-#ifndef mozilla_dom_bluetooth_bluetoothdbuseventservice_h__
-#define mozilla_dom_bluetooth_bluetoothdbuseventservice_h__
+#ifndef mozilla_dom_bluetooth_bluetoothdbusservice_h__
+#define mozilla_dom_bluetooth_bluetoothdbusservice_h__
 
 #include "mozilla/Attributes.h"
 #include "BluetoothCommon.h"
 #include "mozilla/ipc/RawDBusConnection.h"
 #include "BluetoothService.h"
 
 class DBusMessage;