Merge b2ginbound to central, a=merge

This commit is contained in:
Wes Kocher 2015-09-15 16:55:58 -07:00
commit 9d0e2762c8
31 changed files with 292 additions and 324 deletions

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="d2e5c49440bf8410ae747b15c0dd11c54053ef3e"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="994ff1537c2d7ca4d1658806c50f3ceba1053f9b"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="d2e5c49440bf8410ae747b15c0dd11c54053ef3e"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="994ff1537c2d7ca4d1658806c50f3ceba1053f9b"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

View File

@ -19,7 +19,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="d2e5c49440bf8410ae747b15c0dd11c54053ef3e"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="994ff1537c2d7ca4d1658806c50f3ceba1053f9b"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="27eb2f04e149fc2c9976d881b1b5984bbe7ee089"/>

View File

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="d2e5c49440bf8410ae747b15c0dd11c54053ef3e"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="994ff1537c2d7ca4d1658806c50f3ceba1053f9b"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="f5d65f5b17d9766d7925aefd0486a1e526ae9bf0"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="fb28def18ceb2516c460c4bd5825d2dc656c7818"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="d2e5c49440bf8410ae747b15c0dd11c54053ef3e"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="994ff1537c2d7ca4d1658806c50f3ceba1053f9b"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="c9d4fe680662ee44a4bdea42ae00366f5df399cf">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="d2e5c49440bf8410ae747b15c0dd11c54053ef3e"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="994ff1537c2d7ca4d1658806c50f3ceba1053f9b"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

View File

@ -19,7 +19,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="d2e5c49440bf8410ae747b15c0dd11c54053ef3e"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="994ff1537c2d7ca4d1658806c50f3ceba1053f9b"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="27eb2f04e149fc2c9976d881b1b5984bbe7ee089"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="d2e5c49440bf8410ae747b15c0dd11c54053ef3e"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="994ff1537c2d7ca4d1658806c50f3ceba1053f9b"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

View File

@ -1,9 +1,9 @@
{
"git": {
"git_revision": "d2e5c49440bf8410ae747b15c0dd11c54053ef3e",
"git_revision": "994ff1537c2d7ca4d1658806c50f3ceba1053f9b",
"remote": "https://git.mozilla.org/releases/gaia.git",
"branch": ""
},
"revision": "4b08f8a2624bc83d1f839f79b4969671417c42d6",
"revision": "9090c80639ae3689dddbefb8a76ba82c1268b63a",
"repo_path": "integration/gaia-central"
}

View File

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="d2e5c49440bf8410ae747b15c0dd11c54053ef3e"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="994ff1537c2d7ca4d1658806c50f3ceba1053f9b"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="f5d65f5b17d9766d7925aefd0486a1e526ae9bf0"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="fb28def18ceb2516c460c4bd5825d2dc656c7818"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="c9d4fe680662ee44a4bdea42ae00366f5df399cf">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="d2e5c49440bf8410ae747b15c0dd11c54053ef3e"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="994ff1537c2d7ca4d1658806c50f3ceba1053f9b"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

View File

