Backed out changeset 784aae3f40bf (bug 1181479)

This commit is contained in:
Bruce Sun 2015-09-23 13:44:02 +08:00
parent 375562aa34
commit d7e024851c
3 changed files with 20 additions and 6 deletions

View File

@ -634,7 +634,7 @@ BluetoothGattManager::StartLeScan(const nsTArray<nsString>& 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(

View File

@ -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)
{

View File

@ -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);
/**