Bug 950891 - Don't run GetServiceChannel while turning Bluetooth on/off. r=echou, a=1.3+
authorThomas Zimmermann <tdz@users.sourceforge.net>
Tue, 07 Jan 2014 13:46:20 +0100
changeset 175655 f189cc1d8863f1ee3cf5441a88d7ff96c888c4a5
parent 175654 d75ee062cb7b1be9bce1f3af65563adfcd73c67a
child 175656 3e186f49cbb6cb790d60d85cc9737f94d3602278
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechou, 1
bugs950891
milestone28.0a2
Bug 950891 - Don't run GetServiceChannel while turning Bluetooth on/off. r=echou, a=1.3+ This patch adds a check to BluetoothDBusService::GetServiceChannel to ensure that Bluetooth is ready. If the system is in a transition from on to off, or vice versa, the method might operate on an undefined state.
dom/bluetooth/bluez/linux/BluetoothDBusService.cpp
--- a/dom/bluetooth/bluez/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/bluez/linux/BluetoothDBusService.cpp
@@ -2896,20 +2896,23 @@ private:
 };
 
 nsresult
 BluetoothDBusService::GetServiceChannel(const nsAString& aDeviceAddress,
                                         const nsAString& aServiceUUID,
                                         BluetoothProfileManagerBase* aManager)
 {
   MOZ_ASSERT(NS_IsMainThread());
+  if (!IsReady()) {
+    NS_NAMED_LITERAL_STRING(errorStr, "Bluetooth service is not ready yet!");
+    return NS_OK;
+  }
 
   MOZ_ASSERT(!sAdapterPath.IsEmpty());
   nsString objectPath(GetObjectPathFromAddress(sAdapterPath, aDeviceAddress));
-
 #ifdef MOZ_WIDGET_GONK
   static const int sProtocolDescriptorList = 0x0004;
 
   // GetServiceAttributeValue only exists in android's bluez dbus binding
   // implementation
   nsCString serviceUUID = NS_ConvertUTF16toUTF8(aServiceUUID);
   const char* cstrServiceUUID = serviceUUID.get();