Merge m-c to inbound on a CLOSED TREE a=merge

This commit is contained in:
Wes Kocher 2014-08-06 18:18:37 -07:00
commit 36f47ccc2f
24 changed files with 1567 additions and 571 deletions

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="5e6ef81cb9e917657ce050f598229dfc83c58b8f"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="079c5f85875b0f2eb341ca9fd375f1b905ed7157"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cff8f990433810780088c545641c3110d956949f"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>

View File

@ -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="5e6ef81cb9e917657ce050f598229dfc83c58b8f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="079c5f85875b0f2eb341ca9fd375f1b905ed7157"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cff8f990433810780088c545641c3110d956949f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="71f5a35e3bc1801847413cff1f14fc3b5cd991ca"/>
@ -133,7 +133,7 @@
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="683623c76338dccd65e698bfb5c4cfee8808d799"/>
<project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="0e56e450367cd802241b27164a2979188242b95f"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="9f28c4faea3b2f01db227b2467b08aeba96d9bec"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="b6f025acd8ead1c3531e1ad62e70849161ed9340"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="02104803f873a4d5cf9fb611a211b83450e9dfba"/>
<project name="android-sdk" path="sdk" remote="b2g" revision="8b1365af38c9a653df97349ee53a3f5d64fd590a"/>
<project name="darwinstreamingserver" path="system/darwinstreamingserver" remote="b2g" revision="cf85968c7f85e0ec36e72c87ceb4837a943b8af6"/>
</manifest>

View File

@ -12,10 +12,10 @@
<!--original fetch url was https://git.mozilla.org/releases-->
<remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
<!-- B2G specific things. -->
<project name="platform_build" path="build" remote="b2g" revision="999e945b85c578c503ad445c2285940f16aacdae">
<project name="platform_build" path="build" remote="b2g" revision="7945ca73e687be5edbc7b928dc7fe3a208242144">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="5e6ef81cb9e917657ce050f598229dfc83c58b8f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="079c5f85875b0f2eb341ca9fd375f1b905ed7157"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cff8f990433810780088c545641c3110d956949f"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

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="5e6ef81cb9e917657ce050f598229dfc83c58b8f"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="079c5f85875b0f2eb341ca9fd375f1b905ed7157"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cff8f990433810780088c545641c3110d956949f"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>

View File

@ -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="5e6ef81cb9e917657ce050f598229dfc83c58b8f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="079c5f85875b0f2eb341ca9fd375f1b905ed7157"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cff8f990433810780088c545641c3110d956949f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="71f5a35e3bc1801847413cff1f14fc3b5cd991ca"/>
@ -122,7 +122,7 @@
<!-- Flame specific things -->
<project name="device/generic/armv7-a-neon" path="device/generic/armv7-a-neon" revision="e8a318f7690092e639ba88891606f4183e846d3f"/>
<project name="device/qcom/common" path="device/qcom/common" revision="878804e0becfe5635bb8ccbf2671333d546c6fb6"/>
<project name="device-flame" path="device/t2m/flame" remote="b2g" revision="d7e5ed0a081a39419932b8b9fdefc9b2d903850d"/>
<project name="device-flame" path="device/t2m/flame" remote="b2g" revision="7edb4681617cd572a590d7f4c94d548d52679821"/>
<project name="codeaurora_kernel_msm" path="kernel" remote="b2g" revision="ebb14165369f5edc3f335d5bde6eef8439073589"/>
<project name="kernel_lk" path="bootable/bootloader/lk" remote="b2g" revision="2b1d8b5b7a760230f4c94c02e733e3929f44253a"/>
<project name="platform_bootable_recovery" path="bootable/recovery" remote="b2g" revision="e81502511cda303c803e63f049574634bc96f9f2"/>
@ -145,7 +145,7 @@
<project name="platform/hardware/ril" path="hardware/ril" revision="c4e2ac95907a5519a0e09f01a0d8e27fec101af0"/>
<project name="platform/system/bluetooth" path="system/bluetooth" revision="e1eb226fa3ad3874ea7b63c56a9dc7012d7ff3c2"/>
<project name="platform/system/core" path="system/core" revision="b33c9a7b8eefbeaf480f0b8f9af2c6a8a35b0aee"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="b6f025acd8ead1c3531e1ad62e70849161ed9340"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="02104803f873a4d5cf9fb611a211b83450e9dfba"/>
<project name="platform/system/qcom" path="system/qcom" revision="1cdab258b15258b7f9657da70e6f06ebd5a2fc25"/>
<project name="platform/vendor/qcom/msm8610" path="device/qcom/msm8610" revision="4ae5df252123591d5b941191790e7abed1bce5a4"/>
<project name="platform/vendor/qcom-opensource/wlan/prima" path="vendor/qcom/opensource/wlan/prima" revision="ce18b47b4a4f93a581d672bbd5cb6d12fe796ca9"/>

View File

@ -4,6 +4,6 @@
"remote": "",
"branch": ""
},
"revision": "1b07481115b939288cd034a592faef63395fdae9",
"revision": "6b8f72fc133bcfe4cf58a133a2f5e24ae2c25ad6",
"repo_path": "/integration/gaia-central"
}

View File

@ -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="5e6ef81cb9e917657ce050f598229dfc83c58b8f"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="079c5f85875b0f2eb341ca9fd375f1b905ed7157"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cff8f990433810780088c545641c3110d956949f"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

View File

@ -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="5e6ef81cb9e917657ce050f598229dfc83c58b8f"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="079c5f85875b0f2eb341ca9fd375f1b905ed7157"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cff8f990433810780088c545641c3110d956949f"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

View File

@ -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="5e6ef81cb9e917657ce050f598229dfc83c58b8f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="079c5f85875b0f2eb341ca9fd375f1b905ed7157"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cff8f990433810780088c545641c3110d956949f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="71f5a35e3bc1801847413cff1f14fc3b5cd991ca"/>
@ -129,7 +129,7 @@
<project name="device-mako" path="device/lge/mako" remote="b2g" revision="78d17f0c117f0c66dd55ee8d5c5dde8ccc93ecba"/>
<project name="device/generic/armv7-a-neon" path="device/generic/armv7-a-neon" revision="3a9a17613cc685aa232432566ad6cc607eab4ec1"/>
<project name="device/lge/mako-kernel" path="device/lge/mako-kernel" revision="d1729e53d71d711c8fde25eab8728ff2b9b4df0e"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="b6f025acd8ead1c3531e1ad62e70849161ed9340"/>
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="02104803f873a4d5cf9fb611a211b83450e9dfba"/>
<project name="platform/external/libnfc-nci" path="external/libnfc-nci" revision="7d33aaf740bbf6c7c6e9c34a92b371eda311b66b"/>
<project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="0e56e450367cd802241b27164a2979188242b95f"/>
<project name="platform/hardware/broadcom/wlan" path="hardware/broadcom/wlan" revision="0e1929fa3aa38bf9d40e9e953d619fab8164c82e"/>

View File

@ -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="5e6ef81cb9e917657ce050f598229dfc83c58b8f"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="079c5f85875b0f2eb341ca9fd375f1b905ed7157"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="cff8f990433810780088c545641c3110d956949f"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

View File

@ -132,6 +132,20 @@ extern bool gBluetoothDebugFlag;
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 BluetoothSocketType {
RFCOMM = 1,
SCO = 2,
@ -139,6 +153,57 @@ enum BluetoothSocketType {
EL2CAP = 4
};
enum BluetoothHandsfreeAtResponse {
HFP_AT_RESPONSE_ERROR,
HFP_AT_RESPONSE_OK
};
enum BluetoothHandsfreeCallAddressType {
HFP_CALL_ADDRESS_TYPE_UNKNOWN,
HFP_CALL_ADDRESS_TYPE_INTERNATIONAL
};
enum BluetoothHandsfreeCallDirection {
HFP_CALL_DIRECTION_OUTGOING,
HFP_CALL_DIRECTION_INCOMING
};
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 BluetoothHandsfreeNetworkState {
HFP_NETWORK_STATE_NOT_AVAILABLE,
HFP_NETWORK_STATE_AVAILABLE
};
enum BluetoothHandsfreeServiceType {
HFP_SERVICE_TYPE_HOME,
HFP_SERVICE_TYPE_ROAMING
};
enum BluetoothHandsfreeVolumeType {
HFP_VOLUME_TYPE_SPEAKER,
HFP_VOLUME_TYPE_MICROPHONE
};
class BluetoothSignal;
typedef mozilla::Observer<BluetoothSignal> BluetoothSignalObserver;
@ -163,6 +228,49 @@ enum ControlPlayStatus {
PLAYSTATUS_ERROR = 0xFF,
};
enum BluetoothAvrcpPlayerAttribute {
AVRCP_PLAYER_ATTRIBUTE_EQUALIZER,
AVRCP_PLAYER_ATTRIBUTE_REPEAT,
AVRCP_PLAYER_ATTRIBUTE_SHUFFLE,
AVRCP_PLAYER_ATTRIBUTE_SCAN
};
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
};
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];
};
END_BLUETOOTH_NAMESPACE
#endif // mozilla_dom_bluetooth_bluetoothcommon_h__

