Merge b2g-inbound to m-c. a=merge

This commit is contained in:
Ryan VanderMeulen 2015-04-14 16:14:45 -04:00
commit 2cb7348fec
29 changed files with 245 additions and 590 deletions

View File

@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.
Bug 1146355: Run Bluetooth APIs v1 and v2 with same backend code
Bug 1152821: Merge BluetoothCommon.h variants into single file

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="ef937d1aca7c4cf89ecb5cc43ae8c21c2000a9db">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c8cb0c0ebb8dd1f5c0c9037e38f8e4b237beb77b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8e28588496f82f8f069c171c65842d622b9d8d7d"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="42b56ff9f40a572e61b63a660daddc72a7a7ffcb"/>
<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="c8cb0c0ebb8dd1f5c0c9037e38f8e4b237beb77b"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="8e28588496f82f8f069c171c65842d622b9d8d7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="42b56ff9f40a572e61b63a660daddc72a7a7ffcb"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="93f9ba577f68d772093987c2f1c0a4ae293e1802"/>

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="c8cb0c0ebb8dd1f5c0c9037e38f8e4b237beb77b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8e28588496f82f8f069c171c65842d622b9d8d7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="42b56ff9f40a572e61b63a660daddc72a7a7ffcb"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="adb24954bf8068f21705b570450475d183336b2d"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8a1ba73572c713e298ae53821d000fc3a5087b5f"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="ef937d1aca7c4cf89ecb5cc43ae8c21c2000a9db">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c8cb0c0ebb8dd1f5c0c9037e38f8e4b237beb77b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8e28588496f82f8f069c171c65842d622b9d8d7d"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="42b56ff9f40a572e61b63a660daddc72a7a7ffcb"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="6b0721ca0e92788df30daf8f7a5fb2863544f9c8">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c8cb0c0ebb8dd1f5c0c9037e38f8e4b237beb77b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8e28588496f82f8f069c171c65842d622b9d8d7d"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="42b56ff9f40a572e61b63a660daddc72a7a7ffcb"/>
<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="c8cb0c0ebb8dd1f5c0c9037e38f8e4b237beb77b"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="8e28588496f82f8f069c171c65842d622b9d8d7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="42b56ff9f40a572e61b63a660daddc72a7a7ffcb"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="93f9ba577f68d772093987c2f1c0a4ae293e1802"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="ef937d1aca7c4cf89ecb5cc43ae8c21c2000a9db">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c8cb0c0ebb8dd1f5c0c9037e38f8e4b237beb77b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8e28588496f82f8f069c171c65842d622b9d8d7d"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="42b56ff9f40a572e61b63a660daddc72a7a7ffcb"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

View File

@ -17,7 +17,7 @@
</project>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c8cb0c0ebb8dd1f5c0c9037e38f8e4b237beb77b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8e28588496f82f8f069c171c65842d622b9d8d7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="42b56ff9f40a572e61b63a660daddc72a7a7ffcb"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="adb24954bf8068f21705b570450475d183336b2d"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8a1ba73572c713e298ae53821d000fc3a5087b5f"/>

View File

