mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge b2g-inbound to m-c.
This commit is contained in:
commit
65cbb0e81b
@ -19,13 +19,13 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="8341cddb04773957069ac1334692a888b8bb1091"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="8e4420c0c5c8e8c8e58a000278a7129403769f96"/>
|
||||
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="9100fa82fc355f5201e23e400fc6b40e875304ed"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="600ef6ddc915ceffc1a89d51b7be8453fe709992"/>
|
||||
<!-- Stock Android things -->
|
||||
<project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
|
||||
<project name="platform/bionic" path="bionic" revision="c72b8f6359de7ed17c11ddc9dfdde3f615d188a9"/>
|
||||
|
@ -17,10 +17,10 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="8341cddb04773957069ac1334692a888b8bb1091"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="600ef6ddc915ceffc1a89d51b7be8453fe709992"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
|
||||
<!-- Stock Android things -->
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="276ce45e78b09c4a4ee643646f691d22804754c1">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="8341cddb04773957069ac1334692a888b8bb1091"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
|
||||
<project name="librecovery" patch="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
@ -23,7 +23,7 @@
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="600ef6ddc915ceffc1a89d51b7be8453fe709992"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="f92a936f2aa97526d4593386754bdbf02db07a12"/>
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="6e47ff2790f5656b5b074407829ceecf3e6188c4"/>
|
||||
|
@ -19,13 +19,13 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="8341cddb04773957069ac1334692a888b8bb1091"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="8e4420c0c5c8e8c8e58a000278a7129403769f96"/>
|
||||
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="9100fa82fc355f5201e23e400fc6b40e875304ed"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="600ef6ddc915ceffc1a89d51b7be8453fe709992"/>
|
||||
<!-- Stock Android things -->
|
||||
<project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
|
||||
<project name="platform/bionic" path="bionic" revision="c72b8f6359de7ed17c11ddc9dfdde3f615d188a9"/>
|
||||
|
@ -17,10 +17,10 @@
|
||||
</project>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="8341cddb04773957069ac1334692a888b8bb1091"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="600ef6ddc915ceffc1a89d51b7be8453fe709992"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
|
||||
<!-- Stock Android things -->
|
||||
@ -118,7 +118,7 @@
|
||||
<!-- Flame specific things -->
|
||||
<project name="device/generic/armv7-a-neon" path="device/generic/armv7-a-neon" revision="e8a318f7690092e639ba88891606f4183e846d3f"/>
|
||||
<project name="device/qcom/common" path="device/qcom/common" revision="34ed8345250bb97262d70a052217a92e83444ede"/>
|
||||
<project name="device-flame" path="device/t2m/flame" remote="b2g" revision="76f960b9512ec5c4726b5f52dd94bdf3c07e5071"/>
|
||||
<project name="device-flame" path="device/t2m/flame" remote="b2g" revision="75c65fce94693c9b990a7b1dab751bd2a536559b"/>
|
||||
<project name="kernel/msm" path="kernel" revision="228d59147ff524e90774c566eef03260cc6857b8"/>
|
||||
<project name="platform/bootable/recovery" path="bootable/recovery" revision="f2914eacee9120680a41463708bb6ee8291749fc"/>
|
||||
<project name="platform/external/bluetooth/bluedroid" path="external/bluetooth/bluedroid" revision="81c4a859d75d413ad688067829d21b7ba9205f81"/>
|
||||
|
@ -4,6 +4,6 @@
|
||||
"remote": "",
|
||||
"branch": ""
|
||||
},
|
||||
"revision": "01ae06e7d0c3c72d51e6801986339d6c06229c9b",
|
||||
"revision": "e204b914c3ddada45ae5ff5c9fc5e8f55f906ca7",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
@ -17,12 +17,12 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="8341cddb04773957069ac1334692a888b8bb1091"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="600ef6ddc915ceffc1a89d51b7be8453fe709992"/>
|
||||
<!-- Stock Android things -->
|
||||
<project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
|
||||
<project name="platform/bionic" path="bionic" revision="d2eb6c7b6e1bc7643c17df2d9d9bcb1704d0b9ab"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="8341cddb04773957069ac1334692a888b8bb1091"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -17,10 +17,10 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="8341cddb04773957069ac1334692a888b8bb1091"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="600ef6ddc915ceffc1a89d51b7be8453fe709992"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
|
||||
<!-- Stock Android things -->
|
||||
|
@ -17,12 +17,12 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="8341cddb04773957069ac1334692a888b8bb1091"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="600ef6ddc915ceffc1a89d51b7be8453fe709992"/>
|
||||
<project name="gonk-patches" path="patches" remote="b2g" revision="223a2421006e8f5da33f516f6891c87cae86b0f6"/>
|
||||
<!-- Stock Android things -->
|
||||
<project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
|
||||
|
@ -66,3 +66,6 @@ MOZ_JSDOWNLOADS=1
|
||||
MOZ_SERVICES_FXACCOUNTS=1
|
||||
|
||||
MOZ_BUNDLED_FONTS=1
|
||||
|
||||
# Enable exact rooting on b2g.
|
||||
JSGC_USE_EXACT_ROOTING=1
|
||||
|
@ -652,6 +652,7 @@ GK_ATOM(ona2dpstatuschanged, "ona2dpstatuschanged")
|
||||
GK_ATOM(onabort, "onabort")
|
||||
GK_ATOM(onactivate, "onactivate")
|
||||
GK_ATOM(onadapteradded, "onadapteradded")
|
||||
GK_ATOM(onadapterremoved, "onadapterremoved")
|
||||
GK_ATOM(onafterprint, "onafterprint")
|
||||
GK_ATOM(onafterscriptexecute, "onafterscriptexecute")
|
||||
GK_ATOM(onalerting, "onalerting")
|
||||
|
@ -3198,7 +3198,7 @@ nsDOMWindowUtils::GetPlugins(JSContext* cx, JS::MutableHandle<JS::Value> aPlugin
|
||||
doc->GetPlugins(plugins);
|
||||
|
||||
JS::Rooted<JSObject*> jsPlugins(cx);
|
||||
nsresult rv = nsTArrayToJSArray(cx, plugins, jsPlugins.address());
|
||||
nsresult rv = nsTArrayToJSArray(cx, plugins, &jsPlugins);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aPlugins.setObject(*jsPlugins);
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
}
|
||||
|
||||
AutoPushJSContext cx(sc->GetNativeContext());
|
||||
JSObject* JsDevices = nullptr;
|
||||
JS::Rooted<JSObject*> JsDevices(cx);
|
||||
rv = nsTArrayToJSArray(cx, devices, &JsDevices);
|
||||
if (!JsDevices) {
|
||||
BT_WARNING("Cannot create JS array!");
|
||||
@ -260,7 +260,7 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue)
|
||||
|
||||
AutoPushJSContext cx(sc->GetNativeContext());
|
||||
JS::Rooted<JSObject*> uuids(cx);
|
||||
if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, uuids.address()))) {
|
||||
if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, &uuids))) {
|
||||
BT_WARNING("Cannot set JS UUIDs object!");
|
||||
return;
|
||||
}
|
||||
@ -276,8 +276,7 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue)
|
||||
|
||||
AutoPushJSContext cx(sc->GetNativeContext());
|
||||
JS::Rooted<JSObject*> deviceAddresses(cx);
|
||||
if (NS_FAILED(nsTArrayToJSArray(cx, mDeviceAddresses,
|
||||
deviceAddresses.address()))) {
|
||||
if (NS_FAILED(nsTArrayToJSArray(cx, mDeviceAddresses, &deviceAddresses))) {
|
||||
BT_WARNING("Cannot set JS Devices object!");
|
||||
return;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue)
|
||||
AutoPushJSContext cx(sc->GetNativeContext());
|
||||
|
||||
JS::Rooted<JSObject*> uuids(cx);
|
||||
if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, uuids.address()))) {
|
||||
if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, &uuids))) {
|
||||
BT_WARNING("Cannot set JS UUIDs object!");
|
||||
return;
|
||||
}
|
||||
@ -153,7 +153,7 @@ BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue)
|
||||
AutoPushJSContext cx(sc->GetNativeContext());
|
||||
|
||||
JS::Rooted<JSObject*> services(cx);
|
||||
if (NS_FAILED(nsTArrayToJSArray(cx, mServices, services.address()))) {
|
||||
if (NS_FAILED(nsTArrayToJSArray(cx, mServices, &services))) {
|
||||
BT_WARNING("Cannot set JS Services object!");
|
||||
return;
|
||||
}
|
||||
|
@ -57,6 +57,12 @@ extern bool gBluetoothDebugFlag;
|
||||
#define BT_WARNING(msg, ...) printf("%s: " msg, __FUNCTION__, ##__VA_ARGS__))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Prints 'R'ELEASE build logs for WebBluetooth API v2.
|
||||
*/
|
||||
#define BT_API2_LOGR(msg, ...) \
|
||||
BT_LOGR("[WEBBT-API2] " msg, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Wrap literal name and value into a BluetoothNamedValue
|
||||
* and append it to the array.
|
||||
|
@ -11,14 +11,13 @@
|
||||
#include "BluetoothService.h"
|
||||
#include "BluetoothReplyRunnable.h"
|
||||
|
||||
#include "DOMRequest.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
|
||||
#include "mozilla/dom/BluetoothManager2Binding.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
|
||||
#include "mozilla/dom/BluetoothManager2Binding.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -31,61 +30,49 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
NS_IMPL_ADDREF_INHERITED(BluetoothManager, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(BluetoothManager, DOMEventTargetHelper)
|
||||
|
||||
class GetAdapterTask : public BluetoothReplyRunnable
|
||||
class GetAdaptersTask : public BluetoothReplyRunnable
|
||||
{
|
||||
public:
|
||||
GetAdapterTask(BluetoothManager* aManager,
|
||||
nsIDOMDOMRequest* aReq) :
|
||||
BluetoothReplyRunnable(aReq),
|
||||
mManagerPtr(aManager)
|
||||
{
|
||||
}
|
||||
public:
|
||||
GetAdaptersTask(BluetoothManager* aManager)
|
||||
: BluetoothReplyRunnable(nullptr)
|
||||
, mManager(aManager)
|
||||
{ }
|
||||
|
||||
bool
|
||||
ParseSuccessfulReply(JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
/**
|
||||
* Unwrap BluetoothReply.BluetoothReplySuccess.BluetoothValue =
|
||||
* BluetoothNamedValue[]
|
||||
* |
|
||||
* |__ BluetoothNamedValue =
|
||||
* | {"Adapter", BluetoothValue = BluetoothNamedValue[]}
|
||||
* |
|
||||
* |__ BluetoothNamedValue =
|
||||
* | {"Adapter", BluetoothValue = BluetoothNamedValue[]}
|
||||
* ...
|
||||
*/
|
||||
|
||||
// Extract the array of all adapters' properties
|
||||
const BluetoothValue& adaptersProperties =
|
||||
mReply->get_BluetoothReplySuccess().value();
|
||||
NS_ENSURE_TRUE(adaptersProperties.type() ==
|
||||
BluetoothValue::TArrayOfBluetoothNamedValue, false);
|
||||
|
||||
const InfallibleTArray<BluetoothNamedValue>& adaptersPropertiesArray =
|
||||
adaptersProperties.get_ArrayOfBluetoothNamedValue();
|
||||
BT_API2_LOGR("GetAdaptersTask: len[%d]", adaptersPropertiesArray.Length());
|
||||
|
||||
// Append a BluetoothAdapter into adapters array for each properties array
|
||||
uint32_t numAdapters = adaptersPropertiesArray.Length();
|
||||
for (uint32_t i = 0; i < numAdapters; i++) {
|
||||
MOZ_ASSERT(adaptersPropertiesArray[i].name().EqualsLiteral("Adapter"));
|
||||
|
||||
const BluetoothValue& properties = adaptersPropertiesArray[i].value();
|
||||
mManager->AppendAdapter(properties);
|
||||
}
|
||||
|
||||
aValue.setUndefined();
|
||||
|
||||
const BluetoothValue& v = mReply->get_BluetoothReplySuccess().value();
|
||||
if (v.type() != BluetoothValue::TArrayOfBluetoothNamedValue) {
|
||||
BT_WARNING("Not a BluetoothNamedValue array!");
|
||||
SetError(NS_LITERAL_STRING("BluetoothReplyTypeError"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mManagerPtr->GetOwner()) {
|
||||
BT_WARNING("Bluetooth manager was disconnected from owner window.");
|
||||
|
||||
// Stop to create adapter since owner window of Bluetooth manager was
|
||||
// gone. These is no need to create a DOMEvent target which has no owner
|
||||
// to reply to.
|
||||
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) {
|
||||
BT_WARNING("Cannot create script context!");
|
||||
SetError(NS_LITERAL_STRING("BluetoothScriptContextError"));
|
||||
return false;
|
||||
}
|
||||
|
||||
AutoPushJSContext cx(sc->GetNativeContext());
|
||||
|
||||
JS::Rooted<JSObject*> scope(cx, sc->GetWindowProxy());
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
rv = nsContentUtils::WrapNative(cx, adapter, aValue);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("Cannot create native object!");
|
||||
SetError(NS_LITERAL_STRING("BluetoothNativeObjectError"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -93,94 +80,88 @@ public:
|
||||
ReleaseMembers()
|
||||
{
|
||||
BluetoothReplyRunnable::ReleaseMembers();
|
||||
mManagerPtr = nullptr;
|
||||
mManager = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<BluetoothManager> mManagerPtr;
|
||||
nsRefPtr<BluetoothManager> mManager;
|
||||
};
|
||||
|
||||
BluetoothManager::BluetoothManager(nsPIDOMWindow *aWindow)
|
||||
: DOMEventTargetHelper(aWindow)
|
||||
, BluetoothPropertyContainer(BluetoothObjectType::TYPE_MANAGER)
|
||||
, mDefaultAdapterIndex(-1)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(IsDOMBinding());
|
||||
|
||||
mPath.Assign('/');
|
||||
ListenToBluetoothSignal(true);
|
||||
BT_API2_LOGR("aWindow %p", aWindow);
|
||||
|
||||
// Query adapters list from bluetooth backend
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
bs->RegisterBluetoothSignalHandler(NS_LITERAL_STRING(KEY_MANAGER), this);
|
||||
|
||||
nsRefPtr<BluetoothReplyRunnable> result = new GetAdaptersTask(this);
|
||||
NS_ENSURE_SUCCESS_VOID(bs->GetAdaptersInternal(result));
|
||||
}
|
||||
|
||||
BluetoothManager::~BluetoothManager()
|
||||
{
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
bs->UnregisterBluetoothSignalHandler(NS_LITERAL_STRING(KEY_MANAGER), this);
|
||||
ListenToBluetoothSignal(false);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothManager::DisconnectFromOwner()
|
||||
{
|
||||
DOMEventTargetHelper::DisconnectFromOwner();
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
bs->UnregisterBluetoothSignalHandler(NS_LITERAL_STRING(KEY_MANAGER), this);
|
||||
ListenToBluetoothSignal(false);
|
||||
}
|
||||
|
||||
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));
|
||||
BT_WARNING(warningMsg.get());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothManager::GetEnabled(ErrorResult& aRv)
|
||||
BluetoothManager::ListenToBluetoothSignal(bool aStart)
|
||||
{
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
if (!bs) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
return bs->IsEnabled();
|
||||
if (aStart) {
|
||||
bs->RegisterBluetoothSignalHandler(NS_LITERAL_STRING(KEY_MANAGER), this);
|
||||
} else {
|
||||
bs->UnregisterBluetoothSignalHandler(NS_LITERAL_STRING(KEY_MANAGER), this);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<dom::DOMRequest>
|
||||
BluetoothManager::GetDefaultAdapter(ErrorResult& aRv)
|
||||
BluetoothAdapter*
|
||||
BluetoothManager::GetDefaultAdapter()
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetOwner();
|
||||
if (!win) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
BT_API2_LOGR("mDefaultAdapterIndex: %d", mDefaultAdapterIndex);
|
||||
|
||||
return DefaultAdapterExists() ? mAdapters[mDefaultAdapterIndex] : nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothManager::AppendAdapter(const BluetoothValue& aValue)
|
||||
{
|
||||
MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
|
||||
|
||||
// Create a new BluetoothAdapter and append it to adapters array
|
||||
const InfallibleTArray<BluetoothNamedValue>& values =
|
||||
aValue.get_ArrayOfBluetoothNamedValue();
|
||||
nsRefPtr<BluetoothAdapter> adapter =
|
||||
BluetoothAdapter::Create(GetOwner(), values);
|
||||
|
||||
mAdapters.AppendElement(adapter);
|
||||
|
||||
// Set this adapter as default adapter if no adapter exists
|
||||
if (!DefaultAdapterExists()) {
|
||||
MOZ_ASSERT(mAdapters.Length() == 1);
|
||||
ReselectDefaultAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
nsRefPtr<DOMRequest> request = new DOMRequest(win);
|
||||
nsRefPtr<BluetoothReplyRunnable> results =
|
||||
new GetAdapterTask(this, request);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
if (!bs) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsresult rv = bs->GetDefaultAdapterPathInternal(results);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return request.forget();
|
||||
void
|
||||
BluetoothManager::GetAdapters(nsTArray<nsRefPtr<BluetoothAdapter> >& aAdapters)
|
||||
{
|
||||
aAdapters = mAdapters;
|
||||
}
|
||||
|
||||
// static
|
||||
@ -195,36 +176,122 @@ BluetoothManager::Create(nsPIDOMWindow* aWindow)
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothManager::Notify(const BluetoothSignal& aData)
|
||||
BluetoothManager::HandleAdapterAdded(const BluetoothValue& aValue)
|
||||
{
|
||||
BT_LOGD("[M] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
|
||||
MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
|
||||
BT_API2_LOGR();
|
||||
|
||||
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()));
|
||||
BT_WARNING(warningMsg.get());
|
||||
#endif
|
||||
}
|
||||
AppendAdapter(aValue);
|
||||
|
||||
// Notify application of added adapter
|
||||
BluetoothAdapterEventInit init;
|
||||
init.mAdapter = mAdapters.LastElement();
|
||||
DispatchAdapterEvent(NS_LITERAL_STRING("adapteradded"), init);
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothManager::IsConnected(uint16_t aProfileId, ErrorResult& aRv)
|
||||
void
|
||||
BluetoothManager::HandleAdapterRemoved(const BluetoothValue& aValue)
|
||||
{
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
if (!bs) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
MOZ_ASSERT(aValue.type() == BluetoothValue::TnsString);
|
||||
MOZ_ASSERT(DefaultAdapterExists());
|
||||
|
||||
// Remove the adapter of given address from adapters array
|
||||
nsString addressToRemove = aValue.get_nsString();
|
||||
|
||||
uint32_t numAdapters = mAdapters.Length();
|
||||
for (uint32_t i = 0; i < numAdapters; i++) {
|
||||
nsString address;
|
||||
mAdapters[i]->GetAddress(address);
|
||||
if (address.Equals(addressToRemove)) {
|
||||
mAdapters.RemoveElementAt(i);
|
||||
|
||||
if (mDefaultAdapterIndex == (int)i) {
|
||||
ReselectDefaultAdapter();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bs->IsConnected(aProfileId);
|
||||
// Notify application of removed adapter
|
||||
BluetoothAdapterEventInit init;
|
||||
init.mAddress = addressToRemove;
|
||||
DispatchAdapterEvent(NS_LITERAL_STRING("adapterremoved"), init);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothManager::ReselectDefaultAdapter()
|
||||
{
|
||||
// Select the first of existing/remaining adapters as default adapter
|
||||
mDefaultAdapterIndex = mAdapters.IsEmpty() ? -1 : 0;
|
||||
BT_API2_LOGR("mAdapters length: %d => NEW mDefaultAdapterIndex: %d",
|
||||
mAdapters.Length(), mDefaultAdapterIndex);
|
||||
|
||||
// Notify application of default adapter change
|
||||
DispatchAttributeEvent();
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothManager::DispatchAdapterEvent(const nsAString& aType,
|
||||
const BluetoothAdapterEventInit& aInit)
|
||||
{
|
||||
BT_API2_LOGR("aType (%s)", NS_ConvertUTF16toUTF8(aType).get());
|
||||
|
||||
nsRefPtr<BluetoothAdapterEvent> event =
|
||||
BluetoothAdapterEvent::Constructor(this, aType, aInit);
|
||||
DispatchTrustedEvent(event);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothManager::DispatchAttributeEvent()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
BT_API2_LOGR();
|
||||
|
||||
// Wrap default adapter
|
||||
AutoJSContext cx;
|
||||
JS::Rooted<JS::Value> value(cx, JS::NullValue());
|
||||
if (DefaultAdapterExists()) {
|
||||
BluetoothAdapter* adapter = mAdapters[mDefaultAdapterIndex];
|
||||
nsCOMPtr<nsIGlobalObject> global =
|
||||
do_QueryInterface(adapter->GetParentObject());
|
||||
NS_ENSURE_TRUE_VOID(global);
|
||||
|
||||
JS::Rooted<JSObject*> scope(cx, global->GetGlobalJSObject());
|
||||
NS_ENSURE_TRUE_VOID(scope);
|
||||
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
if (!ToJSValue(cx, adapter, &value)) {
|
||||
JS_ClearPendingException(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_API2_LOGR("Default adapter is wrapped");
|
||||
}
|
||||
|
||||
// Notify application of default adapter change
|
||||
RootedDictionary<BluetoothAttributeEventInit> init(cx);
|
||||
init.mAttr = (uint16_t)BluetoothManagerAttribute::DefaultAdapter;
|
||||
init.mValue = value;
|
||||
nsRefPtr<BluetoothAttributeEvent> event =
|
||||
BluetoothAttributeEvent::Constructor(this,
|
||||
NS_LITERAL_STRING("attributechanged"),
|
||||
init);
|
||||
DispatchTrustedEvent(event);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothManager::Notify(const BluetoothSignal& aData)
|
||||
{
|
||||
BT_LOGD("[M] %s", NS_ConvertUTF16toUTF8(aData.name()).get());
|
||||
|
||||
if (aData.name().EqualsLiteral("AdapterAdded")) {
|
||||
HandleAdapterAdded(aData.value());
|
||||
} else if (aData.name().EqualsLiteral("AdapterRemoved")) {
|
||||
HandleAdapterRemoved(aData.value());
|
||||
} else {
|
||||
BT_WARNING("Not handling manager signal: %s",
|
||||
NS_ConvertUTF16toUTF8(aData.name()).get());
|
||||
}
|
||||
}
|
||||
|
||||
JSObject*
|
||||
|
@ -7,59 +7,130 @@
|
||||
#ifndef mozilla_dom_bluetooth_bluetoothmanager_h__
|
||||
#define mozilla_dom_bluetooth_bluetoothmanager_h__
|
||||
|
||||
#include "BluetoothCommon.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/BluetoothAdapterEvent.h"
|
||||
#include "mozilla/dom/BluetoothAttributeEvent.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/Observer.h"
|
||||
#include "BluetoothCommon.h"
|
||||
#include "BluetoothPropertyContainer.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class DOMRequest;
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
class BluetoothNamedValue;
|
||||
class BluetoothAdapter;
|
||||
class BluetoothValue;
|
||||
|
||||
class BluetoothManager : public DOMEventTargetHelper
|
||||
, public BluetoothSignalObserver
|
||||
, public BluetoothPropertyContainer
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Never returns null
|
||||
static already_AddRefed<BluetoothManager>
|
||||
Create(nsPIDOMWindow* aWindow);
|
||||
static already_AddRefed<BluetoothManager> Create(nsPIDOMWindow* aWindow);
|
||||
static bool CheckPermission(nsPIDOMWindow* aWindow);
|
||||
void Notify(const BluetoothSignal& aData);
|
||||
virtual void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE;
|
||||
|
||||
bool GetEnabled(ErrorResult& aRv);
|
||||
bool IsConnected(uint16_t aProfileId, ErrorResult& aRv);
|
||||
/**
|
||||
* Return default adapter if it exists, nullptr otherwise. The function is
|
||||
* called when applications access property BluetoothManager.defaultAdapter
|
||||
*/
|
||||
BluetoothAdapter* GetDefaultAdapter();
|
||||
|
||||
already_AddRefed<DOMRequest> GetDefaultAdapter(ErrorResult& aRv);
|
||||
/**
|
||||
* Return adapters array. The function is called when applications call
|
||||
* method BluetoothManager.getAdapters()
|
||||
*
|
||||
* @param aAdapters [out] Adapters array to return
|
||||
*/
|
||||
void GetAdapters(nsTArray<nsRefPtr<BluetoothAdapter> >& aAdapters);
|
||||
|
||||
IMPL_EVENT_HANDLER(enabled);
|
||||
IMPL_EVENT_HANDLER(disabled);
|
||||
/**
|
||||
* Create a BluetoothAdapter object based on properties array
|
||||
* and append it into adapters array.
|
||||
*
|
||||
* @param aValue [in] Properties array to create BluetoothAdapter object
|
||||
*/
|
||||
void AppendAdapter(const BluetoothValue& aValue);
|
||||
|
||||
IMPL_EVENT_HANDLER(attributechanged);
|
||||
IMPL_EVENT_HANDLER(adapteradded);
|
||||
IMPL_EVENT_HANDLER(adapterremoved);
|
||||
|
||||
void Notify(const BluetoothSignal& aData); // BluetoothSignalObserver
|
||||
nsPIDOMWindow* GetParentObject() const
|
||||
{
|
||||
return GetOwner();
|
||||
return GetOwner();
|
||||
}
|
||||
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
virtual void DisconnectFromOwner() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
BluetoothManager(nsPIDOMWindow* aWindow);
|
||||
~BluetoothManager();
|
||||
|
||||
/**
|
||||
* Start/Stop listening to bluetooth signal.
|
||||
*
|
||||
* @param aStart [in] Whether to start or stop listening to bluetooth signal
|
||||
*/
|
||||
void ListenToBluetoothSignal(bool aStart);
|
||||
|
||||
/**
|
||||
* Check whether default adapter exists.
|
||||
*/
|
||||
bool DefaultAdapterExists()
|
||||
{
|
||||
return (mDefaultAdapterIndex >= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle "AdapterAdded" bluetooth signal.
|
||||
*
|
||||
* @param aValue [in] Properties array of the added adapter
|
||||
*/
|
||||
void HandleAdapterAdded(const BluetoothValue& aValue);
|
||||
|
||||
/**
|
||||
* Handle "AdapterRemoved" bluetooth signal.
|
||||
*
|
||||
* @param aValue [in] Address of the removed adapter
|
||||
*/
|
||||
void HandleAdapterRemoved(const BluetoothValue& aValue);
|
||||
|
||||
/**
|
||||
* Re-select default adapter from adapters array. The function is called
|
||||
* when an adapter is added/removed.
|
||||
*/
|
||||
void ReselectDefaultAdapter();
|
||||
|
||||
/**
|
||||
* Fire BluetoothAdapterEvent to trigger
|
||||
* onadapteradded/onadapterremoved event handler.
|
||||
*
|
||||
* @param aType [in] Event type to fire
|
||||
* @param aInit [in] Event initialization value
|
||||
*/
|
||||
void DispatchAdapterEvent(const nsAString& aType,
|
||||
const BluetoothAdapterEventInit& aInit);
|
||||
|
||||
/**
|
||||
* Fire BluetoothAttributeEvent to trigger onattributechanged event handler.
|
||||
*/
|
||||
void DispatchAttributeEvent();
|
||||
|
||||
/****************************************************************************
|
||||
* Variables
|
||||
***************************************************************************/
|
||||
/**
|
||||
* The index of default adapter in the adapters array.
|
||||
*/
|
||||
int mDefaultAdapterIndex;
|
||||
|
||||
/**
|
||||
* The adapters array.
|
||||
*/
|
||||
nsTArray<nsRefPtr<BluetoothAdapter> > mAdapters;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
@ -34,6 +34,8 @@ BluetoothReplyRunnable::~BluetoothReplyRunnable()
|
||||
nsresult
|
||||
BluetoothReplyRunnable::FireReply(JS::Handle<JS::Value> aVal)
|
||||
{
|
||||
NS_ENSURE_TRUE(mDOMRequest, NS_OK);
|
||||
|
||||
nsCOMPtr<nsIDOMRequestService> rs =
|
||||
do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
|
||||
@ -46,6 +48,8 @@ BluetoothReplyRunnable::FireReply(JS::Handle<JS::Value> aVal)
|
||||
nsresult
|
||||
BluetoothReplyRunnable::FireErrorString()
|
||||
{
|
||||
NS_ENSURE_TRUE(mDOMRequest, NS_OK);
|
||||
|
||||
nsCOMPtr<nsIDOMRequestService> rs =
|
||||
do_GetService("@mozilla.org/dom/dom-request-service;1");
|
||||
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
|
||||
@ -57,7 +61,6 @@ NS_IMETHODIMP
|
||||
BluetoothReplyRunnable::Run()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mDOMRequest);
|
||||
MOZ_ASSERT(mReply);
|
||||
|
||||
nsresult rv;
|
||||
|
@ -48,6 +48,10 @@ private:
|
||||
nsresult FireReply(JS::Handle<JS::Value> aVal);
|
||||
nsresult FireErrorString();
|
||||
|
||||
/**
|
||||
* mDOMRequest is nullptr for internal IPC that require no DOMRequest,
|
||||
* e.g., GetAdaptersTask triggered by BluetoothManager
|
||||
*/
|
||||
nsCOMPtr<nsIDOMDOMRequest> mDOMRequest;
|
||||
nsString mErrorString;
|
||||
};
|
||||
|
@ -375,11 +375,8 @@ BluetoothService::DistributeSignal(const BluetoothSignal& aSignal)
|
||||
|
||||
BluetoothSignalObserverList* ol;
|
||||
if (!mBluetoothSignalObserverTable.Get(aSignal.path(), &ol)) {
|
||||
#if DEBUG
|
||||
nsAutoCString msg("No observer registered for path ");
|
||||
msg.Append(NS_ConvertUTF16toUTF8(aSignal.path()));
|
||||
BT_WARNING(msg.get());
|
||||
#endif
|
||||
BT_WARNING("No observer registered for path %s",
|
||||
NS_ConvertUTF16toUTF8(aSignal.path()).get());
|
||||
return;
|
||||
}
|
||||
MOZ_ASSERT(ol->Length());
|
||||
|
@ -123,13 +123,13 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path of the default adapter, implemented via a platform
|
||||
* Returns an array of each adapter's properties, implemented via a platform
|
||||
* specific method.
|
||||
*
|
||||
* @return NS_OK on success, NS_ERROR_FAILURE otherwise
|
||||
*/
|
||||
virtual nsresult
|
||||
GetDefaultAdapterPathInternal(BluetoothReplyRunnable* aRunnable) = 0;
|
||||
GetAdaptersInternal(BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Returns the properties of paired devices, implemented via a platform
|
||||
|
@ -808,30 +808,45 @@ BluetoothServiceBluedroid::StopInternal()
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::GetDefaultAdapterPathInternal(
|
||||
BluetoothServiceBluedroid::GetAdaptersInternal(
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothValue v = InfallibleTArray<BluetoothNamedValue>();
|
||||
/**
|
||||
* Wrap BluetoothValue =
|
||||
* BluetoothNamedValue[]
|
||||
* |
|
||||
* |__ BluetoothNamedValue =
|
||||
* | {"Adapter", BluetoothValue = BluetoothNamedValue[]}
|
||||
* |
|
||||
* |__ BluetoothNamedValue =
|
||||
* | {"Adapter", BluetoothValue = BluetoothNamedValue[]}
|
||||
* ...
|
||||
*/
|
||||
BluetoothValue adaptersProperties = InfallibleTArray<BluetoothNamedValue>();
|
||||
uint32_t numAdapters = 1; // Bluedroid supports single adapter only
|
||||
|
||||
BT_APPEND_NAMED_VALUE(v.get_ArrayOfBluetoothNamedValue(),
|
||||
"Address", sAdapterBdAddress);
|
||||
for (uint32_t i = 0; i < numAdapters; i++) {
|
||||
BluetoothValue properties = InfallibleTArray<BluetoothNamedValue>();
|
||||
|
||||
BT_APPEND_NAMED_VALUE(v.get_ArrayOfBluetoothNamedValue(),
|
||||
"Name", sAdapterBdName);
|
||||
// TODO: Revise here based on new BluetoothAdapter interface
|
||||
BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
|
||||
"Address", sAdapterBdAddress);
|
||||
BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
|
||||
"Name", sAdapterBdName);
|
||||
BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
|
||||
"Discoverable", sAdapterDiscoverable);
|
||||
BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
|
||||
"DiscoverableTimeout", sAdapterDiscoverableTimeout);
|
||||
BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
|
||||
"Devices", sAdapterBondedAddressArray);
|
||||
|
||||
BT_APPEND_NAMED_VALUE(v.get_ArrayOfBluetoothNamedValue(),
|
||||
"Discoverable", sAdapterDiscoverable);
|
||||
|
||||
BT_APPEND_NAMED_VALUE(v.get_ArrayOfBluetoothNamedValue(),
|
||||
"DiscoverableTimeout", sAdapterDiscoverableTimeout);
|
||||
|
||||
BT_APPEND_NAMED_VALUE(v.get_ArrayOfBluetoothNamedValue(),
|
||||
"Devices", sAdapterBondedAddressArray);
|
||||
|
||||
DispatchBluetoothReply(aRunnable, v, EmptyString());
|
||||
BT_APPEND_NAMED_VALUE(adaptersProperties.get_ArrayOfBluetoothNamedValue(),
|
||||
"Adapter", properties);
|
||||
}
|
||||
|
||||
DispatchBluetoothReply(aRunnable, adaptersProperties, EmptyString());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -25,15 +25,16 @@ public:
|
||||
virtual nsresult StartInternal();
|
||||
virtual nsresult StopInternal();
|
||||
|
||||
virtual nsresult GetDefaultAdapterPathInternal(
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
virtual nsresult
|
||||
GetAdaptersInternal(BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult GetConnectedDevicePropertiesInternal(uint16_t aProfileId,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
virtual nsresult
|
||||
GetConnectedDevicePropertiesInternal(uint16_t aProfileId,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<nsString>& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult StartDiscoveryInternal(BluetoothReplyRunnable* aRunnable);
|
||||
virtual nsresult StopDiscoveryInternal(BluetoothReplyRunnable* aRunnable);
|
||||
|
@ -2376,11 +2376,14 @@ private:
|
||||
};
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::GetDefaultAdapterPathInternal(
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
BluetoothDBusService::GetAdaptersInternal(BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
/**
|
||||
* TODO: implement method GetAdaptersInternal for bluez
|
||||
*/
|
||||
|
||||
if (!IsReady()) {
|
||||
NS_NAMED_LITERAL_STRING(errorStr, "Bluetooth service is not ready yet!");
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(), errorStr);
|
||||
|
@ -51,15 +51,16 @@ public:
|
||||
|
||||
virtual nsresult StopInternal() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult GetDefaultAdapterPathInternal(
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
virtual nsresult
|
||||
GetAdaptersInternal(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult GetConnectedDevicePropertiesInternal(uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
virtual nsresult
|
||||
GetConnectedDevicePropertiesInternal(uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult StartDiscoveryInternal(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
|
@ -183,8 +183,8 @@ BluetoothParent::RecvPBluetoothRequestConstructor(
|
||||
#endif
|
||||
|
||||
switch (aRequest.type()) {
|
||||
case Request::TDefaultAdapterPathRequest:
|
||||
return actor->DoRequest(aRequest.get_DefaultAdapterPathRequest());
|
||||
case Request::TGetAdaptersRequest:
|
||||
return actor->DoRequest(aRequest.get_GetAdaptersRequest());
|
||||
case Request::TSetPropertyRequest:
|
||||
return actor->DoRequest(aRequest.get_SetPropertyRequest());
|
||||
case Request::TStartDiscoveryRequest:
|
||||
@ -303,12 +303,12 @@ BluetoothRequestParent::RequestComplete()
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRequestParent::DoRequest(const DefaultAdapterPathRequest& aRequest)
|
||||
BluetoothRequestParent::DoRequest(const GetAdaptersRequest& aRequest)
|
||||
{
|
||||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TDefaultAdapterPathRequest);
|
||||
MOZ_ASSERT(mRequestType == Request::TGetAdaptersRequest);
|
||||
|
||||
nsresult rv = mService->GetDefaultAdapterPathInternal(mReplyRunnable.get());
|
||||
nsresult rv = mService->GetAdaptersInternal(mReplyRunnable.get());
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
return true;
|
||||
|
@ -126,7 +126,7 @@ protected:
|
||||
RequestComplete();
|
||||
|
||||
bool
|
||||
DoRequest(const DefaultAdapterPathRequest& aRequest);
|
||||
DoRequest(const GetAdaptersRequest& aRequest);
|
||||
|
||||
bool
|
||||
DoRequest(const SetPropertyRequest& aRequest);
|
||||
|
@ -96,10 +96,10 @@ BluetoothServiceChildProcess::UnregisterBluetoothSignalHandler(
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::GetDefaultAdapterPathInternal(
|
||||
BluetoothServiceChildProcess::GetAdaptersInternal(
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, DefaultAdapterPathRequest());
|
||||
SendRequest(aRunnable, GetAdaptersRequest());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
GetDefaultAdapterPathInternal(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
GetAdaptersInternal(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddresses,
|
||||
|
@ -22,7 +22,7 @@ namespace bluetooth {
|
||||
* Bluetooth request types.
|
||||
*/
|
||||
|
||||
struct DefaultAdapterPathRequest
|
||||
struct GetAdaptersRequest
|
||||
{ };
|
||||
|
||||
struct SetPropertyRequest
|
||||
@ -165,7 +165,7 @@ struct SendPlayStatusRequest
|
||||
|
||||
union Request
|
||||
{
|
||||
DefaultAdapterPathRequest;
|
||||
GetAdaptersRequest;
|
||||
SetPropertyRequest;
|
||||
GetPropertyRequest;
|
||||
StartDiscoveryRequest;
|
||||
|
@ -485,11 +485,11 @@ MmsMessage::GetSender(nsAString& aSender)
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetReceivers(JSContext* aCx, JS::MutableHandle<JS::Value> aReceivers)
|
||||
{
|
||||
JS::Rooted<JSObject*> reveiversObj(aCx);
|
||||
nsresult rv = nsTArrayToJSArray(aCx, mReceivers, reveiversObj.address());
|
||||
JS::Rooted<JSObject*> receiversObj(aCx);
|
||||
nsresult rv = nsTArrayToJSArray(aCx, mReceivers, &receiversObj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aReceivers.setObject(*reveiversObj);
|
||||
aReceivers.setObject(*receiversObj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ MobileMessageThread::GetParticipants(JSContext* aCx,
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(aCx);
|
||||
|
||||
nsresult rv = nsTArrayToJSArray(aCx, mData.participants(), obj.address());
|
||||
nsresult rv = nsTArrayToJSArray(aCx, mData.participants(), &obj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aParticipants.setObject(*obj);
|
||||
|
@ -97,9 +97,8 @@ GetParamsFromSendMmsMessageRequest(JSContext* aCx,
|
||||
|
||||
// receivers
|
||||
JS::Rooted<JSObject*> receiverArray(aCx);
|
||||
if (NS_FAILED(nsTArrayToJSArray(aCx,
|
||||
aRequest.receivers(),
|
||||
receiverArray.address()))) {
|
||||
if (NS_FAILED(nsTArrayToJSArray(aCx, aRequest.receivers(), &receiverArray)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!JS_DefineProperty(aCx, paramsObj, "receivers", receiverArray, 0)) {
|
||||
|
@ -3,16 +3,20 @@
|
||||
* 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/. */
|
||||
|
||||
interface BluetoothManager : EventTarget {
|
||||
[Throws]
|
||||
readonly attribute boolean enabled;
|
||||
[CheckPermissions="bluetooth"]
|
||||
interface BluetoothManager: EventTarget
|
||||
{
|
||||
readonly attribute BluetoothAdapter? defaultAdapter;
|
||||
|
||||
attribute EventHandler onenabled;
|
||||
attribute EventHandler ondisabled;
|
||||
attribute EventHandler onattributechanged;
|
||||
attribute EventHandler onadapteradded;
|
||||
attribute EventHandler onadapterremoved;
|
||||
|
||||
[Throws]
|
||||
boolean isConnected(unsigned short aProfile);
|
||||
[NewObject, Throws]
|
||||
DOMRequest? getDefaultAdapter();
|
||||
sequence<BluetoothAdapter> getAdapters();
|
||||
};
|
||||
|
||||
enum BluetoothManagerAttribute
|
||||
{
|
||||
"unknown",
|
||||
"defaultAdapter"
|
||||
};
|
||||
|
3
js/src/devtools/rootAnalysis/expect.b2g.json
Normal file
3
js/src/devtools/rootAnalysis/expect.b2g.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"expect-hazards": 2
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
template <class T>
|
||||
inline nsresult
|
||||
nsTArrayToJSArray(JSContext* aCx, const nsTArray<T>& aSourceArray,
|
||||
JSObject** aResultArray)
|
||||
JS::MutableHandle<JSObject*> aResultArray)
|
||||
{
|
||||
MOZ_ASSERT(aCx);
|
||||
|
||||
@ -45,7 +45,7 @@ nsTArrayToJSArray(JSContext* aCx, const nsTArray<T>& aSourceArray,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aResultArray = arrayObj;
|
||||
aResultArray.set(arrayObj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ template <>
|
||||
inline nsresult
|
||||
nsTArrayToJSArray<nsString>(JSContext* aCx,
|
||||
const nsTArray<nsString>& aSourceArray,
|
||||
JSObject** aResultArray)
|
||||
JS::MutableHandle<JSObject*> aResultArray)
|
||||
{
|
||||
MOZ_ASSERT(aCx);
|
||||
|
||||
@ -85,7 +85,7 @@ nsTArrayToJSArray<nsString>(JSContext* aCx,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aResultArray = arrayObj;
|
||||
aResultArray.set(arrayObj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user