Bug 1139298: Replace type int with BluetoothGattStatus enum for GATT client callbacks. r=btian

This commit is contained in:
Jocelyn Liu 2015-03-06 17:21:00 +08:00
Родитель df56e4d957
Коммит 3cdfc298aa
6 изменённых файлов: 109 добавлений и 75 удалений

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

@ -534,6 +534,11 @@ struct BluetoothAvrcpPlayerSettings {
uint8_t mValues[256];
};
enum BluetoothGattStatus {
GATT_STATUS_SUCCESS,
GATT_STATUS_ERROR
};
struct BluetoothGattAdvData {
uint8_t mAdvData[62];
};

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

@ -463,7 +463,7 @@ public:
virtual ~BluetoothGattClientNotificationHandler();
virtual void
RegisterClientNotification(int aStatus,
RegisterClientNotification(BluetoothGattStatus aStatus,
int aClientIf,
const BluetoothUuid& aAppUuid)
{ }
@ -476,20 +476,20 @@ public:
virtual void
ConnectNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
int aClientIf,
const nsAString& aBdAddr)
{ }
virtual void
DisconnectNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
int aClientIf,
const nsAString& aBdAddr)
{ }
virtual void
SearchCompleteNotification(int aConnId, int aStatus) { }
SearchCompleteNotification(int aConnId, BluetoothGattStatus aStatus) { }
virtual void
SearchResultNotification(int aConnId,
const BluetoothGattServiceId& aServiceId)
@ -497,7 +497,7 @@ public:
virtual void
GetCharacteristicNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
int aCharProperty)
@ -505,7 +505,7 @@ public:
virtual void
GetDescriptorNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
const BluetoothGattId& aDescriptorId)
@ -513,7 +513,7 @@ public:
virtual void
GetIncludedServiceNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattServiceId& aIncludedServId)
{ }
@ -521,7 +521,7 @@ public:
virtual void
RegisterNotificationNotification(int aConnId,
int aIsRegister,
int aStatus,
BluetoothGattStatus aStatus,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId)
{ }
@ -532,40 +532,40 @@ public:
virtual void
ReadCharacteristicNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
const BluetoothGattReadParam& aReadParam)
{ }
virtual void
WriteCharacteristicNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
const BluetoothGattWriteParam& aWriteParam)
{ }
virtual void
ReadDescriptorNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
const BluetoothGattReadParam& aReadParam)
{ }
virtual void
WriteDescriptorNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
const BluetoothGattWriteParam& aWriteParam)
{ }
virtual void
ExecuteWriteNotification(int aConnId, int aStatus) { }
ExecuteWriteNotification(int aConnId, BluetoothGattStatus aStatus) { }
virtual void
ReadRemoteRssiNotification(int aClientIf,
const nsAString& aBdAddr,
int aRssi,
int aStatus)
BluetoothGattStatus aStatus)
{ }
virtual void
ListenNotification(int aStatus, int aServerIf) { }
ListenNotification(BluetoothGattStatus aStatus, int aServerIf) { }
protected:
BluetoothGattClientNotificationHandler()

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

