зеркало из https://github.com/mozilla/gecko-dev.git
Merge b2g-inbound to m-c a=merge
This commit is contained in:
Коммит
d50c490346
|
@ -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="34a52e7f024cc3d0e3aade94970773d2555f5ccb"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="85e97290431ce6aa0a965421e84d6070cd899129"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="34a52e7f024cc3d0e3aade94970773d2555f5ccb"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="85e97290431ce6aa0a965421e84d6070cd899129"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="96cdde4b5b5d8d3785b36c3c68cd746aff3005cc"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="7f9ec13a30f1b2cc8bdb1a199b7da54b9ab8860f"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<project name="platform_build" path="build" remote="b2g" revision="276ce45e78b09c4a4ee643646f691d22804754c1">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="34a52e7f024cc3d0e3aade94970773d2555f5ccb"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="85e97290431ce6aa0a965421e84d6070cd899129"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
|
|
@ -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="34a52e7f024cc3d0e3aade94970773d2555f5ccb"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="85e97290431ce6aa0a965421e84d6070cd899129"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</project>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="34a52e7f024cc3d0e3aade94970773d2555f5ccb"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="85e97290431ce6aa0a965421e84d6070cd899129"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="96cdde4b5b5d8d3785b36c3c68cd746aff3005cc"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="7f9ec13a30f1b2cc8bdb1a199b7da54b9ab8860f"/>
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
"remote": "",
|
||||
"branch": ""
|
||||
},
|
||||
"revision": "ef20236bd60e81103e4d469bd29fd90834dee380",
|
||||
"revision": "ec3cab15f129926a6cfa5e95df71a0c913f34aee",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
|
|
@ -17,7 +17,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="34a52e7f024cc3d0e3aade94970773d2555f5ccb"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="85e97290431ce6aa0a965421e84d6070cd899129"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="34a52e7f024cc3d0e3aade94970773d2555f5ccb"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="85e97290431ce6aa0a965421e84d6070cd899129"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="34a52e7f024cc3d0e3aade94970773d2555f5ccb"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="85e97290431ce6aa0a965421e84d6070cd899129"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="96cdde4b5b5d8d3785b36c3c68cd746aff3005cc"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="7f9ec13a30f1b2cc8bdb1a199b7da54b9ab8860f"/>
|
||||
|
|
|
@ -17,7 +17,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="34a52e7f024cc3d0e3aade94970773d2555f5ccb"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="85e97290431ce6aa0a965421e84d6070cd899129"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
|
|
@ -37,9 +37,9 @@ USING_BLUETOOTH_NAMESPACE
|
|||
namespace {
|
||||
StaticRefPtr<BluetoothA2dpManager> sBluetoothA2dpManager;
|
||||
bool sInShutdown = false;
|
||||
static const btav_interface_t* sBtA2dpInterface;
|
||||
static BluetoothA2dpInterface* sBtA2dpInterface;
|
||||
#if ANDROID_VERSION > 17
|
||||
static const btrc_interface_t* sBtAvrcpInterface;
|
||||
static BluetoothAvrcpInterface* sBtAvrcpInterface;
|
||||
#endif
|
||||
} // anonymous namespace
|
||||
|
||||
|
@ -175,7 +175,7 @@ public:
|
|||
}
|
||||
|
||||
NS_ENSURE_TRUE(sBtAvrcpInterface, NS_OK);
|
||||
sBtAvrcpInterface->get_element_attr_rsp(mNumAttr, attrs);
|
||||
sBtAvrcpInterface->GetElementAttrRsp(mNumAttr, attrs);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -508,24 +508,22 @@ static btrc_callbacks_t sBtAvrcpCallbacks = {
|
|||
void
|
||||
BluetoothA2dpManager::InitA2dpInterface()
|
||||
{
|
||||
const bt_interface_t* btInf = GetBluetoothInterface();
|
||||
BluetoothInterface* btInf = BluetoothInterface::GetInstance();
|
||||
NS_ENSURE_TRUE_VOID(btInf);
|
||||
|
||||
sBtA2dpInterface = (btav_interface_t *)btInf->
|
||||
get_profile_interface(BT_PROFILE_ADVANCED_AUDIO_ID);
|
||||
sBtA2dpInterface = btInf->GetBluetoothA2dpInterface();
|
||||
NS_ENSURE_TRUE_VOID(sBtA2dpInterface);
|
||||
|
||||
int ret = sBtA2dpInterface->init(&sBtA2dpCallbacks);
|
||||
int ret = sBtA2dpInterface->Init(&sBtA2dpCallbacks);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BT_LOGR("Warning: failed to init a2dp module");
|
||||
}
|
||||
|
||||
#if ANDROID_VERSION > 17
|
||||
sBtAvrcpInterface = (btrc_interface_t *)btInf->
|
||||
get_profile_interface(BT_PROFILE_AV_RC_ID);
|
||||
sBtAvrcpInterface = btInf->GetBluetoothAvrcpInterface();
|
||||
NS_ENSURE_TRUE_VOID(sBtAvrcpInterface);
|
||||
|
||||
ret = sBtAvrcpInterface->init(&sBtAvrcpCallbacks);
|
||||
ret = sBtAvrcpInterface->Init(&sBtAvrcpCallbacks);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BT_LOGR("Warning: failed to init avrcp module");
|
||||
}
|
||||
|
@ -610,12 +608,12 @@ BluetoothA2dpManager::DeinitA2dpInterface()
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (sBtA2dpInterface) {
|
||||
sBtA2dpInterface->cleanup();
|
||||
sBtA2dpInterface->Cleanup();
|
||||
sBtA2dpInterface = nullptr;
|
||||
}
|
||||
#if ANDROID_VERSION > 17
|
||||
if (sBtAvrcpInterface) {
|
||||
sBtAvrcpInterface->cleanup();
|
||||
sBtAvrcpInterface->Cleanup();
|
||||
sBtAvrcpInterface = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
@ -661,7 +659,7 @@ BluetoothA2dpManager::Connect(const nsAString& aDeviceAddress,
|
|||
bt_bdaddr_t remoteAddress;
|
||||
StringToBdAddressType(aDeviceAddress, &remoteAddress);
|
||||
|
||||
bt_status_t result = sBtA2dpInterface->connect(&remoteAddress);
|
||||
bt_status_t result = sBtA2dpInterface->Connect(&remoteAddress);
|
||||
if (BT_STATUS_SUCCESS != result) {
|
||||
BT_LOGR("Failed to connect: %x", result);
|
||||
aController->NotifyCompletion(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
|
||||
|
@ -703,7 +701,7 @@ BluetoothA2dpManager::Disconnect(BluetoothProfileController* aController)
|
|||
bt_bdaddr_t remoteAddress;
|
||||
StringToBdAddressType(mDeviceAddress, &remoteAddress);
|
||||
|
||||
bt_status_t result = sBtA2dpInterface->disconnect(&remoteAddress);
|
||||
bt_status_t result = sBtA2dpInterface->Disconnect(&remoteAddress);
|
||||
if (BT_STATUS_SUCCESS != result) {
|
||||
BT_LOGR("Failed to disconnect: %x", result);
|
||||
aController->NotifyCompletion(NS_LITERAL_STRING(ERR_DISCONNECTION_FAILED));
|
||||
|
@ -938,14 +936,14 @@ BluetoothA2dpManager::UpdateMetaData(const nsAString& aTitle,
|
|||
param.track[i] = (aMediaNumber >> (56 - 8 * i));
|
||||
}
|
||||
mTrackChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
|
||||
sBtAvrcpInterface->register_notification_rsp(BTRC_EVT_TRACK_CHANGE,
|
||||
sBtAvrcpInterface->RegisterNotificationRsp(BTRC_EVT_TRACK_CHANGE,
|
||||
BTRC_NOTIFICATION_TYPE_CHANGED,
|
||||
¶m);
|
||||
if (mPlayPosChangedNotifyType == BTRC_NOTIFICATION_TYPE_INTERIM) {
|
||||
param.song_pos = mPosition;
|
||||
// EVENT_PLAYBACK_POS_CHANGED shall be notified if changed current track
|
||||
mPlayPosChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
|
||||
sBtAvrcpInterface->register_notification_rsp(
|
||||
sBtAvrcpInterface->RegisterNotificationRsp(
|
||||
BTRC_EVT_PLAY_POS_CHANGED,
|
||||
BTRC_NOTIFICATION_TYPE_CHANGED,
|
||||
¶m);
|
||||
|
@ -975,7 +973,7 @@ BluetoothA2dpManager::UpdatePlayStatus(uint32_t aDuration,
|
|||
#if ANDROID_VERSION > 17
|
||||
NS_ENSURE_TRUE_VOID(sBtAvrcpInterface);
|
||||
// always update playstatus first
|
||||
sBtAvrcpInterface->get_play_status_rsp((btrc_play_status_t)aPlayStatus,
|
||||
sBtAvrcpInterface->GetPlayStatusRsp((btrc_play_status_t)aPlayStatus,
|
||||
aDuration, aPosition);
|
||||
// when play status changed, send both play status and position
|
||||
if (mPlayStatus != aPlayStatus &&
|
||||
|
@ -983,7 +981,7 @@ BluetoothA2dpManager::UpdatePlayStatus(uint32_t aDuration,
|
|||
btrc_register_notification_t param;
|
||||
param.play_status = (btrc_play_status_t)aPlayStatus;
|
||||
mPlayStatusChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
|
||||
sBtAvrcpInterface->register_notification_rsp(BTRC_EVT_PLAY_STATUS_CHANGED,
|
||||
sBtAvrcpInterface->RegisterNotificationRsp(BTRC_EVT_PLAY_STATUS_CHANGED,
|
||||
BTRC_NOTIFICATION_TYPE_CHANGED,
|
||||
¶m);
|
||||
}
|
||||
|
@ -993,7 +991,7 @@ BluetoothA2dpManager::UpdatePlayStatus(uint32_t aDuration,
|
|||
btrc_register_notification_t param;
|
||||
param.song_pos = aPosition;
|
||||
mPlayPosChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
|
||||
sBtAvrcpInterface->register_notification_rsp(BTRC_EVT_PLAY_POS_CHANGED,
|
||||
sBtAvrcpInterface->RegisterNotificationRsp(BTRC_EVT_PLAY_POS_CHANGED,
|
||||
BTRC_NOTIFICATION_TYPE_CHANGED,
|
||||
¶m);
|
||||
}
|
||||
|
@ -1061,7 +1059,7 @@ BluetoothA2dpManager::UpdateRegisterNotification(int aEventId, int aParam)
|
|||
break;
|
||||
}
|
||||
|
||||
sBtAvrcpInterface->register_notification_rsp((btrc_event_id_t)aEventId,
|
||||
sBtAvrcpInterface->RegisterNotificationRsp((btrc_event_id_t)aEventId,
|
||||
BTRC_NOTIFICATION_TYPE_INTERIM,
|
||||
¶m);
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,659 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#include "BluetoothInterface.h"
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
template<class T>
|
||||
struct interface_traits
|
||||
{ };
|
||||
|
||||
//
|
||||
// Socket Interface
|
||||
//
|
||||
|
||||
template<>
|
||||
struct interface_traits<BluetoothSocketInterface>
|
||||
{
|
||||
typedef const btsock_interface_t const_interface_type;
|
||||
|
||||
static const char* profile_id()
|
||||
{
|
||||
return BT_PROFILE_SOCKETS_ID;
|
||||
}
|
||||
};
|
||||
|
||||
bt_status_t
|
||||
BluetoothSocketInterface::Listen(btsock_type_t aType,
|
||||
const char* aServiceName,
|
||||
const uint8_t* aServiceUuid, int aChannel,
|
||||
int& aSockFd, int aFlags)
|
||||
{
|
||||
return mInterface->listen(aType, aServiceName, aServiceUuid, aChannel,
|
||||
&aSockFd, aFlags);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothSocketInterface::Connect(const bt_bdaddr_t* aBdAddr,
|
||||
btsock_type_t aType, const uint8_t* aUuid,
|
||||
int aChannel, int& aSockFd, int aFlags)
|
||||
{
|
||||
return mInterface->connect(aBdAddr, aType, aUuid, aChannel, &aSockFd,
|
||||
aFlags);
|
||||
}
|
||||
|
||||
BluetoothSocketInterface::BluetoothSocketInterface(
|
||||
const btsock_interface_t* aInterface)
|
||||
: mInterface(aInterface)
|
||||
{
|
||||
MOZ_ASSERT(mInterface);
|
||||
}
|
||||
|
||||
BluetoothSocketInterface::~BluetoothSocketInterface()
|
||||
{ }
|
||||
|
||||
//
|
||||
// Handsfree Interface
|
||||
//
|
||||
|
||||
template<>
|
||||
struct interface_traits<BluetoothHandsfreeInterface>
|
||||
{
|
||||
typedef const bthf_interface_t const_interface_type;
|
||||
|
||||
static const char* profile_id()
|
||||
{
|
||||
return BT_PROFILE_HANDSFREE_ID;
|
||||
}
|
||||
};
|
||||
|
||||
BluetoothHandsfreeInterface::BluetoothHandsfreeInterface(
|
||||
const bthf_interface_t* aInterface)
|
||||
: mInterface(aInterface)
|
||||
{
|
||||
MOZ_ASSERT(mInterface);
|
||||
}
|
||||
|
||||
BluetoothHandsfreeInterface::~BluetoothHandsfreeInterface()
|
||||
{ }
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::Init(bthf_callbacks_t* aCallbacks)
|
||||
{
|
||||
return mInterface->init(aCallbacks);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHandsfreeInterface::Cleanup()
|
||||
{
|
||||
mInterface->cleanup();
|
||||
}
|
||||
|
||||
/* Connect / Disconnect */
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::Connect(bt_bdaddr_t* aBdAddr)
|
||||
{
|
||||
return mInterface->connect(aBdAddr);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::Disconnect(bt_bdaddr_t* aBdAddr)
|
||||
{
|
||||
return mInterface->disconnect(aBdAddr);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::ConnectAudio(bt_bdaddr_t* aBdAddr)
|
||||
{
|
||||
return mInterface->connect_audio(aBdAddr);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::DisconnectAudio(bt_bdaddr_t* aBdAddr)
|
||||
{
|
||||
return mInterface->disconnect_audio(aBdAddr);
|
||||
}
|
||||
|
||||
/* Voice Recognition */
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::StartVoiceRecognition()
|
||||
{
|
||||
return mInterface->start_voice_recognition();
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::StopVoiceRecognition()
|
||||
{
|
||||
return mInterface->stop_voice_recognition();
|
||||
}
|
||||
|
||||
/* Volume */
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::VolumeControl(bthf_volume_type_t aType,
|
||||
int aVolume)
|
||||
{
|
||||
return mInterface->volume_control(aType, aVolume);
|
||||
}
|
||||
|
||||
/* Device status */
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::DeviceStatusNotification(
|
||||
bthf_network_state_t aNtkState, bthf_service_type_t aSvcType, int aSignal,
|
||||
int aBattChg)
|
||||
{
|
||||
return mInterface->device_status_notification(aNtkState, aSvcType, aSignal,
|
||||
aBattChg);
|
||||
}
|
||||
|
||||
/* Responses */
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::CopsResponse(const char* aCops)
|
||||
{
|
||||
return mInterface->cops_response(aCops);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::CindResponse(int aSvc, int aNumActive,
|
||||
int aNumHeld,
|
||||
bthf_call_state_t aCallSetupState,
|
||||
int aSignal, int aRoam, int aBattChg)
|
||||
{
|
||||
return mInterface->cind_response(aSvc, aNumActive, aNumHeld,
|
||||
aCallSetupState, aSignal, aRoam,
|
||||
aBattChg);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::FormattedAtResponse(const char* aRsp)
|
||||
{
|
||||
return mInterface->formatted_at_response(aRsp);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::AtResponse(bthf_at_response_t aResponseCode,
|
||||
int aErrorCode)
|
||||
{
|
||||
return mInterface->at_response(aResponseCode, aErrorCode);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::ClccResponse(int aIndex,
|
||||
bthf_call_direction_t aDir,
|
||||
bthf_call_state_t aState,
|
||||
bthf_call_mode_t aMode,
|
||||
bthf_call_mpty_type_t aMpty,
|
||||
const char* aNumber,
|
||||
bthf_call_addrtype_t aType)
|
||||
{
|
||||
return mInterface->clcc_response(aIndex, aDir, aState, aMode, aMpty,
|
||||
aNumber, aType);
|
||||
}
|
||||
|
||||
/* Phone State */
|
||||
|
||||
bt_status_t
|
||||
BluetoothHandsfreeInterface::PhoneStateChange(int aNumActive, int aNumHeld,
|
||||
bthf_call_state_t aCallSetupState, const char* aNumber,
|
||||
bthf_call_addrtype_t aType)
|
||||
{
|
||||
return mInterface->phone_state_change(aNumActive, aNumHeld, aCallSetupState,
|
||||
aNumber, aType);
|
||||
}
|
||||
|
||||
//
|
||||
// Bluetooth Advanced Audio Interface
|
||||
//
|
||||
|
||||
template<>
|
||||
struct interface_traits<BluetoothA2dpInterface>
|
||||
{
|
||||
typedef const btav_interface_t const_interface_type;
|
||||
|
||||
static const char* profile_id()
|
||||
{
|
||||
return BT_PROFILE_ADVANCED_AUDIO_ID;
|
||||
}
|
||||
};
|
||||
|
||||
BluetoothA2dpInterface::BluetoothA2dpInterface(
|
||||
const btav_interface_t* aInterface)
|
||||
: mInterface(aInterface)
|
||||
{
|
||||
MOZ_ASSERT(mInterface);
|
||||
}
|
||||
|
||||
BluetoothA2dpInterface::~BluetoothA2dpInterface()
|
||||
{ }
|
||||
|
||||
bt_status_t
|
||||
BluetoothA2dpInterface::Init(btav_callbacks_t* aCallbacks)
|
||||
{
|
||||
return mInterface->init(aCallbacks);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpInterface::Cleanup()
|
||||
{
|
||||
mInterface->cleanup();
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothA2dpInterface::Connect(bt_bdaddr_t *aBdAddr)
|
||||
{
|
||||
return mInterface->connect(aBdAddr);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothA2dpInterface::Disconnect(bt_bdaddr_t *aBdAddr)
|
||||
{
|
||||
return mInterface->disconnect(aBdAddr);
|
||||
}
|
||||
|
||||
//
|
||||
// Bluetooth AVRCP Interface
|
||||
//
|
||||
|
||||
#if ANDROID_VERSION >= 18
|
||||
template<>
|
||||
struct interface_traits<BluetoothAvrcpInterface>
|
||||
{
|
||||
typedef const btrc_interface_t const_interface_type;
|
||||
|
||||
static const char* profile_id()
|
||||
{
|
||||
return BT_PROFILE_AV_RC_ID;
|
||||
}
|
||||
};
|
||||
|
||||
BluetoothAvrcpInterface::BluetoothAvrcpInterface(
|
||||
const btrc_interface_t* aInterface)
|
||||
: mInterface(aInterface)
|
||||
{
|
||||
MOZ_ASSERT(mInterface);
|
||||
}
|
||||
|
||||
BluetoothAvrcpInterface::~BluetoothAvrcpInterface()
|
||||
{ }
|
||||
|
||||
bt_status_t
|
||||
BluetoothAvrcpInterface::Init(btrc_callbacks_t* aCallbacks)
|
||||
{
|
||||
return mInterface->init(aCallbacks);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothAvrcpInterface::Cleanup()
|
||||
{
|
||||
mInterface->cleanup();
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothAvrcpInterface::GetPlayStatusRsp(btrc_play_status_t aPlayStatus,
|
||||
uint32_t aSongLen, uint32_t aSongPos)
|
||||
{
|
||||
return mInterface->get_play_status_rsp(aPlayStatus, aSongLen, aSongPos);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothAvrcpInterface::ListPlayerAppAttrRsp(int aNumAttr,
|
||||
btrc_player_attr_t* aPAttrs)
|
||||
{
|
||||
return mInterface->list_player_app_attr_rsp(aNumAttr, aPAttrs);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothAvrcpInterface::ListPlayerAppValueRsp(int aNumVal, uint8_t* aPVals)
|
||||
{
|
||||
return mInterface->list_player_app_value_rsp(aNumVal, aPVals);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothAvrcpInterface::GetPlayerAppValueRsp(btrc_player_settings_t* aPVals)
|
||||
{
|
||||
return mInterface->get_player_app_value_rsp(aPVals);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothAvrcpInterface::GetPlayerAppAttrTextRsp(int aNumAttr,
|
||||
btrc_player_setting_text_t* aPAttrs)
|
||||
{
|
||||
return mInterface->get_player_app_attr_text_rsp(aNumAttr, aPAttrs);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothAvrcpInterface::GetPlayerAppValueTextRsp(int aNumVal,
|
||||
btrc_player_setting_text_t* aPVals)
|
||||
{
|
||||
return mInterface->get_player_app_value_text_rsp(aNumVal, aPVals);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothAvrcpInterface::GetElementAttrRsp(uint8_t aNumAttr,
|
||||
btrc_element_attr_val_t* aPAttrs)
|
||||
{
|
||||
return mInterface->get_element_attr_rsp(aNumAttr, aPAttrs);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothAvrcpInterface::SetPlayerAppValueRsp(btrc_status_t aRspStatus)
|
||||
{
|
||||
return mInterface->set_player_app_value_rsp(aRspStatus);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothAvrcpInterface::RegisterNotificationRsp(btrc_event_id_t aEventId,
|
||||
btrc_notification_type_t aType, btrc_register_notification_t* aPParam)
|
||||
{
|
||||
return mInterface->register_notification_rsp(aEventId, aType, aPParam);
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothAvrcpInterface::SetVolume(uint8_t aVolume)
|
||||
{
|
||||
#if ANDROID_VERSION >= 19
|
||||
return mInterface->set_volume(aVolume);
|
||||
#else
|
||||
return BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
}
|
||||
#endif // ANDROID_VERSION >= 18
|
||||
|
||||
//
|
||||
// Bluetooth Core Interface
|
||||
//
|
||||
|
||||
/* returns the container structure of a variable; _t is the container's
|
||||
* type, _v the name of the variable, and _m is _v's field within _t
|
||||
*/
|
||||
#define container(_t, _v, _m) \
|
||||
( (_t*)( ((const unsigned char*)(_v)) - offsetof(_t, _m) ) )
|
||||
|
||||
BluetoothInterface*
|
||||
BluetoothInterface::GetInstance()
|
||||
{
|
||||
static BluetoothInterface* sBluetoothInterface;
|
||||
|
||||
if (sBluetoothInterface) {
|
||||
return sBluetoothInterface;
|
||||
}
|
||||
|
||||
/* get driver module */
|
||||
|
||||
const hw_module_t* module;
|
||||
int err = hw_get_module(BT_HARDWARE_MODULE_ID, &module);
|
||||
if (err) {
|
||||
BT_WARNING("hw_get_module failed: %s", strerror(err));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* get device */
|
||||
|
||||
hw_device_t* device;
|
||||
err = module->methods->open(module, BT_HARDWARE_MODULE_ID, &device);
|
||||
if (err) {
|
||||
BT_WARNING("open failed: %s", strerror(err));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const bluetooth_device_t* bt_device =
|
||||
container(bluetooth_device_t, device, common);
|
||||
|
||||
/* get interface */
|
||||
|
||||
const bt_interface_t* bt_interface = bt_device->get_bluetooth_interface();
|
||||
if (!bt_interface) {
|
||||
BT_WARNING("get_bluetooth_interface failed");
|
||||
goto err_get_bluetooth_interface;
|
||||
}
|
||||
|
||||
if (bt_interface->size != sizeof(*bt_interface)) {
|
||||
BT_WARNING("interface of incorrect size");
|
||||
goto err_bt_interface_size;
|
||||
}
|
||||
|
||||
sBluetoothInterface = new BluetoothInterface(bt_interface);
|
||||
|
||||
return sBluetoothInterface;
|
||||
|
||||
err_bt_interface_size:
|
||||
err_get_bluetooth_interface:
|
||||
err = device->close(device);
|
||||
if (err) {
|
||||
BT_WARNING("close failed: %s", strerror(err));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BluetoothInterface::BluetoothInterface(const bt_interface_t* aInterface)
|
||||
: mInterface(aInterface)
|
||||
{
|
||||
MOZ_ASSERT(mInterface);
|
||||
}
|
||||
|
||||
BluetoothInterface::~BluetoothInterface()
|
||||
{ }
|
||||
|
||||
int
|
||||
BluetoothInterface::Init(bt_callbacks_t* aCallbacks)
|
||||
{
|
||||
return mInterface->init(aCallbacks);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothInterface::Cleanup()
|
||||
{
|
||||
mInterface->cleanup();
|
||||
}
|
||||
|
||||
int
|
||||
BluetoothInterface::Enable()
|
||||
{
|
||||
return mInterface->enable();
|
||||
}
|
||||
|
||||
int
|
||||
BluetoothInterface::Disable()
|
||||
{
|
||||
return mInterface->disable();
|
||||
}
|
||||
|
||||
/* Adapter Properties */
|
||||
|
||||
int
|
||||
BluetoothInterface::GetAdapterProperties()
|
||||
{
|
||||
return mInterface->get_adapter_properties();
|
||||
}
|
||||
|
||||
int
|
||||
BluetoothInterface::GetAdapterProperty(bt_property_type_t aType)
|
||||
{
|
||||
return mInterface->get_adapter_property(aType);
|
||||
}
|
||||
|
||||
int
|
||||
BluetoothInterface::SetAdapterProperty(const bt_property_t* aProperty)
|
||||
{
|
||||
return mInterface->set_adapter_property(aProperty);
|
||||
}
|
||||
|
||||
/* Remote Device Properties */
|
||||
|
||||
int
|
||||
BluetoothInterface::GetRemoteDeviceProperties(bt_bdaddr_t *aRemoteAddr)
|
||||
{
|
||||
return mInterface->get_remote_device_properties(aRemoteAddr);
|
||||
}
|
||||
|
||||
int
|
||||
BluetoothInterface::GetRemoteDeviceProperty(bt_bdaddr_t* aRemoteAddr,
|
||||
bt_property_type_t aType)
|
||||
{
|
||||
return mInterface->get_remote_device_property(aRemoteAddr, aType);
|
||||
}
|
||||
|
||||
int
|
||||
BluetoothInterface::SetRemoteDeviceProperty(bt_bdaddr_t* aRemoteAddr,
|
||||
const bt_property_t* aProperty)
|
||||
{
|
||||
return mInterface->set_remote_device_property(aRemoteAddr, aProperty);
|
||||
}
|
||||
|
||||
/* Remote Services */
|
||||
|
||||
int
|
||||
BluetoothInterface::GetRemoteServiceRecord(bt_bdaddr_t* aRemoteAddr,
|
||||
bt_uuid_t* aUuid)
|
||||
{
|
||||
return mInterface->get_remote_service_record(aRemoteAddr, aUuid);
|
||||
}
|
||||
|
||||
int
|
||||
BluetoothInterface::GetRemoteServices(bt_bdaddr_t* aRemoteAddr)
|
||||
{
|
||||
return mInterface->get_remote_services(aRemoteAddr);
|
||||
}
|
||||
|
||||
/* Discovery */
|
||||
|
||||
int
|
||||
BluetoothInterface::StartDiscovery()
|
||||
{
|
||||
return mInterface->start_discovery();
|
||||
}
|
||||
|
||||
int
|
||||
BluetoothInterface::CancelDiscovery()
|
||||
{
|
||||
return mInterface->cancel_discovery();
|
||||
}
|
||||
|
||||
/* Bonds */
|
||||
|
||||
int
|
||||
BluetoothInterface::CreateBond(const bt_bdaddr_t* aBdAddr)
|
||||
{
|
||||
return mInterface->create_bond(aBdAddr);
|
||||
}
|
||||
|
||||
int
|
||||
BluetoothInterface::RemoveBond(const bt_bdaddr_t* aBdAddr)
|
||||
{
|
||||
return mInterface->remove_bond(aBdAddr);
|
||||
}
|
||||
|
||||
int
|
||||
BluetoothInterface::CancelBond(const bt_bdaddr_t* aBdAddr)
|
||||
{
|
||||
return mInterface->cancel_bond(aBdAddr);
|
||||
}
|
||||
|
||||
/* Authentication */
|
||||
|
||||
int
|
||||
BluetoothInterface::PinReply(const bt_bdaddr_t* aBdAddr, uint8_t aAccept,
|
||||
uint8_t aPinLen, bt_pin_code_t* aPinCode)
|
||||
{
|
||||
return mInterface->pin_reply(aBdAddr, aAccept, aPinLen, aPinCode);
|
||||
}
|
||||
|
||||
int
|
||||
BluetoothInterface::SspReply(const bt_bdaddr_t* aBdAddr,
|
||||
bt_ssp_variant_t aVariant,
|
||||
uint8_t aAccept, uint32_t aPasskey)
|
||||
{
|
||||
return mInterface->ssp_reply(aBdAddr, aVariant, aAccept, aPasskey);
|
||||
}
|
||||
|
||||
/* DUT Mode */
|
||||
|
||||
int
|
||||
BluetoothInterface::DutModeConfigure(uint8_t aEnable)
|
||||
{
|
||||
return mInterface->dut_mode_configure(aEnable);
|
||||
}
|
||||
|
||||
int
|
||||
BluetoothInterface::DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen)
|
||||
{
|
||||
return mInterface->dut_mode_send(aOpcode, aBuf, aLen);
|
||||
}
|
||||
|
||||
/* LE Mode */
|
||||
|
||||
int
|
||||
BluetoothInterface::LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen)
|
||||
{
|
||||
return mInterface->le_test_mode(aOpcode, aBuf, aLen);
|
||||
}
|
||||
|
||||
/* Profile Interfaces */
|
||||
|
||||
template <class T>
|
||||
T*
|
||||
BluetoothInterface::GetProfileInterface()
|
||||
{
|
||||
static T* sBluetoothProfileInterface;
|
||||
|
||||
if (sBluetoothProfileInterface) {
|
||||
return sBluetoothProfileInterface;
|
||||
}
|
||||
|
||||
typename interface_traits<T>::const_interface_type* interface =
|
||||
reinterpret_cast<typename interface_traits<T>::const_interface_type*>(
|
||||
mInterface->get_profile_interface(interface_traits<T>::profile_id()));
|
||||
|
||||
if (!interface) {
|
||||
BT_WARNING("Bluetooth profile '%s' is not supported",
|
||||
interface_traits<T>::profile_id());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (interface->size != sizeof(*interface)) {
|
||||
BT_WARNING("interface of incorrect size");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sBluetoothProfileInterface = new T(interface);
|
||||
|
||||
return sBluetoothProfileInterface;
|
||||
}
|
||||
|
||||
BluetoothSocketInterface*
|
||||
BluetoothInterface::GetBluetoothSocketInterface()
|
||||
{
|
||||
return GetProfileInterface<BluetoothSocketInterface>();
|
||||
}
|
||||
|
||||
BluetoothHandsfreeInterface*
|
||||
BluetoothInterface::GetBluetoothHandsfreeInterface()
|
||||
{
|
||||
return GetProfileInterface<BluetoothHandsfreeInterface>();
|
||||
}
|
||||
|
||||
BluetoothA2dpInterface*
|
||||
BluetoothInterface::GetBluetoothA2dpInterface()
|
||||
{
|
||||
return GetProfileInterface<BluetoothA2dpInterface>();
|
||||
}
|
||||
|
||||
BluetoothAvrcpInterface*
|
||||
BluetoothInterface::GetBluetoothAvrcpInterface()
|
||||
{
|
||||
#if ANDROID_VERSION >= 18
|
||||
return GetProfileInterface<BluetoothAvrcpInterface>();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
|
@ -0,0 +1,263 @@
|
|||
/* -*- 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_bluedroid_bluetoothinterface_h__
|
||||
#define mozilla_dom_bluetooth_bluedroid_bluetoothinterface_h__
|
||||
|
||||
#include <hardware/bluetooth.h>
|
||||
#include <hardware/bt_sock.h>
|
||||
#include <hardware/bt_hf.h>
|
||||
#include <hardware/bt_av.h>
|
||||
#if ANDROID_VERSION >= 18
|
||||
#include <hardware/bt_rc.h>
|
||||
#endif
|
||||
#include "BluetoothCommon.h"
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
class BluetoothInterface;
|
||||
|
||||
//
|
||||
// Socket Interface
|
||||
//
|
||||
|
||||
class BluetoothSocketInterface
|
||||
{
|
||||
public:
|
||||
friend BluetoothInterface;
|
||||
|
||||
// Init and Cleanup is handled by BluetoothInterface
|
||||
|
||||
bt_status_t Listen(btsock_type_t aType,
|
||||
const char* aServiceName, const uint8_t* aServiceUuid,
|
||||
int aChannel, int& aSockFd, int aFlags);
|
||||
|
||||
bt_status_t Connect(const bt_bdaddr_t* aBdAddr, btsock_type_t aType,
|
||||
const uint8_t* aUuid, int aChannel, int& aSockFd,
|
||||
int aFlags);
|
||||
|
||||
protected:
|
||||
BluetoothSocketInterface(const btsock_interface_t* aInterface);
|
||||
~BluetoothSocketInterface();
|
||||
|
||||
private:
|
||||
const btsock_interface_t* mInterface;
|
||||
};
|
||||
|
||||
//
|
||||
// Handsfree Interface
|
||||
//
|
||||
|
||||
class BluetoothHandsfreeInterface
|
||||
{
|
||||
public:
|
||||
friend BluetoothInterface;
|
||||
|
||||
bt_status_t Init(bthf_callbacks_t* aCallbacks);
|
||||
void Cleanup();
|
||||
|
||||
/* Connect / Disconnect */
|
||||
|
||||
bt_status_t Connect(bt_bdaddr_t* aBdAddr);
|
||||
bt_status_t Disconnect(bt_bdaddr_t* aBdAddr);
|
||||
bt_status_t ConnectAudio(bt_bdaddr_t* aBdAddr);
|
||||
bt_status_t DisconnectAudio(bt_bdaddr_t* aBdAddr);
|
||||
|
||||
/* Voice Recognition */
|
||||
|
||||
bt_status_t StartVoiceRecognition();
|
||||
bt_status_t StopVoiceRecognition();
|
||||
|
||||
/* Volume */
|
||||
|
||||
bt_status_t VolumeControl(bthf_volume_type_t aType, int aVolume);
|
||||
|
||||
/* Device status */
|
||||
|
||||
bt_status_t DeviceStatusNotification(bthf_network_state_t aNtkState,
|
||||
bthf_service_type_t aSvcType,
|
||||
int aSignal, int aBattChg);
|
||||
|
||||
/* Responses */
|
||||
|
||||
bt_status_t CopsResponse(const char* aCops);
|
||||
bt_status_t CindResponse(int aSvc, int aNumActive, int aNumHeld,
|
||||
bthf_call_state_t aCallSetupState, int aSignal,
|
||||
int aRoam, int aBattChg);
|
||||
bt_status_t FormattedAtResponse(const char* aRsp);
|
||||
bt_status_t AtResponse(bthf_at_response_t aResponseCode, int aErrorCode);
|
||||
bt_status_t ClccResponse(int aIndex, bthf_call_direction_t aDir,
|
||||
bthf_call_state_t aState, bthf_call_mode_t aMode,
|
||||
bthf_call_mpty_type_t aMpty, const char* aNumber,
|
||||
bthf_call_addrtype_t aType);
|
||||
|
||||
/* Phone State */
|
||||
|
||||
bt_status_t PhoneStateChange(int aNumActive, int aNumHeld,
|
||||
bthf_call_state_t aCallSetupState,
|
||||
const char* aNumber,
|
||||
bthf_call_addrtype_t aType);
|
||||
|
||||
protected:
|
||||
BluetoothHandsfreeInterface(const bthf_interface_t* aInterface);
|
||||
~BluetoothHandsfreeInterface();
|
||||
|
||||
private:
|
||||
const bthf_interface_t* mInterface;
|
||||
};
|
||||
|
||||
//
|
||||
// Bluetooth Advanced Audio Interface
|
||||
//
|
||||
|
||||
class BluetoothA2dpInterface
|
||||
{
|
||||
public:
|
||||
friend BluetoothInterface;
|
||||
|
||||
bt_status_t Init(btav_callbacks_t *aCallbacks);
|
||||
void Cleanup();
|
||||
|
||||
bt_status_t Connect(bt_bdaddr_t *aBdAddr);
|
||||
bt_status_t Disconnect(bt_bdaddr_t *aBdAddr);
|
||||
|
||||
protected:
|
||||
BluetoothA2dpInterface(const btav_interface_t* aInterface);
|
||||
~BluetoothA2dpInterface();
|
||||
|
||||
private:
|
||||
const btav_interface_t* mInterface;
|
||||
};
|
||||
|
||||
//
|
||||
// Bluetooth AVRCP Interface
|
||||
//
|
||||
|
||||
class BluetoothAvrcpInterface
|
||||
{
|
||||
#if ANDROID_VERSION >= 18
|
||||
public:
|
||||
friend BluetoothInterface;
|
||||
|
||||
bt_status_t Init(btrc_callbacks_t* aCallbacks);
|
||||
void Cleanup();
|
||||
|
||||
bt_status_t GetPlayStatusRsp(btrc_play_status_t aPlayStatus,
|
||||
uint32_t aSongLen, uint32_t aSongPos);
|
||||
|
||||
bt_status_t ListPlayerAppAttrRsp(int aNumAttr, btrc_player_attr_t* aPAttrs);
|
||||
bt_status_t ListPlayerAppValueRsp(int aNumVal, uint8_t* aPVals);
|
||||
|
||||
bt_status_t GetPlayerAppValueRsp(btrc_player_settings_t* aPVals);
|
||||
bt_status_t GetPlayerAppAttrTextRsp(int aNumAttr,
|
||||
btrc_player_setting_text_t* aPAttrs);
|
||||
bt_status_t GetPlayerAppValueTextRsp(int aNumVal,
|
||||
btrc_player_setting_text_t* aPVals);
|
||||
|
||||
bt_status_t GetElementAttrRsp(uint8_t aNumAttr,
|
||||
btrc_element_attr_val_t* aPAttrs);
|
||||
|
||||
bt_status_t SetPlayerAppValueRsp(btrc_status_t aRspStatus);
|
||||
|
||||
bt_status_t RegisterNotificationRsp(btrc_event_id_t aEventId,
|
||||
btrc_notification_type_t aType,
|
||||
btrc_register_notification_t* aPParam);
|
||||
|
||||
bt_status_t SetVolume(uint8_t aVolume);
|
||||
|
||||
protected:
|
||||
BluetoothAvrcpInterface(const btrc_interface_t* aInterface);
|
||||
~BluetoothAvrcpInterface();
|
||||
|
||||
private:
|
||||
const btrc_interface_t* mInterface;
|
||||
#endif
|
||||
};
|
||||
|
||||
//
|
||||
// Bluetooth Core Interface
|
||||
//
|
||||
|
||||
class BluetoothInterface
|
||||
{
|
||||
public:
|
||||
static BluetoothInterface* GetInstance();
|
||||
|
||||
int Init(bt_callbacks_t* aCallbacks);
|
||||
void Cleanup();
|
||||
|
||||
int Enable();
|
||||
int Disable();
|
||||
|
||||
/* Adapter Properties */
|
||||
|
||||
int GetAdapterProperties();
|
||||
int GetAdapterProperty(bt_property_type_t aType);
|
||||
int SetAdapterProperty(const bt_property_t* aProperty);
|
||||
|
||||
/* Remote Device Properties */
|
||||
|
||||
int GetRemoteDeviceProperties(bt_bdaddr_t *aRemoteAddr);
|
||||
int GetRemoteDeviceProperty(bt_bdaddr_t* aRemoteAddr,
|
||||
bt_property_type_t aType);
|
||||
int SetRemoteDeviceProperty(bt_bdaddr_t* aRemoteAddr,
|
||||
const bt_property_t* aProperty);
|
||||
|
||||
/* Remote Services */
|
||||
|
||||
int GetRemoteServiceRecord(bt_bdaddr_t* aRemoteAddr,
|
||||
bt_uuid_t* aUuid);
|
||||
int GetRemoteServices(bt_bdaddr_t* aRemoteAddr);
|
||||
|
||||
/* Discovery */
|
||||
|
||||
int StartDiscovery();
|
||||
int CancelDiscovery();
|
||||
|
||||
/* Bonds */
|
||||
|
||||
int CreateBond(const bt_bdaddr_t* aBdAddr);
|
||||
int RemoveBond(const bt_bdaddr_t* aBdAddr);
|
||||
int CancelBond(const bt_bdaddr_t* aBdAddr);
|
||||
|
||||
/* Authentication */
|
||||
|
||||
int PinReply(const bt_bdaddr_t* aBdAddr, uint8_t aAccept,
|
||||
uint8_t aPinLen, bt_pin_code_t* aPinCode);
|
||||
|
||||
int SspReply(const bt_bdaddr_t* aBdAddr, bt_ssp_variant_t aVariant,
|
||||
uint8_t aAccept, uint32_t aPasskey);
|
||||
|
||||
/* DUT Mode */
|
||||
|
||||
int DutModeConfigure(uint8_t aEnable);
|
||||
int DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen);
|
||||
|
||||
/* LE Mode */
|
||||
|
||||
int LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen);
|
||||
|
||||
/* Profile Interfaces */
|
||||
|
||||
BluetoothSocketInterface* GetBluetoothSocketInterface();
|
||||
BluetoothHandsfreeInterface* GetBluetoothHandsfreeInterface();
|
||||
BluetoothA2dpInterface* GetBluetoothA2dpInterface();
|
||||
BluetoothAvrcpInterface* GetBluetoothAvrcpInterface();
|
||||
|
||||
protected:
|
||||
BluetoothInterface(const bt_interface_t* aInterface);
|
||||
~BluetoothInterface();
|
||||
|
||||
private:
|
||||
template <class T>
|
||||
T* GetProfileInterface();
|
||||
|
||||
const bt_interface_t* mInterface;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -18,10 +18,9 @@
|
|||
|
||||
#include "BluetoothServiceBluedroid.h"
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
#include "BluetoothA2dpManager.h"
|
||||
#include "BluetoothHfpManager.h"
|
||||
#include "BluetoothInterface.h"
|
||||
#include "BluetoothOppManager.h"
|
||||
#include "BluetoothProfileController.h"
|
||||
#include "BluetoothReplyRunnable.h"
|
||||
|
@ -54,7 +53,7 @@ static nsString sAdapterBdName;
|
|||
static InfallibleTArray<nsString> sAdapterBondedAddressArray;
|
||||
|
||||
// Static variables below should only be used on *main thread*
|
||||
static const bt_interface_t* sBtInterface;
|
||||
static BluetoothInterface* sBtInterface;
|
||||
static nsTArray<nsRefPtr<BluetoothProfileController> > sControllerArray;
|
||||
static nsTArray<int> sRequestedDeviceCountArray;
|
||||
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sChangeAdapterStateRunnableArray;
|
||||
|
@ -126,7 +125,7 @@ public:
|
|||
|
||||
NS_ENSURE_TRUE(sBtInterface, NS_ERROR_FAILURE);
|
||||
|
||||
int ret = sBtInterface->set_adapter_property(&prop);
|
||||
int ret = sBtInterface->SetAdapterProperty(&prop);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BT_LOGR("Fail to set: BT_SCAN_MODE_CONNECTABLE");
|
||||
}
|
||||
|
@ -176,7 +175,7 @@ public:
|
|||
// Cleanup bluetooth interfaces after BT state becomes BT_STATE_OFF.
|
||||
BluetoothHfpManager::DeinitHfpInterface();
|
||||
BluetoothA2dpManager::DeinitA2dpInterface();
|
||||
sBtInterface->cleanup();
|
||||
sBtInterface->Cleanup();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -805,19 +804,7 @@ bt_callbacks_t sBluetoothCallbacks =
|
|||
static bool
|
||||
EnsureBluetoothHalLoad()
|
||||
{
|
||||
hw_module_t* module;
|
||||
hw_device_t* device;
|
||||
|
||||
int err = hw_get_module(BT_HARDWARE_MODULE_ID, (hw_module_t const**)&module);
|
||||
if (err != 0) {
|
||||
BT_LOGR("Error: %s", strerror(err));
|
||||
return false;
|
||||
}
|
||||
module->methods->open(module, BT_HARDWARE_MODULE_ID, &device);
|
||||
bluetooth_device_t* btDevice = (bluetooth_device_t *)device;
|
||||
NS_ENSURE_TRUE(btDevice, false);
|
||||
|
||||
sBtInterface = btDevice->get_bluetooth_interface();
|
||||
sBtInterface = BluetoothInterface::GetInstance();
|
||||
NS_ENSURE_TRUE(sBtInterface, false);
|
||||
|
||||
return true;
|
||||
|
@ -826,7 +813,7 @@ EnsureBluetoothHalLoad()
|
|||
static bool
|
||||
EnableInternal()
|
||||
{
|
||||
int ret = sBtInterface->init(&sBluetoothCallbacks);
|
||||
int ret = sBtInterface->Init(&sBluetoothCallbacks);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BT_LOGR("Error while setting the callbacks");
|
||||
sBtInterface = nullptr;
|
||||
|
@ -838,7 +825,7 @@ EnableInternal()
|
|||
// If any interface cannot be initialized, turn on bluetooth core anyway.
|
||||
BluetoothHfpManager::InitHfpInterface();
|
||||
BluetoothA2dpManager::InitA2dpInterface();
|
||||
return sBtInterface->enable();
|
||||
return sBtInterface->Enable();
|
||||
}
|
||||
|
||||
static nsresult
|
||||
|
@ -861,7 +848,7 @@ StartStopGonkBluetooth(bool aShouldEnable)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
int ret = aShouldEnable ? EnableInternal() : sBtInterface->disable();
|
||||
int ret = aShouldEnable ? EnableInternal() : sBtInterface->Disable();
|
||||
NS_ENSURE_TRUE(ret == BT_STATUS_SUCCESS, NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1035,7 +1022,7 @@ BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal(
|
|||
bt_bdaddr_t addressType;
|
||||
StringToBdAddressType(deviceAddresses[i], &addressType);
|
||||
|
||||
int ret = sBtInterface->get_remote_device_properties(&addressType);
|
||||
int ret = sBtInterface->GetRemoteDeviceProperties(&addressType);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(true),
|
||||
NS_LITERAL_STRING("GetConnectedDeviceFailed"));
|
||||
|
@ -1068,7 +1055,7 @@ BluetoothServiceBluedroid::GetPairedDevicePropertiesInternal(
|
|||
// Retrieve all properties of devices
|
||||
bt_bdaddr_t addressType;
|
||||
StringToBdAddressType(aDeviceAddress[i], &addressType);
|
||||
int ret = sBtInterface->get_remote_device_properties(&addressType);
|
||||
int ret = sBtInterface->GetRemoteDeviceProperties(&addressType);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(true),
|
||||
NS_LITERAL_STRING("GetPairedDeviceFailed"));
|
||||
|
@ -1090,7 +1077,7 @@ BluetoothServiceBluedroid::StartDiscoveryInternal(
|
|||
|
||||
ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);
|
||||
|
||||
int ret = sBtInterface->start_discovery();
|
||||
int ret = sBtInterface->StartDiscovery();
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
ReplyStatusError(aRunnable, ret, NS_LITERAL_STRING("StartDiscovery"));
|
||||
|
||||
|
@ -1109,7 +1096,7 @@ BluetoothServiceBluedroid::StopDiscoveryInternal(
|
|||
|
||||
ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);
|
||||
|
||||
int ret = sBtInterface->cancel_discovery();
|
||||
int ret = sBtInterface->CancelDiscovery();
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
ReplyStatusError(aRunnable, ret, NS_LITERAL_STRING("StopDiscovery"));
|
||||
return NS_OK;
|
||||
|
@ -1174,7 +1161,7 @@ BluetoothServiceBluedroid::SetProperty(BluetoothObjectType aType,
|
|||
|
||||
sSetPropertyRunnableArray.AppendElement(aRunnable);
|
||||
|
||||
int ret = sBtInterface->set_adapter_property(&prop);
|
||||
int ret = sBtInterface->SetAdapterProperty(&prop);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
ReplyStatusError(aRunnable, ret, NS_LITERAL_STRING(ERR_SET_PROPERTY));
|
||||
sSetPropertyRunnableArray.RemoveElement(aRunnable);
|
||||
|
@ -1212,7 +1199,7 @@ BluetoothServiceBluedroid::CreatePairedDeviceInternal(
|
|||
bt_bdaddr_t remoteAddress;
|
||||
StringToBdAddressType(aDeviceAddress, &remoteAddress);
|
||||
|
||||
int ret = sBtInterface->create_bond(&remoteAddress);
|
||||
int ret = sBtInterface->CreateBond(&remoteAddress);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
ReplyStatusError(aRunnable, ret, NS_LITERAL_STRING("CreatedPairedDevice"));
|
||||
} else {
|
||||
|
@ -1233,7 +1220,7 @@ BluetoothServiceBluedroid::RemoveDeviceInternal(
|
|||
bt_bdaddr_t remoteAddress;
|
||||
StringToBdAddressType(aDeviceAddress, &remoteAddress);
|
||||
|
||||
int ret = sBtInterface->remove_bond(&remoteAddress);
|
||||
int ret = sBtInterface->RemoveBond(&remoteAddress);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
ReplyStatusError(aRunnable, ret,
|
||||
NS_LITERAL_STRING("RemoveDevice"));
|
||||
|
@ -1256,7 +1243,7 @@ BluetoothServiceBluedroid::SetPinCodeInternal(
|
|||
bt_bdaddr_t remoteAddress;
|
||||
StringToBdAddressType(aDeviceAddress, &remoteAddress);
|
||||
|
||||
int ret = sBtInterface->pin_reply(
|
||||
int ret = sBtInterface->PinReply(
|
||||
&remoteAddress, true, aPinCode.Length(),
|
||||
(bt_pin_code_t*)NS_ConvertUTF16toUTF8(aPinCode).get());
|
||||
|
||||
|
@ -1289,7 +1276,7 @@ BluetoothServiceBluedroid::SetPairingConfirmationInternal(
|
|||
bt_bdaddr_t remoteAddress;
|
||||
StringToBdAddressType(aDeviceAddress, &remoteAddress);
|
||||
|
||||
int ret = sBtInterface->ssp_reply(&remoteAddress, (bt_ssp_variant_t)0,
|
||||
int ret = sBtInterface->SspReply(&remoteAddress, (bt_ssp_variant_t)0,
|
||||
aConfirm, 0);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
ReplyStatusError(aRunnable, ret,
|
||||
|
@ -1340,12 +1327,6 @@ ConnectDisconnect(bool aConnect, const nsAString& aDeviceAddress,
|
|||
}
|
||||
}
|
||||
|
||||
const bt_interface_t*
|
||||
BluetoothServiceBluedroid::GetBluetoothInterface()
|
||||
{
|
||||
return sBtInterface;
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::Connect(const nsAString& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
#include "BluetoothSocket.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <hardware/bluetooth.h>
|
||||
#include <hardware/bt_sock.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "base/message_loop.h"
|
||||
#include "BluetoothInterface.h"
|
||||
#include "BluetoothSocketObserver.h"
|
||||
#include "BluetoothUtils.h"
|
||||
#include "mozilla/FileUtils.h"
|
||||
|
@ -30,7 +29,7 @@ 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 const btsock_interface_t* sBluetoothSocketInterface = nullptr;
|
||||
static BluetoothSocketInterface* sBluetoothSocketInterface;
|
||||
|
||||
// helper functions
|
||||
static bool
|
||||
|
@ -40,11 +39,10 @@ EnsureBluetoothSocketHalLoad()
|
|||
return true;
|
||||
}
|
||||
|
||||
const bt_interface_t* btInf = GetBluetoothInterface();
|
||||
BluetoothInterface* btInf = BluetoothInterface::GetInstance();
|
||||
NS_ENSURE_TRUE(btInf, false);
|
||||
|
||||
sBluetoothSocketInterface =
|
||||
(btsock_interface_t *) btInf->get_profile_interface(BT_PROFILE_SOCKETS_ID);
|
||||
sBluetoothSocketInterface = btInf->GetBluetoothSocketInterface();
|
||||
NS_ENSURE_TRUE(sBluetoothSocketInterface, false);
|
||||
|
||||
return true;
|
||||
|
@ -446,11 +444,11 @@ DroidSocketImpl::Connect()
|
|||
// TODO: uuid as argument
|
||||
int fd = -1;
|
||||
bt_status_t status =
|
||||
sBluetoothSocketInterface->connect(&remoteBdAddress,
|
||||
sBluetoothSocketInterface->Connect(&remoteBdAddress,
|
||||
BTSOCK_RFCOMM,
|
||||
UUID_OBEX_OBJECT_PUSH,
|
||||
mChannel,
|
||||
&fd,
|
||||
fd,
|
||||
(BTSOCK_FLAG_ENCRYPT * mEncrypt) |
|
||||
(BTSOCK_FLAG_AUTH * mAuth));
|
||||
NS_ENSURE_TRUE_VOID(status == BT_STATUS_SUCCESS);
|
||||
|
@ -479,11 +477,11 @@ DroidSocketImpl::Listen()
|
|||
|
||||
int fd = -1;
|
||||
bt_status_t status =
|
||||
sBluetoothSocketInterface->listen(BTSOCK_RFCOMM,
|
||||
sBluetoothSocketInterface->Listen(BTSOCK_RFCOMM,
|
||||
"OBEX Object Push",
|
||||
UUID_OBEX_OBJECT_PUSH,
|
||||
mChannel,
|
||||
&fd,
|
||||
fd,
|
||||
(BTSOCK_FLAG_ENCRYPT * mEncrypt) |
|
||||
(BTSOCK_FLAG_AUTH * mAuth));
|
||||
NS_ENSURE_TRUE_VOID(status == BT_STATUS_SUCCESS);
|
||||
|
|
|
@ -23,12 +23,6 @@
|
|||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
const bt_interface_t*
|
||||
GetBluetoothInterface()
|
||||
{
|
||||
return BluetoothServiceBluedroid::GetBluetoothInterface();
|
||||
}
|
||||
|
||||
void
|
||||
StringToBdAddressType(const nsAString& aBdAddress,
|
||||
bt_bdaddr_t *aRetBdAddressType)
|
||||
|
|
|
@ -18,9 +18,6 @@ class BluetoothNamedValue;
|
|||
class BluetoothValue;
|
||||
class BluetoothReplyRunnable;
|
||||
|
||||
const bt_interface_t*
|
||||
GetBluetoothInterface();
|
||||
|
||||
void
|
||||
StringToBdAddressType(const nsAString& aBdAddress,
|
||||
bt_bdaddr_t *aRetBdAddressType);
|
||||
|
|
|
@ -52,7 +52,7 @@ USING_BLUETOOTH_NAMESPACE
|
|||
|
||||
namespace {
|
||||
StaticRefPtr<BluetoothHfpManager> sBluetoothHfpManager;
|
||||
static const bthf_interface_t* sBluetoothHfpInterface = nullptr;
|
||||
static BluetoothHandsfreeInterface* sBluetoothHfpInterface = nullptr;
|
||||
|
||||
bool sInShutdown = false;
|
||||
|
||||
|
@ -432,20 +432,20 @@ BluetoothHfpManager::Init()
|
|||
void
|
||||
BluetoothHfpManager::InitHfpInterface()
|
||||
{
|
||||
const bt_interface_t* btInf = GetBluetoothInterface();
|
||||
BluetoothInterface* btInf = BluetoothInterface::GetInstance();
|
||||
NS_ENSURE_TRUE_VOID(btInf);
|
||||
|
||||
if (sBluetoothHfpInterface) {
|
||||
sBluetoothHfpInterface->cleanup();
|
||||
sBluetoothHfpInterface->Cleanup();
|
||||
sBluetoothHfpInterface = nullptr;
|
||||
}
|
||||
|
||||
bthf_interface_t *interface = (bthf_interface_t *)
|
||||
btInf->get_profile_interface(BT_PROFILE_HANDSFREE_ID);
|
||||
BluetoothHandsfreeInterface *interface =
|
||||
btInf->GetBluetoothHandsfreeInterface();
|
||||
NS_ENSURE_TRUE_VOID(interface);
|
||||
|
||||
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
|
||||
interface->init(&sBluetoothHfpCallbacks));
|
||||
interface->Init(&sBluetoothHfpCallbacks));
|
||||
sBluetoothHfpInterface = interface;
|
||||
}
|
||||
|
||||
|
@ -471,10 +471,8 @@ BluetoothHfpManager::~BluetoothHfpManager()
|
|||
void
|
||||
BluetoothHfpManager::DeinitHfpInterface()
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(GetBluetoothInterface());
|
||||
|
||||
if (sBluetoothHfpInterface) {
|
||||
sBluetoothHfpInterface->cleanup();
|
||||
sBluetoothHfpInterface->Cleanup();
|
||||
sBluetoothHfpInterface = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -677,7 +675,7 @@ BluetoothHfpManager::ProcessAtCind()
|
|||
int numActive = GetNumberOfCalls(nsITelephonyService::CALL_STATE_CONNECTED);
|
||||
int numHeld = GetNumberOfCalls(nsITelephonyService::CALL_STATE_HELD);
|
||||
|
||||
bt_status_t status = sBluetoothHfpInterface->cind_response(
|
||||
bt_status_t status = sBluetoothHfpInterface->CindResponse(
|
||||
mService,
|
||||
numActive,
|
||||
numHeld,
|
||||
|
@ -693,7 +691,7 @@ BluetoothHfpManager::ProcessAtCops()
|
|||
{
|
||||
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
|
||||
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
|
||||
sBluetoothHfpInterface->cops_response(
|
||||
sBluetoothHfpInterface->CopsResponse(
|
||||
NS_ConvertUTF16toUTF8(mOperatorName).get()));
|
||||
}
|
||||
|
||||
|
@ -723,7 +721,7 @@ BluetoothHfpManager::ProcessUnknownAt(char *aAtString)
|
|||
|
||||
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
|
||||
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
|
||||
sBluetoothHfpInterface->at_response(BTHF_AT_RESPONSE_ERROR, 0));
|
||||
sBluetoothHfpInterface->AtResponse(BTHF_AT_RESPONSE_ERROR, 0));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -879,7 +877,7 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
|
|||
if (IsConnected()) {
|
||||
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
|
||||
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
|
||||
sBluetoothHfpInterface->volume_control(BTHF_VOLUME_TYPE_SPK,
|
||||
sBluetoothHfpInterface->VolumeControl(BTHF_VOLUME_TYPE_SPK,
|
||||
mCurrentVgs));
|
||||
}
|
||||
}
|
||||
|
@ -990,7 +988,7 @@ BluetoothHfpManager::SendCLCC(Call& aCall, int aIndex)
|
|||
callState = BTHF_CALL_STATE_WAITING;
|
||||
}
|
||||
|
||||
bt_status_t status = sBluetoothHfpInterface->clcc_response(
|
||||
bt_status_t status = sBluetoothHfpInterface->ClccResponse(
|
||||
aIndex,
|
||||
aCall.mDirection,
|
||||
callState,
|
||||
|
@ -1006,7 +1004,7 @@ BluetoothHfpManager::SendLine(const char* aMessage)
|
|||
{
|
||||
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
|
||||
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
|
||||
sBluetoothHfpInterface->formatted_at_response(aMessage));
|
||||
sBluetoothHfpInterface->FormattedAtResponse(aMessage));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1014,7 +1012,7 @@ BluetoothHfpManager::SendResponse(bthf_at_response_t aResponseCode)
|
|||
{
|
||||
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
|
||||
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
|
||||
sBluetoothHfpInterface->at_response(aResponseCode, 0));
|
||||
sBluetoothHfpInterface->AtResponse(aResponseCode, 0));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1035,7 +1033,7 @@ BluetoothHfpManager::UpdatePhoneCIND(uint32_t aCallIndex)
|
|||
numActive, numHeld, callSetupState);
|
||||
|
||||
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
|
||||
sBluetoothHfpInterface->phone_state_change(
|
||||
sBluetoothHfpInterface->PhoneStateChange(
|
||||
numActive, numHeld, callSetupState, number.get(), type));
|
||||
}
|
||||
|
||||
|
@ -1044,7 +1042,7 @@ BluetoothHfpManager::UpdateDeviceCIND()
|
|||
{
|
||||
if (sBluetoothHfpInterface) {
|
||||
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
|
||||
sBluetoothHfpInterface->device_status_notification(
|
||||
sBluetoothHfpInterface->DeviceStatusNotification(
|
||||
(bthf_network_state_t) mService,
|
||||
(bthf_service_type_t) mRoam,
|
||||
mSignal,
|
||||
|
@ -1296,7 +1294,7 @@ BluetoothHfpManager::ConnectSco()
|
|||
bt_bdaddr_t deviceBdAddress;
|
||||
StringToBdAddressType(mDeviceAddress, &deviceBdAddress);
|
||||
NS_ENSURE_TRUE(BT_STATUS_SUCCESS ==
|
||||
sBluetoothHfpInterface->connect_audio(&deviceBdAddress), false);
|
||||
sBluetoothHfpInterface->ConnectAudio(&deviceBdAddress), false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1310,7 +1308,7 @@ BluetoothHfpManager::DisconnectSco()
|
|||
bt_bdaddr_t deviceBdAddress;
|
||||
StringToBdAddressType(mDeviceAddress, &deviceBdAddress);
|
||||
NS_ENSURE_TRUE(BT_STATUS_SUCCESS ==
|
||||
sBluetoothHfpInterface->disconnect_audio(&deviceBdAddress), false);
|
||||
sBluetoothHfpInterface->DisconnectAudio(&deviceBdAddress), false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1348,7 +1346,7 @@ BluetoothHfpManager::Connect(const nsAString& aDeviceAddress,
|
|||
bt_bdaddr_t deviceBdAddress;
|
||||
StringToBdAddressType(aDeviceAddress, &deviceBdAddress);
|
||||
|
||||
bt_status_t result = sBluetoothHfpInterface->connect(&deviceBdAddress);
|
||||
bt_status_t result = sBluetoothHfpInterface->Connect(&deviceBdAddress);
|
||||
if (BT_STATUS_SUCCESS != result) {
|
||||
BT_LOGR("Failed to connect: %x", result);
|
||||
aController->NotifyCompletion(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
|
||||
|
@ -1374,7 +1372,7 @@ BluetoothHfpManager::Disconnect(BluetoothProfileController* aController)
|
|||
bt_bdaddr_t deviceBdAddress;
|
||||
StringToBdAddressType(mDeviceAddress, &deviceBdAddress);
|
||||
|
||||
bt_status_t result = sBluetoothHfpInterface->disconnect(&deviceBdAddress);
|
||||
bt_status_t result = sBluetoothHfpInterface->Disconnect(&deviceBdAddress);
|
||||
if (BT_STATUS_SUCCESS != result) {
|
||||
BT_LOGR("Failed to disconnect: %x", result);
|
||||
aController->NotifyCompletion(NS_LITERAL_STRING(ERR_DISCONNECTION_FAILED));
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
#ifndef mozilla_dom_bluetooth_bluetoothhfpmanager_h__
|
||||
#define mozilla_dom_bluetooth_bluetoothhfpmanager_h__
|
||||
|
||||
#include <hardware/bluetooth.h>
|
||||
#include <hardware/bt_hf.h>
|
||||
|
||||
#include "BluetoothInterface.h"
|
||||
#include "BluetoothCommon.h"
|
||||
#include "BluetoothHfpManagerBase.h"
|
||||
#include "BluetoothRilListener.h"
|
||||
|
|
|
@ -43,6 +43,7 @@ if CONFIG['MOZ_B2G_BT']:
|
|||
elif CONFIG['MOZ_B2G_BT_BLUEDROID']:
|
||||
SOURCES += [
|
||||
'bluedroid/BluetoothA2dpManager.cpp',
|
||||
'bluedroid/BluetoothInterface.cpp',
|
||||
'bluedroid/BluetoothOppManager.cpp',
|
||||
'bluedroid/BluetoothServiceBluedroid.cpp',
|
||||
'bluedroid/BluetoothSocket.cpp',
|
||||
|
|
|
@ -9,6 +9,7 @@ let url = "http://www.mozilla.org";
|
|||
// TODO : Get this from emulator console command.
|
||||
const T1T_RE_INDEX = 2;
|
||||
const T2T_RE_INDEX = 3;
|
||||
const T3T_RE_INDEX = 4;
|
||||
|
||||
function testUrlTagDiscover(re) {
|
||||
log("Running \'testUrlTagDiscover\'");
|
||||
|
@ -47,9 +48,14 @@ function testUrlT2TDiscover() {
|
|||
testUrlTagDiscover(T2T_RE_INDEX);
|
||||
}
|
||||
|
||||
function testUrlT3TDiscover() {
|
||||
testUrlTagDiscover(T3T_RE_INDEX);
|
||||
}
|
||||
|
||||
let tests = [
|
||||
testUrlT1TDiscover,
|
||||
testUrlT2TDiscover
|
||||
testUrlT2TDiscover,
|
||||
testUrlT3TDiscover
|
||||
];
|
||||
|
||||
SpecialPowers.pushPermissions(
|
||||
|
|
Загрузка…
Ссылка в новой задаче