@ -1,9 +1,9 @@
{
"git": {
"git_revision": "c8cb0c0ebb8dd1f5c0c9037e38f8e4b237beb77b",
"git_revision": "8e28588496f82f8f069c171c65842d622b9d8d7d",
"remote": "https://git.mozilla.org/releases/gaia.git",
"branch": ""
},
"revision": "f9a4193e82db33f7717a939b769b0b90975231fe",
"revision": "ff36a42838b338d750be214ac110c5cc4369b180",
"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="c8cb0c0ebb8dd1f5c0c9037e38f8e4b237beb77b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8e28588496f82f8f069c171c65842d622b9d8d7d"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="42b56ff9f40a572e61b63a660daddc72a7a7ffcb"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="adb24954bf8068f21705b570450475d183336b2d"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8a1ba73572c713e298ae53821d000fc3a5087b5f"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="6b0721ca0e92788df30daf8f7a5fb2863544f9c8">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c8cb0c0ebb8dd1f5c0c9037e38f8e4b237beb77b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="8e28588496f82f8f069c171c65842d622b9d8d7d"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="42b56ff9f40a572e61b63a660daddc72a7a7ffcb"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

View File

@ -4,9 +4,10 @@
* 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/. */
#ifndef mozilla_dom_bluetooth_bluetoothcommon_h__
#define mozilla_dom_bluetooth_bluetoothcommon_h__
#ifndef mozilla_dom_bluetooth_bluetoothcommon_h
#define mozilla_dom_bluetooth_bluetoothcommon_h
#include "mozilla/Compiler.h"
#include "mozilla/Observer.h"
#include "nsPrintfCString.h"
#include "nsString.h"
@ -16,10 +17,16 @@ extern bool gBluetoothDebugFlag;
#define SWITCH_BT_DEBUG(V) (gBluetoothDebugFlag = V)
#if MOZ_IS_GCC && MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
#if MOZ_IS_GCC
# if MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
/* use designated array initializers if supported */
#define INIT_ARRAY_AT(in_, out_) \
[in_] = out_
# define INIT_ARRAY_AT(in_, out_) \
[in_] = out_
# else
/* otherwise init array element by position */
# define INIT_ARRAY_AT(in_, out_) \
out_
# endif
#else
/* otherwise init array element by position */
#define INIT_ARRAY_AT(in_, out_) \
@ -179,6 +186,21 @@ extern bool gBluetoothDebugFlag;
#define PAIRING_REQ_TYPE_CONFIRMATION "pairingconfirmationreq"
#define PAIRING_REQ_TYPE_CONSENT "pairingconsentreq"
/**
* When the pair status of a Bluetooth device is changed, we'll dispatch an
* event.
*
* TODO: remove with bluetooth1
*/
#define PAIRED_STATUS_CHANGED_ID "pairedstatuschanged"
/**
* This event would be fired when discovery procedure starts or stops.
*
* TODO: remove with bluetooth1
*/
#define DISCOVERY_STATE_CHANGED_ID "discoverystatechanged"
/**
* System message to launch bluetooth app if no pairing listener is ready to
* receive pairing requests.
@ -503,13 +525,13 @@ enum {
};
enum BluetoothAvrcpMediaAttribute {
AVRCP_MEDIA_ATTRIBUTE_TITLE,
AVRCP_MEDIA_ATTRIBUTE_ARTIST,
AVRCP_MEDIA_ATTRIBUTE_ALBUM,
AVRCP_MEDIA_ATTRIBUTE_TRACK_NUM,
AVRCP_MEDIA_ATTRIBUTE_NUM_TRACKS,
AVRCP_MEDIA_ATTRIBUTE_GENRE,
AVRCP_MEDIA_ATTRIBUTE_PLAYING_TIME
AVRCP_MEDIA_ATTRIBUTE_TITLE = 0x01,
AVRCP_MEDIA_ATTRIBUTE_ARTIST = 0x02,
AVRCP_MEDIA_ATTRIBUTE_ALBUM = 0x03,
AVRCP_MEDIA_ATTRIBUTE_TRACK_NUM = 0x04,
AVRCP_MEDIA_ATTRIBUTE_NUM_TRACKS = 0x05,
AVRCP_MEDIA_ATTRIBUTE_GENRE = 0x06,
AVRCP_MEDIA_ATTRIBUTE_PLAYING_TIME = 0x07
};
enum BluetoothAvrcpPlayerAttribute {
@ -519,6 +541,19 @@ enum BluetoothAvrcpPlayerAttribute {
AVRCP_PLAYER_ATTRIBUTE_SCAN
};
enum BluetoothAvrcpPlayerRepeatValue {
AVRCP_PLAYER_VAL_OFF_REPEAT = 0x01,
AVRCP_PLAYER_VAL_SINGLE_REPEAT = 0x02,
AVRCP_PLAYER_VAL_ALL_REPEAT = 0x03,
AVRCP_PLAYER_VAL_GROUP_REPEAT = 0x04
};
enum BluetoothAvrcpPlayerShuffleValue {
AVRCP_PLAYER_VAL_OFF_SHUFFLE = 0x01,
AVRCP_PLAYER_VAL_ALL_SHUFFLE = 0x02,
AVRCP_PLAYER_VAL_GROUP_SHUFFLE = 0x03
};
enum BluetoothAvrcpStatus {
AVRCP_STATUS_BAD_COMMAND,
AVRCP_STATUS_BAD_PARAMETER,

View File

@ -39,24 +39,32 @@ using namespace mozilla::dom;
using namespace mozilla::ipc;
namespace {
// Sending system message "bluetooth-opp-update-progress" every 50kb
static const uint32_t kUpdateProgressBase = 50 * 1024;
// Sending system message "bluetooth-opp-update-progress" every 50kb
static const uint32_t kUpdateProgressBase = 50 * 1024;
/*
* The format of the header of an PUT request is
* [opcode:1][packet length:2][headerId:1][header length:2]
*/
static const uint32_t kPutRequestHeaderSize = 6;
/*
* The format of the header of an PUT request is
* [opcode:1][packet length:2][headerId:1][header length:2]
*/
static const uint32_t kPutRequestHeaderSize = 6;
/*
* The format of the appended header of an PUT request is
* [headerId:1][header length:4]
* P.S. Length of name header is 4 since unicode is 2 bytes per char.
*/
static const uint32_t kPutRequestAppendHeaderSize = 5;
/*
* The format of the appended header of an PUT request is
* [headerId:1][header length:4]
* P.S. Length of name header is 4 since unicode is 2 bytes per char.
*/
static const uint32_t kPutRequestAppendHeaderSize = 5;
StaticRefPtr<BluetoothOppManager> sBluetoothOppManager;
static bool sInShutdown = false;
// UUID of OBEX Object Push
static const BluetoothUuid kObexObjectPush = {
{
0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
}
};
StaticRefPtr<BluetoothOppManager> sBluetoothOppManager;
static bool sInShutdown = false;
}
BEGIN_BLUETOOTH_NAMESPACE
@ -301,7 +309,7 @@ BluetoothOppManager::ConnectInternal(const nsAString& aDeviceAddress)
mSocket =
new BluetoothSocket(this, BluetoothSocketType::RFCOMM, false, true);
mSocket->ConnectSocket(aDeviceAddress, -1);
mSocket->ConnectSocket(aDeviceAddress, kObexObjectPush, -1);
}
void
@ -374,7 +382,9 @@ BluetoothOppManager::Listen()
mServerSocket =
new BluetoothSocket(this, BluetoothSocketType::RFCOMM, false, true);
if (!mServerSocket->ListenSocket(BluetoothReservedChannels::CHANNEL_OPUSH)) {
if (!mServerSocket->ListenSocket(NS_LITERAL_STRING("OBEX Object Push"),
kObexObjectPush,
BluetoothReservedChannels::CHANNEL_OPUSH)) {
BT_WARNING("[OPP] Can't listen on RFCOMM socket!");
mServerSocket = nullptr;
return false;

View File

@ -1976,6 +1976,43 @@ BluetoothServiceBluedroid::UuidToServiceClassInt(const BluetoothUuid& mUuid)
memcpy(&shortUuid, mUuid.mUuid + 2, sizeof(uint16_t));
return ntohs(shortUuid);
}
bool
BluetoothServiceBluedroid::IsConnected(const nsAString& aRemoteBdAddr)
{
MOZ_ASSERT(NS_IsMainThread());
nsString connectedAddress;
// Check whether HFP/HSP are connected.
BluetoothProfileManagerBase* profile;
profile = BluetoothHfpManager::Get();
if (profile && profile->IsConnected()) {
profile->GetAddress(connectedAddress);
if (aRemoteBdAddr.Equals(connectedAddress)) {
return true;
}
}
// Check whether OPP is connected.
profile = BluetoothOppManager::Get();
if (profile->IsConnected()) {
profile->GetAddress(connectedAddress);
if (aRemoteBdAddr.Equals(connectedAddress)) {
return true;
}
}
// Check whether A2DP is connected.
profile = BluetoothA2dpManager::Get();
if (profile->IsConnected()) {
profile->GetAddress(connectedAddress);
if (aRemoteBdAddr.Equals(connectedAddress)) {
return true;
}
}
return false;
}
#endif
//
@ -2485,6 +2522,10 @@ BluetoothServiceBluedroid::RemoteDevicePropertiesNotification(
}
}
// BlueDroid wouldn't notify the status of connection, therefore, query the
// connection state and append to properties array
BT_APPEND_NAMED_VALUE(props, "Connected", IsConnected(aBdAddr));
if (sRequestedDeviceCountArray.IsEmpty()) {
// This is possible because the callback would be called after turning
// Bluetooth on.

View File

@ -505,6 +505,8 @@ protected:
const nsAString& aPlayStatus);
uint16_t UuidToServiceClassInt(const BluetoothUuid& mUuid);
static bool IsConnected(const nsAString& aRemoteBdAddr);
};
END_BLUETOOTH_NAMESPACE

