From f7f48d9e946e5e343e45306766226c4585213fd4 Mon Sep 17 00:00:00 2001 From: Bruce Sun Date: Wed, 23 Sep 2015 13:44:02 +0800 Subject: [PATCH] Backed out changeset 784aae3f40bf (bug 1181479) --- dom/bluetooth/bluedroid/BluetoothGattManager.cpp | 6 +++--- dom/bluetooth/common/BluetoothUtils.cpp | 11 ++++++++--- dom/bluetooth/common/BluetoothUtils.h | 9 +++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/dom/bluetooth/bluedroid/BluetoothGattManager.cpp b/dom/bluetooth/bluedroid/BluetoothGattManager.cpp index d955573f629..29b7356353e 100644 --- a/dom/bluetooth/bluedroid/BluetoothGattManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothGattManager.cpp @@ -634,7 +634,7 @@ BluetoothGattManager::StartLeScan(const nsTArray& aServiceUuids, client->mStartLeScanRunnable = aRunnable; BluetoothUuid appUuid; - StringToUuid(appUuidStr, appUuid); + StringToUuid(NS_ConvertUTF16toUTF8(appUuidStr).get(), appUuid); // 'startLeScan' will be proceeded after client registered sBluetoothGattInterface->RegisterClient( @@ -726,7 +726,7 @@ BluetoothGattManager::Connect(const nsAString& aAppUuid, new ConnectResultHandler(client)); } else { BluetoothUuid uuid; - StringToUuid(aAppUuid, uuid); + StringToUuid(NS_ConvertUTF16toUTF8(aAppUuid).get(), uuid); // connect will be proceeded after client registered sBluetoothGattInterface->RegisterClient( @@ -1507,7 +1507,7 @@ BluetoothGattManager::ConnectPeripheral( new ConnectPeripheralResultHandler(server, aAddress)); } else { BluetoothUuid uuid; - StringToUuid(aAppUuid, uuid); + StringToUuid(NS_ConvertUTF16toUTF8(aAppUuid).get(), uuid); // connect will be proceeded after server registered sBluetoothGattInterface->RegisterServer( diff --git a/dom/bluetooth/common/BluetoothUtils.cpp b/dom/bluetooth/common/BluetoothUtils.cpp index d0eef49ddb6..a811b0c690d 100644 --- a/dom/bluetooth/common/BluetoothUtils.cpp +++ b/dom/bluetooth/common/BluetoothUtils.cpp @@ -43,13 +43,12 @@ UuidToString(const BluetoothUuid& aUuid, nsAString& aString) } void -StringToUuid(const nsAString& aString, BluetoothUuid& aUuid) +StringToUuid(const char* aString, BluetoothUuid& aUuid) { uint32_t uuid0, uuid4; uint16_t uuid1, uuid2, uuid3, uuid5; - sscanf(NS_ConvertUTF16toUTF8(aString).get(), - "%08x-%04hx-%04hx-%04hx-%08x%04hx", + sscanf(aString, "%08x-%04hx-%04hx-%04hx-%08x%04hx", &uuid0, &uuid1, &uuid2, &uuid3, &uuid4, &uuid5); uuid0 = htonl(uuid0); @@ -67,6 +66,12 @@ StringToUuid(const nsAString& aString, BluetoothUuid& aUuid) memcpy(&aUuid.mUuid[14], &uuid5, sizeof(uint16_t)); } +void +StringToUuid(const nsAString& aString, BluetoothUuid& aUuid) +{ + StringToUuid(NS_ConvertUTF16toUTF8(aString).get(), aUuid); +} + void GenerateUuid(nsAString &aUuidString) { diff --git a/dom/bluetooth/common/BluetoothUtils.h b/dom/bluetooth/common/BluetoothUtils.h index 0e0aec5401f..923f9b05f74 100644 --- a/dom/bluetooth/common/BluetoothUtils.h +++ b/dom/bluetooth/common/BluetoothUtils.h @@ -36,6 +36,15 @@ UuidToString(const BluetoothUuid& aUuid, nsAString& aString); * string created by gecko back to BluetoothUuid representation. */ void +StringToUuid(const char* aString, BluetoothUuid& aUuid); + +/** + * Convert xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx uuid string to BluetoothUuid object. + * + * This utility function is used by gecko internal only to convert uuid string + * created by gecko back to BluetoothUuid representation. + */ +void StringToUuid(const nsAString& aString, BluetoothUuid& aUuid); /**