View File

@ -89,8 +89,8 @@ public:
class UpdateRegisterNotificationTask : public nsRunnable
{
public:
UpdateRegisterNotificationTask(btrc_event_id_t aEventId, uint32_t aParam)
: mEventId(aEventId)
UpdateRegisterNotificationTask(BluetoothAvrcpEvent aEvent, uint32_t aParam)
: mEvent(aEvent)
, mParam(aParam)
{
MOZ_ASSERT(!NS_IsMainThread());
@ -102,11 +102,11 @@ public:
BluetoothA2dpManager* a2dp = BluetoothA2dpManager::Get();
NS_ENSURE_TRUE(a2dp, NS_OK);
a2dp->UpdateRegisterNotification(mEventId, mParam);
a2dp->UpdateRegisterNotification(mEvent, mParam);
return NS_OK;
}
private:
btrc_event_id_t mEventId;
BluetoothAvrcpEvent mEvent;
uint32_t mParam;
};
@ -149,33 +149,35 @@ ConvertAttributeString(int aAttrId, nsAString& aAttrStr)
class UpdateElementAttrsTask : public nsRunnable
{
public:
UpdateElementAttrsTask(uint8_t aNumAttr, btrc_media_attr_t* aPlayerAttrs)
: mNumAttr(aNumAttr)
, mPlayerAttrs(aPlayerAttrs)
UpdateElementAttrsTask(uint8_t aNumAttr, const btrc_media_attr_t* aPlayerAttrs)
: mNumAttr(aNumAttr)
{
MOZ_ASSERT(!NS_IsMainThread());
mAttrs = new BluetoothAvrcpElementAttribute[mNumAttr];
for (uint8_t i = 0; i < mNumAttr; ++i) {
mAttrs[i].mId = aPlayerAttrs[i];
}
}
nsresult Run()
{
MOZ_ASSERT(NS_IsMainThread());
btrc_element_attr_val_t* attrs = new btrc_element_attr_val_t[mNumAttr];
for (int i = 0; i < mNumAttr; i++) {
nsAutoString attrText;
attrs[i].attr_id = mPlayerAttrs[i];
ConvertAttributeString(mPlayerAttrs[i], attrText);
strcpy((char *)attrs[i].text, NS_ConvertUTF16toUTF8(attrText).get());
for (uint8_t i = 0; i < mNumAttr; ++i) {
ConvertAttributeString(mAttrs[i].mId, mAttrs[i].mValue);
}
NS_ENSURE_TRUE(sBtAvrcpInterface, NS_OK);
sBtAvrcpInterface->GetElementAttrRsp(mNumAttr, attrs, nullptr);
sBtAvrcpInterface->GetElementAttrRsp(mNumAttr, mAttrs, nullptr);
return NS_OK;
}
private:
uint8_t mNumAttr;
btrc_media_attr_t* mPlayerAttrs;
nsAutoArrayPtr<BluetoothAvrcpElementAttribute> mAttrs;
};
class UpdatePassthroughCmdTask : public nsRunnable
@ -342,9 +344,30 @@ AvrcpGetElementAttrCallback(uint8_t aNumAttr, btrc_media_attr_t* aPlayerAttrs)
static void
AvrcpRegisterNotificationCallback(btrc_event_id_t aEventId, uint32_t aParam)
{
BluetoothAvrcpEvent event;
MOZ_ASSERT(!NS_IsMainThread());
NS_DispatchToMainThread(new UpdateRegisterNotificationTask(aEventId, aParam));
switch (aEventId) {
case BTRC_EVT_PLAY_STATUS_CHANGED:
event = AVRCP_EVENT_PLAY_STATUS_CHANGED;
case BTRC_EVT_TRACK_CHANGE:
event = AVRCP_EVENT_TRACK_CHANGE;
case BTRC_EVT_TRACK_REACHED_END:
event = AVRCP_EVENT_TRACK_REACHED_END;
case BTRC_EVT_TRACK_REACHED_START:
event = AVRCP_EVENT_TRACK_REACHED_START;
case BTRC_EVT_PLAY_POS_CHANGED:
event = AVRCP_EVENT_PLAY_POS_CHANGED;
case BTRC_EVT_APP_SETTINGS_CHANGED:
event = AVRCP_EVENT_APP_SETTINGS_CHANGED;
break;
default:
BT_LOGR("Unknown event 0x%x", aEventId);
return;
}
NS_DispatchToMainThread(new UpdateRegisterNotificationTask(event, aParam));
}
/*
@ -500,7 +523,7 @@ public:
: mRes(aRes)
{ }
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothAvrcpInterface::Init failed: %d",
(int)aStatus);
@ -528,7 +551,7 @@ public:
: mRes(aRes)
{ }
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothA2dpInterface::Init failed: %d",
(int)aStatus);
@ -659,7 +682,7 @@ public:
: mRes(aRes)
{ }
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothAvrcpInterface::Cleanup failed: %d",
(int)aStatus);
@ -688,7 +711,7 @@ public:
: mRes(aRes)
{ }
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothA2dpInterface::Cleanup failed: %d",
(int)aStatus);
@ -785,7 +808,7 @@ BluetoothA2dpManager::OnConnectError()
class ConnectResultHandler MOZ_FINAL : public BluetoothA2dpResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_LOGR("BluetoothA2dpInterface::Connect failed: %d", (int)aStatus);
@ -822,10 +845,7 @@ BluetoothA2dpManager::Connect(const nsAString& aDeviceAddress,
return;
}
bt_bdaddr_t remoteAddress;
StringToBdAddressType(aDeviceAddress, &remoteAddress);
sBtA2dpInterface->Connect(&remoteAddress, new ConnectResultHandler());
sBtA2dpInterface->Connect(aDeviceAddress, new ConnectResultHandler());
}
void
@ -839,7 +859,7 @@ BluetoothA2dpManager::OnDisconnectError()
class DisconnectResultHandler MOZ_FINAL : public BluetoothA2dpResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_LOGR("BluetoothA2dpInterface::Disconnect failed: %d", (int)aStatus);
@ -879,10 +899,7 @@ BluetoothA2dpManager::Disconnect(BluetoothProfileController* aController)
return;
}
bt_bdaddr_t remoteAddress;
StringToBdAddressType(mDeviceAddress, &remoteAddress);
sBtA2dpInterface->Disconnect(&remoteAddress, new DisconnectResultHandler());
sBtA2dpInterface->Disconnect(mDeviceAddress, new DisconnectResultHandler());
}
void
@ -1103,26 +1120,25 @@ BluetoothA2dpManager::UpdateMetaData(const nsAString& aTitle,
// Send track changed and position changed if track num is not the same.
// See also AVRCP 1.3 Spec 5.4.2
if (mMediaNumber != aMediaNumber &&
mTrackChangedNotifyType == BTRC_NOTIFICATION_TYPE_INTERIM) {
btrc_register_notification_t param;
mTrackChangedNotifyType == AVRCP_NTF_INTERIM) {
BluetoothAvrcpNotificationParam param;
// convert to network big endian format
// since track stores as uint8[8]
// 56 = 8 * (BTRC_UID_SIZE -1)
for (int i = 0; i < BTRC_UID_SIZE; ++i) {
param.track[i] = (aMediaNumber >> (56 - 8 * i));
param.mTrack[i] = (aMediaNumber >> (56 - 8 * i));
}
mTrackChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
sBtAvrcpInterface->RegisterNotificationRsp(BTRC_EVT_TRACK_CHANGE,
BTRC_NOTIFICATION_TYPE_CHANGED,
&param, nullptr);
if (mPlayPosChangedNotifyType == BTRC_NOTIFICATION_TYPE_INTERIM) {
param.song_pos = mPosition;
mTrackChangedNotifyType = AVRCP_NTF_CHANGED;
sBtAvrcpInterface->RegisterNotificationRsp(AVRCP_EVENT_TRACK_CHANGE,
AVRCP_NTF_CHANGED,
param, nullptr);
if (mPlayPosChangedNotifyType == AVRCP_NTF_INTERIM) {
param.mSongPos = mPosition;
// EVENT_PLAYBACK_POS_CHANGED shall be notified if changed current track
mPlayPosChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
sBtAvrcpInterface->RegisterNotificationRsp(
BTRC_EVT_PLAY_POS_CHANGED,
BTRC_NOTIFICATION_TYPE_CHANGED,
&param, nullptr);
mPlayPosChangedNotifyType = AVRCP_NTF_CHANGED;
sBtAvrcpInterface->RegisterNotificationRsp(AVRCP_EVENT_PLAY_POS_CHANGED,
AVRCP_NTF_CHANGED,
param, nullptr);
}
}
@ -1149,27 +1165,27 @@ BluetoothA2dpManager::UpdatePlayStatus(uint32_t aDuration,
#if ANDROID_VERSION > 17
NS_ENSURE_TRUE_VOID(sBtAvrcpInterface);
// always update playstatus first
sBtAvrcpInterface->GetPlayStatusRsp((btrc_play_status_t)aPlayStatus,
aDuration, aPosition, nullptr);
sBtAvrcpInterface->GetPlayStatusRsp(aPlayStatus, aDuration,
aPosition, nullptr);
// when play status changed, send both play status and position
if (mPlayStatus != aPlayStatus &&
mPlayStatusChangedNotifyType == BTRC_NOTIFICATION_TYPE_INTERIM) {
btrc_register_notification_t param;
param.play_status = (btrc_play_status_t)aPlayStatus;
mPlayStatusChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
sBtAvrcpInterface->RegisterNotificationRsp(BTRC_EVT_PLAY_STATUS_CHANGED,
BTRC_NOTIFICATION_TYPE_CHANGED,
&param, nullptr);
mPlayStatusChangedNotifyType == AVRCP_NTF_INTERIM) {
BluetoothAvrcpNotificationParam param;
param.mPlayStatus = aPlayStatus;
mPlayStatusChangedNotifyType = AVRCP_NTF_CHANGED;
sBtAvrcpInterface->RegisterNotificationRsp(AVRCP_EVENT_PLAY_STATUS_CHANGED,
AVRCP_NTF_CHANGED,
param, nullptr);
}
if (mPosition != aPosition &&
mPlayPosChangedNotifyType == BTRC_NOTIFICATION_TYPE_INTERIM) {
btrc_register_notification_t param;
param.song_pos = aPosition;
mPlayPosChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
sBtAvrcpInterface->RegisterNotificationRsp(BTRC_EVT_PLAY_POS_CHANGED,
BTRC_NOTIFICATION_TYPE_CHANGED,
&param, nullptr);
mPlayPosChangedNotifyType == AVRCP_NTF_INTERIM) {
BluetoothAvrcpNotificationParam param;
param.mSongPos = aPosition;
mPlayPosChangedNotifyType = AVRCP_NTF_CHANGED;
sBtAvrcpInterface->RegisterNotificationRsp(AVRCP_EVENT_PLAY_POS_CHANGED,
AVRCP_NTF_CHANGED,
param, nullptr);
}
mDuration = aDuration;
@ -1186,21 +1202,22 @@ BluetoothA2dpManager::UpdatePlayStatus(uint32_t aDuration,
* aParam is only valid when position changed
*/
void
BluetoothA2dpManager::UpdateRegisterNotification(int aEventId, int aParam)
BluetoothA2dpManager::UpdateRegisterNotification(BluetoothAvrcpEvent aEvent,
uint32_t aParam)
{
MOZ_ASSERT(NS_IsMainThread());
#if ANDROID_VERSION > 17
NS_ENSURE_TRUE_VOID(sBtAvrcpInterface);
btrc_register_notification_t param;
BluetoothAvrcpNotificationParam param;
switch (aEventId) {
case BTRC_EVT_PLAY_STATUS_CHANGED:
mPlayStatusChangedNotifyType = BTRC_NOTIFICATION_TYPE_INTERIM;
param.play_status = (btrc_play_status_t)mPlayStatus;
switch (aEvent) {
case AVRCP_EVENT_PLAY_STATUS_CHANGED:
mPlayStatusChangedNotifyType = AVRCP_NTF_INTERIM;
param.mPlayStatus = mPlayStatus;
break;
case BTRC_EVT_TRACK_CHANGE:
case AVRCP_EVENT_TRACK_CHANGE:
// In AVRCP 1.3 and 1.4, the identifier parameter of EVENT_TRACK_CHANGED
// is different.
// AVRCP 1.4: If no track is selected, we shall return 0xFFFFFFFFFFFFFFFF,
@ -1208,26 +1225,26 @@ BluetoothA2dpManager::UpdateRegisterNotification(int aEventId, int aParam)
// version 1.4 is to allow for new UID feature. As for AVRCP 1.3, we shall
// return 0xFFFFFFFF. Since PTS enforces to check this part to comply with
// the most updated spec.
mTrackChangedNotifyType = BTRC_NOTIFICATION_TYPE_INTERIM;
mTrackChangedNotifyType = AVRCP_NTF_INTERIM;
// needs to convert to network big endian format since track stores
// as uint8[8]. 56 = 8 * (BTRC_UID_SIZE -1).
for (int index = 0; index < BTRC_UID_SIZE; ++index) {
// We cannot easily check if a track is selected, so whenever A2DP is
// streaming, we assume a track is selected.
if (mSinkState == BluetoothA2dpManager::SinkState::SINK_PLAYING) {
param.track[index] = 0x0;
param.mTrack[index] = 0x0;
} else {
param.track[index] = 0xFF;
param.mTrack[index] = 0xFF;
}
}
break;
case BTRC_EVT_PLAY_POS_CHANGED:
case AVRCP_EVENT_PLAY_POS_CHANGED:
// If no track is selected, return 0xFFFFFFFF in the INTERIM response
mPlayPosChangedNotifyType = BTRC_NOTIFICATION_TYPE_INTERIM;
mPlayPosChangedNotifyType = AVRCP_NTF_INTERIM;
if (mSinkState == BluetoothA2dpManager::SinkState::SINK_PLAYING) {
param.song_pos = mPosition;
param.mSongPos = mPosition;
} else {
param.song_pos = 0xFFFFFFFF;
param.mSongPos = 0xFFFFFFFF;
}
mPlaybackInterval = aParam;
break;
@ -1235,9 +1252,8 @@ BluetoothA2dpManager::UpdateRegisterNotification(int aEventId, int aParam)
break;
}
sBtAvrcpInterface->RegisterNotificationRsp((btrc_event_id_t)aEventId,
BTRC_NOTIFICATION_TYPE_INTERIM,
&param, nullptr);
sBtAvrcpInterface->RegisterNotificationRsp(aEvent, AVRCP_NTF_INTERIM,
param, nullptr);
#endif
}

View File

@ -52,7 +52,7 @@ public:
void UpdatePlayStatus(uint32_t aDuration,
uint32_t aPosition,
ControlPlayStatus aPlayStatus);
void UpdateRegisterNotification(int aEventId, int aParam);
void UpdateRegisterNotification(BluetoothAvrcpEvent aEvent, uint32_t aParam);
void GetAlbum(nsAString& aAlbum);
uint32_t GetDuration();
ControlPlayStatus GetPlayStatus();
@ -105,9 +105,9 @@ private:
* mPlayPosChangedNotifType represents current RegisterNotification
* notification type.
*/
int mPlayStatusChangedNotifyType;
int mTrackChangedNotifyType;
int mPlayPosChangedNotifyType;
BluetoothAvrcpNotification mPlayStatusChangedNotifyType;
BluetoothAvrcpNotification mTrackChangedNotifyType;
BluetoothAvrcpNotification mPlayPosChangedNotifyType;
};
END_BLUETOOTH_NAMESPACE

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,7 @@
#include <hardware/bt_rc.h>
#endif
#include "BluetoothCommon.h"
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
BEGIN_BLUETOOTH_NAMESPACE
@ -31,9 +32,9 @@ public:
virtual ~BluetoothSocketResultHandler() { }
virtual void OnError(bt_status_t aStatus)
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("received error code %d", (int)aStatus);
BT_WARNING("Received error code %d", (int)aStatus);
}
virtual void Listen(int aSockFd) { }
@ -50,12 +51,16 @@ public:
// Init and Cleanup is handled by BluetoothInterface
void Listen(btsock_type_t aType,
const char* aServiceName, const uint8_t* aServiceUuid,
int aChannel, int aFlags, BluetoothSocketResultHandler* aRes);
void Listen(BluetoothSocketType aType,
const nsAString& aServiceName,
const uint8_t aServiceUuid[16],
int aChannel, bool aEncrypt, bool aAuth,
BluetoothSocketResultHandler* aRes);
void Connect(const bt_bdaddr_t* aBdAddr, btsock_type_t aType,
const uint8_t* aUuid, int aChannel, int aFlags,
void Connect(const nsAString& aBdAddr,
BluetoothSocketType aType,
const uint8_t aUuid[16],
int aChannel, bool aEncrypt, bool aAuth,
BluetoothSocketResultHandler* aRes);
void Accept(int aFd, BluetoothSocketResultHandler* aRes);
@ -79,7 +84,7 @@ public:
virtual ~BluetoothHandsfreeResultHandler() { }
virtual void OnError(bt_status_t aStatus)
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("Received error code %d", (int)aStatus);
}
@ -118,13 +123,13 @@ public:
/* Connect / Disconnect */
void Connect(bt_bdaddr_t* aBdAddr,
void Connect(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void Disconnect(bt_bdaddr_t* aBdAddr,
void Disconnect(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void ConnectAudio(bt_bdaddr_t* aBdAddr,
void ConnectAudio(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void DisconnectAudio(bt_bdaddr_t* aBdAddr,
void DisconnectAudio(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Voice Recognition */
@ -134,13 +139,13 @@ public:
/* Volume */
void VolumeControl(bthf_volume_type_t aType, int aVolume,
void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume,
BluetoothHandsfreeResultHandler* aRes);
/* Device status */
void DeviceStatusNotification(bthf_network_state_t aNtkState,
bthf_service_type_t aSvcType,
void DeviceStatusNotification(BluetoothHandsfreeNetworkState aNtkState,
BluetoothHandsfreeServiceType aSvcType,
int aSignal, int aBattChg,
BluetoothHandsfreeResultHandler* aRes);
@ -149,24 +154,27 @@ public:
void CopsResponse(const char* aCops,
BluetoothHandsfreeResultHandler* aRes);
void CindResponse(int aSvc, int aNumActive, int aNumHeld,
bthf_call_state_t aCallSetupState, int aSignal,
BluetoothHandsfreeCallState aCallSetupState, int aSignal,
int aRoam, int aBattChg,
BluetoothHandsfreeResultHandler* aRes);
void FormattedAtResponse(const char* aRsp,
BluetoothHandsfreeResultHandler* aRes);
void AtResponse(bthf_at_response_t aResponseCode, int aErrorCode,
void AtResponse(BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
BluetoothHandsfreeResultHandler* aRes);
void 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,
void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir,
BluetoothHandsfreeCallState aState,
BluetoothHandsfreeCallMode aMode,
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes);
/* Phone State */
void PhoneStateChange(int aNumActive, int aNumHeld,
bthf_call_state_t aCallSetupState,
const char* aNumber, bthf_call_addrtype_t aType,
BluetoothHandsfreeCallState aCallSetupState,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes);
protected:
@ -188,9 +196,9 @@ public:
virtual ~BluetoothA2dpResultHandler() { }
virtual void OnError(bt_status_t aStatus)
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("received error code %d", (int)aStatus);
BT_WARNING("Received error code %d", (int)aStatus);
}
virtual void Init() { }
@ -208,9 +216,9 @@ public:
BluetoothA2dpResultHandler* aRes);
void Cleanup(BluetoothA2dpResultHandler* aRes);
void Connect(bt_bdaddr_t *aBdAddr,
void Connect(const nsAString& aBdAddr,
BluetoothA2dpResultHandler* aRes);
void Disconnect(bt_bdaddr_t *aBdAddr,
void Disconnect(const nsAString& aBdAddr,
BluetoothA2dpResultHandler* aRes);
protected:
@ -232,9 +240,9 @@ public:
virtual ~BluetoothAvrcpResultHandler() { }
virtual void OnError(bt_status_t aStatus)
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("received error code %d", (int)aStatus);
BT_WARNING("Received error code %d", (int)aStatus);
}
virtual void Init() { }
@ -268,33 +276,39 @@ public:
BluetoothAvrcpResultHandler* aRes);
void Cleanup(BluetoothAvrcpResultHandler* aRes);
void GetPlayStatusRsp(btrc_play_status_t aPlayStatus,
void GetPlayStatusRsp(ControlPlayStatus aPlayStatus,
uint32_t aSongLen, uint32_t aSongPos,
BluetoothAvrcpResultHandler* aRes);
void ListPlayerAppAttrRsp(int aNumAttr, btrc_player_attr_t* aPAttrs,
void ListPlayerAppAttrRsp(int aNumAttr,
const BluetoothAvrcpPlayerAttribute* aPAttrs,
BluetoothAvrcpResultHandler* aRes);
void ListPlayerAppValueRsp(int aNumVal, uint8_t* aPVals,
BluetoothAvrcpResultHandler* aRes);
void GetPlayerAppValueRsp(btrc_player_settings_t* aPVals,
/* TODO: redesign this interface once we actually use it */
void GetPlayerAppValueRsp(uint8_t aNumAttrs,
const uint8_t* aIds, const uint8_t* aValues,
BluetoothAvrcpResultHandler* aRes);
/* TODO: redesign this interface once we actually use it */
void GetPlayerAppAttrTextRsp(int aNumAttr,
btrc_player_setting_text_t* aPAttrs,
const uint8_t* aIds, const char** aTexts,
BluetoothAvrcpResultHandler* aRes);
/* TODO: redesign this interface once we actually use it */
void GetPlayerAppValueTextRsp(int aNumVal,
btrc_player_setting_text_t* aPVals,
const uint8_t* aIds, const char** aTexts,
BluetoothAvrcpResultHandler* aRes);
void GetElementAttrRsp(uint8_t aNumAttr, btrc_element_attr_val_t* aPAttrs,
void GetElementAttrRsp(uint8_t aNumAttr,
const BluetoothAvrcpElementAttribute* aAttr,
BluetoothAvrcpResultHandler* aRes);
void SetPlayerAppValueRsp(btrc_status_t aRspStatus,
void SetPlayerAppValueRsp(BluetoothAvrcpStatus aRspStatus,
BluetoothAvrcpResultHandler* aRes);
void RegisterNotificationRsp(btrc_event_id_t aEventId,
btrc_notification_type_t aType,
btrc_register_notification_t* aPParam,
void RegisterNotificationRsp(BluetoothAvrcpEvent aEvent,
BluetoothAvrcpNotification aType,
const BluetoothAvrcpNotificationParam& aParam,
BluetoothAvrcpResultHandler* aRes);
void SetVolume(uint8_t aVolume, BluetoothAvrcpResultHandler* aRes);
@ -319,9 +333,9 @@ public:
virtual ~BluetoothResultHandler() { }
virtual void OnError(int aStatus)
virtual void OnError(BluetoothStatus aStatus)
{
BT_LOGR("received error code %d", aStatus);
BT_LOGR("Received error code %d", aStatus);
}
virtual void Init() { }
@ -371,28 +385,28 @@ public:
/* Adapter Properties */
void GetAdapterProperties(BluetoothResultHandler* aRes);
void GetAdapterProperty(bt_property_type_t aType,
void GetAdapterProperty(const nsAString& aName,
BluetoothResultHandler* aRes);
void SetAdapterProperty(const bt_property_t* aProperty,
void SetAdapterProperty(const BluetoothNamedValue& aProperty,
BluetoothResultHandler* aRes);
/* Remote Device Properties */
void GetRemoteDeviceProperties(bt_bdaddr_t *aRemoteAddr,
void GetRemoteDeviceProperties(const nsAString& aRemoteAddr,
BluetoothResultHandler* aRes);
void GetRemoteDeviceProperty(bt_bdaddr_t* aRemoteAddr,
bt_property_type_t aType,
void GetRemoteDeviceProperty(const nsAString& aRemoteAddr,
const nsAString& aName,
BluetoothResultHandler* aRes);
void SetRemoteDeviceProperty(bt_bdaddr_t* aRemoteAddr,
const bt_property_t* aProperty,
void SetRemoteDeviceProperty(const nsAString& aRemoteAddr,
const BluetoothNamedValue& aProperty,
BluetoothResultHandler* aRes);
/* Remote Services */
void GetRemoteServiceRecord(bt_bdaddr_t* aRemoteAddr,
bt_uuid_t* aUuid,
void GetRemoteServiceRecord(const nsAString& aRemoteAddr,
const uint8_t aUuid[16],
BluetoothResultHandler* aRes);
void GetRemoteServices(bt_bdaddr_t* aRemoteAddr,
void GetRemoteServices(const nsAString& aRemoteAddr,
BluetoothResultHandler* aRes);
/* Discovery */
@ -402,23 +416,23 @@ public:
/* Bonds */
void CreateBond(const bt_bdaddr_t* aBdAddr, BluetoothResultHandler* aRes);
void RemoveBond(const bt_bdaddr_t* aBdAddr, BluetoothResultHandler* aRes);
void CancelBond(const bt_bdaddr_t* aBdAddr, BluetoothResultHandler* aRes);
void CreateBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
void RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
void CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
/* Authentication */
void PinReply(const bt_bdaddr_t* aBdAddr, uint8_t aAccept,
uint8_t aPinLen, bt_pin_code_t* aPinCode,
void PinReply(const nsAString& aBdAddr, bool aAccept,
const nsAString& aPinCode,
BluetoothResultHandler* aRes);
void SspReply(const bt_bdaddr_t* aBdAddr, bt_ssp_variant_t aVariant,
uint8_t aAccept, uint32_t aPasskey,
void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes);
/* DUT Mode */
void DutModeConfigure(uint8_t aEnable, BluetoothResultHandler* aRes);
void DutModeConfigure(bool aEnable, BluetoothResultHandler* aRes);
void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
BluetoothResultHandler* aRes);

View File

@ -108,7 +108,7 @@ public:
: public BluetoothResultHandler
{
public:
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_LOGR("Fail to set: BT_SCAN_MODE_CONNECTABLE");
}
@ -127,15 +127,10 @@ public:
sUnbondingRunnableArray.Clear();
// Bluetooth scan mode is NONE by default
bt_scan_mode_t mode = BT_SCAN_MODE_CONNECTABLE;
bt_property_t prop;
prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE;
prop.val = (void*)&mode;
prop.len = sizeof(mode);
NS_ENSURE_TRUE(sBtInterface, NS_ERROR_FAILURE);
sBtInterface->SetAdapterProperty(&prop,
new SetAdapterPropertyResultHandler());
sBtInterface->SetAdapterProperty(
BluetoothNamedValue(NS_ConvertUTF8toUTF16("Discoverable"), true),
new SetAdapterPropertyResultHandler());
// Try to fire event 'AdapterAdded' to fit the original behaviour when
// we used BlueZ as backend.
@ -850,7 +845,7 @@ EnsureBluetoothHalLoad()
class EnableResultHandler MOZ_FINAL : public BluetoothResultHandler
{
public:
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
@ -923,7 +918,7 @@ public:
}
}
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
@ -965,7 +960,7 @@ StartGonkBluetooth()
class DisableResultHandler MOZ_FINAL : public BluetoothResultHandler
{
public:
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
@ -1004,7 +999,7 @@ StopGonkBluetooth()
static void
ReplyStatusError(BluetoothReplyRunnable* aBluetoothReplyRunnable,
int aStatusCode, const nsAString& aCustomMsg)
BluetoothStatus aStatusCode, const nsAString& aCustomMsg)
{
MOZ_ASSERT(aBluetoothReplyRunnable, "Reply runnable is nullptr");
@ -1013,17 +1008,17 @@ ReplyStatusError(BluetoothReplyRunnable* aBluetoothReplyRunnable,
nsAutoString replyError;
replyError.Assign(aCustomMsg);
if (aStatusCode == BT_STATUS_BUSY) {
if (aStatusCode == STATUS_BUSY) {
replyError.AppendLiteral(":BT_STATUS_BUSY");
} else if (aStatusCode == BT_STATUS_NOT_READY) {
} else if (aStatusCode == STATUS_NOT_READY) {
replyError.AppendLiteral(":BT_STATUS_NOT_READY");
} else if (aStatusCode == BT_STATUS_DONE) {
} else if (aStatusCode == STATUS_DONE) {
replyError.AppendLiteral(":BT_STATUS_DONE");
} else if (aStatusCode == BT_STATUS_AUTH_FAILURE) {
} else if (aStatusCode == STATUS_AUTH_FAILURE) {
replyError.AppendLiteral(":BT_STATUS_AUTH_FAILURE");
} else if (aStatusCode == BT_STATUS_RMT_DEV_DOWN) {
} else if (aStatusCode == STATUS_RMT_DEV_DOWN) {
replyError.AppendLiteral(":BT_STATUS_RMT_DEV_DOWN");
} else if (aStatusCode == BT_STATUS_FAIL) {
} else if (aStatusCode == STATUS_FAIL) {
replyError.AppendLiteral(":BT_STATUS_FAIL");
}
@ -1123,7 +1118,7 @@ public:
: mDeviceAddress(aDeviceAddress)
{ }
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
@ -1183,10 +1178,7 @@ BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal(
for (int i = 0; i < requestedDeviceCount; i++) {
// Retrieve all properties of devices
bt_bdaddr_t addressType;
StringToBdAddressType(deviceAddresses[i], &addressType);
sBtInterface->GetRemoteDeviceProperties(&addressType,
sBtInterface->GetRemoteDeviceProperties(deviceAddresses[i],
new GetRemoteDevicePropertiesResultHandler(deviceAddresses[i]));
}
@ -1213,10 +1205,7 @@ BluetoothServiceBluedroid::GetPairedDevicePropertiesInternal(
for (int i = 0; i < requestedDeviceCount; i++) {
// Retrieve all properties of devices
bt_bdaddr_t addressType;
StringToBdAddressType(aDeviceAddress[i], &addressType);
sBtInterface->GetRemoteDeviceProperties(&addressType,
sBtInterface->GetRemoteDeviceProperties(aDeviceAddress[i],
new GetRemoteDevicePropertiesResultHandler(aDeviceAddress[i]));
}
@ -1236,7 +1225,7 @@ public:
DispatchBluetoothReply(mRunnable, true, EmptyString());
}
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("StartDiscovery"));
@ -1271,7 +1260,7 @@ public:
DispatchBluetoothReply(mRunnable, true, EmptyString());
}
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("StopDiscovery"));
@ -1300,7 +1289,7 @@ public:
: mRunnable(aRunnable)
{ }
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("SetProperty"));
@ -1315,49 +1304,11 @@ BluetoothServiceBluedroid::SetProperty(BluetoothObjectType aType,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);
const nsString propName = aValue.name();
bt_property_t prop;
bt_scan_mode_t scanMode;
nsCString str;
// For Bluedroid, it's necessary to check property name for SetProperty
if (propName.EqualsLiteral("Name")) {
prop.type = BT_PROPERTY_BDNAME;
} else if (propName.EqualsLiteral("Discoverable")) {
prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE;
} else if (propName.EqualsLiteral("DiscoverableTimeout")) {
prop.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT;
} else {
BT_LOGR("Warning: Property type is not supported yet, type: %d", prop.type);
}
if (aValue.value().type() == BluetoothValue::Tuint32_t) {
// Set discoverable timeout
prop.val = (void*)aValue.value().get_uint32_t();
} else if (aValue.value().type() == BluetoothValue::TnsString) {
// Set name
str = NS_ConvertUTF16toUTF8(aValue.value().get_nsString());
const char* name = str.get();
prop.val = (void*)name;
prop.len = strlen(name);
} else if (aValue.value().type() == BluetoothValue::Tbool) {
scanMode = aValue.value().get_bool() ?
BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE :
BT_SCAN_MODE_CONNECTABLE;
prop.val = (void*)&scanMode;
prop.len = sizeof(scanMode);
} else {
BT_LOGR("SetProperty but the property cannot be recognized correctly.");
return NS_OK;
}
sSetPropertyRunnableArray.AppendElement(aRunnable);
sBtInterface->SetAdapterProperty(&prop,
sBtInterface->SetAdapterProperty(aValue,
new SetAdapterPropertyResultHandler(aRunnable));
return NS_OK;
@ -1387,7 +1338,7 @@ public:
: mRunnable(aRunnable)
{ }
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
sBondingRunnableArray.RemoveElement(mRunnable);
ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("CreatedPairedDevice"));
@ -1406,12 +1357,9 @@ BluetoothServiceBluedroid::CreatePairedDeviceInternal(
ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);
bt_bdaddr_t remoteAddress;
StringToBdAddressType(aDeviceAddress, &remoteAddress);
sBondingRunnableArray.AppendElement(aRunnable);
sBtInterface->CreateBond(&remoteAddress,
sBtInterface->CreateBond(aDeviceAddress,
new CreateBondResultHandler(aRunnable));
return NS_OK;
@ -1424,7 +1372,7 @@ public:
: mRunnable(aRunnable)
{ }
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
sUnbondingRunnableArray.RemoveElement(mRunnable);
ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("RemoveDevice"));
@ -1442,13 +1390,9 @@ BluetoothServiceBluedroid::RemoveDeviceInternal(
ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);
bt_bdaddr_t remoteAddress;
StringToBdAddressType(aDeviceAddress, &remoteAddress);
PRUint32 i = sUnbondingRunnableArray.Length();
sUnbondingRunnableArray.AppendElement(aRunnable);
sBtInterface->RemoveBond(&remoteAddress,
sBtInterface->RemoveBond(aDeviceAddress,
new RemoveBondResultHandler(aRunnable));
return NS_OK;
@ -1466,7 +1410,7 @@ public:
DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString());
}
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("SetPinCode"));
}
@ -1484,12 +1428,7 @@ BluetoothServiceBluedroid::SetPinCodeInternal(
ENSURE_BLUETOOTH_IS_READY(aRunnable, false);
bt_bdaddr_t remoteAddress;
StringToBdAddressType(aDeviceAddress, &remoteAddress);
sBtInterface->PinReply(
&remoteAddress, true, aPinCode.Length(),
(bt_pin_code_t*)NS_ConvertUTF16toUTF8(aPinCode).get(),
sBtInterface->PinReply(aDeviceAddress, true, aPinCode,
new PinReplyResultHandler(aRunnable));
return true;
@ -1515,7 +1454,7 @@ public:
DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString());
}
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
ReplyStatusError(mRunnable, aStatus,
NS_LITERAL_STRING("SetPairingConfirmation"));
@ -1534,11 +1473,9 @@ BluetoothServiceBluedroid::SetPairingConfirmationInternal(
ENSURE_BLUETOOTH_IS_READY(aRunnable, false);
bt_bdaddr_t remoteAddress;
StringToBdAddressType(aDeviceAddress, &remoteAddress);
sBtInterface->SspReply(&remoteAddress, (bt_ssp_variant_t)0, aConfirm, 0,
new SspReplyResultHandler(aRunnable));
sBtInterface->SspReply(aDeviceAddress,
NS_ConvertUTF8toUTF16("PasskeyConfirmation"),
aConfirm, 0, new SspReplyResultHandler(aRunnable));
return true;
}

View File

@ -650,7 +650,7 @@ public:
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new AcceptTask(mImpl, aFd));
}
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
BT_LOGR("BluetoothSocketInterface::Accept failed: %d", (int)aStatus);
@ -832,7 +832,7 @@ public:
new SocketConnectTask(mImpl, aFd));
}
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
BT_WARNING("Connect failed: %d", (int)aStatus);
@ -851,17 +851,14 @@ BluetoothSocket::Connect(const nsAString& aDeviceAddress, int aChannel)
mImpl = new DroidSocketImpl(XRE_GetIOMessageLoop(), this, aDeviceAddress,
aChannel, mAuth, mEncrypt);
bt_bdaddr_t remoteBdAddress;
StringToBdAddressType(aDeviceAddress, &remoteBdAddress);
// TODO: uuid as argument
sBluetoothSocketInterface->Connect(&remoteBdAddress,
BTSOCK_RFCOMM,
UUID_OBEX_OBJECT_PUSH,
aChannel,
(BTSOCK_FLAG_ENCRYPT * mEncrypt) |
(BTSOCK_FLAG_AUTH * mAuth),
new ConnectSocketResultHandler(mImpl));
sBluetoothSocketInterface->Connect(
aDeviceAddress,
BluetoothSocketType::RFCOMM,
UUID_OBEX_OBJECT_PUSH,
aChannel, mEncrypt, mAuth,
new ConnectSocketResultHandler(mImpl));
return true;
}
@ -882,7 +879,7 @@ public:
new SocketListenTask(mImpl, aFd));
}
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
@ -902,13 +899,13 @@ BluetoothSocket::Listen(int aChannel)
mImpl = new DroidSocketImpl(XRE_GetIOMessageLoop(), this, aChannel, mAuth,
mEncrypt);
sBluetoothSocketInterface->Listen(BTSOCK_RFCOMM,
"OBEX Object Push",
UUID_OBEX_OBJECT_PUSH,
aChannel,
(BTSOCK_FLAG_ENCRYPT * mEncrypt) |
(BTSOCK_FLAG_AUTH * mAuth),
new ListenResultHandler(mImpl));
sBluetoothSocketInterface->Listen(
BluetoothSocketType::RFCOMM,
NS_LITERAL_STRING("OBEX Object Push"),
UUID_OBEX_OBJECT_PUSH,
aChannel, mEncrypt, mAuth,
new ListenResultHandler(mImpl));
return true;
}

View File

@ -251,7 +251,7 @@ private:
if (!sBluetoothHfpManager->mDialingRequestProcessed) {
sBluetoothHfpManager->mDialingRequestProcessed = true;
sBluetoothHfpManager->SendResponse(BTHF_AT_RESPONSE_ERROR);
sBluetoothHfpManager->SendResponse(HFP_AT_RESPONSE_ERROR);
}
}
};
@ -325,11 +325,13 @@ void
Call::Set(const nsAString& aNumber, const bool aIsOutgoing)
{
mNumber = aNumber;
mDirection = (aIsOutgoing) ? BTHF_CALL_DIRECTION_OUTGOING :
BTHF_CALL_DIRECTION_INCOMING;
mDirection = (aIsOutgoing) ? HFP_CALL_DIRECTION_OUTGOING :
HFP_CALL_DIRECTION_INCOMING;
// Same logic as implementation in ril_worker.js
if (aNumber.Length() && aNumber[0] == '+') {
mType = BTHF_CALL_ADDRTYPE_INTERNATIONAL;
mType = HFP_CALL_ADDRESS_TYPE_INTERNATIONAL;
} else {
mType = HFP_CALL_ADDRESS_TYPE_UNKNOWN;
}
}
@ -337,9 +339,9 @@ void
Call::Reset()
{
mState = nsITelephonyService::CALL_STATE_DISCONNECTED;
mDirection = BTHF_CALL_DIRECTION_OUTGOING;
mDirection = HFP_CALL_DIRECTION_OUTGOING;
mNumber.Truncate();
mType = BTHF_CALL_ADDRTYPE_UNKNOWN;
mType = HFP_CALL_ADDRESS_TYPE_UNKNOWN;
}
bool
@ -379,8 +381,8 @@ BluetoothHfpManager::Cleanup()
mConnectionState = BTHF_CONNECTION_STATE_DISCONNECTED;
mPrevConnectionState = BTHF_CONNECTION_STATE_DISCONNECTED;
mBattChg = 5;
mService = 0;
mRoam = 0;
mService = HFP_NETWORK_STATE_NOT_AVAILABLE;
mRoam = HFP_SERVICE_TYPE_HOME;
mSignal = 0;
mController = nullptr;
@ -445,7 +447,7 @@ public:
MOZ_ASSERT(mInterface);
}
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::Init failed: %d", (int)aStatus);
if (mRes) {
@ -552,7 +554,7 @@ public:
: mRes(aRes)
{ }
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::Cleanup failed: %d", (int)aStatus);
if (mRes) {
@ -745,7 +747,7 @@ BluetoothHfpManager::ProcessAtChld(bthf_chld_type_t aChld)
BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER,
NS_ConvertUTF8toUTF16(message));
SendResponse(BTHF_AT_RESPONSE_OK);
SendResponse(HFP_AT_RESPONSE_OK);
}
void BluetoothHfpManager::ProcessDialCall(char *aNumber)
@ -777,7 +779,7 @@ void BluetoothHfpManager::ProcessDialCall(char *aNumber)
newMsg += StringHead(message, message.Length() - 1);
BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER,
NS_ConvertUTF8toUTF16(newMsg));
SendResponse(BTHF_AT_RESPONSE_OK);
SendResponse(HFP_AT_RESPONSE_OK);
}
}
@ -794,14 +796,14 @@ BluetoothHfpManager::ProcessAtCnum()
SendLine(message.get());
}
SendResponse(BTHF_AT_RESPONSE_OK);
SendResponse(HFP_AT_RESPONSE_OK);
}
class CindResponseResultHandler MOZ_FINAL
: public BluetoothHandsfreeResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::CindResponse failed: %d",
(int)aStatus);
@ -815,7 +817,8 @@ BluetoothHfpManager::ProcessAtCind()
int numActive = GetNumberOfCalls(nsITelephonyService::CALL_STATE_CONNECTED);
int numHeld = GetNumberOfCalls(nsITelephonyService::CALL_STATE_HELD);
bthf_call_state_t callState = ConvertToBthfCallState(GetCallSetupState());
BluetoothHandsfreeCallState callState =
ConvertToBluetoothHandsfreeCallState(GetCallSetupState());
sBluetoothHfpInterface->CindResponse(mService, numActive, numHeld,
callState, mSignal, mRoam, mBattChg,
@ -826,7 +829,7 @@ class CopsResponseResultHandler MOZ_FINAL
: public BluetoothHandsfreeResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::CopsResponse failed: %d",
(int)aStatus);
@ -859,14 +862,14 @@ BluetoothHfpManager::ProcessAtClcc()
SendCLCC(mCdmaSecondCall, 2);
}
SendResponse(BTHF_AT_RESPONSE_OK);
SendResponse(HFP_AT_RESPONSE_OK);
}
class AtResponseResultHandler MOZ_FINAL
: public BluetoothHandsfreeResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::AtResponse failed: %d",
(int)aStatus);
@ -880,7 +883,7 @@ BluetoothHfpManager::ProcessUnknownAt(char *aAtString)
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
sBluetoothHfpInterface->AtResponse(BTHF_AT_RESPONSE_ERROR, 0,
sBluetoothHfpInterface->AtResponse(HFP_AT_RESPONSE_ERROR, 0,
new AtResponseResultHandler());
}
@ -996,7 +999,7 @@ class VolumeControlResultHandler MOZ_FINAL
: public BluetoothHandsfreeResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::VolumeControl failed: %d",
(int)aStatus);
@ -1047,7 +1050,7 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
// Only send volume back when there's a connected headset
if (IsConnected()) {
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
sBluetoothHfpInterface->VolumeControl(BTHF_VOLUME_TYPE_SPK, mCurrentVgs,
sBluetoothHfpInterface->VolumeControl(HFP_VOLUME_TYPE_SPEAKER, mCurrentVgs,
new VolumeControlResultHandler());
}
}
@ -1070,7 +1073,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
// Roam
bool roaming;
voiceInfo->GetRoaming(&roaming);
mRoam = (roaming) ? 1 : 0;
mRoam = (roaming) ? HFP_SERVICE_TYPE_ROAMING : HFP_SERVICE_TYPE_HOME;
// Service
nsString regState;
@ -1081,7 +1084,8 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
// Notify BluetoothRilListener of service change
mListener->ServiceChanged(aClientId, service);
}
mService = service;
mService = service ? HFP_NETWORK_STATE_AVAILABLE :
HFP_NETWORK_STATE_NOT_AVAILABLE;
// Signal
JSContext* cx = nsContentUtils::GetSafeJSContext();
@ -1143,7 +1147,7 @@ class ClccResponseResultHandler MOZ_FINAL
: public BluetoothHandsfreeResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::ClccResponse failed: %d",
(int)aStatus);
@ -1157,21 +1161,22 @@ BluetoothHfpManager::SendCLCC(Call& aCall, int aIndex)
nsITelephonyService::CALL_STATE_DISCONNECTED);
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
bthf_call_state_t callState = ConvertToBthfCallState(aCall.mState);
BluetoothHandsfreeCallState callState =
ConvertToBluetoothHandsfreeCallState(aCall.mState);
if (mPhoneType == PhoneType::CDMA && aIndex == 1 && aCall.IsActive()) {
callState = (mCdmaSecondCall.IsActive()) ? BTHF_CALL_STATE_HELD :
BTHF_CALL_STATE_ACTIVE;
callState = (mCdmaSecondCall.IsActive()) ? HFP_CALL_STATE_HELD :
HFP_CALL_STATE_ACTIVE;
}
if (callState == BTHF_CALL_STATE_INCOMING &&
if (callState == HFP_CALL_STATE_INCOMING &&
FindFirstCall(nsITelephonyService::CALL_STATE_CONNECTED)) {
callState = BTHF_CALL_STATE_WAITING;
callState = HFP_CALL_STATE_WAITING;
}
sBluetoothHfpInterface->ClccResponse(
aIndex, aCall.mDirection, callState, BTHF_CALL_TYPE_VOICE,
BTHF_CALL_MPTY_TYPE_SINGLE, NS_ConvertUTF16toUTF8(aCall.mNumber).get(),
aIndex, aCall.mDirection, callState, HFP_CALL_MODE_VOICE,
HFP_CALL_MPTY_TYPE_SINGLE, aCall.mNumber,
aCall.mType, new ClccResponseResultHandler());
}
@ -1179,7 +1184,7 @@ class FormattedAtResponseResultHandler MOZ_FINAL
: public BluetoothHandsfreeResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::FormattedAtResponse failed: %d",
(int)aStatus);
@ -1196,7 +1201,7 @@ BluetoothHfpManager::SendLine(const char* aMessage)
}
void
BluetoothHfpManager::SendResponse(bthf_at_response_t aResponseCode)
BluetoothHfpManager::SendResponse(BluetoothHandsfreeAtResponse aResponseCode)
{
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
@ -1208,7 +1213,7 @@ class PhoneStateChangeResultHandler MOZ_FINAL
: public BluetoothHandsfreeResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::PhoneStateChange failed: %d",
(int)aStatus);
@ -1222,18 +1227,17 @@ BluetoothHfpManager::UpdatePhoneCIND(uint32_t aCallIndex)
int numActive = GetNumberOfCalls(nsITelephonyService::CALL_STATE_CONNECTED);
int numHeld = GetNumberOfCalls(nsITelephonyService::CALL_STATE_HELD);
bthf_call_state_t callSetupState =
ConvertToBthfCallState(GetCallSetupState());
nsAutoCString number =
NS_ConvertUTF16toUTF8(mCurrentCallArray[aCallIndex].mNumber);
bthf_call_addrtype_t type = mCurrentCallArray[aCallIndex].mType;
BluetoothHandsfreeCallState callSetupState =
ConvertToBluetoothHandsfreeCallState(GetCallSetupState());
BluetoothHandsfreeCallAddressType type = mCurrentCallArray[aCallIndex].mType;
BT_LOGR("[%d] state %d => BTHF: active[%d] held[%d] setupstate[%d]",
aCallIndex, mCurrentCallArray[aCallIndex].mState,
numActive, numHeld, callSetupState);
sBluetoothHfpInterface->PhoneStateChange(
numActive, numHeld, callSetupState, number.get(), type,
numActive, numHeld, callSetupState,
mCurrentCallArray[aCallIndex].mNumber, type,
new PhoneStateChangeResultHandler());
}
@ -1241,7 +1245,7 @@ class DeviceStatusNotificationResultHandler MOZ_FINAL
: public BluetoothHandsfreeResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING(
"BluetoothHandsfreeInterface::DeviceStatusNotification failed: %d",
@ -1254,8 +1258,8 @@ BluetoothHfpManager::UpdateDeviceCIND()
{
if (sBluetoothHfpInterface) {
sBluetoothHfpInterface->DeviceStatusNotification(
(bthf_network_state_t) mService,
(bthf_service_type_t) mRoam,
mService,
mRoam,
mSignal,
mBattChg, new DeviceStatusNotificationResultHandler());
}
@ -1309,24 +1313,24 @@ BluetoothHfpManager::GetCallSetupState()
return nsITelephonyService::CALL_STATE_DISCONNECTED;
}
bthf_call_state_t
BluetoothHfpManager::ConvertToBthfCallState(int aCallState)
BluetoothHandsfreeCallState
BluetoothHfpManager::ConvertToBluetoothHandsfreeCallState(int aCallState) const
{
bthf_call_state_t state;
BluetoothHandsfreeCallState state;
// Refer to AOSP BluetoothPhoneService.convertCallState
if (aCallState == nsITelephonyService::CALL_STATE_INCOMING) {
state = BTHF_CALL_STATE_INCOMING;
state = HFP_CALL_STATE_INCOMING;
} else if (aCallState == nsITelephonyService::CALL_STATE_DIALING) {
state = BTHF_CALL_STATE_DIALING;
state = HFP_CALL_STATE_DIALING;
} else if (aCallState == nsITelephonyService::CALL_STATE_ALERTING) {
state = BTHF_CALL_STATE_ALERTING;
state = HFP_CALL_STATE_ALERTING;
} else if (aCallState == nsITelephonyService::CALL_STATE_CONNECTED) {
state = BTHF_CALL_STATE_ACTIVE;
state = HFP_CALL_STATE_ACTIVE;
} else if (aCallState == nsITelephonyService::CALL_STATE_HELD) {
state = BTHF_CALL_STATE_HELD;
state = HFP_CALL_STATE_HELD;
} else { // disconnected
state = BTHF_CALL_STATE_IDLE;
state = HFP_CALL_STATE_IDLE;
}
return state;
@ -1400,7 +1404,7 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
case nsITelephonyService::CALL_STATE_DIALING:
// We've send Dialer a dialing request and this is the response.
if (!mDialingRequestProcessed) {
SendResponse(BTHF_AT_RESPONSE_OK);
SendResponse(HFP_AT_RESPONSE_OK);
mDialingRequestProcessed = true;
}
break;
@ -1497,7 +1501,7 @@ class ConnectAudioResultHandler MOZ_FINAL
: public BluetoothHandsfreeResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::ConnectAudio failed: %d",
(int)aStatus);
@ -1513,9 +1517,7 @@ BluetoothHfpManager::ConnectSco()
NS_ENSURE_TRUE(IsConnected() && !IsScoConnected(), false);
NS_ENSURE_TRUE(sBluetoothHfpInterface, false);
bt_bdaddr_t deviceBdAddress;
StringToBdAddressType(mDeviceAddress, &deviceBdAddress);
sBluetoothHfpInterface->ConnectAudio(&deviceBdAddress,
sBluetoothHfpInterface->ConnectAudio(mDeviceAddress,
new ConnectAudioResultHandler());
return true;
@ -1525,7 +1527,7 @@ class DisconnectAudioResultHandler MOZ_FINAL
: public BluetoothHandsfreeResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::DisconnectAudio failed: %d",
(int)aStatus);
@ -1538,9 +1540,7 @@ BluetoothHfpManager::DisconnectSco()
NS_ENSURE_TRUE(IsScoConnected(), false);
NS_ENSURE_TRUE(sBluetoothHfpInterface, false);
bt_bdaddr_t deviceBdAddress;
StringToBdAddressType(mDeviceAddress, &deviceBdAddress);
sBluetoothHfpInterface->DisconnectAudio(&deviceBdAddress,
sBluetoothHfpInterface->DisconnectAudio(mDeviceAddress,
new DisconnectAudioResultHandler());
return true;
@ -1578,7 +1578,7 @@ public:
MOZ_ASSERT(mHfpManager);
}
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::Connect failed: %d",
(int)aStatus);
@ -1607,13 +1607,10 @@ BluetoothHfpManager::Connect(const nsAString& aDeviceAddress,
return;
}
bt_bdaddr_t deviceBdAddress;
StringToBdAddressType(aDeviceAddress, &deviceBdAddress);
mDeviceAddress = aDeviceAddress;
mController = aController;
sBluetoothHfpInterface->Connect(&deviceBdAddress,
sBluetoothHfpInterface->Connect(mDeviceAddress,
new ConnectResultHandler(this));
}
@ -1634,7 +1631,7 @@ public:
MOZ_ASSERT(mHfpManager);
}
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::Disconnect failed: %d",
(int)aStatus);
@ -1658,12 +1655,9 @@ BluetoothHfpManager::Disconnect(BluetoothProfileController* aController)
return;
}
bt_bdaddr_t deviceBdAddress;
StringToBdAddressType(mDeviceAddress, &deviceBdAddress);
mController = aController;
sBluetoothHfpInterface->Disconnect(&deviceBdAddress,
sBluetoothHfpInterface->Disconnect(mDeviceAddress,
new DisconnectResultHandler(this));
}

