Merge b2ginbound to central, a=merge

This commit is contained in:
Wes Kocher 2015-08-21 08:39:53 -07:00
Родитель f07a882610 9783d824f1
Коммит dcc2753eed
41 изменённых файлов: 1089 добавлений и 205 удалений

Просмотреть файл

@ -575,7 +575,7 @@ let settingsToObserve = {
},
'dom.mozApps.use_reviewer_certs': false,
'dom.mozApps.signed_apps_installable_from': 'https://marketplace.firefox.com',
'dom.presentation.discovery.enabled': true,
'dom.presentation.discovery.enabled': false,
'dom.presentation.discoverable': false,
'dom.serviceWorkers.interception.enabled': true,
'dom.serviceWorkers.testing.enabled': false,

Просмотреть файл

@ -12,10 +12,10 @@
<!--original fetch url was https://git.mozilla.org/releases-->
<remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
<!-- B2G specific things. -->
<project name="platform_build" path="build" remote="b2g" revision="aacd9b12da7fc3c8f4deaaa8eedfbb158f4fefe7">
<project name="platform_build" path="build" remote="b2g" revision="e935894ef5f27e2f04b9e929a45a958e6288a223">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c6705f739fb605031eb2a0b943ba55c64bee5a03"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="f6cde6b8a2af2d2cfa3ce9b7f4cda2daab9174a8"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="62cfa11ae7d77f6330de019a5aa79607e35be7d1"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

Просмотреть файл

@ -12,10 +12,10 @@
<!--original fetch url was https://git.mozilla.org/releases-->
<remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
<!-- B2G specific things. -->
<project name="platform_build" path="build" remote="b2g" revision="aacd9b12da7fc3c8f4deaaa8eedfbb158f4fefe7">
<project name="platform_build" path="build" remote="b2g" revision="e935894ef5f27e2f04b9e929a45a958e6288a223">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c6705f739fb605031eb2a0b943ba55c64bee5a03"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="f6cde6b8a2af2d2cfa3ce9b7f4cda2daab9174a8"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="62cfa11ae7d77f6330de019a5aa79607e35be7d1"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

Просмотреть файл

@ -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="c6705f739fb605031eb2a0b943ba55c64bee5a03"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f6cde6b8a2af2d2cfa3ce9b7f4cda2daab9174a8"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="62cfa11ae7d77f6330de019a5aa79607e35be7d1"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="2d58f4b9206b50b8fda0d5036da6f0c62608db7c"/>

Просмотреть файл

@ -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="c6705f739fb605031eb2a0b943ba55c64bee5a03"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="f6cde6b8a2af2d2cfa3ce9b7f4cda2daab9174a8"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="62cfa11ae7d77f6330de019a5aa79607e35be7d1"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="bfdb6348725a33bdcdc4e17999cb500be6beedb5"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="a6f9a1245d98c51172c15afecb9ade1a6ca511e2"/>

Просмотреть файл

@ -12,10 +12,10 @@
<!--original fetch url was https://git.mozilla.org/releases-->
<remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
<!-- B2G specific things. -->
<project name="platform_build" path="build" remote="b2g" revision="aacd9b12da7fc3c8f4deaaa8eedfbb158f4fefe7">
<project name="platform_build" path="build" remote="b2g" revision="e935894ef5f27e2f04b9e929a45a958e6288a223">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c6705f739fb605031eb2a0b943ba55c64bee5a03"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="f6cde6b8a2af2d2cfa3ce9b7f4cda2daab9174a8"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="62cfa11ae7d77f6330de019a5aa79607e35be7d1"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

Просмотреть файл

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="05a36844c1046a1eb07d5b1325f85ed741f961ea">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c6705f739fb605031eb2a0b943ba55c64bee5a03"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="f6cde6b8a2af2d2cfa3ce9b7f4cda2daab9174a8"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="62cfa11ae7d77f6330de019a5aa79607e35be7d1"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

Просмотреть файл

@ -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="c6705f739fb605031eb2a0b943ba55c64bee5a03"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f6cde6b8a2af2d2cfa3ce9b7f4cda2daab9174a8"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="62cfa11ae7d77f6330de019a5aa79607e35be7d1"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="2d58f4b9206b50b8fda0d5036da6f0c62608db7c"/>

Просмотреть файл

@ -12,10 +12,10 @@
<!--original fetch url was https://git.mozilla.org/releases-->
<remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
<!-- B2G specific things. -->
<project name="platform_build" path="build" remote="b2g" revision="aacd9b12da7fc3c8f4deaaa8eedfbb158f4fefe7">
<project name="platform_build" path="build" remote="b2g" revision="e935894ef5f27e2f04b9e929a45a958e6288a223">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c6705f739fb605031eb2a0b943ba55c64bee5a03"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="f6cde6b8a2af2d2cfa3ce9b7f4cda2daab9174a8"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="62cfa11ae7d77f6330de019a5aa79607e35be7d1"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

Просмотреть файл

@ -1,9 +1,9 @@
{
"git": {
"git_revision": "c6705f739fb605031eb2a0b943ba55c64bee5a03",
"git_revision": "f6cde6b8a2af2d2cfa3ce9b7f4cda2daab9174a8",
"remote": "https://git.mozilla.org/releases/gaia.git",
"branch": ""
},
"revision": "69fd2d2a3adce973a5e86ea2f96d1e311e11239d",
"revision": "9b8b1ae55ed0ab8411fb71e451aa7cf58065985b",
"repo_path": "integration/gaia-central"
}

Просмотреть файл

@ -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="c6705f739fb605031eb2a0b943ba55c64bee5a03"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="f6cde6b8a2af2d2cfa3ce9b7f4cda2daab9174a8"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="62cfa11ae7d77f6330de019a5aa79607e35be7d1"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="bfdb6348725a33bdcdc4e17999cb500be6beedb5"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="a6f9a1245d98c51172c15afecb9ade1a6ca511e2"/>

Просмотреть файл

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="05a36844c1046a1eb07d5b1325f85ed741f961ea">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c6705f739fb605031eb2a0b943ba55c64bee5a03"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="f6cde6b8a2af2d2cfa3ce9b7f4cda2daab9174a8"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="62cfa11ae7d77f6330de019a5aa79607e35be7d1"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

Просмотреть файл

@ -1847,7 +1847,7 @@ public:
return rv;
}
/* Read connected */
rv = UnpackPDU(pdu, aArg3);
rv = UnpackPDU(pdu, UnpackConversion<int32_t, bool>(aArg3));
if (NS_FAILED(rv)) {
return rv;
}

Просмотреть файл