View File

@ -22,10 +22,6 @@ using namespace mozilla::ipc;
USING_BLUETOOTH_NAMESPACE
static const size_t MAX_READ_SIZE = 1 << 16;
static const uint8_t UUID_OBEX_OBJECT_PUSH[] = {
0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
};
static BluetoothSocketInterface* sBluetoothSocketInterface;
// helper functions
@ -559,7 +555,9 @@ private:
};
bool
BluetoothSocket::ConnectSocket(const nsAString& aDeviceAddress, int aChannel)
BluetoothSocket::ConnectSocket(const nsAString& aDeviceAddress,
const BluetoothUuid& aServiceUuid,
int aChannel)
{
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_FALSE(mImpl, false);
@ -571,12 +569,11 @@ BluetoothSocket::ConnectSocket(const nsAString& aDeviceAddress, int aChannel)
BluetoothSocketResultHandler* res = new ConnectSocketResultHandler(mImpl);
SetCurrentResultHandler(res);
// TODO: uuid as argument
sBluetoothSocketInterface->Connect(
aDeviceAddress,
BluetoothSocketType::RFCOMM,
UUID_OBEX_OBJECT_PUSH,
aChannel, mEncrypt, mAuth, res);
aServiceUuid.mUuid, aChannel,
mEncrypt, mAuth, res);
return true;
}
@ -610,7 +607,9 @@ private:
};
bool
BluetoothSocket::ListenSocket(int aChannel)
BluetoothSocket::ListenSocket(const nsAString& aServiceName,
const BluetoothUuid& aServiceUuid,
int aChannel)
{
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_FALSE(mImpl, false);
@ -624,9 +623,8 @@ BluetoothSocket::ListenSocket(int aChannel)
sBluetoothSocketInterface->Listen(
BluetoothSocketType::RFCOMM,
NS_LITERAL_STRING("OBEX Object Push"),
UUID_OBEX_OBJECT_PUSH,
aChannel, mEncrypt, mAuth, res);
aServiceName, aServiceUuid.mUuid, aChannel,
mEncrypt, mAuth, res);
return true;
}

View File

@ -24,9 +24,13 @@ public:
bool aAuth,
bool aEncrypt);
bool ConnectSocket(const nsAString& aDeviceAddress, int aChannel);
bool ConnectSocket(const nsAString& aDeviceAddress,
const BluetoothUuid& aServiceUuid,
int aChannel);
bool ListenSocket(int aChannel);
bool ListenSocket(const nsAString& aServiceName,
const BluetoothUuid& aServiceUuid,
int aChannel);
void CloseSocket();

View File