View File

@ -66,8 +66,8 @@ public:
uint16_t mState;
nsString mNumber;
bthf_call_direction_t mDirection; // 0: outgoing call; 1: incoming call
bthf_call_addrtype_t mType;
BluetoothHandsfreeCallDirection mDirection;
BluetoothHandsfreeCallAddressType mType;
};
class BluetoothHfpManager : public BluetoothHfpManagerBase
@ -153,21 +153,22 @@ private:
uint32_t GetNumberOfCalls(uint16_t aState);
uint16_t GetCallSetupState();
bool IsTransitionState(uint16_t aCallState, bool aIsConference);
bthf_call_state_t ConvertToBthfCallState(int aCallState);
BluetoothHandsfreeCallState
ConvertToBluetoothHandsfreeCallState(int aCallState) const;
void UpdatePhoneCIND(uint32_t aCallIndex);
void UpdateDeviceCIND();
void SendCLCC(Call& aCall, int aIndex);
void SendLine(const char* aMessage);
void SendResponse(bthf_at_response_t aResponseCode);
void SendResponse(BluetoothHandsfreeAtResponse aResponseCode);
int mConnectionState;
int mPrevConnectionState;
int mAudioState;
// Device CIND
int mBattChg;
int mService;
int mRoam;
BluetoothHandsfreeNetworkState mService;
BluetoothHandsfreeServiceType mRoam;
int mSignal;
int mCurrentVgs;