@ -14,14 +14,15 @@
#include "mozilla/dom/bluetooth/BluetoothCommon.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPtr.h"
#include "nsDataHashtable.h"
#include "nsIObserverService.h"
#include "nsThreadUtils.h"
#define ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(runnable) \
#define ENSURE_GATT_INTF_IS_READY_VOID(runnable) \
do { \
if (!sBluetoothGattInterface) { \
DispatchReplyError(runnable, \
NS_LITERAL_STRING("BluetoothGattClientInterface is not ready")); \
NS_LITERAL_STRING("BluetoothGattInterface is not ready")); \
return; \
} \
} while(0)
@ -29,6 +30,8 @@
using namespace mozilla;
USING_BLUETOOTH_NAMESPACE
class BluetoothGattServer;
namespace {
StaticRefPtr<BluetoothGattManager> sBluetoothGattManager;
static BluetoothGattInterface* sBluetoothGattInterface;
@ -37,6 +40,7 @@ namespace {
bool BluetoothGattManager::mInShutdown = false;
static StaticAutoPtr<nsTArray<nsRefPtr<BluetoothGattClient> > > sClients;
static StaticAutoPtr<nsTArray<nsRefPtr<BluetoothGattServer> > > sServers;
struct BluetoothGattClientReadCharState
{
@ -202,6 +206,32 @@ private:
NS_IMPL_ISUPPORTS0(BluetoothGattClient)
class BluetoothGattServer final : public nsISupports
{
public:
NS_DECL_ISUPPORTS
BluetoothGattServer(const nsAString& aAppUuid)
: mAppUuid(aAppUuid)
, mServerIf(0)
{ }
nsString mAppUuid;
int mServerIf;
nsRefPtr<BluetoothReplyRunnable> mConnectPeripheralRunnable;
nsRefPtr<BluetoothReplyRunnable> mDisconnectPeripheralRunnable;
nsRefPtr<BluetoothReplyRunnable> mUnregisterServerRunnable;
// Map connection id from device address
nsDataHashtable<nsStringHashKey, int> mConnectionMap;
private:
~BluetoothGattServer()
{ }
};
NS_IMPL_ISUPPORTS0(BluetoothGattServer)
class UuidComparator
{
public:
@ -210,9 +240,15 @@ public:
{
return aClient->mAppUuid.Equals(aAppUuid);
}
bool Equals(const nsRefPtr<BluetoothGattServer>& aServer,
const nsAString& aAppUuid) const
{
return aServer->mAppUuid.Equals(aAppUuid);
}
};
class ClientIfComparator
class InterfaceIdComparator
{
public:
bool Equals(const nsRefPtr<BluetoothGattClient>& aClient,
@ -220,6 +256,12 @@ public:
{
return aClient->mClientIf == aClientIf;
}
bool Equals(const nsRefPtr<BluetoothGattServer>& aServer,
int aServerIf) const
{
return aServer->mServerIf == aServerIf;
}
};
class ConnIdComparator
@ -305,6 +347,10 @@ BluetoothGattManager::InitGattInterface(BluetoothProfileResultHandler* aRes)
sClients = new nsTArray<nsRefPtr<BluetoothGattClient> >;
}
if (!sServers) {
sServers = new nsTArray<nsRefPtr<BluetoothGattServer> >;
}
BluetoothGattManager* gattManager = BluetoothGattManager::Get();
sBluetoothGattInterface->Init(gattManager,
new InitGattResultHandler(aRes));
@ -331,6 +377,7 @@ public:
{
sBluetoothGattInterface = nullptr;
sClients = nullptr;
sServers = nullptr;
if (mRes) {
mRes->Deinit();
@ -434,10 +481,8 @@ public:
NS_ENSURE_TRUE_VOID(bs);
// Notify BluetoothGatt to clear the clientIf
bs->DistributeSignal(
NS_LITERAL_STRING("ClientUnregistered"),
mClient->mAppUuid,
BluetoothValue(true));
bs->DistributeSignal(NS_LITERAL_STRING("ClientUnregistered"),
mClient->mAppUuid);
// Resolve the unregister request
DispatchReplySuccess(mClient->mUnregisterClientRunnable);
@ -469,10 +514,10 @@ BluetoothGattManager::UnregisterClient(int aClientIf,
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sClients->IndexOf(aClientIf, 0 /* Start */,
ClientIfComparator());
InterfaceIdComparator());
if (NS_WARN_IF(index == sClients->NoIndex)) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
@ -569,7 +614,7 @@ BluetoothGattManager::StartLeScan(const nsTArray<nsString>& aServiceUuids,
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
nsString appUuidStr;
GenerateUuid(appUuidStr);
@ -603,7 +648,7 @@ BluetoothGattManager::StopLeScan(const nsAString& aScanUuid,
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sClients->IndexOf(aScanUuid, 0 /* Start */, UuidComparator());
if (NS_WARN_IF(index == sClients->NoIndex)) {
@ -662,7 +707,7 @@ BluetoothGattManager::Connect(const nsAString& aAppUuid,
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sClients->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
if (index == sClients->NoIndex) {
@ -732,7 +777,7 @@ BluetoothGattManager::Disconnect(const nsAString& aAppUuid,
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sClients->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
if (NS_WARN_IF(index == sClients->NoIndex)) {
@ -779,7 +824,7 @@ BluetoothGattManager::Discover(const nsAString& aAppUuid,
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sClients->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
if (NS_WARN_IF(index == sClients->NoIndex)) {
@ -850,10 +895,10 @@ BluetoothGattManager::ReadRemoteRssi(int aClientIf,
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sClients->IndexOf(aClientIf, 0 /* Start */,
ClientIfComparator());
InterfaceIdComparator());
if (NS_WARN_IF(index == sClients->NoIndex)) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
@ -918,7 +963,7 @@ BluetoothGattManager::RegisterNotifications(
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sClients->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
if (NS_WARN_IF(index == sClients->NoIndex)) {
@ -994,7 +1039,7 @@ BluetoothGattManager::DeregisterNotifications(
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sClients->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
if (NS_WARN_IF(index == sClients->NoIndex)) {
@ -1057,7 +1102,7 @@ BluetoothGattManager::ReadCharacteristicValue(
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sClients->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
if (NS_WARN_IF(index == sClients->NoIndex)) {
@ -1137,7 +1182,7 @@ BluetoothGattManager::WriteCharacteristicValue(
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sClients->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
if (NS_WARN_IF(index == sClients->NoIndex)) {
@ -1219,7 +1264,7 @@ BluetoothGattManager::ReadDescriptorValue(
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sClients->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
if (NS_WARN_IF(index == sClients->NoIndex)) {
@ -1300,7 +1345,7 @@ BluetoothGattManager::WriteDescriptorValue(
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sClients->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
if (NS_WARN_IF(index == sClients->NoIndex)) {
@ -1342,6 +1387,278 @@ BluetoothGattManager::WriteDescriptorValue(
new WriteDescriptorValueResultHandler(client));
}
class BluetoothGattManager::RegisterServerResultHandler final
: public BluetoothGattResultHandler
{
public:
RegisterServerResultHandler(BluetoothGattServer* aServer)
: mServer(aServer)
{
MOZ_ASSERT(mServer);
}
void OnError(BluetoothStatus aStatus) override
{
BT_WARNING("BluetoothGattServerInterface::RegisterServer failed: %d",
(int)aStatus);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
// Reject the connect request
if (mServer->mConnectPeripheralRunnable) {
DispatchReplyError(mServer->mConnectPeripheralRunnable,
NS_LITERAL_STRING("Register GATT server failed"));
mServer->mConnectPeripheralRunnable = nullptr;
}
sServers->RemoveElement(mServer);
}
private:
nsRefPtr<BluetoothGattServer> mServer;
};
class BluetoothGattManager::ConnectPeripheralResultHandler final
: public BluetoothGattResultHandler
{
public:
ConnectPeripheralResultHandler(BluetoothGattServer* aServer,
const nsAString& aDeviceAddr)
: mServer(aServer)
, mDeviceAddr(aDeviceAddr)
{
MOZ_ASSERT(mServer);
MOZ_ASSERT(!mDeviceAddr.IsEmpty());
}
void OnError(BluetoothStatus aStatus) override
{
BT_WARNING("BluetoothGattServerInterface::ConnectPeripheral failed: %d",
(int)aStatus);
MOZ_ASSERT(mServer->mConnectPeripheralRunnable);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
DispatchReplyError(mServer->mConnectPeripheralRunnable,
NS_LITERAL_STRING("ConnectPeripheral failed"));
mServer->mConnectPeripheralRunnable = nullptr;
mServer->mConnectionMap.Remove(mDeviceAddr);
}
private:
nsRefPtr<BluetoothGattServer> mServer;
nsString mDeviceAddr;
};
void
BluetoothGattManager::ConnectPeripheral(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sServers->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
if (index == sServers->NoIndex) {
index = sServers->Length();
sServers->AppendElement(new BluetoothGattServer(aAppUuid));
}
nsRefPtr<BluetoothGattServer> server = (*sServers)[index];
/**
* Early resolve or reject the request based on the current status before
* sending a request to bluetooth stack.
*
* case 1) Connecting/Disconnecting: If connect/disconnect peripheral
* runnable exists, reject the request since the local GATT server is
* busy connecting or disconnecting to a device.
* case 2) Connected: If there is an entry whose key is |aAddress| in the
* connection map, resolve the request. Since disconnected devices
* will not be in the map, all entries in the map are connected
* devices.
*/
if (server->mConnectPeripheralRunnable ||
server->mDisconnectPeripheralRunnable) {
DispatchReplyError(aRunnable, STATUS_BUSY);
return;
}
int connId = 0;
if (server->mConnectionMap.Get(aAddress, &connId)) {
MOZ_ASSERT(connId > 0);
DispatchReplySuccess(aRunnable);
return;
}
server->mConnectionMap.Put(aAddress, 0);
server->mConnectPeripheralRunnable = aRunnable;
if (server->mServerIf > 0) {
sBluetoothGattInterface->ConnectPeripheral(
server->mServerIf,
aAddress,
true, // direct connect
TRANSPORT_AUTO,
new ConnectPeripheralResultHandler(server, aAddress));
} else {
BluetoothUuid uuid;
StringToUuid(NS_ConvertUTF16toUTF8(aAppUuid).get(), uuid);
// connect will be proceeded after server registered
sBluetoothGattInterface->RegisterServer(
uuid, new RegisterServerResultHandler(server));
}
}
class BluetoothGattManager::DisconnectPeripheralResultHandler final
: public BluetoothGattResultHandler
{
public:
DisconnectPeripheralResultHandler(BluetoothGattServer* aServer)
: mServer(aServer)
{
MOZ_ASSERT(mServer);
}
void OnError(BluetoothStatus aStatus) override
{
BT_WARNING("BluetoothGattServerInterface::DisconnectPeripheral failed: %d",
(int)aStatus);
MOZ_ASSERT(mServer->mDisconnectPeripheralRunnable);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
// Reject the disconnect request
DispatchReplyError(mServer->mDisconnectPeripheralRunnable,
NS_LITERAL_STRING("DisconnectPeripheral failed"));
mServer->mDisconnectPeripheralRunnable = nullptr;
}
private:
nsRefPtr<BluetoothGattServer> mServer;
};
void
BluetoothGattManager::DisconnectPeripheral(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sServers->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
if (NS_WARN_IF(index == sServers->NoIndex)) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
nsRefPtr<BluetoothGattServer> server = (*sServers)[index];
if (NS_WARN_IF(server->mServerIf <= 0)) {
DispatchReplyError(aRunnable,
NS_LITERAL_STRING("Disconnect failed"));
return;
}
// Reject the request if there is an ongoing connect/disconnect request.
if (server->mConnectPeripheralRunnable ||
server->mDisconnectPeripheralRunnable) {
DispatchReplyError(aRunnable, STATUS_BUSY);
return;
}
// Resolve the request if the device is not connected.
int connId = 0;
if (!server->mConnectionMap.Get(aAddress, &connId)) {
DispatchReplySuccess(aRunnable);
return;
}
server->mDisconnectPeripheralRunnable = aRunnable;
sBluetoothGattInterface->DisconnectPeripheral(
server->mServerIf,
aAddress,
connId,
new DisconnectPeripheralResultHandler(server));
}
class BluetoothGattManager::UnregisterServerResultHandler final
: public BluetoothGattResultHandler
{
public:
UnregisterServerResultHandler(BluetoothGattServer* aServer)
: mServer(aServer)
{
MOZ_ASSERT(mServer);
}
void UnregisterServer() override
{
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
// Notify BluetoothGattServer to clear the serverIf
bs->DistributeSignal(NS_LITERAL_STRING("ServerUnregistered"),
mServer->mAppUuid);
// Resolve the unregister request
if (mServer->mUnregisterServerRunnable) {
DispatchReplySuccess(mServer->mUnregisterServerRunnable);
mServer->mUnregisterServerRunnable = nullptr;
}
sServers->RemoveElement(mServer);
}
void OnError(BluetoothStatus aStatus) override
{
BT_WARNING("BluetoothGattServerInterface::UnregisterServer failed: %d",
(int)aStatus);
// Reject the unregister request
if (mServer->mUnregisterServerRunnable) {
DispatchReplyError(mServer->mUnregisterServerRunnable,
NS_LITERAL_STRING("Unregister GATT Server failed"));
mServer->mUnregisterServerRunnable = nullptr;
}
}
private:
nsRefPtr<BluetoothGattServer> mServer;
};
void
BluetoothGattManager::UnregisterServer(int aServerIf,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
ENSURE_GATT_INTF_IS_READY_VOID(aRunnable);
size_t index = sServers->IndexOf(aServerIf, 0 /* Start */,
InterfaceIdComparator());
if (NS_WARN_IF(index == sServers->NoIndex)) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
nsRefPtr<BluetoothGattServer> server = (*sServers)[index];
server->mUnregisterServerRunnable = aRunnable;
sBluetoothGattInterface->UnregisterServer(
aServerIf,
new UnregisterServerResultHandler(server));
}
//
// Notification Handlers
//
@ -1486,7 +1803,7 @@ BluetoothGattManager::ConnectNotification(int aConnId,
NS_ENSURE_TRUE_VOID(bs);
size_t index = sClients->IndexOf(aClientIf, 0 /* Start */,
ClientIfComparator());
InterfaceIdComparator());
NS_ENSURE_TRUE_VOID(index != sClients->NoIndex);
nsRefPtr<BluetoothGattClient> client = sClients->ElementAt(index);
@ -1538,7 +1855,7 @@ BluetoothGattManager::DisconnectNotification(int aConnId,
NS_ENSURE_TRUE_VOID(bs);
size_t index = sClients->IndexOf(aClientIf, 0 /* Start */,
ClientIfComparator());
InterfaceIdComparator());
NS_ENSURE_TRUE_VOID(index != sClients->NoIndex);
nsRefPtr<BluetoothGattClient> client = sClients->ElementAt(index);
@ -2064,7 +2381,7 @@ BluetoothGattManager::ReadRemoteRssiNotification(int aClientIf,
NS_ENSURE_TRUE_VOID(bs);
size_t index = sClients->IndexOf(aClientIf, 0 /* Start */,
ClientIfComparator());
InterfaceIdComparator());
NS_ENSURE_TRUE_VOID(index != sClients->NoIndex);
nsRefPtr<BluetoothGattClient> client = sClients->ElementAt(index);
@ -2097,6 +2414,110 @@ BluetoothGattManager::ListenNotification(BluetoothGattStatus aStatus,
int aServerIf)
{ }
void
BluetoothGattManager::RegisterServerNotification(BluetoothGattStatus aStatus,
int aServerIf,
const BluetoothUuid& aAppUuid)
{
MOZ_ASSERT(NS_IsMainThread());
nsString uuid;
UuidToString(aAppUuid, uuid);
size_t index = sServers->IndexOf(uuid, 0 /* Start */, UuidComparator());
NS_ENSURE_TRUE_VOID(index != sServers->NoIndex);
nsRefPtr<BluetoothGattServer> server = (*sServers)[index];
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
if (aStatus != GATT_STATUS_SUCCESS) {
BT_LOGD("RegisterServer failed: serverIf = %d, status = %d, appUuid = %s",
aServerIf, aStatus, NS_ConvertUTF16toUTF8(uuid).get());
if (server->mConnectPeripheralRunnable) {
// Reject the connect peripheral request
DispatchReplyError(
server->mConnectPeripheralRunnable,
NS_LITERAL_STRING(
"ConnectPeripheral failed due to registration failed"));
server->mConnectPeripheralRunnable = nullptr;
}
sServers->RemoveElement(server);
}
server->mServerIf = aServerIf;
// Notify BluetoothGattServer to update the serverIf
bs->DistributeSignal(
NS_LITERAL_STRING("ServerRegistered"),
uuid, BluetoothValue(uint32_t(aServerIf)));
if (server->mConnectPeripheralRunnable) {
// Only one entry exists in the map during first connect peripheral request
nsString deviceAddr(server->mConnectionMap.Iter().Key());
sBluetoothGattInterface->ConnectPeripheral(
aServerIf, deviceAddr, true /* direct connect */, TRANSPORT_AUTO,
new ConnectPeripheralResultHandler(server, deviceAddr));
}
}
void
BluetoothGattManager::ConnectionNotification(int aConnId,
int aServerIf,
bool aConnected,
const nsAString& aBdAddr)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
size_t index = sServers->IndexOf(aServerIf, 0 /* Start */,
InterfaceIdComparator());
NS_ENSURE_TRUE_VOID(index != sServers->NoIndex);
nsRefPtr<BluetoothGattServer> server = (*sServers)[index];
// Update the connection map based on the connection status
if (aConnected) {
server->mConnectionMap.Put(aBdAddr, aConnId);
} else {
server->mConnectionMap.Remove(aBdAddr);
}
// Notify BluetoothGattServer that connection status changed
InfallibleTArray<BluetoothNamedValue> props;
BT_APPEND_NAMED_VALUE(props, "Connected", aConnected);
BT_APPEND_NAMED_VALUE(props, "Address", nsString(aBdAddr));
bs->DistributeSignal(
NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
server->mAppUuid,
BluetoothValue(props));
// Resolve or reject connect/disconnect peripheral requests
if (server->mConnectPeripheralRunnable) {
if (aConnected) {
DispatchReplySuccess(server->mConnectPeripheralRunnable);
} else {
DispatchReplyError(server->mConnectPeripheralRunnable,
NS_LITERAL_STRING("ConnectPeripheral failed"));
}
server->mConnectPeripheralRunnable = nullptr;
} else if (server->mDisconnectPeripheralRunnable) {
if (!aConnected) {
DispatchReplySuccess(server->mDisconnectPeripheralRunnable);
} else {
DispatchReplyError(server->mDisconnectPeripheralRunnable,
NS_LITERAL_STRING("DisconnectPeripheral failed"));
}
server->mDisconnectPeripheralRunnable = nullptr;
}
}
BluetoothGattManager::BluetoothGattManager()
{ }
@ -2132,6 +2553,7 @@ BluetoothGattManager::HandleShutdown()
mInShutdown = true;
sBluetoothGattManager = nullptr;
sClients = nullptr;
sServers = nullptr;
}
void

Просмотреть файл

@ -90,6 +90,19 @@ public:
const nsTArray<uint8_t>& aValue,
BluetoothReplyRunnable* aRunnable);
void ConnectPeripheral(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable);
void DisconnectPeripheral(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable);
void UnregisterServer(int aServerIf,
BluetoothReplyRunnable* aRunnable);
private:
~BluetoothGattManager();
@ -112,6 +125,11 @@ private:
class WriteDescriptorValueResultHandler;
class ScanDeviceTypeResultHandler;
class RegisterServerResultHandler;
class ConnectPeripheralResultHandler;
class DisconnectPeripheralResultHandler;
class UnregisterServerResultHandler;
BluetoothGattManager();
void HandleShutdown();
@ -200,6 +218,15 @@ private:
void ProceedDiscoverProcess(BluetoothGattClient* aClient,
const BluetoothGattServiceId& aServiceId);
void RegisterServerNotification(BluetoothGattStatus aStatus,
int aServerIf,
const BluetoothUuid& aAppUuid) override;
void ConnectionNotification(int aConnId,
int aServerIf,
bool aConnected,
const nsAString& aBdAddr) override;
static bool mInShutdown;
};

Просмотреть файл

@ -552,6 +552,51 @@ BluetoothServiceBluedroid::GattClientWriteDescriptorValueInternal(
aDescriptorId, aValue, aRunnable);
}
// GATT Server
void
BluetoothServiceBluedroid::GattServerConnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
BluetoothGattManager* gatt = BluetoothGattManager::Get();
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
gatt->ConnectPeripheral(aAppUuid, aAddress, aRunnable);
}
void
BluetoothServiceBluedroid::GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
BluetoothGattManager* gatt = BluetoothGattManager::Get();
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
gatt->DisconnectPeripheral(aAppUuid, aAddress, aRunnable);
}
void
BluetoothServiceBluedroid::UnregisterGattServerInternal(
int aServerIf, BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
BluetoothGattManager* gatt = BluetoothGattManager::Get();
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
gatt->UnregisterServer(aServerIf, aRunnable);
}
nsresult
BluetoothServiceBluedroid::GetAdaptersInternal(
BluetoothReplyRunnable* aRunnable)

Просмотреть файл

@ -259,6 +259,22 @@ public:
const nsTArray<uint8_t>& aValue,
BluetoothReplyRunnable* aRunnable) override;
virtual void
GattServerConnectPeripheralInternal(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) override;
virtual void
GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) override;
virtual void
UnregisterGattServerInternal(int aServerIf,
BluetoothReplyRunnable* aRunnable) override;
//
// Bluetooth notifications
//

Просмотреть файл

@ -23,7 +23,6 @@ NS_IMPL_RELEASE_INHERITED(BluetoothDiscoveryHandle, DOMEventTargetHelper)
BluetoothDiscoveryHandle::BluetoothDiscoveryHandle(nsPIDOMWindow* aWindow)
: DOMEventTargetHelper(aWindow)
, mLeScanUuid(EmptyString())
{
MOZ_ASSERT(aWindow);
}

Просмотреть файл

@ -51,7 +51,6 @@ NS_IMPL_RELEASE_INHERITED(BluetoothGatt, DOMEventTargetHelper)
BluetoothGatt::BluetoothGatt(nsPIDOMWindow* aWindow,
const nsAString& aDeviceAddr)
: DOMEventTargetHelper(aWindow)
, mAppUuid(EmptyString())
, mClientIf(0)
, mConnectionState(BluetoothConnectionState::Disconnected)
, mDeviceAddr(aDeviceAddr)

Просмотреть файл

@ -6,32 +6,91 @@
#include "BluetoothGattServer.h"
#include "BluetoothReplyRunnable.h"
#include "BluetoothService.h"
#include "BluetoothUtils.h"
#include "mozilla/dom/BluetoothStatusChangedEvent.h"
#include "mozilla/dom/Promise.h"
using namespace mozilla;
using namespace mozilla::dom;
USING_BLUETOOTH_NAMESPACE
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(BluetoothGattServer,
mOwner)
NS_IMPL_CYCLE_COLLECTION_CLASS(BluetoothGattServer)
NS_IMPL_CYCLE_COLLECTING_ADDREF(BluetoothGattServer)
NS_IMPL_CYCLE_COLLECTING_RELEASE(BluetoothGattServer)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BluetoothGattServer)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BluetoothGattServer,
DOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner)
/**
* Unregister the bluetooth signal handler after unlinked.
*
* This is needed to avoid ending up with exposing a deleted object to JS or
* accessing deleted objects while receiving signals from parent process
* after unlinked. Please see Bug 1138267 for detail informations.
*/
UnregisterBluetoothSignalHandler(tmp->mAppUuid, tmp);
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BluetoothGattServer,
DOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothGattServer)
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(BluetoothGattServer, DOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(BluetoothGattServer, DOMEventTargetHelper)
BluetoothGattServer::BluetoothGattServer(nsPIDOMWindow* aOwner)
: mOwner(aOwner)
, mServerIf(0)
, mValid(true)
{
}
{ }
BluetoothGattServer::~BluetoothGattServer()
{
Invalidate();
}
void
BluetoothGattServer::Notify(const BluetoothSignal& aData)
{
BT_LOGD("[GattServer] %s", NS_ConvertUTF16toUTF8(aData.name()).get());
NS_ENSURE_TRUE_VOID(mSignalRegistered);
BluetoothValue v = aData.value();
if (aData.name().EqualsLiteral("ServerRegistered")) {
MOZ_ASSERT(v.type() == BluetoothValue::Tuint32_t);
mServerIf = v.get_uint32_t();
} else if (aData.name().EqualsLiteral("ServerUnregistered")) {
mServerIf = 0;
} else if (aData.name().EqualsLiteral(GATT_CONNECTION_STATE_CHANGED_ID)) {
MOZ_ASSERT(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
const InfallibleTArray<BluetoothNamedValue>& arr =
v.get_ArrayOfBluetoothNamedValue();
MOZ_ASSERT(arr.Length() == 2 &&
arr[0].value().type() == BluetoothValue::Tbool &&
arr[1].value().type() == BluetoothValue::TnsString);
BluetoothStatusChangedEventInit init;
init.mStatus = arr[0].value().get_bool();
init.mAddress = arr[1].value().get_nsString();
nsRefPtr<BluetoothStatusChangedEvent> event =
BluetoothStatusChangedEvent::Constructor(
this, NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID), init);
DispatchTrustedEvent(event);
} else {
BT_WARNING("Not handling GATT signal: %s",
NS_ConvertUTF16toUTF8(aData.name()).get());
}
}
JSObject*
BluetoothGattServer::WrapObject(JSContext* aContext,
JS::Handle<JSObject*> aGivenProto)
@ -39,12 +98,76 @@ BluetoothGattServer::WrapObject(JSContext* aContext,
return BluetoothGattServerBinding::Wrap(aContext, this, aGivenProto);
}
void
BluetoothGattServer::DisconnectFromOwner()
{
DOMEventTargetHelper::DisconnectFromOwner();
Invalidate();
}
void
BluetoothGattServer::Invalidate()
{
mValid = false;
/* TODO: add tear down stuff here */
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
return;
if (mServerIf > 0) {
bs->UnregisterGattServerInternal(mServerIf, nullptr);
}
UnregisterBluetoothSignalHandler(mAppUuid, this);
}
already_AddRefed<Promise>
BluetoothGattServer::Connect(const nsAString& aAddress, ErrorResult& aRv)
{
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
if (!global) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
BluetoothService* bs = BluetoothService::Get();
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
if (mAppUuid.IsEmpty()) {
GenerateUuid(mAppUuid);
BT_ENSURE_TRUE_REJECT(!mAppUuid.IsEmpty(),
promise,
NS_ERROR_DOM_OPERATION_ERR);
RegisterBluetoothSignalHandler(mAppUuid, this);
}
bs->GattServerConnectPeripheralInternal(
mAppUuid, aAddress, new BluetoothVoidReplyRunnable(nullptr, promise));
return promise.forget();
}
already_AddRefed<Promise>
BluetoothGattServer::Disconnect(const nsAString& aAddress, ErrorResult& aRv)
{
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
if (!global) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
BluetoothService* bs = BluetoothService::Get();
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
bs->GattServerDisconnectPeripheralInternal(
mAppUuid, aAddress, new BluetoothVoidReplyRunnable(nullptr, promise));
return promise.forget();
}

Просмотреть файл

@ -7,20 +7,29 @@
#ifndef mozilla_dom_bluetooth_BluetoothGattServer_h
#define mozilla_dom_bluetooth_BluetoothGattServer_h
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/BluetoothGattServerBinding.h"
#include "mozilla/dom/bluetooth/BluetoothCommon.h"
#include "nsCOMPtr.h"
#include "nsPIDOMWindow.h"
#include "nsWrapperCache.h"
namespace mozilla {
namespace dom {
class Promise;
}
}
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothGattServer final : public nsISupports
, public nsWrapperCache
class BluetoothSignal;
class BluetoothGattServer final : public DOMEventTargetHelper
, public BluetoothSignalObserver
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(BluetoothGattServer)
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BluetoothGattServer,
DOMEventTargetHelper)
/****************************************************************************
* Attribute Getters
@ -29,14 +38,21 @@ public:
/****************************************************************************
* Event Handlers
***************************************************************************/
IMPL_EVENT_HANDLER(connectionstatechanged);
/****************************************************************************
* Methods (Web API Implementation)
***************************************************************************/
already_AddRefed<Promise> Connect(
const nsAString& aAddress, ErrorResult& aRv);
already_AddRefed<Promise> Disconnect(
const nsAString& aAddress, ErrorResult& aRv);
/****************************************************************************
* Others
***************************************************************************/
void Notify(const BluetoothSignal& aData); // BluetoothSignalObserver
nsPIDOMWindow* GetParentObject() const
{
return mOwner;
@ -45,6 +61,7 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
virtual void DisconnectFromOwner() override;
BluetoothGattServer(nsPIDOMWindow* aOwner);
/* Invalidate the GATT server.
@ -61,6 +78,17 @@ private:
***************************************************************************/
nsCOMPtr<nsPIDOMWindow> mOwner;
/**
* Random generated UUID of this GATT client.
*/
nsString mAppUuid;
/**
* Id of the GATT server interface given by bluetooth stack.
* 0 if the interface is not registered yet, nonzero otherwise.
*/
int mServerIf;
bool mValid;
};

Просмотреть файл

@ -458,6 +458,25 @@ public:
const nsTArray<uint8_t>& aValue,
BluetoothReplyRunnable* aRunnable) = 0;
virtual void
GattServerConnectPeripheralInternal(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) = 0;
virtual void
GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) = 0;
/**
* Unregister a GATT server. (platform specific implementation)
*/
virtual void
UnregisterGattServerInternal(int aServerIf,
BluetoothReplyRunnable* aRunnable) = 0;
bool
IsEnabled() const
{

Просмотреть файл

@ -286,6 +286,14 @@ BluetoothParent::RecvPBluetoothRequestConstructor(
case Request::TGattClientWriteDescriptorValueRequest:
return actor->DoRequest(
aRequest.get_GattClientWriteDescriptorValueRequest());
case Request::TGattServerConnectPeripheralRequest:
return actor->DoRequest(
aRequest.get_GattServerConnectPeripheralRequest());
case Request::TGattServerDisconnectPeripheralRequest:
return actor->DoRequest(
aRequest.get_GattServerDisconnectPeripheralRequest());
case Request::TUnregisterGattServerRequest:
return actor->DoRequest(aRequest.get_UnregisterGattServerRequest());
default:
MOZ_CRASH("Unknown type!");
}
@ -929,3 +937,45 @@ BluetoothRequestParent::DoRequest(
return true;
}
bool
BluetoothRequestParent::DoRequest(
const GattServerConnectPeripheralRequest& aRequest)
{
MOZ_ASSERT(mService);
MOZ_ASSERT(mRequestType ==
Request::TGattServerConnectPeripheralRequest);
mService->GattServerConnectPeripheralInternal(aRequest.appUuid(),
aRequest.address(),
mReplyRunnable.get());
return true;
}
bool
BluetoothRequestParent::DoRequest(
const GattServerDisconnectPeripheralRequest& aRequest)
{
MOZ_ASSERT(mService);
MOZ_ASSERT(mRequestType ==
Request::TGattServerDisconnectPeripheralRequest);
mService->GattServerDisconnectPeripheralInternal(aRequest.appUuid(),
aRequest.address(),
mReplyRunnable.get());
return true;
}
bool
BluetoothRequestParent::DoRequest(const UnregisterGattServerRequest& aRequest)
{
MOZ_ASSERT(mService);
MOZ_ASSERT(mRequestType == Request::TUnregisterGattServerRequest);
mService->UnregisterGattServerInternal(aRequest.serverIf(),
mReplyRunnable.get());
return true;
}

Просмотреть файл

@ -261,6 +261,15 @@ protected:
bool
DoRequest(const GattClientWriteDescriptorValueRequest& aRequest);
bool
DoRequest(const GattServerConnectPeripheralRequest& aRequest);
bool
DoRequest(const GattServerDisconnectPeripheralRequest& aRequest);
bool
DoRequest(const UnregisterGattServerRequest& aRequest);
};
END_BLUETOOTH_NAMESPACE

Просмотреть файл

@ -538,6 +538,35 @@ BluetoothServiceChildProcess::GattClientWriteDescriptorValueInternal(
aValue));
}
void
BluetoothServiceChildProcess::GattServerConnectPeripheralInternal(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable)
{
SendRequest(aRunnable,
GattServerConnectPeripheralRequest(nsString(aAppUuid),
nsString(aAddress)));
}
void
BluetoothServiceChildProcess::GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable)
{
SendRequest(aRunnable,
GattServerDisconnectPeripheralRequest(nsString(aAppUuid),
nsString(aAddress)));
}
void
BluetoothServiceChildProcess::UnregisterGattServerInternal(
int aServerIf, BluetoothReplyRunnable* aRunnable)
{
SendRequest(aRunnable, UnregisterGattServerRequest(aServerIf));
}
nsresult
BluetoothServiceChildProcess::HandleStartup()
{

Просмотреть файл

@ -267,6 +267,22 @@ public:
const nsTArray<uint8_t>& aValue,
BluetoothReplyRunnable* aRunnable);
virtual void
GattServerConnectPeripheralInternal(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable);
virtual void
GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable);
virtual void
UnregisterGattServerInternal(int aServerIf,
BluetoothReplyRunnable* aRunnable) override;
protected:
BluetoothServiceChildProcess();
virtual ~BluetoothServiceChildProcess();

Просмотреть файл

@ -275,6 +275,23 @@ struct GattClientWriteDescriptorValueRequest
uint8_t[] value;
};
struct GattServerConnectPeripheralRequest
{
nsString appUuid;
nsString address;
};
struct GattServerDisconnectPeripheralRequest
{
nsString appUuid;
nsString address;
};
struct UnregisterGattServerRequest
{
int serverIf;
};
union Request
{
GetAdaptersRequest;
@ -322,6 +339,9 @@ union Request
GattClientWriteCharacteristicValueRequest;
GattClientReadDescriptorValueRequest;
GattClientWriteDescriptorValueRequest;
GattServerConnectPeripheralRequest;
GattServerDisconnectPeripheralRequest;
UnregisterGattServerRequest;
};
protocol PBluetooth

Просмотреть файл

@ -4378,3 +4378,23 @@ BluetoothDBusService::GattClientWriteDescriptorValueInternal(
BluetoothReplyRunnable* aRunnable)
{
}
void
BluetoothDBusService::GattServerConnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable)
{
}
void
BluetoothDBusService::GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable)
{
}
void
BluetoothDBusService::UnregisterGattServerInternal(
int aServerIf, BluetoothReplyRunnable* aRunnable)
{
}

Просмотреть файл

@ -274,6 +274,22 @@ public:
const nsTArray<uint8_t>& aValue,
BluetoothReplyRunnable* aRunnable) override;
virtual void
GattServerConnectPeripheralInternal(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) override;
virtual void
GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid,
const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) override;
virtual void
UnregisterGattServerInternal(int aServerIf,
BluetoothReplyRunnable* aRunnable) override;
private:
nsresult SendGetPropertyMessage(const nsAString& aPath,
const char* aInterface,

Просмотреть файл

@ -6,6 +6,7 @@
#include "base/basictypes.h"
#include "mozilla/Assertions.h"
#include "mozilla/unused.h"
#include "nsPrintfCString.h"
#include "nsIWeakReferenceUtils.h"
#include "CameraCommon.h"
#include "nsGlobalWindow.h"

Просмотреть файл

@ -145,7 +145,13 @@ nsGonkCameraControl::StartInternal(const Configuration* aInitialConfig)
}
if (aInitialConfig) {
rv = SetConfigurationInternal(*aInitialConfig);
Configuration config;
rv = ValidateConfiguration(*aInitialConfig, config);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = SetConfigurationInternal(config);
if (NS_WARN_IF(NS_FAILED(rv))) {
// The initial configuration failed, close up the hardware
StopInternal();
@ -183,6 +189,8 @@ nsGonkCameraControl::Initialize()
DOM_CAMERA_LOGI("Initializing camera %d (this=%p, mCameraHw=%p)\n", mCameraId, this, mCameraHw.get());
mCurrentConfiguration.mRecorderProfile.Truncate();
mRequestedPreviewSize.width = UINT32_MAX;
mRequestedPreviewSize.height = UINT32_MAX;
// Initialize our camera configuration database.
mCameraHw->PullParameters(mParams);
@ -321,9 +329,19 @@ nsGonkCameraControl::ValidateConfiguration(const Configuration& aConfig, Configu
return NS_ERROR_INVALID_ARG;
}
if (mCurrentConfiguration.mMode == aConfig.mMode &&
mRequestedPreviewSize.width == aConfig.mPreviewSize.width &&
mRequestedPreviewSize.height == aConfig.mPreviewSize.height &&
mCurrentConfiguration.mRecorderProfile.Equals(profile->GetName()))
{
DOM_CAMERA_LOGI("Camera configuration is unchanged\n");
return NS_ERROR_ALREADY_INITIALIZED;
}
aValidatedConfig.mMode = aConfig.mMode;
aValidatedConfig.mPreviewSize = aConfig.mPreviewSize;
aValidatedConfig.mRecorderProfile = profile->GetName();
mRequestedPreviewSize = aConfig.mPreviewSize;
return NS_OK;
}
@ -332,53 +350,46 @@ nsGonkCameraControl::SetConfigurationInternal(const Configuration& aConfig)
{
DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
// Ensure sanity of all provided parameters and determine defaults if
// none are provided when given a new configuration
Configuration config;
nsresult rv = ValidateConfiguration(aConfig, config);
ICameraControlParameterSetAutoEnter set(this);
nsresult rv;
switch (aConfig.mMode) {
case kPictureMode:
rv = SetPictureConfiguration(aConfig);
break;
case kVideoMode:
rv = SetVideoConfiguration(aConfig);
break;
default:
MOZ_ASSERT_UNREACHABLE("Unanticipated camera mode in SetConfigurationInternal()");
rv = NS_ERROR_FAILURE;
break;
}
DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
if (NS_WARN_IF(NS_FAILED(rv))) {
mRequestedPreviewSize.width = UINT32_MAX;
mRequestedPreviewSize.height = UINT32_MAX;
return rv;
}
{
ICameraControlParameterSetAutoEnter set(this);
rv = Set(CAMERA_PARAM_RECORDINGHINT, aConfig.mMode == kVideoMode);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Failed to set recording hint (0x%x)\n", rv);
}
switch (config.mMode) {
case kPictureMode:
rv = SetPictureConfiguration(config);
break;
mCurrentConfiguration.mMode = aConfig.mMode;
mCurrentConfiguration.mRecorderProfile = aConfig.mRecorderProfile;
case kVideoMode:
rv = SetVideoConfiguration(config);
break;
default:
MOZ_ASSERT_UNREACHABLE("Unanticipated camera mode in SetConfigurationInternal()");
rv = NS_ERROR_FAILURE;
break;
}
DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = Set(CAMERA_PARAM_RECORDINGHINT, config.mMode == kVideoMode);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Failed to set recording hint (0x%x)\n", rv);
}
mCurrentConfiguration.mMode = config.mMode;
mCurrentConfiguration.mRecorderProfile = config.mRecorderProfile;
if (config.mMode == kPictureMode) {
mCurrentConfiguration.mPictureSize = config.mPictureSize;
} else /* if config.mMode == kVideoMode */ {
// The following is best-effort; we don't currently support taking
// pictures while in video mode, but we should at least return
// sane values to OnConfigurationChange() handlers...
SetPictureSizeImpl(config.mPictureSize);
}
if (aConfig.mMode == kPictureMode) {
mCurrentConfiguration.mPictureSize = aConfig.mPictureSize;
} else /* if config.mMode == kVideoMode */ {
// The following is best-effort; we don't currently support taking
// pictures while in video mode, but we should at least return
// sane values to OnConfigurationChange() handlers...
SetPictureSizeImpl(aConfig.mPictureSize);
}
return NS_OK;
}
@ -394,8 +405,19 @@ nsGonkCameraControl::SetConfigurationImpl(const Configuration& aConfig)
return NS_ERROR_INVALID_ARG;
}
Configuration config;
nsresult rv = ValidateConfiguration(aConfig, config);
if (rv == NS_ERROR_ALREADY_INITIALIZED) {
// Configuration did not change, so no need to stop/start the preview
// or push parameters to the camera hardware
OnConfigurationChange();
return NS_OK;
} else if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// Stop any currently running preview
nsresult rv = PausePreview();
rv = PausePreview();
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGW("PausePreview() in SetConfigurationImpl() failed (0x%x)\n", rv);
if (rv == NS_ERROR_NOT_INITIALIZED) {
@ -406,7 +428,7 @@ nsGonkCameraControl::SetConfigurationImpl(const Configuration& aConfig)
}
DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
rv = SetConfigurationInternal(aConfig);
rv = SetConfigurationInternal(config);
if (NS_WARN_IF(NS_FAILED(rv))) {
StopPreviewImpl();
return rv;

Просмотреть файл

@ -179,6 +179,7 @@ protected:
Size mLastThumbnailSize;
Size mLastRecorderSize;
Size mRequestedPreviewSize;
uint32_t mPreviewFps;
bool mResumePreviewAfterTakingPicture;
bool mFlashSupported;

Просмотреть файл

@ -66,6 +66,22 @@ nsVolume::nsVolume(const Volume* aVolume)
{
}
nsVolume::nsVolume(const nsVolume* aVolume)
: mName(aVolume->mName),
mMountPoint(aVolume->mMountPoint),
mState(aVolume->mState),
mMountGeneration(aVolume->mMountGeneration),
mMountLocked(aVolume->mMountLocked),
mIsFake(aVolume->mIsFake),
mIsMediaPresent(aVolume->mIsMediaPresent),
mIsSharing(aVolume->mIsSharing),
mIsFormatting(aVolume->mIsFormatting),
mIsUnmounting(aVolume->mIsUnmounting),
mIsRemovable(aVolume->mIsRemovable),
mIsHotSwappable(aVolume->mIsHotSwappable)
{
}
void nsVolume::Dump(const char* aLabel) const
{
LOG("%s: Volume: %s is %s and %s @ %s gen %d locked %d",
@ -333,40 +349,28 @@ nsVolume::LogState() const
LOG("nsVolume: %s state %s", NameStr().get(), StateStr());
}
void nsVolume::Set(nsIVolume* aVolume)
void nsVolume::UpdateMountLock(nsVolume* aOldVolume)
{
MOZ_ASSERT(NS_IsMainThread());
aVolume->GetName(mName);
aVolume->GetMountPoint(mMountPoint);
aVolume->GetState(&mState);
aVolume->GetIsFake(&mIsFake);
aVolume->GetIsMediaPresent(&mIsMediaPresent);
aVolume->GetIsSharing(&mIsSharing);
aVolume->GetIsFormatting(&mIsFormatting);
aVolume->GetIsUnmounting(&mIsUnmounting);
aVolume->GetIsRemovable(&mIsRemovable);
aVolume->GetIsHotSwappable(&mIsHotSwappable);
int32_t volMountGeneration;
aVolume->GetMountGeneration(&volMountGeneration);
bool oldMountLocked = aOldVolume ? aOldVolume->mMountLocked : false;
if (mState != nsIVolume::STATE_MOUNTED) {
// Since we're not in the mounted state, we need to
// forgot whatever mount generation we may have had.
mMountGeneration = -1;
return;
}
if (mMountGeneration == volMountGeneration) {
// No change in mount generation, nothing else to do
mMountLocked = oldMountLocked;
return;
}
mMountGeneration = volMountGeneration;
int32_t oldMountGeneration = aOldVolume ? aOldVolume->mMountGeneration : -1;
if (mMountGeneration == oldMountGeneration) {
// No change in mount generation, nothing else to do
mMountLocked = oldMountLocked;
return;
}
if (!XRE_IsParentProcess()) {
// Child processes just track the state, not maintain it.
aVolume->GetIsMountLocked(&mMountLocked);
return;
}

Просмотреть файл

@ -24,6 +24,9 @@ public:
// This constructor is used by the UpdateVolumeRunnable constructor
nsVolume(const Volume* aVolume);
// This constructor is used by nsVolumeService::SetFakeVolumeState
nsVolume(const nsVolume* aVolume);
// This constructor is used by ContentChild::RecvFileSystemUpdate which is
// used to update the volume cache maintained in the child process.
nsVolume(const nsAString& aName, const nsAString& aMountPoint,
@ -47,25 +50,8 @@ public:
{
}
// This constructor is used by nsVolumeService::FindAddVolumeByName, and
// will be followed shortly by a Set call.
nsVolume(const nsAString& aName)
: mName(aName),
mState(STATE_INIT),
mMountGeneration(-1),
mMountLocked(true), // Needs to agree with Volume::Volume
mIsFake(false),
mIsMediaPresent(false),
mIsSharing(false),
mIsFormatting(false),
mIsUnmounting(false),
mIsRemovable(false),
mIsHotSwappable(false)
{
}
bool Equals(nsIVolume* aVolume);
void Set(nsIVolume* aVolume);
void UpdateMountLock(nsVolume* aOldVolume);
void LogState() const;

Просмотреть файл

@ -368,7 +368,7 @@ nsVolumeService::FindVolumeByMountLockName(const nsAString& aMountLockName)
}
already_AddRefed<nsVolume>
nsVolumeService::FindVolumeByName(const nsAString& aName)
nsVolumeService::FindVolumeByName(const nsAString& aName, nsVolume::Array::index_type* aIndex)
{
mArrayMonitor.AssertCurrentThreadOwns();
@ -377,52 +377,35 @@ nsVolumeService::FindVolumeByName(const nsAString& aName)
for (volIndex = 0; volIndex < numVolumes; volIndex++) {
nsRefPtr<nsVolume> vol = mVolumeArray[volIndex];
if (vol->Name().Equals(aName)) {
if (aIndex) {
*aIndex = volIndex;
}
return vol.forget();
}
}
return nullptr;
}
//static
already_AddRefed<nsVolume>
nsVolumeService::CreateOrFindVolumeByName(const nsAString& aName, bool aIsFake /*= false*/)
{
MonitorAutoLock autoLock(mArrayMonitor);
nsRefPtr<nsVolume> vol;
vol = FindVolumeByName(aName);
if (vol) {
return vol.forget();
}
// Volume not found - add a new one
vol = new nsVolume(aName);
vol->SetIsFake(aIsFake);
mVolumeArray.AppendElement(vol);
return vol.forget();
}
void
nsVolumeService::UpdateVolume(nsIVolume* aVolume, bool aNotifyObservers)
nsVolumeService::UpdateVolume(nsVolume* aVolume, bool aNotifyObservers)
{
MOZ_ASSERT(NS_IsMainThread());
nsString volName;
aVolume->GetName(volName);
bool aIsFake;
aVolume->GetIsFake(&aIsFake);
nsRefPtr<nsVolume> vol = CreateOrFindVolumeByName(volName, aIsFake);
if (vol->Equals(aVolume)) {
// Nothing has really changed. Don't bother telling anybody.
return;
{
MonitorAutoLock autoLock(mArrayMonitor);
nsVolume::Array::index_type volIndex;
nsRefPtr<nsVolume> vol = FindVolumeByName(aVolume->Name(), &volIndex);
if (!vol) {
mVolumeArray.AppendElement(aVolume);
} else if (vol->Equals(aVolume) || (!vol->IsFake() && aVolume->IsFake())) {
// Ignore if nothing changed or if a fake tries to override a real volume.
return;
} else {
mVolumeArray.ReplaceElementAt(volIndex, aVolume);
}
aVolume->UpdateMountLock(vol);
}
if (!vol->IsFake() && aIsFake) {
// Prevent an incoming fake volume from overriding an existing real volume.
return;
}
vol->Set(aVolume);
if (!aNotifyObservers) {
return;
}
@ -431,8 +414,8 @@ nsVolumeService::UpdateVolume(nsIVolume* aVolume, bool aNotifyObservers)
if (!obs) {
return;
}
NS_ConvertUTF8toUTF16 stateStr(vol->StateStr());
obs->NotifyObservers(vol, NS_VOLUME_STATE_CHANGED, stateStr.get());
NS_ConvertUTF8toUTF16 stateStr(aVolume->StateStr());
obs->NotifyObservers(aVolume, NS_VOLUME_STATE_CHANGED, stateStr.get());
}
NS_IMETHODIMP
@ -471,11 +454,8 @@ nsVolumeService::SetFakeVolumeState(const nsAString& name, int32_t state)
return NS_ERROR_NOT_AVAILABLE;
}
// UpdateVolume expects the volume passed in to NOT be the
// same pointer as what CreateOrFindVolumeByName would return,
// which is why we allocate a temporary volume here.
nsRefPtr<nsVolume> volume = new nsVolume(name);
volume->Set(vol);
// Clone the existing volume so we can replace it
nsRefPtr<nsVolume> volume = new nsVolume(vol);
volume->SetState(state);
volume->LogState();
UpdateVolume(volume.get());
@ -502,15 +482,15 @@ nsVolumeService::RemoveFakeVolume(const nsAString& name)
void
nsVolumeService::RemoveVolumeByName(const nsAString& aName)
{
nsRefPtr<nsVolume> vol;
{
MonitorAutoLock autoLock(mArrayMonitor);
vol = FindVolumeByName(aName);
nsVolume::Array::index_type volIndex;
nsRefPtr<nsVolume> vol = FindVolumeByName(aName, &volIndex);
if (!vol) {
return;
}
mVolumeArray.RemoveElementAt(volIndex);
}
if (!vol) {
return;
}
mVolumeArray.RemoveElement(vol);
if (XRE_IsParentProcess()) {
nsCOMPtr<nsIObserverService> obs = GetObserverService();

Просмотреть файл

@ -47,7 +47,7 @@ public:
void DumpNoLock(const char* aLabel);
// To use this function, you have to create a new volume and pass it in.
void UpdateVolume(nsIVolume* aVolume, bool aNotifyObservers = true);
void UpdateVolume(nsVolume* aVolume, bool aNotifyObservers = true);
void UpdateVolumeIOThread(const Volume* aVolume);
void RecvVolumesFromParent(const nsTArray<dom::VolumeInfo>& aVolumes);
@ -61,8 +61,9 @@ private:
void CheckMountLock(const nsAString& aMountLockName,
const nsAString& aMountLockState);
already_AddRefed<nsVolume> FindVolumeByMountLockName(const nsAString& aMountLockName);
already_AddRefed<nsVolume> FindVolumeByName(const nsAString& aName);
already_AddRefed<nsVolume> CreateOrFindVolumeByName(const nsAString& aName, bool aIsFake = false);
already_AddRefed<nsVolume> FindVolumeByName(const nsAString& aName,
nsVolume::Array::index_type* aIndex = nullptr);
Monitor mArrayMonitor;
nsVolume::Array mVolumeArray;

Просмотреть файл

@ -5,9 +5,19 @@
*/
[CheckAnyPermissions="bluetooth"]
interface BluetoothGattServer
interface BluetoothGattServer : EventTarget
{
/* The implementation of BluetoothGattServer will come later.
* (see dependent bugs of bug 933358)
// Fired when a remote device has been connected/disconnected
attribute EventHandler onconnectionstatechanged;
/**
* Connect/Disconnect to the remote BLE device with the target address.
*
* Promise will be rejected if the local GATT server is busy connecting or
* disconnecting to other devices.
*/
[NewObject]
Promise<void> connect(DOMString address);
[NewObject]
Promise<void> disconnect(DOMString address);
};

Просмотреть файл

@ -261,7 +261,7 @@ interface CameraControl : MediaStream
'TrackCompleted' if audio or video track complete when stopping
'TrackFailed' if audio or video track incomplete when stopping
'MediaRecorderFailed' if failed due to local error
'MediaServerFailed' if failed due to media server
'MediaServerFailed' if failed due to media server */
attribute EventHandler onrecorderstatechange;
/* the event dispatched when the viewfinder stops or starts,

Просмотреть файл

@ -53,6 +53,8 @@ builds:
types:
opt:
task: tasks/builds/b2g_emulator_x86_kk_opt.yml
debug:
task: tasks/builds/b2g_emulator_x86_kk_debug.yml
emulator-jb:
platforms:
- b2g
@ -197,10 +199,14 @@ tests:
task: tasks/tests/b2g_emulator_cpp_unit.yml
tasks/builds/b2g_emulator_ics_debug.yml:
task: tasks/tests/b2g_emulator_cpp_unit.yml
tasks/builds/b2g_emulator_x86_kk_opt.yml:
task: tasks/tests/b2g_emulator_cpp_unit.yml
crashtest:
allowed_build_tasks:
tasks/builds/b2g_emulator_ics_opt.yml:
task: tasks/tests/b2g_emulator_crashtest.yml
tasks/builds/b2g_emulator_x86_kk_opt.yml:
task: tasks/tests/b2g_emulator_crashtest.yml
gaia-build:
allowed_build_tasks:
tasks/builds/b2g_desktop_opt.yml:
@ -251,12 +257,16 @@ tests:
allowed_build_tasks:
tasks/builds/b2g_emulator_kk_opt.yml:
task: tasks/tests/b2g_emulator_marionette.yml
tasks/builds/b2g_emulator_x86_kk_opt.yml:
task: tasks/tests/b2g_emulator_marionette.yml
tasks/builds/b2g_emulator_ics_opt.yml:
task: tasks/tests/b2g_emulator_marionette.yml
marionette-webapi:
allowed_build_tasks:
tasks/builds/b2g_emulator_kk_opt.yml:
task: tasks/tests/b2g_emulator_marionette_webapi.yml
tasks/builds/b2g_emulator_x86_kk_opt.yml:
task: tasks/tests/b2g_emulator_marionette_webapi.yml
tasks/builds/b2g_emulator_ics_opt.yml:
task: tasks/tests/b2g_emulator_marionette_webapi.yml
mochitest:
@ -297,10 +307,10 @@ tests:
task: tasks/tests/b2g_reftests_sanity_oop.yml
xpcshell:
allowed_build_tasks:
tasks/builds/b2g_emulator_x86_kk_opt.yml:
task: tasks/tests/b2g_emulator_xpcshell_chunked.yml
tasks/builds/b2g_emulator_kk_opt.yml:
task: tasks/tests/b2g_emulator_xpcshell_chunked.yml
tasks/builds/b2g_emulator_x86_kk_opt.yml:
task: tasks/tests/b2g_emulator_xpcshell_chunked.yml
tasks/builds/b2g_emulator_ics_opt.yml:
task: tasks/tests/b2g_emulator_xpcshell_chunked.yml
tasks/builds/b2g_emulator_ics_debug.yml:

Просмотреть файл

@ -0,0 +1,30 @@
$inherits:
from: 'tasks/builds/b2g_emulator_x86_base.yml'
variables:
build_name: 'emulator-x86-kk'
build_type: 'debug'
task:
workerType: emulator-x86-kk
scopes:
- 'docker-worker:cache:workspace-emulator-kk-x86-debug'
metadata:
name: '[TC] B2G KK X86 Emulator (Debug)'
extra:
treeherderEnv:
- production
- staging
treeherder:
# Disable "TC" prefix...
groupSymbol: "?"
collection:
debug: true
machine:
platform: b2g-emu-x86-kk
payload:
cache:
workspace-emulator-kk-x86-debug: /home/worker/workspace
env:
TARGET: 'emulator-x86-kk'
B2G_DEBUG: 1

Просмотреть файл

@ -12,6 +12,7 @@ task:
extra:
treeherderEnv:
- production
- staging
treeherder:
# Disable "TC" prefix...