@ -98,8 +98,8 @@ struct BluetoothGattClientCallback
// GATT Client Notification
typedef BluetoothNotificationHALRunnable3<
GattClientNotificationHandlerWrapper, void,
int, int, BluetoothUuid,
int, int, const BluetoothUuid&>
BluetoothGattStatus, int, BluetoothUuid,
BluetoothGattStatus, int, const BluetoothUuid&>
RegisterClientNotification;
typedef BluetoothNotificationHALRunnable3<
@ -110,19 +110,19 @@ struct BluetoothGattClientCallback
typedef BluetoothNotificationHALRunnable4<
GattClientNotificationHandlerWrapper, void,
int, int, int, nsString,
int, int, int, const nsAString&>
int, BluetoothGattStatus, int, nsString,
int, BluetoothGattStatus, int, const nsAString&>
ConnectNotification;
typedef BluetoothNotificationHALRunnable4<
GattClientNotificationHandlerWrapper, void,
int, int, int, nsString,
int, int, int, const nsAString&>
int, BluetoothGattStatus, int, nsString,
int, BluetoothGattStatus, int, const nsAString&>
DisconnectNotification;
typedef BluetoothNotificationHALRunnable2<
GattClientNotificationHandlerWrapper, void,
int, int>
int, BluetoothGattStatus>
SearchCompleteNotification;
typedef BluetoothNotificationHALRunnable2<
@ -133,29 +133,32 @@ struct BluetoothGattClientCallback
typedef BluetoothNotificationHALRunnable5<
GattClientNotificationHandlerWrapper, void,
int, int, BluetoothGattServiceId, BluetoothGattId, int,
int, int, const BluetoothGattServiceId&, const BluetoothGattId&>
int, BluetoothGattStatus, BluetoothGattServiceId,
BluetoothGattId, int,
int, BluetoothGattStatus, const BluetoothGattServiceId&,
const BluetoothGattId&>
GetCharacteristicNotification;
typedef BluetoothNotificationHALRunnable5<
GattClientNotificationHandlerWrapper, void,
int, int, BluetoothGattServiceId,
int, BluetoothGattStatus, BluetoothGattServiceId,
BluetoothGattId, BluetoothGattId,
int, int, const BluetoothGattServiceId&,
int, BluetoothGattStatus, const BluetoothGattServiceId&,
const BluetoothGattId&, const BluetoothGattId&>
GetDescriptorNotification;
typedef BluetoothNotificationHALRunnable4<
GattClientNotificationHandlerWrapper, void,
int, int, BluetoothGattServiceId, BluetoothGattServiceId,
int, int, const BluetoothGattServiceId&, const BluetoothGattServiceId&>
int, BluetoothGattStatus, BluetoothGattServiceId, BluetoothGattServiceId,
int, BluetoothGattStatus, const BluetoothGattServiceId&,
const BluetoothGattServiceId&>
GetIncludedServiceNotification;
typedef BluetoothNotificationHALRunnable5<
GattClientNotificationHandlerWrapper, void,
int, int, int,
int, int, BluetoothGattStatus,
BluetoothGattServiceId, BluetoothGattId,
int, int, int,
int, int, BluetoothGattStatus,
const BluetoothGattServiceId&, const BluetoothGattId&>
RegisterNotificationNotification;
@ -167,42 +170,42 @@ struct BluetoothGattClientCallback
typedef BluetoothNotificationHALRunnable3<
GattClientNotificationHandlerWrapper, void,
int, int, BluetoothGattReadParam,
int, int, const BluetoothGattReadParam&>
int, BluetoothGattStatus, BluetoothGattReadParam,
int, BluetoothGattStatus, const BluetoothGattReadParam&>
ReadCharacteristicNotification;
typedef BluetoothNotificationHALRunnable3<
GattClientNotificationHandlerWrapper, void,
int, int, BluetoothGattWriteParam,
int, int, const BluetoothGattWriteParam&>
int, BluetoothGattStatus, BluetoothGattWriteParam,
int, BluetoothGattStatus, const BluetoothGattWriteParam&>
WriteCharacteristicNotification;
typedef BluetoothNotificationHALRunnable3<
GattClientNotificationHandlerWrapper, void,
int, int, BluetoothGattReadParam,
int, int, const BluetoothGattReadParam&>
int, BluetoothGattStatus, BluetoothGattReadParam,
int, BluetoothGattStatus, const BluetoothGattReadParam&>
ReadDescriptorNotification;
typedef BluetoothNotificationHALRunnable3<
GattClientNotificationHandlerWrapper, void,
int, int, BluetoothGattWriteParam,
int, int, const BluetoothGattWriteParam&>
int, BluetoothGattStatus, BluetoothGattWriteParam,
int, BluetoothGattStatus, const BluetoothGattWriteParam&>
WriteDescriptorNotification;
typedef BluetoothNotificationHALRunnable2<
GattClientNotificationHandlerWrapper, void,
int, int>
int, BluetoothGattStatus>
ExecuteWriteNotification;
typedef BluetoothNotificationHALRunnable4<
GattClientNotificationHandlerWrapper, void,
int, nsString, int, int,
int, const nsAString&, int, int>
int, nsString, int, BluetoothGattStatus,
int, const nsAString&, int, BluetoothGattStatus>
ReadRemoteRssiNotification;
typedef BluetoothNotificationHALRunnable2<
GattClientNotificationHandlerWrapper, void,
int, int>
BluetoothGattStatus, int>
ListenNotification;
// Bluedroid GATT client callbacks

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