@ -1,500 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=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/. */
#ifndef mozilla_dom_bluetooth_bluetoothcommon_h__
#define mozilla_dom_bluetooth_bluetoothcommon_h__
#include "mozilla/Compiler.h"
#include "mozilla/Observer.h"
#include "nsPrintfCString.h"
#include "nsString.h"
#include "nsTArray.h"
#if MOZ_IS_GCC
# if MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
/* use designated array initializers if supported */
# define INIT_ARRAY_AT(in_, out_) \
[in_] = out_
# else
/* otherwise init array element by position */
# define INIT_ARRAY_AT(in_, out_) \
out_
# endif
#else
/* otherwise init array element by position */
#define INIT_ARRAY_AT(in_, out_) \
out_
#endif
#define CONVERT(in_, out_) \
INIT_ARRAY_AT(in_, out_)
extern bool gBluetoothDebugFlag;
#define SWITCH_BT_DEBUG(V) (gBluetoothDebugFlag = V)
#undef BT_LOG
#if defined(MOZ_WIDGET_GONK)
#include <android/log.h>
/**
* Prints 'D'EBUG build logs, which show in DEBUG build only when
* developer setting 'Bluetooth output in adb' is enabled.
*/
#define BT_LOGD(msg, ...) \
do { \
if (gBluetoothDebugFlag) { \
__android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth", \
"%s: " msg, __FUNCTION__, ##__VA_ARGS__); \
} \
} while(0)
/**
* Prints 'R'ELEASE build logs, which show in both RELEASE and DEBUG builds.
*/
#define BT_LOGR(msg, ...) \
__android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth", \
"%s: " msg, __FUNCTION__, ##__VA_ARGS__) \
/**
* Prints DEBUG build warnings, which show in DEBUG build only.
*/
#define BT_WARNING(args...) \
NS_WARNING(nsPrintfCString(args).get()) \
#else
#define BT_LOGD(msg, ...) \
do { \
if (gBluetoothDebugFlag) { \
printf("%s: " msg, __FUNCTION__, ##__VA_ARGS__); \
} \
} while(0)
#define BT_LOGR(msg, ...) printf("%s: " msg, __FUNCTION__, ##__VA_ARGS__)
#define BT_WARNING(msg, ...) printf("%s: " msg, __FUNCTION__, ##__VA_ARGS__)
#endif
/**
* Wrap literal name and value into a BluetoothNamedValue
* and append it to the array.
*/
#define BT_APPEND_NAMED_VALUE(array, name, value) \
array.AppendElement(BluetoothNamedValue(NS_LITERAL_STRING(name), value))
/**
* Ensure success of system message broadcast with void return.
*/
#define BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters) \
do { \
if (!BroadcastSystemMessage(type, parameters)) { \
BT_WARNING("Failed to broadcast [%s]", \
NS_ConvertUTF16toUTF8(type).get()); \
return; \
} \
} while(0)
#define BEGIN_BLUETOOTH_NAMESPACE \
namespace mozilla { namespace dom { namespace bluetooth {
#define END_BLUETOOTH_NAMESPACE \
} /* namespace bluetooth */ } /* namespace dom */ } /* namespace mozilla */
#define USING_BLUETOOTH_NAMESPACE \
using namespace mozilla::dom::bluetooth;
#define KEY_LOCAL_AGENT "/B2G/bluetooth/agent"
#define KEY_REMOTE_AGENT "/B2G/bluetooth/remote_device_agent"
#define KEY_MANAGER "/B2G/bluetooth/manager"
#define KEY_ADAPTER "/B2G/bluetooth/adapter"
/**
* When the connection status of a Bluetooth profile is changed, we'll notify
* observers which register the following topics.
*/
#define BLUETOOTH_A2DP_STATUS_CHANGED_ID "bluetooth-a2dp-status-changed"
#define BLUETOOTH_HFP_STATUS_CHANGED_ID "bluetooth-hfp-status-changed"
#define BLUETOOTH_HID_STATUS_CHANGED_ID "bluetooth-hid-status-changed"
#define BLUETOOTH_SCO_STATUS_CHANGED_ID "bluetooth-sco-status-changed"
/**
* When the connection status of a Bluetooth profile is changed, we'll
* dispatch one of the following events.
*/
#define A2DP_STATUS_CHANGED_ID "a2dpstatuschanged"
#define HFP_STATUS_CHANGED_ID "hfpstatuschanged"
#define SCO_STATUS_CHANGED_ID "scostatuschanged"
/**
* When the pair status of a Bluetooth device is changed, we'll dispatch an
* event.
*/
#define PAIRED_STATUS_CHANGED_ID "pairedstatuschanged"
/**
* This event would be fired when discovery procedure starts or stops.
*/
#define DISCOVERY_STATE_CHANGED_ID "discoverystatechanged"
/**
* When receiving a query about current play status from remote device, we'll
* dispatch an event.
*/
#define REQUEST_MEDIA_PLAYSTATUS_ID "requestmediaplaystatus"
// Bluetooth address format: xx:xx:xx:xx:xx:xx (or xx_xx_xx_xx_xx_xx)
#define BLUETOOTH_ADDRESS_LENGTH 17
#define BLUETOOTH_ADDRESS_NONE "00:00:00:00:00:00"
#define BLUETOOTH_ADDRESS_BYTES 6
// Bluetooth stack internal error, such as I/O error
#define ERR_INTERNAL_ERROR "InternalError"
BEGIN_BLUETOOTH_NAMESPACE
enum BluetoothStatus {
STATUS_SUCCESS,
STATUS_FAIL,
STATUS_NOT_READY,
STATUS_NOMEM,
STATUS_BUSY,
STATUS_DONE,
STATUS_UNSUPPORTED,
STATUS_PARM_INVALID,
STATUS_UNHANDLED,
STATUS_AUTH_FAILURE,
STATUS_RMT_DEV_DOWN
};
enum BluetoothBondState {
BOND_STATE_NONE,
BOND_STATE_BONDING,
BOND_STATE_BONDED
};
enum BluetoothTypeOfDevice {
TYPE_OF_DEVICE_BREDR,
TYPE_OF_DEVICE_BLE,
TYPE_OF_DEVICE_DUAL
};
enum BluetoothPropertyType {
PROPERTY_UNKNOWN,
PROPERTY_BDNAME,
PROPERTY_BDADDR,
PROPERTY_UUIDS,
PROPERTY_CLASS_OF_DEVICE,
PROPERTY_TYPE_OF_DEVICE,
PROPERTY_SERVICE_RECORD,
PROPERTY_ADAPTER_SCAN_MODE,
PROPERTY_ADAPTER_BONDED_DEVICES,
PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
PROPERTY_REMOTE_FRIENDLY_NAME,
PROPERTY_REMOTE_RSSI,
PROPERTY_REMOTE_VERSION_INFO,
PROPERTY_REMOTE_DEVICE_TIMESTAMP
};
enum BluetoothScanMode {
SCAN_MODE_NONE,
SCAN_MODE_CONNECTABLE,
SCAN_MODE_CONNECTABLE_DISCOVERABLE
};
enum BluetoothSspVariant {
SSP_VARIANT_PASSKEY_CONFIRMATION,
SSP_VARIANT_PASSKEY_ENTRY,
SSP_VARIANT_CONSENT,
SSP_VARIANT_PASSKEY_NOTIFICATION
};
struct BluetoothUuid {
uint8_t mUuid[16];
};
struct BluetoothServiceRecord {
BluetoothUuid mUuid;
uint16_t mChannel;
char mName[256];
};
struct BluetoothRemoteInfo {
int mVerMajor;
int mVerMinor;
int mManufacturer;
};
struct BluetoothProperty {
/* Type */
BluetoothPropertyType mType;
/* Value
*/
/* PROPERTY_BDNAME
PROPERTY_BDADDR
PROPERTY_REMOTE_FRIENDLY_NAME */
nsString mString;
/* PROPERTY_UUIDS */
nsTArray<BluetoothUuid> mUuidArray;
/* PROPERTY_ADAPTER_BONDED_DEVICES */
nsTArray<nsString> mStringArray;
/* PROPERTY_CLASS_OF_DEVICE
PROPERTY_ADAPTER_DISCOVERY_TIMEOUT */
uint32_t mUint32;
/* PROPERTY_RSSI_VALUE */
int32_t mInt32;
/* PROPERTY_TYPE_OF_DEVICE */
BluetoothTypeOfDevice mTypeOfDevice;
/* PROPERTY_SERVICE_RECORD */
BluetoothServiceRecord mServiceRecord;
/* PROPERTY_SCAN_MODE */
BluetoothScanMode mScanMode;
/* PROPERTY_REMOTE_VERSION_INFO */
BluetoothRemoteInfo mRemoteInfo;
};
/* Physical transport for GATT connections to remote dual-mode devices */
enum BluetoothTransport {
TRANSPORT_AUTO, /* No preference of physical transport */
TRANSPORT_BREDR, /* Prefer BR/EDR transport */
TRANSPORT_LE /* Prefer LE transport */
};
struct BluetoothActivityEnergyInfo {
uint8_t mStatus;
uint8_t mStackState; /* stack reported state */
uint64_t mTxTime; /* in ms */
uint64_t mRxTime; /* in ms */
uint64_t mIdleTime; /* in ms */
uint64_t mEnergyUsed; /* a product of mA, V and ms */
};
enum BluetoothSocketType {
RFCOMM = 1,
SCO = 2,
L2CAP = 3,
EL2CAP = 4
};
enum BluetoothHandsfreeAtResponse {
HFP_AT_RESPONSE_ERROR,
HFP_AT_RESPONSE_OK
};
enum BluetoothHandsfreeAudioState {
HFP_AUDIO_STATE_DISCONNECTED,
HFP_AUDIO_STATE_CONNECTING,
HFP_AUDIO_STATE_CONNECTED,
HFP_AUDIO_STATE_DISCONNECTING,
};
enum BluetoothHandsfreeCallAddressType {
HFP_CALL_ADDRESS_TYPE_UNKNOWN,
HFP_CALL_ADDRESS_TYPE_INTERNATIONAL
};
enum BluetoothHandsfreeCallDirection {
HFP_CALL_DIRECTION_OUTGOING,
HFP_CALL_DIRECTION_INCOMING
};
enum BluetoothHandsfreeCallHoldType {
HFP_CALL_HOLD_RELEASEHELD,
HFP_CALL_HOLD_RELEASEACTIVE_ACCEPTHELD,
HFP_CALL_HOLD_HOLDACTIVE_ACCEPTHELD,
HFP_CALL_HOLD_ADDHELDTOCONF
};
enum BluetoothHandsfreeCallMode {
HFP_CALL_MODE_VOICE,
HFP_CALL_MODE_DATA,
HFP_CALL_MODE_FAX
};
enum BluetoothHandsfreeCallMptyType {
HFP_CALL_MPTY_TYPE_SINGLE,
HFP_CALL_MPTY_TYPE_MULTI
};
enum BluetoothHandsfreeCallState {
HFP_CALL_STATE_ACTIVE,
HFP_CALL_STATE_HELD,
HFP_CALL_STATE_DIALING,
HFP_CALL_STATE_ALERTING,
HFP_CALL_STATE_INCOMING,
HFP_CALL_STATE_WAITING,
HFP_CALL_STATE_IDLE
};
enum BluetoothHandsfreeConnectionState
{
HFP_CONNECTION_STATE_DISCONNECTED,
HFP_CONNECTION_STATE_CONNECTING,
HFP_CONNECTION_STATE_CONNECTED,
HFP_CONNECTION_STATE_SLC_CONNECTED,
HFP_CONNECTION_STATE_DISCONNECTING
};
enum BluetoothHandsfreeNetworkState {
HFP_NETWORK_STATE_NOT_AVAILABLE,
HFP_NETWORK_STATE_AVAILABLE
};
enum BluetoothHandsfreeWbsConfig {
HFP_WBS_NONE, /* Neither CVSD nor mSBC codec, but other optional codec.*/
HFP_WBS_NO, /* CVSD */
HFP_WBS_YES /* mSBC */
};
enum BluetoothHandsfreeNRECState {
HFP_NREC_STOPPED,
HFP_NREC_STARTED
};
enum BluetoothHandsfreeServiceType {
HFP_SERVICE_TYPE_HOME,
HFP_SERVICE_TYPE_ROAMING
};
enum BluetoothHandsfreeVoiceRecognitionState {
HFP_VOICE_RECOGNITION_STOPPED,
HFP_VOICE_RECOGNITION_STARTED
};
enum BluetoothHandsfreeVolumeType {
HFP_VOLUME_TYPE_SPEAKER,
HFP_VOLUME_TYPE_MICROPHONE
};
class BluetoothSignal;
typedef mozilla::Observer<BluetoothSignal> BluetoothSignalObserver;
// Enums for object types, currently used for shared function lookups
// (get/setproperty, etc...). Possibly discernable via dbus paths, but this
// method is future-proofed for platform independence.
enum BluetoothObjectType {
TYPE_MANAGER = 0,
TYPE_ADAPTER = 1,
TYPE_DEVICE = 2,
TYPE_INVALID
};
enum BluetoothA2dpAudioState {
A2DP_AUDIO_STATE_REMOTE_SUSPEND,
A2DP_AUDIO_STATE_STOPPED,
A2DP_AUDIO_STATE_STARTED,
};
enum BluetoothA2dpConnectionState {
A2DP_CONNECTION_STATE_DISCONNECTED,
A2DP_CONNECTION_STATE_CONNECTING,
A2DP_CONNECTION_STATE_CONNECTED,
A2DP_CONNECTION_STATE_DISCONNECTING
};
enum ControlPlayStatus {
PLAYSTATUS_STOPPED = 0x00,
PLAYSTATUS_PLAYING = 0x01,
PLAYSTATUS_PAUSED = 0x02,
PLAYSTATUS_FWD_SEEK = 0x03,
PLAYSTATUS_REV_SEEK = 0x04,
PLAYSTATUS_UNKNOWN,
PLAYSTATUS_ERROR = 0xFF,
};
enum {
AVRCP_UID_SIZE = 8
};
enum BluetoothAvrcpMediaAttribute {
AVRCP_MEDIA_ATTRIBUTE_TITLE = 0x01,
AVRCP_MEDIA_ATTRIBUTE_ARTIST = 0x02,
AVRCP_MEDIA_ATTRIBUTE_ALBUM = 0x03,
AVRCP_MEDIA_ATTRIBUTE_TRACK_NUM = 0x04,
AVRCP_MEDIA_ATTRIBUTE_NUM_TRACKS = 0x05,
AVRCP_MEDIA_ATTRIBUTE_GENRE = 0x6,
AVRCP_MEDIA_ATTRIBUTE_PLAYING_TIME = 0x7
};
enum BluetoothAvrcpPlayerAttribute {
AVRCP_PLAYER_ATTRIBUTE_EQUALIZER,
AVRCP_PLAYER_ATTRIBUTE_REPEAT,
AVRCP_PLAYER_ATTRIBUTE_SHUFFLE,
AVRCP_PLAYER_ATTRIBUTE_SCAN
};
enum BluetoothAvrcpPlayerRepeatValue {
AVRCP_PLAYER_VAL_OFF_REPEAT = 0x01,
AVRCP_PLAYER_VAL_SINGLE_REPEAT = 0x02,
AVRCP_PLAYER_VAL_ALL_REPEAT = 0x03,
AVRCP_PLAYER_VAL_GROUP_REPEAT = 0x04,
};
enum BluetoothAvrcpPlayerShuffleValue {
AVRCP_PLAYER_VAL_OFF_SHUFFLE = 0x01,
AVRCP_PLAYER_VAL_ALL_SHUFFLE = 0x02,
AVRCP_PLAYER_VAL_GROUP_SHUFFLE = 0x03,
};
enum BluetoothAvrcpStatus {
AVRCP_STATUS_BAD_COMMAND,
AVRCP_STATUS_BAD_PARAMETER,
AVRCP_STATUS_NOT_FOUND,
AVRCP_STATUS_INTERNAL_ERROR,
AVRCP_STATUS_SUCCESS
};
enum BluetoothAvrcpEvent {
AVRCP_EVENT_PLAY_STATUS_CHANGED,
AVRCP_EVENT_TRACK_CHANGE,
AVRCP_EVENT_TRACK_REACHED_END,
AVRCP_EVENT_TRACK_REACHED_START,
AVRCP_EVENT_PLAY_POS_CHANGED,
AVRCP_EVENT_APP_SETTINGS_CHANGED
};
enum BluetoothAvrcpNotification {
AVRCP_NTF_INTERIM,
AVRCP_NTF_CHANGED
};
enum BluetoothAvrcpRemoteFeature {
AVRCP_REMOTE_FEATURE_NONE,
AVRCP_REMOTE_FEATURE_METADATA,
AVRCP_REMOTE_FEATURE_ABSOLUTE_VOLUME,
AVRCP_REMOTE_FEATURE_BROWSE
};
struct BluetoothAvrcpElementAttribute {
uint32_t mId;
nsString mValue;
};
struct BluetoothAvrcpNotificationParam {
ControlPlayStatus mPlayStatus;
uint8_t mTrack[8];
uint32_t mSongPos;
uint8_t mNumAttr;
uint8_t mIds[256];
uint8_t mValues[256];
};
struct BluetoothAvrcpPlayerSettings {
uint8_t mNumAttr;
uint8_t mIds[256];
uint8_t mValues[256];
};
END_BLUETOOTH_NAMESPACE
#endif // mozilla_dom_bluetooth_bluetoothcommon_h__

View File

@ -50,6 +50,8 @@ BluetoothDevice::BluetoothDevice(nsPIDOMWindow* aWindow,
, mJsUuids(nullptr)
, mJsServices(nullptr)
, mAdapterPath(aAdapterPath)
, mConnected(false)
, mPaired(false)
, mIsRooted(false)
{
MOZ_ASSERT(aWindow);

View File

@ -17,7 +17,7 @@ struct ParamTraits<mozilla::dom::bluetooth::BluetoothObjectType>
: public ContiguousEnumSerializer<
mozilla::dom::bluetooth::BluetoothObjectType,
mozilla::dom::bluetooth::TYPE_MANAGER,
mozilla::dom::bluetooth::TYPE_INVALID>
mozilla::dom::bluetooth::NUM_TYPE>
{ };
} // namespace IPC

View File

@ -81,6 +81,30 @@ namespace {
bool sInShutdown = false;
static const char kHfpCrlf[] = "\xd\xa";
// UUID of Handsfree Audio Gateway
static const BluetoothUuid kHandsfreeAG = {
{
0x00, 0x00, 0x11, 0x1F, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
}
};
// UUID of Headset Audio Gateway
static const BluetoothUuid kHeadsetAG = {
{
0x00, 0x00, 0x11, 0x12, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
}
};
// Unknown service UUID (for SCO socket)
static const BluetoothUuid kUnknownService = {
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
}
};
#ifdef MOZ_B2G_RIL
// Sending ringtone related
static bool sStopSendingRingFlag = true;
@ -1180,6 +1204,8 @@ BluetoothHfpManager::Listen()
new BluetoothSocket(this, BluetoothSocketType::RFCOMM, true, true);
if (!mHandsfreeSocket->Listen(
NS_LITERAL_STRING("Handsfree Audio Gateway"),
kHandsfreeAG,
BluetoothReservedChannels::CHANNEL_HANDSFREE_AG)) {
BT_WARNING("[HFP] Can't listen on RFCOMM socket!");
mHandsfreeSocket = nullptr;
@ -1192,6 +1218,8 @@ BluetoothHfpManager::Listen()
new BluetoothSocket(this, BluetoothSocketType::RFCOMM, true, true);
if (!mHeadsetSocket->Listen(
NS_LITERAL_STRING("Headset Audio Gateway"),
kHeadsetAG,
BluetoothReservedChannels::CHANNEL_HEADSET_AG)) {
BT_WARNING("[HSP] Can't listen on RFCOMM socket!");
mHandsfreeSocket->Disconnect();
@ -1900,7 +1928,9 @@ BluetoothHfpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
MOZ_ASSERT(mSocket);
if (!mSocket->Connect(NS_ConvertUTF16toUTF8(aDeviceAddress), aChannel)) {
if (!mSocket->Connect(aDeviceAddress,
mIsHsp? kHeadsetAG : kHandsfreeAG,
aChannel)) {
OnConnect(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
}
}
@ -1996,7 +2026,7 @@ BluetoothHfpManager::ConnectSco(BluetoothReplyRunnable* aRunnable)
// Stop listening
mScoSocket->Disconnect();
mScoSocket->Connect(NS_ConvertUTF16toUTF8(mDeviceAddress), -1);
mScoSocket->Connect(mDeviceAddress, kUnknownService, -1);
mScoSocketStatus = mScoSocket->GetConnectionStatus();
mScoRunnable = aRunnable;
@ -2033,7 +2063,8 @@ BluetoothHfpManager::ListenSco()
mScoSocket->Disconnect();
if (!mScoSocket->Listen(-1)) {
if (!mScoSocket->Listen(NS_LITERAL_STRING("Handsfree Audio Gateway SCO"),
kUnknownService, -1)) {
BT_WARNING("Can't listen on SCO socket!");
return false;
}

View File

@ -41,28 +41,36 @@ using mozilla::TimeDuration;
using mozilla::TimeStamp;
namespace {
// Sending system message "bluetooth-opp-update-progress" every 50kb
static const uint32_t kUpdateProgressBase = 50 * 1024;
// Sending system message "bluetooth-opp-update-progress" every 50kb
static const uint32_t kUpdateProgressBase = 50 * 1024;
/*
* The format of the header of an PUT request is
* [opcode:1][packet length:2][headerId:1][header length:2]
*/
static const uint32_t kPutRequestHeaderSize = 6;
/*
* The format of the header of an PUT request is
* [opcode:1][packet length:2][headerId:1][header length:2]
*/
static const uint32_t kPutRequestHeaderSize = 6;
/*
* The format of the appended header of an PUT request is
* [headerId:1][header length:4]
* P.S. Length of name header is 4 since unicode is 2 bytes per char.
*/
static const uint32_t kPutRequestAppendHeaderSize = 5;
/*
* The format of the appended header of an PUT request is
* [headerId:1][header length:4]
* P.S. Length of name header is 4 since unicode is 2 bytes per char.
*/
static const uint32_t kPutRequestAppendHeaderSize = 5;
// The default timeout we permit to wait for SDP updating if we can't get
// service channel.
static const double kSdpUpdatingTimeoutMs = 3000.0;
// The default timeout we permit to wait for SDP updating if we can't get
// service channel.
static const double kSdpUpdatingTimeoutMs = 3000.0;
StaticRefPtr<BluetoothOppManager> sBluetoothOppManager;
static bool sInShutdown = false;
// UUID of OBEX Object Push
static const BluetoothUuid kObexObjectPush = {
{
0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
}
};
StaticRefPtr<BluetoothOppManager> sBluetoothOppManager;
static bool sInShutdown = false;
}
class mozilla::dom::bluetooth::SendFileBatch {
@ -314,7 +322,9 @@ BluetoothOppManager::Listen()
mRfcommSocket =
new BluetoothSocket(this, BluetoothSocketType::RFCOMM, true, true);
if (!mRfcommSocket->Listen(BluetoothReservedChannels::CHANNEL_OPUSH)) {
if (!mRfcommSocket->Listen(NS_LITERAL_STRING("OBEX Object Push"),
kObexObjectPush,
BluetoothReservedChannels::CHANNEL_OPUSH)) {
BT_WARNING("[OPP] Can't listen on RFCOMM socket!");
mRfcommSocket = nullptr;
return false;
@ -325,7 +335,9 @@ BluetoothOppManager::Listen()
mL2capSocket =
new BluetoothSocket(this, BluetoothSocketType::EL2CAP, true, true);
if (!mL2capSocket->Listen(BluetoothReservedChannels::CHANNEL_OPUSH_L2CAP)) {
if (!mL2capSocket->Listen(NS_LITERAL_STRING("OBEX Object Push"),
kObexObjectPush,
BluetoothReservedChannels::CHANNEL_OPUSH_L2CAP)) {
BT_WARNING("[OPP] Can't listen on L2CAP socket!");
mRfcommSocket->Disconnect();
mRfcommSocket = nullptr;
@ -1624,7 +1636,7 @@ BluetoothOppManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
return;
}
if (!mSocket->Connect(NS_ConvertUTF16toUTF8(aDeviceAddress), aChannel)) {
if (!mSocket->Connect(aDeviceAddress, kObexObjectPush, aChannel)) {
OnSocketConnectError(mSocket);
}
}

View File

@ -26,7 +26,9 @@ BluetoothSocket::BluetoothSocket(BluetoothSocketObserver* aObserver,
}
bool
BluetoothSocket::Connect(const nsACString& aDeviceAddress, int aChannel)
BluetoothSocket::Connect(const nsAString& aDeviceAddress,
const BluetoothUuid& aServiceUuid,
int aChannel)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
@ -34,7 +36,8 @@ BluetoothSocket::Connect(const nsACString& aDeviceAddress, int aChannel)
nsAutoPtr<BluetoothUnixSocketConnector> c(
new BluetoothUnixSocketConnector(mType, aChannel, mAuth, mEncrypt));
if (!ConnectSocket(c.forget(), aDeviceAddress.BeginReading())) {
if (!ConnectSocket(c.forget(),
NS_ConvertUTF16toUTF8(aDeviceAddress).BeginReading())) {
nsAutoString addr;
GetAddress(addr);
BT_LOGD("%s failed. Current connected device address: %s",
@ -46,7 +49,9 @@ BluetoothSocket::Connect(const nsACString& aDeviceAddress, int aChannel)
}
bool
BluetoothSocket::Listen(int aChannel)
BluetoothSocket::Listen(const nsAString& aServiceName,
const BluetoothUuid& aServiceUuid,
int aChannel)
{
MOZ_ASSERT(NS_IsMainThread());

View File

@ -22,8 +22,12 @@ public:
bool aAuth,
bool aEncrypt);
bool Connect(const nsACString& aDeviceAddress, int aChannel);
bool Listen(int aChannel);
bool Connect(const nsAString& aDeviceAddress,
const BluetoothUuid& aServiceUuid,
int aChannel);
bool Listen(const nsAString& aServiceName,
const BluetoothUuid& aServiceUuid,
int aChannel);
inline void Disconnect()
{
CloseSocket();

View File

@ -160,6 +160,10 @@ if CONFIG['MOZ_B2G_BT']:
# Exported interfaces
#
EXPORTS.mozilla.dom.bluetooth += [
'BluetoothCommon.h'
]
if CONFIG['MOZ_B2G_BT_API_V2']:
EXPORTS.mozilla.dom.bluetooth.ipc += [
'bluetooth2/ipc/BluetoothMessageUtils.h',
@ -167,7 +171,6 @@ if CONFIG['MOZ_B2G_BT_API_V2']:
EXPORTS.mozilla.dom.bluetooth += [
'bluetooth2/BluetoothAdapter.h',
'bluetooth2/BluetoothClassOfDevice.h',
'bluetooth2/BluetoothCommon.h',
'bluetooth2/BluetoothDevice.h',
'bluetooth2/BluetoothDiscoveryHandle.h',
'bluetooth2/BluetoothGatt.h',
@ -189,7 +192,6 @@ else:
]
EXPORTS.mozilla.dom.bluetooth += [
'bluetooth1/BluetoothAdapter.h',
'bluetooth1/BluetoothCommon.h',
'bluetooth1/BluetoothDevice.h',
'bluetooth1/BluetoothManager.h',
]

View File

@ -41,6 +41,9 @@ function testAddContact(aIcc, aType, aPin2) {
return aIcc.updateContact(aType, contact, aPin2)
.then((aResult) => {
is(aResult.id, aIcc.iccInfo.iccid + "5");
is(aResult.name[0], "add");
is(aResult.tel[0].value, "0912345678");
// Get ICC contact for checking new contact
return aIcc.readContacts(aType)
.then((aResult) => {
@ -49,6 +52,7 @@ function testAddContact(aIcc, aType, aPin2) {
is(aResult[4].name[0], "add");
is(aResult[4].tel[0].value, "0912345678");
is(aResult[4].id, aIcc.iccInfo.iccid + "5");
}, (aError) => {
ok(false, "Cannot get " + aType + " contacts: " + aError.name);
})

View File

@ -124,6 +124,8 @@ tests:
task: tasks/tests/b2g_mochitest_oop.yml
reftest:
allowed_build_tasks:
tasks/builds/mulet_linux.yml:
task: tasks/tests/mulet_reftests.yml
tasks/builds/b2g_emulator_ics_opt.yml:
task: tasks/tests/b2g_emulator_reftest.yml
reftest-sanity-oop:

View File

@ -34,10 +34,13 @@ task:
expires: '{{#from_now}}1 year{{/from_now}}'
extra:
treeherderEnv:
- production
- staging
chunks:
total: 6
treeherder:
groupName: Reftest
groupSymbol: tc-R
groupSymbol: R
groupName: Mulet Reftest
symbol: 'R{{chunk}}'
productName: b2g