View File

@ -78,6 +78,7 @@
#include "mozilla/gfx/Matrix.h"
#include "UnitTransforms.h"
#include "ClientLayerManager.h"
#include "LayersLogging.h"
#include "nsColorPickerProxy.h"
@ -88,6 +89,9 @@
#define BROWSER_ELEMENT_CHILD_SCRIPT \
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js")
#define TABC_LOG(...)
// #define TABC_LOG(...) printf_stderr("TABC: " __VA_ARGS__)
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::dom::ipc;
@ -174,12 +178,16 @@ TabChildBase::InitializeRootMetrics()
// as the resolution.
mLastRootMetrics.mResolution = mLastRootMetrics.mCumulativeResolution / LayoutDeviceToParentLayerScale(1);
mLastRootMetrics.SetScrollOffset(CSSPoint(0, 0));
TABC_LOG("After InitializeRootMetrics, mLastRootMetrics is %s\n",
Stringify(mLastRootMetrics).c_str());
}
void
TabChildBase::SetCSSViewport(const CSSSize& aSize)
{
mOldViewportSize = aSize;
TABC_LOG("Setting CSS viewport to %s\n", Stringify(aSize).c_str());
if (mContentDocumentIsDisplayed) {
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
@ -213,12 +221,15 @@ TabChildBase::GetPageSize(nsCOMPtr<nsIDocument> aDocument, const CSSSize& aViewp
}
bool
TabChildBase::HandlePossibleViewportChange()
TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize)
{
if (!IsAsyncPanZoomEnabled()) {
return false;
}
TABC_LOG("HandlePossibleViewportChange aOldScreenSize=%s mInnerSize=%s\n",
Stringify(aOldScreenSize).c_str(), Stringify(mInnerSize).c_str());
nsCOMPtr<nsIDocument> document(GetDocument());
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
@ -249,6 +260,8 @@ TabChildBase::HandlePossibleViewportChange()
return false;
}
TABC_LOG("HandlePossibleViewportChange mOldViewportSize=%s viewport=%s\n",
Stringify(mOldViewportSize).c_str(), Stringify(viewport).c_str());
CSSSize oldBrowserSize = mOldViewportSize;
mLastRootMetrics.mViewport.SizeTo(viewport);
if (oldBrowserSize == CSSSize()) {
@ -269,9 +282,7 @@ TabChildBase::HandlePossibleViewportChange()
return false;
}
ScreenIntSize oldScreenSize = ViewAs<ScreenPixel>(
RoundedToInt(mLastRootMetrics.mCompositionBounds).Size(),
PixelCastJustification::ScreenToParentLayerForRoot);
ScreenIntSize oldScreenSize = aOldScreenSize;
if (oldScreenSize == ScreenIntSize()) {
oldScreenSize = mInnerSize;
}
@ -748,7 +759,7 @@ TabChild::HandleEvent(nsIDOMEvent* aEvent)
if (eventType.EqualsLiteral("DOMMetaAdded")) {
// This meta data may or may not have been a meta viewport tag. If it was,
// we should handle it immediately.
HandlePossibleViewportChange();
HandlePossibleViewportChange(mInnerSize);
}
return NS_OK;
@ -799,7 +810,7 @@ TabChild::Observe(nsISupports *aSubject,
InitializeRootMetrics();
utils->SetResolution(mLastRootMetrics.mResolution.scale,
mLastRootMetrics.mResolution.scale);
HandlePossibleViewportChange();
HandlePossibleViewportChange(mInnerSize);
}
}
}
@ -1750,6 +1761,7 @@ TabChild::RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const
}
mOrientation = orientation;
ScreenIntSize oldScreenSize = mInnerSize;
mInnerSize = ScreenIntSize::FromUnknownSize(
gfx::IntSize(size.width, size.height));
mWidget->Resize(0, 0, size.width, size.height,
@ -1767,7 +1779,7 @@ TabChild::RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const
InitializeRootMetrics();
}
HandlePossibleViewportChange();
HandlePossibleViewportChange(oldScreenSize);
return true;
}