@ -488,7 +488,7 @@ BluetoothGattManager::Disconnect(const nsAString& aAppUuid,
// Notification Handlers
//
void
BluetoothGattManager::RegisterClientNotification(int aStatus,
BluetoothGattManager::RegisterClientNotification(BluetoothGattStatus aStatus,
int aClientIf,
const BluetoothUuid& aAppUuid)
{
@ -505,7 +505,7 @@ BluetoothGattManager::RegisterClientNotification(int aStatus,
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
if (aStatus) { // operation failed
if (aStatus != GATT_STATUS_SUCCESS) {
BT_API2_LOGR(
"RegisterClient failed, clientIf = %d, status = %d, appUuid = %s",
aClientIf, aStatus, NS_ConvertUTF16toUTF8(uuid).get());
@ -550,7 +550,7 @@ BluetoothGattManager::ScanResultNotification(
void
BluetoothGattManager::ConnectNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
int aClientIf,
const nsAString& aDeviceAddr)
{
@ -565,7 +565,7 @@ BluetoothGattManager::ConnectNotification(int aConnId,
NS_ENSURE_TRUE_VOID(index != sClients->NoIndex);
nsRefPtr<BluetoothGattClient> client = sClients->ElementAt(index);
if (aStatus) { // operation failed
if (aStatus != GATT_STATUS_SUCCESS) {
BT_API2_LOGR("Connect failed, clientIf = %d, connId = %d, status = %d",
aClientIf, aConnId, aStatus);
@ -602,7 +602,7 @@ BluetoothGattManager::ConnectNotification(int aConnId,
void
BluetoothGattManager::DisconnectNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
int aClientIf,
const nsAString& aDeviceAddr)
{
@ -617,7 +617,7 @@ BluetoothGattManager::DisconnectNotification(int aConnId,
NS_ENSURE_TRUE_VOID(index != sClients->NoIndex);
nsRefPtr<BluetoothGattClient> client = sClients->ElementAt(index);
if (aStatus) { // operation failed
if (aStatus != GATT_STATUS_SUCCESS) {
// Notify BluetoothGatt that the client remains connected
bs->DistributeSignal(
NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
@ -650,7 +650,8 @@ BluetoothGattManager::DisconnectNotification(int aConnId,
}
void
BluetoothGattManager::SearchCompleteNotification(int aConnId, int aStatus)
BluetoothGattManager::SearchCompleteNotification(int aConnId,
BluetoothGattStatus aStatus)
{ }
void
@ -660,7 +661,7 @@ BluetoothGattManager::SearchResultNotification(
void
BluetoothGattManager::GetCharacteristicNotification(
int aConnId, int aStatus,
int aConnId, BluetoothGattStatus aStatus,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
int aCharProperty)
@ -668,7 +669,7 @@ BluetoothGattManager::GetCharacteristicNotification(
void
BluetoothGattManager::GetDescriptorNotification(
int aConnId, int aStatus,
int aConnId, BluetoothGattStatus aStatus,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
const BluetoothGattId& aDescriptorId)
@ -676,14 +677,14 @@ BluetoothGattManager::GetDescriptorNotification(
void
BluetoothGattManager::GetIncludedServiceNotification(
int aConnId, int aStatus,
int aConnId, BluetoothGattStatus aStatus,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattServiceId& aIncludedServId)
{ }
void
BluetoothGattManager::RegisterNotificationNotification(
int aConnId, int aIsRegister, int aStatus,
int aConnId, int aIsRegister, BluetoothGattStatus aStatus,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId)
{ }
@ -695,37 +696,42 @@ BluetoothGattManager::NotifyNotification(
void
BluetoothGattManager::ReadCharacteristicNotification(
int aConnId, int aStatus, const BluetoothGattReadParam& aReadParam)
int aConnId, BluetoothGattStatus aStatus,
const BluetoothGattReadParam& aReadParam)
{ }
void
BluetoothGattManager::WriteCharacteristicNotification(
int aConnId, int aStatus, const BluetoothGattWriteParam& aWriteParam)
int aConnId, BluetoothGattStatus aStatus,
const BluetoothGattWriteParam& aWriteParam)
{ }
void
BluetoothGattManager::ReadDescriptorNotification(
int aConnId, int aStatus, const BluetoothGattReadParam& aReadParam)
int aConnId, BluetoothGattStatus aStatus,
const BluetoothGattReadParam& aReadParam)
{ }
void
BluetoothGattManager::WriteDescriptorNotification(
int aConnId, int aStatus, const BluetoothGattWriteParam& aWriteParam)
int aConnId, BluetoothGattStatus aStatus,
const BluetoothGattWriteParam& aWriteParam)
{ }
void
BluetoothGattManager::ExecuteWriteNotification(int aConnId, int aStatus)
BluetoothGattManager::ExecuteWriteNotification(int aConnId,
BluetoothGattStatus aStatus)
{ }
void
BluetoothGattManager::ReadRemoteRssiNotification(int aClientIf,
const nsAString& aBdAddr,
int aRssi,
int aStatus)
BluetoothGattStatus aStatus)
{ }
void
BluetoothGattManager::ListenNotification(int aStatus,
BluetoothGattManager::ListenNotification(BluetoothGattStatus aStatus,
int aServerIf)
{ }

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

@ -51,7 +51,7 @@ private:
void HandleShutdown();
void RegisterClientNotification(int aStatus,
void RegisterClientNotification(BluetoothGattStatus aStatus,
int aClientIf,
const BluetoothUuid& aAppUuid) MOZ_OVERRIDE;
@ -60,40 +60,41 @@ private:
const BluetoothGattAdvData& aAdvData) MOZ_OVERRIDE;
void ConnectNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
int aClientIf,
const nsAString& aBdAddr) MOZ_OVERRIDE;
void DisconnectNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
int aClientIf,
const nsAString& aBdAddr) MOZ_OVERRIDE;
void SearchCompleteNotification(int aConnId, int aStatus) MOZ_OVERRIDE;
void SearchCompleteNotification(int aConnId,
BluetoothGattStatus aStatus) MOZ_OVERRIDE;
void SearchResultNotification(int aConnId,
const BluetoothGattServiceId& aServiceId)
MOZ_OVERRIDE;
void GetCharacteristicNotification(
int aConnId, int aStatus,
int aConnId, BluetoothGattStatus aStatus,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
int aCharProperty) MOZ_OVERRIDE;
void GetDescriptorNotification(
int aConnId, int aStatus,
int aConnId, BluetoothGattStatus aStatus,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId,
const BluetoothGattId& aDescriptorId) MOZ_OVERRIDE;
void GetIncludedServiceNotification(
int aConnId, int aStatus,
int aConnId, BluetoothGattStatus aStatus,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattServiceId& aIncludedServId) MOZ_OVERRIDE;
void RegisterNotificationNotification(
int aConnId, int aIsRegister, int aStatus,
int aConnId, int aIsRegister, BluetoothGattStatus aStatus,
const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId) MOZ_OVERRIDE;
@ -102,32 +103,34 @@ private:
MOZ_OVERRIDE;
void ReadCharacteristicNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
const BluetoothGattReadParam& aReadParam)
MOZ_OVERRIDE;
void WriteCharacteristicNotification(
int aConnId, int aStatus,
int aConnId, BluetoothGattStatus aStatus,
const BluetoothGattWriteParam& aWriteParam) MOZ_OVERRIDE;
void ReadDescriptorNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
const BluetoothGattReadParam& aReadParam)
MOZ_OVERRIDE;
void WriteDescriptorNotification(int aConnId,
int aStatus,
BluetoothGattStatus aStatus,
const BluetoothGattWriteParam& aWriteParam)
MOZ_OVERRIDE;
void ExecuteWriteNotification(int aConnId, int aStatus) MOZ_OVERRIDE;
void ExecuteWriteNotification(int aConnId,
BluetoothGattStatus aStatus) MOZ_OVERRIDE;
void ReadRemoteRssiNotification(int aClientIf,
const nsAString& aBdAddr,
int aRssi,
int aStatus) MOZ_OVERRIDE;
BluetoothGattStatus aStatus) MOZ_OVERRIDE;
void ListenNotification(int aStatus, int aServerIf) MOZ_OVERRIDE;
void ListenNotification(BluetoothGattStatus aStatus,
int aServerIf) MOZ_OVERRIDE;
static bool mInShutdown;
};

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

@ -766,6 +766,23 @@ Convert(btrc_remote_features_t aIn, unsigned long& aOut)
}
#endif // ANDROID_VERSION >= 19
inline nsresult
Convert(int aIn, BluetoothGattStatus& aOut)
{
/**
* Currently we only map bluedroid's GATT status into GATT_STATUS_SUCCESS and
* GATT_STATUS_ERROR. This function needs to be revised if we want to support
* specific error status.
*/
if (!aIn) {
aOut = GATT_STATUS_SUCCESS;
} else {
aOut = GATT_STATUS_ERROR;
}
return NS_OK;
}
nsresult
Convert(const uint8_t* aIn, BluetoothGattAdvData& aOut);