本文整理汇总了C++中ConvertDefault函数的典型用法代码示例。如果您正苦于以下问题:C++ ConvertDefault函数的具体用法?C++ ConvertDefault怎么用?C++ ConvertDefault使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ConvertDefault函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NS_SUCCEEDED
void
BluetoothHandsfreeHALInterface::VolumeControl(
BluetoothHandsfreeVolumeType aType, int aVolume, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status;
bthf_volume_type_t type = BTHF_VOLUME_TYPE_SPK;
#if ANDROID_VERSION >= 21
bt_bdaddr_t bdAddr;
if (NS_SUCCEEDED(Convert(aType, type)) &&
NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->volume_control(type, aVolume, &bdAddr);
#else
if (NS_SUCCEEDED(Convert(aType, type))) {
status = mInterface->volume_control(type, aVolume);
#endif
} else {
status = BT_STATUS_PARM_INVALID;
}
if (aRes) {
DispatchBluetoothHandsfreeHALResult(
aRes, &BluetoothHandsfreeResultHandler::VolumeControl,
ConvertDefault(status, STATUS_FAIL));
}
}
/* Device status */
void
BluetoothHandsfreeHALInterface::DeviceStatusNotification(
BluetoothHandsfreeNetworkState aNtkState,
BluetoothHandsfreeServiceType aSvcType, int aSignal,
int aBattChg, BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status;
bthf_network_state_t ntkState = BTHF_NETWORK_STATE_NOT_AVAILABLE;
bthf_service_type_t svcType = BTHF_SERVICE_TYPE_HOME;
if (NS_SUCCEEDED(Convert(aNtkState, ntkState)) &&
NS_SUCCEEDED(Convert(aSvcType, svcType))) {
status = mInterface->device_status_notification(ntkState, svcType,
aSignal, aBattChg);
} else {
status = BT_STATUS_PARM_INVALID;
}
if (aRes) {
DispatchBluetoothHandsfreeHALResult(
aRes, &BluetoothHandsfreeResultHandler::DeviceStatusNotification,
ConvertDefault(status, STATUS_FAIL));
}
}
示例2: NS_SUCCEEDED
void
BluetoothHALInterface::CreateBond(const nsAString& aBdAddr,
BluetoothTransport aTransport,
BluetoothResultHandler* aRes)
{
bt_bdaddr_t bdAddr;
int status;
#if ANDROID_VERSION >= 21
int transport = 0; /* TRANSPORT_AUTO */
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) &&
NS_SUCCEEDED(Convert(aTransport, transport))) {
status = mInterface->create_bond(&bdAddr, transport);
#else
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->create_bond(&bdAddr);
#endif
} else {
status = BT_STATUS_PARM_INVALID;
}
if (aRes) {
DispatchBluetoothHALResult(aRes,
&BluetoothResultHandler::CreateBond,
ConvertDefault(status, STATUS_FAIL));
}
}
void
BluetoothHALInterface::RemoveBond(const nsAString& aBdAddr,
BluetoothResultHandler* aRes)
{
bt_bdaddr_t bdAddr;
int status;
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->remove_bond(&bdAddr);
} else {
status = BT_STATUS_PARM_INVALID;
}
if (aRes) {
DispatchBluetoothHALResult(aRes,
&BluetoothResultHandler::RemoveBond,
ConvertDefault(status, STATUS_FAIL));
}
}
示例3: NS_NOTREACHED
void
BluetoothHALInterface::GetRemoteDeviceProperty(
const nsAString& aRemoteAddr, const nsAString& aName,
BluetoothResultHandler* aRes)
{
int status;
bt_bdaddr_t remoteAddr;
bt_property_type_t name;
/* FIXME: you need to implement the missing conversion functions */
NS_NOTREACHED("Conversion function missing");
if (NS_SUCCEEDED(Convert(aRemoteAddr, remoteAddr)) &&
false /* TODO: we don't support any values for aName currently */) {
// silence uninitialized variable warning for |name|
name = static_cast<bt_property_type_t>(0);
status = mInterface->get_remote_device_property(&remoteAddr, name);
} else {
status = BT_STATUS_PARM_INVALID;
}
if (aRes) {
DispatchBluetoothHALResult(aRes,
&BluetoothResultHandler::GetRemoteDeviceProperty,
ConvertDefault(status, STATUS_FAIL));
}
}
示例4: DispatchBluetoothHandsfreeHALResult
void
BluetoothHandsfreeHALInterface::CopsResponse(
const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status;
#if ANDROID_VERSION >= 21
bt_bdaddr_t bdAddr;
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->cops_response(aCops, &bdAddr);
} else {
status = BT_STATUS_PARM_INVALID;
}
#else
status = mInterface->cops_response(aCops);
#endif
if (aRes) {
DispatchBluetoothHandsfreeHALResult(
aRes, &BluetoothHandsfreeResultHandler::CopsResponse,
ConvertDefault(status, STATUS_FAIL));
}
}
示例5: NS_ConvertUTF16toUTF8
void
BluetoothSocketHALInterface::Listen(BluetoothSocketType aType,
const nsAString& aServiceName,
const uint8_t aServiceUuid[16],
int aChannel, bool aEncrypt,
bool aAuth,
BluetoothSocketResultHandler* aRes)
{
int fd;
bt_status_t status;
btsock_type_t type = BTSOCK_RFCOMM; // silences compiler warning
if (NS_SUCCEEDED(Convert(aType, type))) {
status = mInterface->listen(type,
NS_ConvertUTF16toUTF8(aServiceName).get(),
aServiceUuid, aChannel, &fd,
(BTSOCK_FLAG_ENCRYPT * aEncrypt) |
(BTSOCK_FLAG_AUTH * aAuth));
} else {
status = BT_STATUS_PARM_INVALID;
}
if (aRes) {
DispatchBluetoothSocketHALResult(
aRes, &BluetoothSocketResultHandler::Listen, fd,
ConvertDefault(status, STATUS_FAIL));
}
}
示例6: if
void
BluetoothGattClientHALInterface::SearchService(
int aConnId, bool aSearchAll, const BluetoothUuid& aUuid,
BluetoothGattClientResultHandler* aRes)
{
bt_status_t status;
#if ANDROID_VERSION >= 19
bt_uuid_t uuid;
if (aSearchAll) {
status = mInterface->search_service(aConnId, 0);
} else if (NS_SUCCEEDED(Convert(aUuid, uuid))) {
status = mInterface->search_service(aConnId, &uuid);
} else {
status = BT_STATUS_PARM_INVALID;
}
#else
status = BT_STATUS_UNSUPPORTED;
#endif
if (aRes) {
DispatchBluetoothGattClientHALResult(
aRes, &BluetoothGattClientResultHandler::SearchService,
ConvertDefault(status, STATUS_FAIL));
}
}
示例7: NS_SUCCEEDED
void
BluetoothGattClientHALInterface::WriteCharacteristic(
int aConnId, const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId, BluetoothGattWriteType aWriteType,
BluetoothGattAuthReq aAuthReq, const nsTArray<uint8_t>& aValue,
BluetoothGattClientResultHandler* aRes)
{
bt_status_t status;
#if ANDROID_VERSION >= 19
btgatt_srvc_id_t serviceId;
btgatt_gatt_id_t charId;
int writeType;
int authReq;
if (NS_SUCCEEDED(Convert(aServiceId, serviceId)) &&
NS_SUCCEEDED(Convert(aCharId, charId)) &&
NS_SUCCEEDED(Convert(aWriteType, writeType)) &&
NS_SUCCEEDED(Convert(aAuthReq, authReq))) {
status = mInterface->write_characteristic(
aConnId, &serviceId, &charId, writeType,
aValue.Length() * sizeof(uint8_t), authReq,
reinterpret_cast<char*>(const_cast<uint8_t*>(aValue.Elements())));
} else {
status = BT_STATUS_PARM_INVALID;
}
#else
status = BT_STATUS_UNSUPPORTED;
#endif
if (aRes) {
DispatchBluetoothGattClientHALResult(
aRes, &BluetoothGattClientResultHandler::WriteCharacteristic,
ConvertDefault(status, STATUS_FAIL));
}
}
示例8: sizeof
void
BluetoothHALInterface::Init(
BluetoothNotificationHandler* aNotificationHandler,
BluetoothResultHandler* aRes)
{
static bt_callbacks_t sBluetoothCallbacks = {
sizeof(sBluetoothCallbacks),
BluetoothCallback::AdapterStateChanged,
BluetoothCallback::AdapterProperties,
BluetoothCallback::RemoteDeviceProperties,
BluetoothCallback::DeviceFound,
BluetoothCallback::DiscoveryStateChanged,
BluetoothCallback::PinRequest,
BluetoothCallback::SspRequest,
BluetoothCallback::BondStateChanged,
BluetoothCallback::AclStateChanged,
BluetoothCallback::ThreadEvt,
BluetoothCallback::DutModeRecv
#if ANDROID_VERSION >= 18
,
BluetoothCallback::LeTestMode
#endif
};
sNotificationHandler = aNotificationHandler;
int status = mInterface->init(&sBluetoothCallbacks);
if (aRes) {
DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::Init,
ConvertDefault(status, STATUS_FAIL));
}
}
示例9: DispatchBluetoothGattClientHALResult
void
BluetoothGattClientHALInterface::SetAdvData(
int aServerIf, bool aIsScanRsp, bool aIsNameIncluded,
bool aIsTxPowerIncluded, int aMinInterval, int aMaxInterval, int aApperance,
uint8_t aManufacturerLen, const ArrayBuffer& aManufacturerData,
BluetoothGattClientResultHandler* aRes)
{
bt_status_t status;
#if ANDROID_VERSION >= 19
char value[aManufacturerLen + 1];
if (NS_SUCCEEDED(Convert(aManufacturerData, value))) {
status = mInterface->set_adv_data(
aServerIf, aIsScanRsp, aIsNameIncluded, aIsTxPowerIncluded, aMinInterval,
aMaxInterval, aApperance, aManufacturerLen, value);
} else {
status = BT_STATUS_PARM_INVALID;
}
#else
status = BT_STATUS_UNSUPPORTED;
#endif
if (aRes) {
DispatchBluetoothGattClientHALResult(
aRes, &BluetoothGattClientResultHandler::SetAdvData,
ConvertDefault(status, STATUS_FAIL));
}
}
示例10: NS_SUCCEEDED
void
BluetoothSocketHALInterface::Connect(const nsAString& aBdAddr,
BluetoothSocketType aType,
const uint8_t aUuid[16],
int aChannel, bool aEncrypt,
bool aAuth,
BluetoothSocketResultHandler* aRes)
{
int fd;
bt_status_t status;
bt_bdaddr_t bdAddr;
btsock_type_t type = BTSOCK_RFCOMM; // silences compiler warning
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) &&
NS_SUCCEEDED(Convert(aType, type))) {
status = mInterface->connect(&bdAddr, type, aUuid, aChannel, &fd,
(BTSOCK_FLAG_ENCRYPT * aEncrypt) |
(BTSOCK_FLAG_AUTH * aAuth));
} else {
status = BT_STATUS_PARM_INVALID;
}
if (status == BT_STATUS_SUCCESS) {
/* receive Bluedroid's socket-setup messages */
Task* t = new SocketMessageWatcherTask(new ConnectWatcher(fd, aRes));
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, t);
} else if (aRes) {
DispatchBluetoothSocketHALResult(
aRes, &BluetoothSocketResultHandler::Connect, -1, EmptyString(), 0,
ConvertDefault(status, STATUS_FAIL));
}
}
示例11: NS_NOTREACHED
void
BluetoothHALInterface::SetRemoteDeviceProperty(
const nsAString& aRemoteAddr, const BluetoothNamedValue& aProperty,
BluetoothResultHandler* aRes)
{
int status;
bt_bdaddr_t remoteAddr;
bt_property_t property;
/* FIXME: you need to implement the missing conversion functions */
NS_NOTREACHED("Conversion function missing");
if (NS_SUCCEEDED(Convert(aRemoteAddr, remoteAddr)) &&
false /* TODO: we don't support any values for aProperty currently */) {
status = mInterface->set_remote_device_property(&remoteAddr, &property);
} else {
status = BT_STATUS_PARM_INVALID;
}
if (aRes) {
DispatchBluetoothHALResult(aRes,
&BluetoothResultHandler::SetRemoteDeviceProperty,
ConvertDefault(status, STATUS_FAIL));
}
}
示例12: DispatchBluetoothHALResult
void
BluetoothHALInterface::Disable(BluetoothResultHandler* aRes)
{
int status = mInterface->disable();
if (aRes) {
DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::Disable,
ConvertDefault(status, STATUS_FAIL));
}
}
示例13: sizeof
void
BluetoothHALInterface::Init(
BluetoothNotificationHandler* aNotificationHandler,
BluetoothResultHandler* aRes)
{
static bt_callbacks_t sBluetoothCallbacks = {
sizeof(sBluetoothCallbacks),
BluetoothCallback::AdapterStateChanged,
BluetoothCallback::AdapterProperties,
BluetoothCallback::RemoteDeviceProperties,
BluetoothCallback::DeviceFound,
BluetoothCallback::DiscoveryStateChanged,
BluetoothCallback::PinRequest,
BluetoothCallback::SspRequest,
BluetoothCallback::BondStateChanged,
BluetoothCallback::AclStateChanged,
BluetoothCallback::ThreadEvt,
BluetoothCallback::DutModeRecv,
#if ANDROID_VERSION >= 18
BluetoothCallback::LeTestMode,
#endif
#if ANDROID_VERSION >= 21
BluetoothCallback::EnergyInfo
#endif
};
#if ANDROID_VERSION >= 21
static bt_os_callouts_t sBluetoothOsCallouts = {
sizeof(sBluetoothOsCallouts),
BluetoothOsCallout::SetWakeAlarm,
BluetoothOsCallout::AcquireWakeLock,
BluetoothOsCallout::ReleaseWakeLock
};
#endif
sNotificationHandler = aNotificationHandler;
int status = mInterface->init(&sBluetoothCallbacks);
#if ANDROID_VERSION >= 21
if (status == BT_STATUS_SUCCESS) {
status = mInterface->set_os_callouts(&sBluetoothOsCallouts);
if (status != BT_STATUS_SUCCESS) {
mInterface->cleanup();
}
}
#endif
if (aRes) {
DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::Init,
ConvertDefault(status, STATUS_FAIL));
}
}
示例14: AdapterProperties
static void
AdapterProperties(bt_status_t aStatus, int aNumProperties,
bt_property_t* aProperties)
{
nsAutoArrayPtr<bt_property_t> propertiesArray;
AdapterPropertiesNotification::Dispatch(
&BluetoothNotificationHandler::AdapterPropertiesNotification,
ConvertDefault(aStatus, STATUS_FAIL), aNumProperties,
ConvertArray<bt_property_t>(
AlignedProperties(aProperties, aNumProperties, propertiesArray),
aNumProperties));
}
示例15: RemoteDeviceProperties
static void
RemoteDeviceProperties(bt_status_t aStatus, bt_bdaddr_t* aBdAddress,
int aNumProperties, bt_property_t* aProperties)
{
nsAutoArrayPtr<bt_property_t> propertiesArray;
RemoteDevicePropertiesNotification::Dispatch(
&BluetoothNotificationHandler::RemoteDevicePropertiesNotification,
ConvertDefault(aStatus, STATUS_FAIL), aBdAddress, aNumProperties,
ConvertArray<bt_property_t>(
AlignedProperties(aProperties, aNumProperties, propertiesArray),
aNumProperties));
}