View File

@ -178,7 +178,7 @@ public:
// viewport data on a document may have changed. If it didn't
// change, this function doesn't do anything. However, it should
// not be called all the time as it is fairly expensive.
bool HandlePossibleViewportChange();
bool HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize);
virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId,
const mozilla::layers::FrameMetrics::ViewID& aViewId,
const bool& aIsRoot,

View File

@ -204,14 +204,12 @@ mozNfc.prototype = {
if (this._nfcContentHelper.setSessionToken(sessionToken)) {
return this._window.MozNFCTag._create(this._window, obj);
}
throw new Error("Unable to create NFCTag object, Reason: Bad SessionToken " +
sessionToken);
return null;
},
getNFCPeer: function getNFCPeer(sessionToken) {
if (!sessionToken || !this._nfcContentHelper.setSessionToken(sessionToken)) {
throw new Error("Unable to create NFCPeer object, Reason: Bad SessionToken " +
sessionToken);
return null;
}
if (!this.nfcObject) {

View File

@ -85,18 +85,6 @@ function testCheckP2PRegFailure() {
toggleNFC(true).then(() => NCI.activateRE(emulator.P2P_RE_INDEX_0));
}
function testCheckNfcPeerObjForInvalidToken() {
try {
// Use a'fakeSessionToken'
let peer = nfc.getNFCPeer("fakeSessionToken");
ok(false, "Should not get a NFCPeer object.");
} catch (ex) {
ok(true, "Exception expected");
}
toggleNFC(false).then(runNextTest);
}
function testPeerLostShouldNotBeCalled() {
nfc.onpeerlost = function () {
ok(false, "onpeerlost shouldn't be called");
@ -151,12 +139,31 @@ function testPeerShouldThrow() {
toggleNFC(false).then(runNextTest);
}
function testPeerInvalidToken() {
let peer = nfc.getNFCPeer("fakeSessionToken");
is(peer, null, "NFCPeer should be null on wrong session token");
runNextTest();
}
/**
* Added for completeness in Bug 1042651,
* TODO: remove once Bug 963531 lands
*/
function testTagInvalidToken() {
let tag = nfc.getNFCTag("fakeSessionToken");
is(tag, null, "NFCTag should be null on wrong session token");
runNextTest();
}
let tests = [
testPeerReady,
testCheckP2PRegFailure,
testCheckNfcPeerObjForInvalidToken,
testPeerLostShouldNotBeCalled,
testPeerShouldThrow
testPeerShouldThrow,
testPeerInvalidToken,
testTagInvalidToken
];
SpecialPowers.pushPermissions(

View File

@ -46,10 +46,15 @@ interface MozNFCManager {
NavigatorProperty="mozNfc",
Func="Navigator::HasNFCSupport"]
interface MozNFC : EventTarget {
[Throws]
MozNFCTag getNFCTag(DOMString sessionId);
[Throws]
MozNFCPeer getNFCPeer(DOMString sessionId);
/**
* Returns MozNFCTag object or null in case of invalid sessionToken
*/
MozNFCTag? getNFCTag(DOMString sessionToken);
/**
* Returns MozNFCPeer object or null in case of invalid sessionToken
*/
MozNFCPeer? getNFCPeer(DOMString sessionToken);
[CheckPermissions="nfc-write"]
attribute EventHandler onpeerready;