Bug 956258 - [cleanup] Patch 2/2: reduce warnings and remove cancel_discovery() in SendFile(), r=echou

This commit is contained in:
Ben Tian 2014-01-03 17:25:04 +08:00
parent 51c5e6a6c8
commit bca0e37677
6 changed files with 22 additions and 38 deletions

View File

@ -570,9 +570,12 @@ BluetoothHfpManager::ProcessVolumeControl(bthf_volume_type_t aType,
if (aType == BTHF_VOLUME_TYPE_MIC) {
mCurrentVgm = aVolume;
} else if (aType == BTHF_VOLUME_TYPE_SPK) {
// Adjust volume by headset
mReceiveVgsFlag = true;
NS_ENSURE_TRUE_VOID(aVolume != mCurrentVgs);
if (aVolume == mCurrentVgs) {
// Keep current volume
return;
}
nsString data;
data.AppendInt(aVolume);
@ -851,10 +854,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
// Signal
JS::Value value;
voiceInfo->GetRelSignalStrength(&value);
if (!value.isNumber()) {
BT_WARNING("Failed to get relSignalStrength in BluetoothHfpManager");
return;
}
NS_ENSURE_TRUE_VOID(value.isNumber());
mSignal = (int)ceil(value.toNumber() / 20.0);
UpdateDeviceCIND();

View File

@ -37,12 +37,6 @@ public:
aName.AssignLiteral("OPP");
}
/*
* Channel of reserved services are fixed values, please check
* function add_reserved_service_records() in
* external/bluetooth/bluez/src/adapter.c for more information.
*/
static const int DEFAULT_OPP_CHANNEL = 10;
static const int MAX_PACKET_LENGTH = 0xFFFE;
virtual ~BluetoothOppManager();

View File

@ -605,10 +605,12 @@ BluetoothSocket::Connect(const nsAString& aDeviceAddress, int aChannel)
// TODO: uuid as argument
int fd;
NS_ENSURE_TRUE(BT_STATUS_SUCCESS ==
sBluetoothSocketInterface->connect((bt_bdaddr_t *) &remoteBdAddress,
(btsock_type_t) BTSOCK_RFCOMM,
sBluetoothSocketInterface->connect(&remoteBdAddress,
BTSOCK_RFCOMM,
UUID_OBEX_OBJECT_PUSH,
aChannel, &fd, (mAuth << 1) | mEncrypt),
aChannel,
&fd,
(mAuth << 1) | mEncrypt),
false);
NS_ENSURE_TRUE(fd >= 0, false);
@ -626,10 +628,12 @@ BluetoothSocket::Listen(int aChannel)
nsAutoCString serviceName("OBEX Object Push");
int fd;
NS_ENSURE_TRUE(BT_STATUS_SUCCESS ==
sBluetoothSocketInterface->listen((btsock_type_t) BTSOCK_RFCOMM,
sBluetoothSocketInterface->listen(BTSOCK_RFCOMM,
serviceName.get(),
UUID_OBEX_OBJECT_PUSH,
aChannel, &fd, (mAuth << 1) | mEncrypt),
aChannel,
&fd,
(mAuth << 1) | mEncrypt),
false);
NS_ENSURE_TRUE(fd >= 0, false);

View File

@ -666,9 +666,12 @@ static nsresult
StartStopGonkBluetooth(bool aShouldEnable)
{
MOZ_ASSERT(!NS_IsMainThread());
NS_ENSURE_TRUE(sBtInterface, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(sIsBtEnabled != aShouldEnable, NS_OK);
if (sIsBtEnabled == aShouldEnable) {
// Keep current enable status
return NS_OK;
}
int ret = aShouldEnable ? sBtInterface->enable() : sBtInterface->disable();
NS_ENSURE_TRUE(ret == BT_STATUS_SUCCESS, NS_ERROR_FAILURE);
@ -1221,13 +1224,6 @@ BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
{
MOZ_ASSERT(NS_IsMainThread());
// Force to stop discovery, otherwise socket connecting would fail
if (!IsReady() || BT_STATUS_SUCCESS != sBtInterface->cancel_discovery()) {
NS_NAMED_LITERAL_STRING(errorStr, "Calling cancel_discovery() failed");
DispatchBluetoothReply(aRunnable, BluetoothValue(true), errorStr);
return;
}
// Currently we only support one device sending one file at a time,
// so we don't need aDeviceAddress here because the target device
// has been determined when calling 'Connect()'. Nevertheless, keep

View File

@ -620,14 +620,10 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
}
UpdateCIND(CINDType::SERVICE, service);
uint8_t signal;
JS::Value value;
voiceInfo->GetRelSignalStrength(&value);
if (!value.isNumber()) {
BT_WARNING("Failed to get relSignalStrength in BluetoothHfpManager");
return;
}
signal = ceil(value.toNumber() / 20.0);
NS_ENSURE_TRUE_VOID(value.isNumber());
uint8_t signal = ceil(value.toNumber() / 20.0);
UpdateCIND(CINDType::SIGNAL, signal);
/**

View File

@ -37,12 +37,6 @@ public:
aName.AssignLiteral("OPP");
}
/*
* Channel of reserved services are fixed values, please check
* function add_reserved_service_records() in
* external/bluetooth/bluez/src/adapter.c for more information.
*/
static const int DEFAULT_OPP_CHANNEL = 10;
static const int MAX_PACKET_LENGTH = 0xFFFE;
virtual ~BluetoothOppManager();