Bug 1038591: Convert Bluedroid status codes and error handlers, r=shuang

This patch converts Bluedroid status codes in Gecko to the
backend-neutral data type |BluetoothStatus|. All error handlers
have been adapted. The Bluedroid type |bt_status_t| only remains
in |BluetoothInterface|.
This commit is contained in:
Thomas Zimmermann 2014-08-06 11:45:32 +02:00
Родитель ee587b2e81
Коммит d4a10240a2
7 изменённых файлов: 222 добавлений и 137 удалений

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

@ -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,

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

@ -523,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);
@ -551,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);
@ -682,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);
@ -711,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);
@ -808,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);
@ -859,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);

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

@ -23,6 +23,35 @@ struct interface_traits
// Conversion
//
static nsresult
Convert(bt_status_t aIn, BluetoothStatus& aOut)
{
static const BluetoothStatus sStatus[] = {
[BT_STATUS_SUCCESS] = STATUS_SUCCESS,
[BT_STATUS_FAIL] = STATUS_FAIL,
[BT_STATUS_NOT_READY] = STATUS_NOT_READY,
[BT_STATUS_NOMEM] = STATUS_NOMEM,
[BT_STATUS_BUSY] = STATUS_BUSY,
[BT_STATUS_DONE] = STATUS_DONE,
[BT_STATUS_UNSUPPORTED] = STATUS_UNSUPPORTED,
[BT_STATUS_PARM_INVALID] = STATUS_PARM_INVALID,
[BT_STATUS_UNHANDLED] = STATUS_UNHANDLED,
[BT_STATUS_AUTH_FAILURE] = STATUS_AUTH_FAILURE,
[BT_STATUS_RMT_DEV_DOWN] = STATUS_RMT_DEV_DOWN
};
if (aIn >= MOZ_ARRAY_LENGTH(sStatus)) {
return NS_ERROR_ILLEGAL_VALUE;
}
aOut = sStatus[aIn];
return NS_OK;
}
static nsresult
Convert(int aIn, BluetoothStatus& aOut)
{
return Convert(static_cast<bt_status_t>(aIn), aOut);
}
static nsresult
Convert(const nsAString& aIn, bt_property_type_t& aOut)
{
@ -502,6 +531,20 @@ Convert(const ConvertArray<Tin>& aIn, nsAutoArrayPtr<Tout>& aOut)
return Convert<Tin, Tout*>(aIn, out);
}
/* |ConvertDefault| is a helper function to return the result of a
* conversion or a default value if the conversion fails.
*/
template<typename Tin, typename Tout>
static Tout
ConvertDefault(const Tin& aIn, const Tout& aDefault)
{
Tout out = aDefault; // assignment silences compiler warning
if (NS_FAILED(Convert(aIn, out))) {
return aDefault;
}
return out;
}
//
// Result handling
//
@ -619,19 +662,19 @@ typedef
typedef
BluetoothInterfaceRunnable1<BluetoothSocketResultHandler, void,
bt_status_t, bt_status_t>
BluetoothStatus, BluetoothStatus>
BluetoothSocketErrorRunnable;
static nsresult
DispatchBluetoothSocketResult(BluetoothSocketResultHandler* aRes,
void (BluetoothSocketResultHandler::*aMethod)(int),
int aArg, bt_status_t aStatus)
int aArg, BluetoothStatus aStatus)
{
MOZ_ASSERT(aRes);
nsRunnable* runnable;
if (aStatus == BT_STATUS_SUCCESS) {
if (aStatus == STATUS_SUCCESS) {
runnable = new BluetoothSocketIntResultRunnable(aRes, aMethod, aArg);
} else {
runnable = new BluetoothSocketErrorRunnable(aRes,
@ -648,13 +691,13 @@ static nsresult
DispatchBluetoothSocketResult(
BluetoothSocketResultHandler* aRes,
void (BluetoothSocketResultHandler::*aMethod)(int, const nsAString&, int),
int aArg1, const nsAString& aArg2, int aArg3, bt_status_t aStatus)
int aArg1, const nsAString& aArg2, int aArg3, BluetoothStatus aStatus)
{
MOZ_ASSERT(aRes);
nsRunnable* runnable;
if (aStatus == BT_STATUS_SUCCESS) {
if (aStatus == STATUS_SUCCESS) {
runnable = new BluetoothSocketIntStringIntResultRunnable(aRes, aMethod,
aArg1, aArg2,
aArg3);
@ -692,7 +735,7 @@ BluetoothSocketInterface::Listen(BluetoothSocketType aType,
if (aRes) {
DispatchBluetoothSocketResult(aRes, &BluetoothSocketResultHandler::Listen,
fd, status);
fd, ConvertDefault(status, STATUS_FAIL));
}
}
@ -735,11 +778,11 @@ public:
virtual ~SocketMessageWatcher()
{ }
virtual void Proceed(bt_status_t aStatus) = 0;
virtual void Proceed(BluetoothStatus aStatus) = 0;
void OnFileCanReadWithoutBlocking(int aFd) MOZ_OVERRIDE
{
bt_status_t status;
BluetoothStatus status;
switch (mLen) {
case 0:
@ -750,11 +793,11 @@ public:
break;
default:
/* message-size error */
status = BT_STATUS_FAIL;
status = STATUS_FAIL;
break;
}
if (IsComplete() || status != BT_STATUS_SUCCESS) {
if (IsComplete() || status != STATUS_SUCCESS) {
mWatcher.StopWatchingFileDescriptor();
Proceed(status);
}
@ -816,7 +859,7 @@ public:
}
private:
bt_status_t RecvMsg1()
BluetoothStatus RecvMsg1()
{
struct iovec iv;
memset(&iv, 0, sizeof(iv));
@ -830,15 +873,15 @@ private:
ssize_t res = TEMP_FAILURE_RETRY(recvmsg(mFd, &msg, MSG_NOSIGNAL));
if (res < 0) {
return BT_STATUS_FAIL;
return STATUS_FAIL;
}
mLen += res;
return BT_STATUS_SUCCESS;
return STATUS_SUCCESS;
}
bt_status_t RecvMsg2()
BluetoothStatus RecvMsg2()
{
struct iovec iv;
memset(&iv, 0, sizeof(iv));
@ -855,13 +898,13 @@ private:
ssize_t res = TEMP_FAILURE_RETRY(recvmsg(mFd, &msg, MSG_NOSIGNAL));
if (res < 0) {
return BT_STATUS_FAIL;
return STATUS_FAIL;
}
mLen += res;
if (msg.msg_flags & (MSG_CTRUNC | MSG_OOB | MSG_ERRQUEUE)) {
return BT_STATUS_FAIL;
return STATUS_FAIL;
}
struct cmsghdr *cmsgptr = CMSG_FIRSTHDR(&msg);
@ -879,7 +922,7 @@ private:
}
}
return BT_STATUS_SUCCESS;
return STATUS_SUCCESS;
}
int16_t ReadInt16(unsigned long aOffset) const
@ -968,7 +1011,7 @@ public:
, mRes(aRes)
{ }
void Proceed(bt_status_t aStatus) MOZ_OVERRIDE
void Proceed(BluetoothStatus aStatus) MOZ_OVERRIDE
{
if (mRes) {
DispatchBluetoothSocketResult(mRes,
@ -1012,7 +1055,8 @@ BluetoothSocketInterface::Connect(const nsAString& aBdAddr,
} else if (aRes) {
DispatchBluetoothSocketResult(aRes,
&BluetoothSocketResultHandler::Connect,
-1, EmptyString(), 0, status);
-1, EmptyString(), 0,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1034,7 +1078,7 @@ public:
MOZ_ASSERT(mRes);
}
void Proceed(bt_status_t aStatus) MOZ_OVERRIDE
void Proceed(BluetoothStatus aStatus) MOZ_OVERRIDE
{
if (mRes) {
DispatchBluetoothSocketResult(mRes,
@ -1090,20 +1134,20 @@ typedef
typedef
BluetoothInterfaceRunnable1<BluetoothHandsfreeResultHandler, void,
bt_status_t, bt_status_t>
BluetoothStatus, BluetoothStatus>
BluetoothHandsfreeErrorRunnable;
static nsresult
DispatchBluetoothHandsfreeResult(
BluetoothHandsfreeResultHandler* aRes,
void (BluetoothHandsfreeResultHandler::*aMethod)(),
bt_status_t aStatus)
BluetoothStatus aStatus)
{
MOZ_ASSERT(aRes);
nsRunnable* runnable;
if (aStatus == BT_STATUS_SUCCESS) {
if (aStatus == STATUS_SUCCESS) {
runnable = new BluetoothHandsfreeResultRunnable(aRes, aMethod);
} else {
runnable = new BluetoothHandsfreeErrorRunnable(aRes,
@ -1135,7 +1179,7 @@ BluetoothHandsfreeInterface::Init(bthf_callbacks_t* aCallbacks,
if (aRes) {
DispatchBluetoothHandsfreeResult(aRes,
&BluetoothHandsfreeResultHandler::Init,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1147,7 +1191,7 @@ BluetoothHandsfreeInterface::Cleanup(BluetoothHandsfreeResultHandler* aRes)
if (aRes) {
DispatchBluetoothHandsfreeResult(aRes,
&BluetoothHandsfreeResultHandler::Cleanup,
BT_STATUS_SUCCESS);
STATUS_SUCCESS);
}
}
@ -1168,7 +1212,8 @@ BluetoothHandsfreeInterface::Connect(const nsAString& aBdAddr,
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::Connect, status);
aRes, &BluetoothHandsfreeResultHandler::Connect,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1187,7 +1232,8 @@ BluetoothHandsfreeInterface::Disconnect(
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::Disconnect, status);
aRes, &BluetoothHandsfreeResultHandler::Disconnect,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1206,7 +1252,8 @@ BluetoothHandsfreeInterface::ConnectAudio(
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::ConnectAudio, status);
aRes, &BluetoothHandsfreeResultHandler::ConnectAudio,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1225,7 +1272,8 @@ BluetoothHandsfreeInterface::DisconnectAudio(
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::DisconnectAudio, status);
aRes, &BluetoothHandsfreeResultHandler::DisconnectAudio,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1239,7 +1287,8 @@ BluetoothHandsfreeInterface::StartVoiceRecognition(
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::StartVoiceRecognition, status);
aRes, &BluetoothHandsfreeResultHandler::StartVoiceRecognition,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1251,7 +1300,8 @@ BluetoothHandsfreeInterface::StopVoiceRecognition(
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::StopVoiceRecognition, status);
aRes, &BluetoothHandsfreeResultHandler::StopVoiceRecognition,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1273,7 +1323,8 @@ BluetoothHandsfreeInterface::VolumeControl(
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::VolumeControl, status);
aRes, &BluetoothHandsfreeResultHandler::VolumeControl,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1300,7 +1351,7 @@ BluetoothHandsfreeInterface::DeviceStatusNotification(
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::DeviceStatusNotification,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1314,7 +1365,8 @@ BluetoothHandsfreeInterface::CopsResponse(
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::CopsResponse, status);
aRes, &BluetoothHandsfreeResultHandler::CopsResponse,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1338,7 +1390,8 @@ BluetoothHandsfreeInterface::CindResponse(
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::CindResponse, status);
aRes, &BluetoothHandsfreeResultHandler::CindResponse,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1350,7 +1403,8 @@ BluetoothHandsfreeInterface::FormattedAtResponse(
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::FormattedAtResponse, status);
aRes, &BluetoothHandsfreeResultHandler::FormattedAtResponse,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1370,7 +1424,8 @@ BluetoothHandsfreeInterface::AtResponse(
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::AtResponse, status);
aRes, &BluetoothHandsfreeResultHandler::AtResponse,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1406,7 +1461,8 @@ BluetoothHandsfreeInterface::ClccResponse(
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::ClccResponse, status);
aRes, &BluetoothHandsfreeResultHandler::ClccResponse,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1433,7 +1489,8 @@ BluetoothHandsfreeInterface::PhoneStateChange(int aNumActive, int aNumHeld,
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::PhoneStateChange, status);
aRes, &BluetoothHandsfreeResultHandler::PhoneStateChange,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1458,20 +1515,20 @@ typedef
typedef
BluetoothInterfaceRunnable1<BluetoothA2dpResultHandler, void,
bt_status_t, bt_status_t>
BluetoothStatus, BluetoothStatus>
BluetoothA2dpErrorRunnable;
static nsresult
DispatchBluetoothA2dpResult(
BluetoothA2dpResultHandler* aRes,
void (BluetoothA2dpResultHandler::*aMethod)(),
bt_status_t aStatus)
BluetoothStatus aStatus)
{
MOZ_ASSERT(aRes);
nsRunnable* runnable;
if (aStatus == BT_STATUS_SUCCESS) {
if (aStatus == STATUS_SUCCESS) {
runnable = new BluetoothA2dpResultRunnable(aRes, aMethod);
} else {
runnable = new BluetoothA2dpErrorRunnable(aRes,
@ -1502,7 +1559,7 @@ BluetoothA2dpInterface::Init(btav_callbacks_t* aCallbacks,
if (aRes) {
DispatchBluetoothA2dpResult(aRes, &BluetoothA2dpResultHandler::Init,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1513,7 +1570,7 @@ BluetoothA2dpInterface::Cleanup(BluetoothA2dpResultHandler* aRes)
if (aRes) {
DispatchBluetoothA2dpResult(aRes, &BluetoothA2dpResultHandler::Cleanup,
BT_STATUS_SUCCESS);
STATUS_SUCCESS);
}
}
@ -1532,7 +1589,7 @@ BluetoothA2dpInterface::Connect(const nsAString& aBdAddr,
if (aRes) {
DispatchBluetoothA2dpResult(aRes, &BluetoothA2dpResultHandler::Connect,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1551,7 +1608,7 @@ BluetoothA2dpInterface::Disconnect(const nsAString& aBdAddr,
if (aRes) {
DispatchBluetoothA2dpResult(aRes, &BluetoothA2dpResultHandler::Disconnect,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1577,20 +1634,20 @@ typedef
typedef
BluetoothInterfaceRunnable1<BluetoothAvrcpResultHandler, void,
bt_status_t, bt_status_t>
BluetoothStatus, BluetoothStatus>
BluetoothAvrcpErrorRunnable;
static nsresult
DispatchBluetoothAvrcpResult(
BluetoothAvrcpResultHandler* aRes,
void (BluetoothAvrcpResultHandler::*aMethod)(),
bt_status_t aStatus)
BluetoothStatus aStatus)
{
MOZ_ASSERT(aRes);
nsRunnable* runnable;
if (aStatus == BT_STATUS_SUCCESS) {
if (aStatus == STATUS_SUCCESS) {
runnable = new BluetoothAvrcpResultRunnable(aRes, aMethod);
} else {
runnable = new BluetoothAvrcpErrorRunnable(aRes,
@ -1621,7 +1678,7 @@ BluetoothAvrcpInterface::Init(btrc_callbacks_t* aCallbacks,
if (aRes) {
DispatchBluetoothAvrcpResult(aRes, &BluetoothAvrcpResultHandler::Init,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1632,7 +1689,7 @@ BluetoothAvrcpInterface::Cleanup(BluetoothAvrcpResultHandler* aRes)
if (aRes) {
DispatchBluetoothAvrcpResult(aRes, &BluetoothAvrcpResultHandler::Cleanup,
BT_STATUS_SUCCESS);
STATUS_SUCCESS);
}
}
@ -1652,7 +1709,8 @@ BluetoothAvrcpInterface::GetPlayStatusRsp(ControlPlayStatus aPlayStatus,
if (aRes) {
DispatchBluetoothAvrcpResult(
aRes, &BluetoothAvrcpResultHandler::GetPlayStatusRsp, status);
aRes, &BluetoothAvrcpResultHandler::GetPlayStatusRsp,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1673,7 +1731,8 @@ BluetoothAvrcpInterface::ListPlayerAppAttrRsp(
if (aRes) {
DispatchBluetoothAvrcpResult(
aRes, &BluetoothAvrcpResultHandler::ListPlayerAppAttrRsp, status);
aRes, &BluetoothAvrcpResultHandler::ListPlayerAppAttrRsp,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1685,7 +1744,8 @@ BluetoothAvrcpInterface::ListPlayerAppValueRsp(
if (aRes) {
DispatchBluetoothAvrcpResult(
aRes, &BluetoothAvrcpResultHandler::ListPlayerAppValueRsp, status);
aRes, &BluetoothAvrcpResultHandler::ListPlayerAppValueRsp,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1708,7 +1768,8 @@ BluetoothAvrcpInterface::GetPlayerAppValueRsp(
if (aRes) {
DispatchBluetoothAvrcpResult(
aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueRsp, status);
aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueRsp,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1731,7 +1792,8 @@ BluetoothAvrcpInterface::GetPlayerAppAttrTextRsp(
if (aRes) {
DispatchBluetoothAvrcpResult(
aRes, &BluetoothAvrcpResultHandler::GetPlayerAppAttrTextRsp, status);
aRes, &BluetoothAvrcpResultHandler::GetPlayerAppAttrTextRsp,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1754,7 +1816,8 @@ BluetoothAvrcpInterface::GetPlayerAppValueTextRsp(
if (aRes) {
DispatchBluetoothAvrcpResult(
aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueTextRsp, status);
aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueTextRsp,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1775,7 +1838,8 @@ BluetoothAvrcpInterface::GetElementAttrRsp(
if (aRes) {
DispatchBluetoothAvrcpResult(
aRes, &BluetoothAvrcpResultHandler::GetElementAttrRsp, status);
aRes, &BluetoothAvrcpResultHandler::GetElementAttrRsp,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1794,7 +1858,8 @@ BluetoothAvrcpInterface::SetPlayerAppValueRsp(
if (aRes) {
DispatchBluetoothAvrcpResult(
aRes, &BluetoothAvrcpResultHandler::SetPlayerAppValueRsp, status);
aRes, &BluetoothAvrcpResultHandler::SetPlayerAppValueRsp,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1851,7 +1916,8 @@ BluetoothAvrcpInterface::RegisterNotificationRsp(
if (aRes) {
DispatchBluetoothAvrcpResult(
aRes, &BluetoothAvrcpResultHandler::RegisterNotificationRsp, status);
aRes, &BluetoothAvrcpResultHandler::RegisterNotificationRsp,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1867,7 +1933,8 @@ BluetoothAvrcpInterface::SetVolume(uint8_t aVolume,
if (aRes) {
DispatchBluetoothAvrcpResult(
aRes, &BluetoothAvrcpResultHandler::SetVolume, status);
aRes, &BluetoothAvrcpResultHandler::SetVolume,
ConvertDefault(status, STATUS_FAIL));
}
}
#endif
@ -1881,19 +1948,20 @@ typedef
BluetoothResultRunnable;
typedef
BluetoothInterfaceRunnable1<BluetoothResultHandler, void, int, int>
BluetoothInterfaceRunnable1<BluetoothResultHandler, void,
BluetoothStatus, BluetoothStatus>
BluetoothErrorRunnable;
static nsresult
DispatchBluetoothResult(BluetoothResultHandler* aRes,
void (BluetoothResultHandler::*aMethod)(),
int aStatus)
BluetoothStatus aStatus)
{
MOZ_ASSERT(aRes);
nsRunnable* runnable;
if (aStatus == BT_STATUS_SUCCESS) {
if (aStatus == STATUS_SUCCESS) {
runnable = new BluetoothResultRunnable(aRes, aMethod);
} else {
runnable = new
@ -1984,7 +2052,8 @@ BluetoothInterface::Init(bt_callbacks_t* aCallbacks,
int status = mInterface->init(aCallbacks);
if (aRes) {
DispatchBluetoothResult(aRes, &BluetoothResultHandler::Init, status);
DispatchBluetoothResult(aRes, &BluetoothResultHandler::Init,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -1995,7 +2064,7 @@ BluetoothInterface::Cleanup(BluetoothResultHandler* aRes)
if (aRes) {
DispatchBluetoothResult(aRes, &BluetoothResultHandler::Cleanup,
BT_STATUS_SUCCESS);
STATUS_SUCCESS);
}
}
@ -2005,7 +2074,8 @@ BluetoothInterface::Enable(BluetoothResultHandler* aRes)
int status = mInterface->enable();
if (aRes) {
DispatchBluetoothResult(aRes, &BluetoothResultHandler::Enable, status);
DispatchBluetoothResult(aRes, &BluetoothResultHandler::Enable,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2015,7 +2085,8 @@ BluetoothInterface::Disable(BluetoothResultHandler* aRes)
int status = mInterface->disable();
if (aRes) {
DispatchBluetoothResult(aRes, &BluetoothResultHandler::Disable, status);
DispatchBluetoothResult(aRes, &BluetoothResultHandler::Disable,
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2029,7 +2100,7 @@ BluetoothInterface::GetAdapterProperties(BluetoothResultHandler* aRes)
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::GetAdapterProperties,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2052,7 +2123,7 @@ BluetoothInterface::GetAdapterProperty(const nsAString& aName,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::GetAdapterProperties,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2073,7 +2144,7 @@ BluetoothInterface::SetAdapterProperty(const BluetoothNamedValue& aProperty,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::SetAdapterProperty,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2095,7 +2166,7 @@ BluetoothInterface::GetRemoteDeviceProperties(const nsAString& aRemoteAddr,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::GetRemoteDeviceProperties,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2121,7 +2192,7 @@ BluetoothInterface::GetRemoteDeviceProperty(const nsAString& aRemoteAddr,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::GetRemoteDeviceProperty,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2147,7 +2218,7 @@ BluetoothInterface::SetRemoteDeviceProperty(const nsAString& aRemoteAddr,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::SetRemoteDeviceProperty,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2172,7 +2243,7 @@ BluetoothInterface::GetRemoteServiceRecord(const nsAString& aRemoteAddr,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::GetRemoteServiceRecord,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2192,7 +2263,7 @@ BluetoothInterface::GetRemoteServices(const nsAString& aRemoteAddr,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::GetRemoteServices,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2206,7 +2277,7 @@ BluetoothInterface::StartDiscovery(BluetoothResultHandler* aRes)
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::StartDiscovery,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2218,7 +2289,7 @@ BluetoothInterface::CancelDiscovery(BluetoothResultHandler* aRes)
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::CancelDiscovery,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2240,7 +2311,7 @@ BluetoothInterface::CreateBond(const nsAString& aBdAddr,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::CreateBond,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2260,7 +2331,7 @@ BluetoothInterface::RemoveBond(const nsAString& aBdAddr,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::RemoveBond,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2280,7 +2351,7 @@ BluetoothInterface::CancelBond(const nsAString& aBdAddr,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::CancelBond,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2308,7 +2379,7 @@ BluetoothInterface::PinReply(const nsAString& aBdAddr, bool aAccept,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::PinReply,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2334,7 +2405,7 @@ BluetoothInterface::SspReply(const nsAString& aBdAddr,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::SspReply,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2356,7 +2427,7 @@ BluetoothInterface::DutModeConfigure(bool aEnable,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::DutModeConfigure,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2369,7 +2440,7 @@ BluetoothInterface::DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::DutModeSend,
status);
ConvertDefault(status, STATUS_FAIL));
}
}
@ -2388,7 +2459,7 @@ BluetoothInterface::LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
if (aRes) {
DispatchBluetoothResult(aRes,
&BluetoothResultHandler::LeTestMode,
status);
ConvertDefault(status, STATUS_FAIL));
}
}

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

@ -32,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) { }
@ -84,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);
}
@ -196,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() { }
@ -240,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() { }
@ -333,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() { }

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

@ -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");
}
@ -845,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());
@ -918,7 +918,7 @@ public:
}
}
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
@ -960,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());
@ -999,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");
@ -1008,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");
}
@ -1118,7 +1118,7 @@ public:
: mDeviceAddress(aDeviceAddress)
{ }
void OnError(int aStatus) MOZ_OVERRIDE
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
@ -1225,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"));
@ -1260,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"));
@ -1289,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"));
@ -1338,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"));
@ -1372,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"));
@ -1410,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"));
}
@ -1454,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"));

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

@ -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);
@ -879,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());

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

@ -447,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) {
@ -554,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) {
@ -803,7 +803,7 @@ 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);
@ -829,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);
@ -869,7 +869,7 @@ 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);
@ -999,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);
@ -1147,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);
@ -1184,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);
@ -1213,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);
@ -1245,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",
@ -1501,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);
@ -1527,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);
@ -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);
@ -1631,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);