@ -28,25 +28,14 @@ BluetoothDaemonA2dpModule::SetNotificationHandler(
sNotificationHandler = aNotificationHandler;
}
nsresult
BluetoothDaemonA2dpModule::Send(DaemonSocketPDU* aPDU,
BluetoothA2dpResultHandler* aRes)
{
nsRefPtr<BluetoothA2dpResultHandler> res(aRes);
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
if (NS_FAILED(rv)) {
return rv;
}
unused << res.forget(); // Keep reference for response
return NS_OK;
}
void
BluetoothDaemonA2dpModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData)
DaemonSocketPDU& aPDU,
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonA2dpModule::* const HandleOp[])(
const DaemonSocketPDUHeader&, DaemonSocketPDU&, void*) = {
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
DaemonSocketResultHandler*) = {
[0] = &BluetoothDaemonA2dpModule::HandleRsp,
[1] = &BluetoothDaemonA2dpModule::HandleNtf
};
@ -56,7 +45,7 @@ BluetoothDaemonA2dpModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
// negate twice to map bit to 0/1
unsigned int isNtf = !!(aHeader.mOpcode & 0x80);
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aUserData);
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aRes);
}
// Commands
@ -139,7 +128,7 @@ BluetoothDaemonA2dpModule::DisconnectRsp(
void
BluetoothDaemonA2dpModule::HandleRsp(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonA2dpModule::* const HandleRsp[])(
const DaemonSocketPDUHeader&,
@ -158,8 +147,7 @@ BluetoothDaemonA2dpModule::HandleRsp(
}
nsRefPtr<BluetoothA2dpResultHandler> res =
already_AddRefed<BluetoothA2dpResultHandler>(
static_cast<BluetoothA2dpResultHandler*>(aUserData));
static_cast<BluetoothA2dpResultHandler*>(aRes);
if (!res) {
return; // Return early if no result handler has been set for response
@ -315,7 +303,7 @@ BluetoothDaemonA2dpModule::AudioConfigNtf(
void
BluetoothDaemonA2dpModule::HandleNtf(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonA2dpModule::* const HandleNtf[])(
const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {

View File

@ -15,6 +15,7 @@ BEGIN_BLUETOOTH_NAMESPACE
using mozilla::ipc::DaemonSocketPDU;
using mozilla::ipc::DaemonSocketPDUHeader;
using mozilla::ipc::DaemonSocketResultHandler;
class BluetoothSetupResultHandler;
@ -33,7 +34,8 @@ public:
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
virtual nsresult Send(DaemonSocketPDU* aPDU,
DaemonSocketResultHandler* aRes) = 0;
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
@ -55,11 +57,8 @@ public:
BluetoothA2dpResultHandler* aRes);
protected:
nsresult Send(DaemonSocketPDU* aPDU,
BluetoothA2dpResultHandler* aRes);
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData);
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
//
// Responses
@ -87,7 +86,7 @@ protected:
void HandleRsp(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU,
void* aUserData);
DaemonSocketResultHandler* aRes);
//
// Notifications
@ -125,7 +124,7 @@ protected:
void HandleNtf(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU,
void* aUserData);
DaemonSocketResultHandler* aRes);
static BluetoothA2dpNotificationHandler* sNotificationHandler;
};
@ -142,15 +141,15 @@ public:
void Init(
BluetoothA2dpNotificationHandler* aNotificationHandler,
BluetoothA2dpResultHandler* aRes);
void Cleanup(BluetoothA2dpResultHandler* aRes);
BluetoothA2dpResultHandler* aRes) override;
void Cleanup(BluetoothA2dpResultHandler* aRes) override;
/* Connect / Disconnect */
void Connect(const nsAString& aBdAddr,
BluetoothA2dpResultHandler* aRes);
BluetoothA2dpResultHandler* aRes) override;
void Disconnect(const nsAString& aBdAddr,
BluetoothA2dpResultHandler* aRes);
BluetoothA2dpResultHandler* aRes) override;
private:
void DispatchError(BluetoothA2dpResultHandler* aRes,

View File

@ -28,25 +28,14 @@ BluetoothDaemonAvrcpModule::SetNotificationHandler(
sNotificationHandler = aNotificationHandler;
}
nsresult
BluetoothDaemonAvrcpModule::Send(DaemonSocketPDU* aPDU,
BluetoothAvrcpResultHandler* aRes)
{
nsRefPtr<BluetoothAvrcpResultHandler> res(aRes);
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
if (NS_FAILED(rv)) {
return rv;
}
unused << res.forget(); // Keep reference for response
return NS_OK;
}
void
BluetoothDaemonAvrcpModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData)
DaemonSocketPDU& aPDU,
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonAvrcpModule::* const HandleOp[])(
const DaemonSocketPDUHeader&, DaemonSocketPDU&, void*) = {
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
DaemonSocketResultHandler*) = {
[0] = &BluetoothDaemonAvrcpModule::HandleRsp,
[1] = &BluetoothDaemonAvrcpModule::HandleNtf
};
@ -55,7 +44,7 @@ BluetoothDaemonAvrcpModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
unsigned int isNtf = !!(aHeader.mOpcode & 0x80);
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aUserData);
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aRes);
}
// Commands
@ -421,7 +410,7 @@ BluetoothDaemonAvrcpModule::SetVolumeRsp(
void
BluetoothDaemonAvrcpModule::HandleRsp(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonAvrcpModule::* const HandleRsp[])(
const DaemonSocketPDUHeader&,
@ -459,8 +448,7 @@ BluetoothDaemonAvrcpModule::HandleRsp(
}
nsRefPtr<BluetoothAvrcpResultHandler> res =
already_AddRefed<BluetoothAvrcpResultHandler>(
static_cast<BluetoothAvrcpResultHandler*>(aUserData));
static_cast<BluetoothAvrcpResultHandler*>(aRes);
if (!res) {
return; // Return early if no result handler has been set for response
@ -792,7 +780,7 @@ BluetoothDaemonAvrcpModule::PassthroughCmdNtf(
void
BluetoothDaemonAvrcpModule::HandleNtf(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonAvrcpModule::* const HandleNtf[])(
const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {

View File

@ -15,6 +15,7 @@ BEGIN_BLUETOOTH_NAMESPACE
using mozilla::ipc::DaemonSocketPDU;
using mozilla::ipc::DaemonSocketPDUHeader;
using mozilla::ipc::DaemonSocketResultHandler;
class BluetoothSetupResultHandler;
@ -65,7 +66,8 @@ public:
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
virtual nsresult Send(DaemonSocketPDU* aPDU,
DaemonSocketResultHandler* aRes) = 0;
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
@ -119,11 +121,8 @@ public:
nsresult SetVolumeCmd(uint8_t aVolume, BluetoothAvrcpResultHandler* aRes);
protected:
nsresult Send(DaemonSocketPDU* aPDU,
BluetoothAvrcpResultHandler* aRes);
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData);
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
//
// Responses
@ -183,7 +182,7 @@ protected:
void HandleRsp(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU,
void* aUserData);
DaemonSocketResultHandler* aRes);
//
// Notifications
@ -293,7 +292,7 @@ protected:
void HandleNtf(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU,
void* aUserData);
DaemonSocketResultHandler* aRes);
static BluetoothAvrcpNotificationHandler* sNotificationHandler;
};

View File

@ -28,25 +28,14 @@ BluetoothDaemonGattModule::SetNotificationHandler(
sNotificationHandler = aNotificationHandler;
}
nsresult
BluetoothDaemonGattModule::Send(DaemonSocketPDU* aPDU,
BluetoothGattResultHandler* aRes)
{
nsRefPtr<BluetoothGattResultHandler> res(aRes);
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
if (NS_FAILED(rv)) {
return rv;
}
unused << res.forget(); // Keep reference for response
return NS_OK;
}
void
BluetoothDaemonGattModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData)
DaemonSocketPDU& aPDU,
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonGattModule::* const HandleOp[])(
const DaemonSocketPDUHeader&, DaemonSocketPDU&, void*) = {
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
DaemonSocketResultHandler*) = {
[0] = &BluetoothDaemonGattModule::HandleRsp,
[1] = &BluetoothDaemonGattModule::HandleNtf
};
@ -56,7 +45,7 @@ BluetoothDaemonGattModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
// Negate twice to map bit to 0/1
unsigned long isNtf = !!(aHeader.mOpcode & 0x80);
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aUserData);
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aRes);
}
// Commands
@ -1405,7 +1394,7 @@ BluetoothDaemonGattModule::ServerSendResponseRsp(
void
BluetoothDaemonGattModule::HandleRsp(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonGattModule::* const HandleRsp[])(
const DaemonSocketPDUHeader&,
@ -1493,8 +1482,7 @@ BluetoothDaemonGattModule::HandleRsp(
}
nsRefPtr<BluetoothGattResultHandler> res =
already_AddRefed<BluetoothGattResultHandler>(
static_cast<BluetoothGattResultHandler*>(aUserData));
static_cast<BluetoothGattResultHandler*>(aRes);
if (!res) {
return;
@ -2152,7 +2140,7 @@ BluetoothDaemonGattModule::ServerResponseConfirmationNtf(
void
BluetoothDaemonGattModule::HandleNtf(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonGattModule::* const HandleNtf[])(
const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {

View File

@ -15,6 +15,7 @@ BEGIN_BLUETOOTH_NAMESPACE
using mozilla::ipc::DaemonSocketPDU;
using mozilla::ipc::DaemonSocketPDUHeader;
using mozilla::ipc::DaemonSocketResultHandler;
class BluetoothSetupResultHandler;
@ -67,7 +68,8 @@ public:
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
virtual nsresult Send(DaemonSocketPDU* aPDU,
DaemonSocketResultHandler* aRes) = 0;
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
@ -300,11 +302,8 @@ public:
// TODO: Add L support
protected:
nsresult Send(DaemonSocketPDU* aPDU,
BluetoothGattResultHandler* aRes);
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData);
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
//
// Responses
@ -471,7 +470,7 @@ protected:
void HandleRsp(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU,
void* aUserData);
DaemonSocketResultHandler* aRes);
//
// Notifications
@ -770,7 +769,7 @@ protected:
void HandleNtf(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU,
void* aUserData);
DaemonSocketResultHandler* aRes);
static BluetoothGattNotificationHandler* sNotificationHandler;
};
@ -786,81 +785,81 @@ public:
~BluetoothDaemonGattInterface();
void Init(BluetoothGattNotificationHandler* aNotificationHandler,
BluetoothGattResultHandler* aRes);
void Cleanup(BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void Cleanup(BluetoothGattResultHandler* aRes) override;
/* Register / Unregister */
void RegisterClient(const BluetoothUuid& aUuid,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void UnregisterClient(int aClientIf,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Start / Stop LE Scan */
void Scan(int aClientIf, bool aStart,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Connect / Disconnect */
void Connect(int aClientIf,
const nsAString& aBdAddr,
bool aIsDirect, /* auto connect */
BluetoothTransport aTransport,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void Disconnect(int aClientIf,
const nsAString& aBdAddr,
int aConnId,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Start / Stop advertisements to listen for incoming connections */
void Listen(int aClientIf,
bool aIsStart,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Clear the attribute cache for a given device*/
void Refresh(int aClientIf,
const nsAString& aBdAddr,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Enumerate Attributes */
void SearchService(int aConnId,
bool aSearchAll,
const BluetoothUuid& aUuid,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void GetIncludedService(int aConnId,
const BluetoothGattServiceId& aServiceId,
bool aFirst,
const BluetoothGattServiceId& aStartServiceId,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void GetCharacteristic(int aConnId,
const BluetoothGattServiceId& aServiceId,
bool aFirst,
const BluetoothGattId& aStartCharId,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void GetDescriptor(int aConnId,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
bool aFirst,
const BluetoothGattId& aDescriptorId,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Read / Write An Attribute */
void ReadCharacteristic(int aConnId,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
BluetoothGattAuthReq aAuthReq,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void WriteCharacteristic(int aConnId,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
BluetoothGattWriteType aWriteType,
BluetoothGattAuthReq aAuthReq,
const nsTArray<uint8_t>& aValue,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void ReadDescriptor(int aConnId,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
const BluetoothGattId& aDescriptorId,
BluetoothGattAuthReq aAuthReq,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void WriteDescriptor(int aConnId,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
@ -868,12 +867,12 @@ public:
BluetoothGattWriteType aWriteType,
BluetoothGattAuthReq aAuthReq,
const nsTArray<uint8_t>& aValue,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Execute / Abort Prepared Write*/
void ExecuteWrite(int aConnId,
int aIsExecute,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Register / Deregister Characteristic Notifications or Indications */
@ -881,19 +880,19 @@ public:
const nsAString& aBdAddr,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void DeregisterNotification(int aClientIf,
const nsAString& aBdAddr,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void ReadRemoteRssi(int aClientIf,
const nsAString& aBdAddr,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void GetDeviceType(const nsAString& aBdAddr,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Set advertising data or scan response data */
void SetAdvData(int aServerIf,
@ -906,61 +905,61 @@ public:
uint16_t aManufacturerLen, char* aManufacturerData,
uint16_t aServiceDataLen, char* aServiceData,
uint16_t aServiceUuidLen, char* aServiceUuid,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void TestCommand(int aCommand,
const BluetoothGattTestParam& aTestParam,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Register / Unregister */
void RegisterServer(const BluetoothUuid& aUuid,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void UnregisterServer(int aServerIf,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Connect / Disconnect */
void ConnectPeripheral(int aServerIf,
const nsAString& aBdAddr,
bool aIsDirect, /* auto connect */
BluetoothTransport aTransport,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void DisconnectPeripheral(int aServerIf,
const nsAString& aBdAddr,
int aConnId,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Add a services / a characteristic / a descriptor */
void AddService(int aServerIf,
const BluetoothGattServiceId& aServiceId,
int aNumHandles,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void AddIncludedService(int aServerIf,
int aServiceHandle,
int aIncludedServiceHandle,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void AddCharacteristic(int aServerIf,
int aServiceHandle,
const BluetoothUuid& aUuid,
BluetoothGattCharProp aProperties,
BluetoothGattAttrPerm aPermissions,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void AddDescriptor(int aServerIf,
int aServiceHandle,
const BluetoothUuid& aUuid,
BluetoothGattAttrPerm aPermissions,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Start / Stop / Delete a service */
void StartService(int aServerIf,
int aServiceHandle,
BluetoothTransport aTransport,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void StopService(int aServerIf,
int aServiceHandle,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
void DeleteService(int aServerIf,
int aServiceHandle,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Send an indication or a notification */
void SendIndication(
@ -969,14 +968,14 @@ public:
int aConnId,
const nsTArray<uint8_t>& aValue,
bool aConfirm, /* true: indication, false: notification */
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
/* Send a response for an incoming indication */
void SendResponse(int aConnId,
int aTransId,
BluetoothGattStatus aStatus,
const BluetoothGattResponse& aResponse,
BluetoothGattResultHandler* aRes);
BluetoothGattResultHandler* aRes) override;
private:
void DispatchError(BluetoothGattResultHandler* aRes,

View File

@ -31,25 +31,14 @@ BluetoothDaemonHandsfreeModule::SetNotificationHandler(
sNotificationHandler = aNotificationHandler;
}
nsresult
BluetoothDaemonHandsfreeModule::Send(DaemonSocketPDU* aPDU,
BluetoothHandsfreeResultHandler* aRes)
{
nsRefPtr<BluetoothHandsfreeResultHandler> res(aRes);
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
if (NS_FAILED(rv)) {
return rv;
}
unused << res.forget(); // Keep reference for response
return NS_OK;
}
void
BluetoothDaemonHandsfreeModule::HandleSvc(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU, void* aUserData)
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonHandsfreeModule::* const HandleOp[])(
const DaemonSocketPDUHeader&, DaemonSocketPDU&, void*) = {
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
DaemonSocketResultHandler*) = {
[0] = &BluetoothDaemonHandsfreeModule::HandleRsp,
[1] = &BluetoothDaemonHandsfreeModule::HandleNtf
};
@ -59,7 +48,7 @@ BluetoothDaemonHandsfreeModule::HandleSvc(
// Negate twice to map bit to 0/1
unsigned long isNtf = !!(aHeader.mOpcode & 0x80);
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aUserData);
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aRes);
}
// Commands
@ -679,7 +668,7 @@ BluetoothDaemonHandsfreeModule::ConfigureWbsRsp(
void
BluetoothDaemonHandsfreeModule::HandleRsp(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonHandsfreeModule::* const HandleRsp[])(
const DaemonSocketPDUHeader&,
@ -727,8 +716,7 @@ BluetoothDaemonHandsfreeModule::HandleRsp(
}
nsRefPtr<BluetoothHandsfreeResultHandler> res =
already_AddRefed<BluetoothHandsfreeResultHandler>(
static_cast<BluetoothHandsfreeResultHandler*>(aUserData));
static_cast<BluetoothHandsfreeResultHandler*>(aRes);
if (!res) {
return; // Return early if no result handler has been set for response
@ -1463,7 +1451,7 @@ BluetoothDaemonHandsfreeModule::WbsNtf(
void
BluetoothDaemonHandsfreeModule::HandleNtf(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonHandsfreeModule::* const HandleNtf[])(
const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {

View File

@ -15,6 +15,7 @@ BEGIN_BLUETOOTH_NAMESPACE
using mozilla::ipc::DaemonSocketPDU;
using mozilla::ipc::DaemonSocketPDUHeader;
using mozilla::ipc::DaemonSocketResultHandler;
class BluetoothSetupResultHandler;
@ -44,7 +45,8 @@ public:
OPCODE_CONFIGURE_WBS = 0x0f
};
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
virtual nsresult Send(DaemonSocketPDU* aPDU,
DaemonSocketResultHandler* aRes) = 0;
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
@ -128,11 +130,9 @@ public:
BluetoothHandsfreeResultHandler* aRes);
protected:
nsresult Send(DaemonSocketPDU* aPDU,
BluetoothHandsfreeResultHandler* aRes);
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData);
DaemonSocketPDU& aPDU,
DaemonSocketResultHandler* aRes);
//
// Responses
@ -212,7 +212,7 @@ protected:
void HandleRsp(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU,
void* aUserData);
DaemonSocketResultHandler* aRes);
//
// Notifications
@ -369,7 +369,7 @@ protected:
void HandleNtf(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU,
void* aUserData);
DaemonSocketResultHandler* aRes);
static BluetoothHandsfreeNotificationHandler* sNotificationHandler;
#if ANDROID_VERSION < 21
@ -400,39 +400,39 @@ public:
void Init(
BluetoothHandsfreeNotificationHandler* aNotificationHandler,
int aMaxNumClients, BluetoothHandsfreeResultHandler* aRes);
void Cleanup(BluetoothHandsfreeResultHandler* aRes);
int aMaxNumClients, BluetoothHandsfreeResultHandler* aRes) override;
void Cleanup(BluetoothHandsfreeResultHandler* aRes) override;
/* Connect / Disconnect */
void Connect(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
void Disconnect(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
void ConnectAudio(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
void DisconnectAudio(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
/* Voice Recognition */
void StartVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
void StopVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
/* Volume */
void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
/* Device status */
void DeviceStatusNotification(BluetoothHandsfreeNetworkState aNtkState,
BluetoothHandsfreeServiceType aSvcType,
int aSignal, int aBattChg,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
/* Responses */
@ -442,12 +442,12 @@ public:
BluetoothHandsfreeCallState aCallSetupState,
int aSignal, int aRoam, int aBattChg,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
void FormattedAtResponse(const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
void AtResponse(BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir,
BluetoothHandsfreeCallState aState,
BluetoothHandsfreeCallMode aMode,
@ -455,7 +455,7 @@ public:
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
/* Phone State */
@ -463,12 +463,12 @@ public:
BluetoothHandsfreeCallState aCallSetupState,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
/* Wide Band Speech */
void ConfigureWbs(const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes);
BluetoothHandsfreeResultHandler* aRes) override;
private:
void DispatchError(BluetoothHandsfreeResultHandler* aRes,

View File

@ -34,7 +34,8 @@ static const int sRetryInterval = 100; // ms
class BluetoothDaemonSetupModule
{
public:
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
virtual nsresult Send(DaemonSocketPDU* aPDU,
DaemonSocketResultHandler* aRes) = 0;
// Commands
//
@ -107,7 +108,7 @@ protected:
// Called to handle PDUs with Service field equal to 0x00, which
// contains internal operations for setup and configuration.
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData)
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonSetupModule::* const HandleRsp[])(
const DaemonSocketPDUHeader&,
@ -125,27 +126,15 @@ protected:
}
nsRefPtr<BluetoothSetupResultHandler> res =
already_AddRefed<BluetoothSetupResultHandler>(
static_cast<BluetoothSetupResultHandler*>(aUserData));
static_cast<BluetoothSetupResultHandler*>(aRes);
if (!res) {
if (!aRes) {
return; // Return early if no result handler has been set
}
(this->*(HandleRsp[aHeader.mOpcode]))(aHeader, aPDU, res);
}
nsresult Send(DaemonSocketPDU* aPDU, BluetoothSetupResultHandler* aRes)
{
nsRefPtr<BluetoothSetupResultHandler> res(aRes);
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
if (NS_FAILED(rv)) {
return rv;
}
unused << res.forget(); // Keep reference for response
return NS_OK;
}
private:
// Responses
@ -211,7 +200,8 @@ public:
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
virtual nsresult Send(DaemonSocketPDU* aPDU,
DaemonSocketResultHandler* aRes) = 0;
nsresult EnableCmd(BluetoothResultHandler* aRes)
{
@ -600,28 +590,18 @@ public:
protected:
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData)
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonCoreModule::* const HandleOp[])(
const DaemonSocketPDUHeader&, DaemonSocketPDU&, void*) = {
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
DaemonSocketResultHandler*) = {
[0] = &BluetoothDaemonCoreModule::HandleRsp,
[1] = &BluetoothDaemonCoreModule::HandleNtf
};
MOZ_ASSERT(!NS_IsMainThread());
(this->*(HandleOp[!!(aHeader.mOpcode & 0x80)]))(aHeader, aPDU, aUserData);
}
nsresult Send(DaemonSocketPDU* aPDU, BluetoothResultHandler* aRes)
{
nsRefPtr<BluetoothResultHandler> res(aRes);
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
if (NS_FAILED(rv)) {
return rv;
}
unused << res.forget(); // Keep reference for response
return NS_OK;
(this->*(HandleOp[!!(aHeader.mOpcode & 0x80)]))(aHeader, aPDU, aRes);
}
private:
@ -825,7 +805,7 @@ private:
}
void HandleRsp(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData)
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonCoreModule::* const HandleRsp[])(
const DaemonSocketPDUHeader&,
@ -862,8 +842,7 @@ private:
}
nsRefPtr<BluetoothResultHandler> res =
already_AddRefed<BluetoothResultHandler>(
static_cast<BluetoothResultHandler*>(aUserData));
static_cast<BluetoothResultHandler*>(aRes);
if (!res) {
return; // Return early if no result handler has been set for response
@ -1345,7 +1324,7 @@ private:
}
void HandleNtf(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData)
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonCoreModule::* const HandleNtf[])(
const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {
@ -1453,35 +1432,44 @@ public:
// Outgoing PDUs
//
nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) override;
nsresult Send(DaemonSocketPDU* aPDU,
DaemonSocketResultHandler* aRes) override;
void StoreUserData(const DaemonSocketPDU& aPDU) override;
void StoreResultHandler(const DaemonSocketPDU& aPDU) override;
// Incoming PUDs
//
void Handle(DaemonSocketPDU& aPDU) override;
void* FetchUserData(const DaemonSocketPDUHeader& aHeader);
already_AddRefed<DaemonSocketResultHandler> FetchResultHandler(
const DaemonSocketPDUHeader& aHeader);
private:
void HandleSetupSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData);
DaemonSocketPDU& aPDU,
DaemonSocketResultHandler* aRes);
void HandleCoreSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData);
DaemonSocketPDU& aPDU,
DaemonSocketResultHandler* aRes);
void HandleSocketSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData);
DaemonSocketPDU& aPDU,
DaemonSocketResultHandler* aRes);
void HandleHandsfreeSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData);
DaemonSocketPDU& aPDU,
DaemonSocketResultHandler* aRes);
void HandleA2dpSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData);
DaemonSocketPDU& aPDU,
DaemonSocketResultHandler* aUserData);
void HandleAvrcpSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData);
DaemonSocketPDU& aPDU,
DaemonSocketResultHandler* aRes);
void HandleGattSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData);
DaemonSocketPDU& aPDU,
DaemonSocketResultHandler* aRes);
DaemonSocket* mConnection;
nsTArray<void*> mUserDataQ;
nsTArray<nsRefPtr<DaemonSocketResultHandler>> mResQ;
};
BluetoothDaemonProtocol::BluetoothDaemonProtocol()
@ -1510,13 +1498,14 @@ BluetoothDaemonProtocol::UnregisterModule(uint8_t aId,
}
nsresult
BluetoothDaemonProtocol::Send(DaemonSocketPDU* aPDU, void* aUserData)
BluetoothDaemonProtocol::Send(DaemonSocketPDU* aPDU,
DaemonSocketResultHandler* aRes)
{
MOZ_ASSERT(mConnection);
MOZ_ASSERT(aPDU);
aPDU->SetConsumer(this);
aPDU->SetUserData(aUserData);
aPDU->SetResultHandler(aRes);
aPDU->UpdateHeader();
if (mConnection->GetConnectionStatus() == SOCKET_DISCONNECTED) {
@ -1532,64 +1521,65 @@ BluetoothDaemonProtocol::Send(DaemonSocketPDU* aPDU, void* aUserData)
void
BluetoothDaemonProtocol::HandleSetupSvc(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
BluetoothDaemonSetupModule::HandleSvc(aHeader, aPDU, aUserData);
BluetoothDaemonSetupModule::HandleSvc(aHeader, aPDU, aRes);
}
void
BluetoothDaemonProtocol::HandleCoreSvc(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
BluetoothDaemonCoreModule::HandleSvc(aHeader, aPDU, aUserData);
BluetoothDaemonCoreModule::HandleSvc(aHeader, aPDU, aRes);
}
void
BluetoothDaemonProtocol::HandleSocketSvc(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
BluetoothDaemonSocketModule::HandleSvc(aHeader, aPDU, aUserData);
BluetoothDaemonSocketModule::HandleSvc(aHeader, aPDU, aRes);
}
void
BluetoothDaemonProtocol::HandleHandsfreeSvc(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
BluetoothDaemonHandsfreeModule::HandleSvc(aHeader, aPDU, aUserData);
BluetoothDaemonHandsfreeModule::HandleSvc(aHeader, aPDU, aRes);
}
void
BluetoothDaemonProtocol::HandleA2dpSvc(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
BluetoothDaemonA2dpModule::HandleSvc(aHeader, aPDU, aUserData);
BluetoothDaemonA2dpModule::HandleSvc(aHeader, aPDU, aRes);
}
void
BluetoothDaemonProtocol::HandleAvrcpSvc(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
BluetoothDaemonAvrcpModule::HandleSvc(aHeader, aPDU, aUserData);
BluetoothDaemonAvrcpModule::HandleSvc(aHeader, aPDU, aRes);
}
void
BluetoothDaemonProtocol::HandleGattSvc(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
BluetoothDaemonGattModule::HandleSvc(aHeader, aPDU, aUserData);
BluetoothDaemonGattModule::HandleSvc(aHeader, aPDU, aRes);
}
void
BluetoothDaemonProtocol::Handle(DaemonSocketPDU& aPDU)
{
static void (BluetoothDaemonProtocol::* const HandleSvc[])(
const DaemonSocketPDUHeader&, DaemonSocketPDU&, void*) = {
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
DaemonSocketResultHandler*) = {
[0x00] = &BluetoothDaemonProtocol::HandleSetupSvc,
[0x01] = &BluetoothDaemonProtocol::HandleCoreSvc,
[0x02] = &BluetoothDaemonProtocol::HandleSocketSvc,
@ -1614,19 +1604,22 @@ BluetoothDaemonProtocol::Handle(DaemonSocketPDU& aPDU)
return;
}
(this->*(HandleSvc[header.mService]))(header, aPDU, FetchUserData(header));
nsRefPtr<DaemonSocketResultHandler> res = FetchResultHandler(header);
(this->*(HandleSvc[header.mService]))(header, aPDU, res);
}
void
BluetoothDaemonProtocol::StoreUserData(const DaemonSocketPDU& aPDU)
BluetoothDaemonProtocol::StoreResultHandler(const DaemonSocketPDU& aPDU)
{
MOZ_ASSERT(!NS_IsMainThread());
mUserDataQ.AppendElement(aPDU.GetUserData());
mResQ.AppendElement(aPDU.GetResultHandler());
}
void*
BluetoothDaemonProtocol::FetchUserData(const DaemonSocketPDUHeader& aHeader)
already_AddRefed<DaemonSocketResultHandler>
BluetoothDaemonProtocol::FetchResultHandler(
const DaemonSocketPDUHeader& aHeader)
{
MOZ_ASSERT(!NS_IsMainThread());
@ -1634,10 +1627,10 @@ BluetoothDaemonProtocol::FetchUserData(const DaemonSocketPDUHeader& aHeader)
return nullptr; // Ignore notifications
}
void* userData = mUserDataQ.ElementAt(0);
mUserDataQ.RemoveElementAt(0);
nsRefPtr<DaemonSocketResultHandler> userData = mResQ.ElementAt(0);
mResQ.RemoveElementAt(0);
return userData;
return userData.forget();
}
//

View File

@ -46,80 +46,82 @@ public:
static BluetoothDaemonInterface* GetInstance();
void Init(BluetoothNotificationHandler* aNotificationHandler,
BluetoothResultHandler* aRes);
void Cleanup(BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
void Cleanup(BluetoothResultHandler* aRes) override;
void Enable(BluetoothResultHandler* aRes);
void Disable(BluetoothResultHandler* aRes);
void Enable(BluetoothResultHandler* aRes) override;
void Disable(BluetoothResultHandler* aRes) override;
/* Adapter Properties */
void GetAdapterProperties(BluetoothResultHandler* aRes);
void GetAdapterProperties(BluetoothResultHandler* aRes) override;
void GetAdapterProperty(const nsAString& aName,
BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
void SetAdapterProperty(const BluetoothNamedValue& aProperty,
BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
/* Remote Device Properties */
void GetRemoteDeviceProperties(const nsAString& aRemoteAddr,
BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
void GetRemoteDeviceProperty(const nsAString& aRemoteAddr,
const nsAString& aName,
BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
void SetRemoteDeviceProperty(const nsAString& aRemoteAddr,
const BluetoothNamedValue& aProperty,
BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
/* Remote Services */
void GetRemoteServiceRecord(const nsAString& aRemoteAddr,
const uint8_t aUuid[16],
BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
void GetRemoteServices(const nsAString& aRemoteAddr,
BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
/* Discovery */
void StartDiscovery(BluetoothResultHandler* aRes);
void CancelDiscovery(BluetoothResultHandler* aRes);
void StartDiscovery(BluetoothResultHandler* aRes) override;
void CancelDiscovery(BluetoothResultHandler* aRes) override;
/* Bonds */
void CreateBond(const nsAString& aBdAddr, BluetoothTransport aTransport,
BluetoothResultHandler* aRes);
void RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
void CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
void RemoveBond(const nsAString& aBdAddr,
BluetoothResultHandler* aRes) override;
void CancelBond(const nsAString& aBdAddr,
BluetoothResultHandler* aRes) override;
/* Connection */
void GetConnectionState(const nsAString& aBdAddr,
BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
/* Authentication */
void PinReply(const nsAString& aBdAddr, bool aAccept,
const nsAString& aPinCode,
BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
void SspReply(const nsAString& aBdAddr, BluetoothSspVariant aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
/* DUT Mode */
void DutModeConfigure(bool aEnable, BluetoothResultHandler* aRes);
void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
/* LE Mode */
void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
BluetoothResultHandler* aRes);
BluetoothResultHandler* aRes) override;
/* Energy Information */
void ReadEnergyInfo(BluetoothResultHandler* aRes);
void ReadEnergyInfo(BluetoothResultHandler* aRes) override;
/* Profile Interfaces */

View File

@ -8,14 +8,14 @@
#define mozilla_dom_bluetooth_bluedroid_BluetoothDaemonSetupInterface_h
#include "BluetoothCommon.h"
#include "mozilla/ipc/DaemonSocketMessageHandlers.h"
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothSetupResultHandler
: public mozilla::ipc::DaemonSocketResultHandler
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothSetupResultHandler)
virtual void OnError(BluetoothStatus aStatus);
virtual void RegisterModule();
virtual void UnregisterModule();

View File

@ -160,7 +160,7 @@ BluetoothDaemonSocketModule::CloseCmd(BluetoothSocketResultHandler* aRes)
void
BluetoothDaemonSocketModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU,
void* aUserData)
DaemonSocketResultHandler* aRes)
{
static void (BluetoothDaemonSocketModule::* const HandleRsp[])(
const DaemonSocketPDUHeader&,
@ -177,8 +177,7 @@ BluetoothDaemonSocketModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
}
nsRefPtr<BluetoothSocketResultHandler> res =
already_AddRefed<BluetoothSocketResultHandler>(
static_cast<BluetoothSocketResultHandler*>(aUserData));
static_cast<BluetoothSocketResultHandler*>(aRes);
if (!res) {
return; // Return early if no result handler has been set
@ -187,19 +186,6 @@ BluetoothDaemonSocketModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
(this->*(HandleRsp[aHeader.mOpcode]))(aHeader, aPDU, res);
}
nsresult
BluetoothDaemonSocketModule::Send(DaemonSocketPDU* aPDU,
BluetoothSocketResultHandler* aRes)
{
nsRefPtr<BluetoothSocketResultHandler> res(aRes);
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
if (NS_FAILED(rv)) {
return rv;
}
unused << res.forget(); // Keep reference for response
return NS_OK;
}
uint8_t
BluetoothDaemonSocketModule::SocketFlags(bool aEncrypt, bool aAuth)
{

View File

@ -15,13 +15,15 @@ BEGIN_BLUETOOTH_NAMESPACE
using mozilla::ipc::DaemonSocketPDU;
using mozilla::ipc::DaemonSocketPDUHeader;
using mozilla::ipc::DaemonSocketResultHandler;
class BluetoothDaemonSocketModule
{
public:
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
virtual nsresult Send(DaemonSocketPDU* aPDU,
DaemonSocketResultHandler* aRes) = 0;
// Commands
//
@ -45,9 +47,7 @@ public:
protected:
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU, void* aUserData);
nsresult Send(DaemonSocketPDU* aPDU, BluetoothSocketResultHandler* aRes);
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
private:
class AcceptWatcher;
@ -100,17 +100,17 @@ public:
const nsAString& aServiceName,
const uint8_t aServiceUuid[16],
int aChannel, bool aEncrypt, bool aAuth,
BluetoothSocketResultHandler* aRes);
BluetoothSocketResultHandler* aRes) override;
void Connect(const nsAString& aBdAddr,
BluetoothSocketType aType,
const uint8_t aUuid[16],
int aChannel, bool aEncrypt, bool aAuth,
BluetoothSocketResultHandler* aRes);
BluetoothSocketResultHandler* aRes) override;
void Accept(int aFd, BluetoothSocketResultHandler* aRes);
void Accept(int aFd, BluetoothSocketResultHandler* aRes) override;
void Close(BluetoothSocketResultHandler* aRes);
void Close(BluetoothSocketResultHandler* aRes) override;
private:
void DispatchError(BluetoothSocketResultHandler* aRes,

View File

@ -1399,9 +1399,7 @@ BluetoothHfpManager::ConnectionStateNotification(
} else if (aState == HFP_CONNECTION_STATE_CONNECTED) {
// Once RFCOMM is connected, enable NREC before each new SLC connection
mNrecEnabled = HFP_NREC_STARTED;
NotifyConnectionStateChanged(
NS_LITERAL_STRING(BLUETOOTH_HFP_NREC_STATUS_CHANGED_ID));
NRECNotification(HFP_NREC_STARTED, mDeviceAddress);
}
}
@ -1478,6 +1476,12 @@ BluetoothHfpManager::DtmfNotification(char aDtmf, const nsAString& aBdAddress)
NotifyDialer(NS_ConvertUTF8toUTF16(message));
}
/**
* NREC status will be set when:
* 1. Get an AT command from HF device.
* (Bluetooth HFP spec v1.6 merely defines for the "Disable" part.)
* 2. Once RFCOMM is connected, enable NREC before each new SLC connection.
*/
void
BluetoothHfpManager::NRECNotification(BluetoothHandsfreeNRECState aNrec,
const nsAString& aBdAddr)
@ -1488,7 +1492,6 @@ BluetoothHfpManager::NRECNotification(BluetoothHandsfreeNRECState aNrec,
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
NS_ENSURE_TRUE_VOID(obs);
// Set NREC status once getting AT command
mNrecEnabled = static_cast<bool>(aNrec);
// Notify audio manager

View File

@ -9,6 +9,7 @@
#include "BluetoothCommon.h"
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
#include "mozilla/ipc/DaemonSocketMessageHandlers.h"
BEGIN_BLUETOOTH_NAMESPACE
@ -17,10 +18,9 @@ BEGIN_BLUETOOTH_NAMESPACE
//
class BluetoothSocketResultHandler
: public mozilla::ipc::DaemonSocketResultHandler
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothSocketResultHandler)
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("Received error code %d", (int)aStatus);
@ -155,10 +155,9 @@ protected:
};
class BluetoothHandsfreeResultHandler
: public mozilla::ipc::DaemonSocketResultHandler
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothHandsfreeResultHandler)
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("Received error code %d", (int)aStatus);
@ -303,10 +302,9 @@ protected:
};
class BluetoothA2dpResultHandler
: public mozilla::ipc::DaemonSocketResultHandler
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothA2dpResultHandler)
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("Received error code %d", (int)aStatus);
@ -406,10 +404,9 @@ protected:
};
class BluetoothAvrcpResultHandler
: public mozilla::ipc::DaemonSocketResultHandler
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothAvrcpResultHandler)
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("Received error code %d", (int)aStatus);
@ -720,10 +717,9 @@ protected:
};
class BluetoothGattResultHandler
: public mozilla::ipc::DaemonSocketResultHandler
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothGattResultHandler)
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("Received error code %d", (int)aStatus);
@ -1048,10 +1044,9 @@ protected:
};
class BluetoothResultHandler
: public mozilla::ipc::DaemonSocketResultHandler
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothResultHandler)
virtual void OnError(BluetoothStatus aStatus)
{
BT_LOGR("Received error code %d", aStatus);

View File

@ -23,7 +23,7 @@ public:
virtual ~DaemonSocketIOConsumer();
virtual void Handle(DaemonSocketPDU& aPDU) = 0;
virtual void StoreUserData(const DaemonSocketPDU& aPDU) = 0;
virtual void StoreResultHandler(const DaemonSocketPDU& aPDU) = 0;
protected:
DaemonSocketIOConsumer();

View File

@ -0,0 +1,40 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=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/. */
/*
* Message handlers
*
* This file contains base classes for message handling.
*/
#ifndef mozilla_ipc_DaemonSocketMessageHandlers_h
#define mozilla_ipc_DaemonSocketMessageHandlers_h
#include "nsISupportsImpl.h" // for ref-counting
namespace mozilla {
namespace ipc {
/**
* |DaemonSocketResultHandler| is the base class for all protocol-specific
* result handlers. It currently only manages the reference counting.
*/
class DaemonSocketResultHandler
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DaemonSocketResultHandler);
protected:
DaemonSocketResultHandler()
{ }
virtual ~DaemonSocketResultHandler()
{ }
};
} // namespace ipc
} // namespace mozilla
#endif // mozilla_ipc_DaemonSocketMessageHandlers_h

View File

@ -29,9 +29,8 @@ namespace ipc {
//
DaemonSocketPDU::DaemonSocketPDU(uint8_t aService, uint8_t aOpcode,
uint16_t aPayloadSize)
uint16_t aPayloadSize)
: mConsumer(nullptr)
, mUserData(nullptr)
{
MOZ_COUNT_CTOR_INHERITED(DaemonSocketPDU, UnixSocketIOBuffer);
@ -51,7 +50,6 @@ DaemonSocketPDU::DaemonSocketPDU(uint8_t aService, uint8_t aOpcode,
DaemonSocketPDU::DaemonSocketPDU(size_t aPayloadSize)
: mConsumer(nullptr)
, mUserData(nullptr)
{
MOZ_COUNT_CTOR_INHERITED(DaemonSocketPDU, UnixSocketIOBuffer);
@ -102,8 +100,8 @@ DaemonSocketPDU::Send(int aFd)
if (mConsumer) {
// We successfully sent a PDU, now store the
// result runnable in the consumer.
mConsumer->StoreUserData(*this);
// result handler in the consumer.
mConsumer->StoreResultHandler(*this);
}
return res;

View File

@ -9,6 +9,7 @@
#include "mozilla/FileUtils.h"
#include "mozilla/ipc/SocketBase.h"
#include "mozilla/ipc/DaemonSocketMessageHandlers.h"
namespace mozilla {
namespace ipc {
@ -55,14 +56,14 @@ public:
mConsumer = aConsumer;
}
void SetUserData(void* aUserData)
void SetResultHandler(DaemonSocketResultHandler* aRes)
{
mUserData = aUserData;
mRes = aRes;
}
void* GetUserData() const
DaemonSocketResultHandler* GetResultHandler() const
{
return mUserData;
return mRes;
}
void GetHeader(uint8_t& aService, uint8_t& aOpcode,
@ -80,7 +81,7 @@ private:
void OnError(const char* aFunction, int aErrno);
DaemonSocketIOConsumer* mConsumer;
void* mUserData;
nsRefPtr<DaemonSocketResultHandler> mRes;
ScopedClose mReceivedFd;
};

View File

@ -9,6 +9,7 @@ EXPORTS.mozilla.ipc += [
'DaemonSocket.h',
'DaemonSocketConnector.h',
'DaemonSocketConsumer.h',
'DaemonSocketMessageHandlers.h',
'DaemonSocketPDU.h',
'DaemonSocketPDUHelpers.h'
]