mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 05:10:49 +00:00
Bug 1215525: Replace strings with Bluetooth addresses and UUIDs in Bluetooth mid-layer, r=brsun
This commit is contained in:
parent
da8fa8c983
commit
cb9c58250a
@ -411,7 +411,7 @@ BluetoothA2dpManager::OnConnectError()
|
||||
mController->NotifyCompletion(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
|
||||
|
||||
mController = nullptr;
|
||||
mDeviceAddress.Truncate();
|
||||
mDeviceAddress.Clear();
|
||||
}
|
||||
|
||||
class BluetoothA2dpManager::ConnectResultHandler final
|
||||
@ -428,11 +428,11 @@ public:
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothA2dpManager::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(aController);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
@ -455,13 +455,7 @@ BluetoothA2dpManager::Connect(const nsAString& aDeviceAddress,
|
||||
return;
|
||||
}
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sBtA2dpInterface->Connect(deviceAddress, new ConnectResultHandler());
|
||||
sBtA2dpInterface->Connect(mDeviceAddress, new ConnectResultHandler());
|
||||
}
|
||||
|
||||
void
|
||||
@ -509,7 +503,7 @@ BluetoothA2dpManager::Disconnect(BluetoothProfileController* aController)
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
|
||||
mController = aController;
|
||||
|
||||
@ -522,13 +516,7 @@ BluetoothA2dpManager::Disconnect(BluetoothProfileController* aController)
|
||||
return;
|
||||
}
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(mDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sBtA2dpInterface->Disconnect(deviceAddress, new DisconnectResultHandler());
|
||||
sBtA2dpInterface->Disconnect(mDeviceAddress, new DisconnectResultHandler());
|
||||
}
|
||||
|
||||
void
|
||||
@ -588,14 +576,15 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||
MOZ_ASSERT(aSignal.value().type() ==
|
||||
BluetoothValue::TArrayOfBluetoothNamedValue);
|
||||
|
||||
const nsString& address = aSignal.path();
|
||||
BluetoothAddress address;
|
||||
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(StringToAddress(aSignal.path(), address)));
|
||||
|
||||
/**
|
||||
* Update sink property only if
|
||||
* - mDeviceAddress is empty (A2dp is disconnected), or
|
||||
* - this property change is from the connected sink.
|
||||
*/
|
||||
NS_ENSURE_TRUE_VOID(mDeviceAddress.IsEmpty() ||
|
||||
mDeviceAddress.Equals(address));
|
||||
NS_ENSURE_TRUE_VOID(mDeviceAddress.IsCleared() || mDeviceAddress == address);
|
||||
|
||||
const InfallibleTArray<BluetoothNamedValue>& arr =
|
||||
aSignal.value().get_ArrayOfBluetoothNamedValue();
|
||||
@ -658,7 +647,7 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||
|
||||
mA2dpConnected = false;
|
||||
NotifyConnectionStatusChanged();
|
||||
mDeviceAddress.Truncate();
|
||||
mDeviceAddress.Clear();
|
||||
OnDisconnect(EmptyString());
|
||||
break;
|
||||
default:
|
||||
@ -674,14 +663,8 @@ void
|
||||
BluetoothA2dpManager::HandleBackendError()
|
||||
{
|
||||
if (mSinkState != SinkState::SINK_DISCONNECTED) {
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(mDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConnectionStateNotification(A2DP_CONNECTION_STATE_DISCONNECTED,
|
||||
deviceAddress);
|
||||
mDeviceAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@ -694,31 +677,34 @@ BluetoothA2dpManager::NotifyConnectionStatusChanged()
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
NS_ENSURE_TRUE_VOID(obs);
|
||||
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
if (NS_FAILED(obs->NotifyObservers(this,
|
||||
BLUETOOTH_A2DP_STATUS_CHANGED_ID,
|
||||
mDeviceAddress.get()))) {
|
||||
deviceAddressStr.get()))) {
|
||||
BT_WARNING("Failed to notify bluetooth-a2dp-status-changed observsers!");
|
||||
}
|
||||
|
||||
// Dispatch an event of status change
|
||||
DispatchStatusChangedEvent(
|
||||
NS_LITERAL_STRING(A2DP_STATUS_CHANGED_ID), mDeviceAddress, mA2dpConnected);
|
||||
NS_LITERAL_STRING(A2DP_STATUS_CHANGED_ID), deviceAddressStr, mA2dpConnected);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
BluetoothA2dpManager::OnGetServiceChannel(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
BluetoothA2dpManager::OnUpdateSdpRecords(const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::GetAddress(nsAString& aDeviceAddress)
|
||||
BluetoothA2dpManager::GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
aDeviceAddress = mDeviceAddress;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ private:
|
||||
void AudioStateNotification(BluetoothA2dpAudioState aState,
|
||||
const BluetoothAddress& aBdAddr) override;
|
||||
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
RefPtr<BluetoothProfileController> mController;
|
||||
|
||||
// A2DP data member
|
||||
|
@ -441,11 +441,11 @@ private:
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothAvrcpManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothAvrcpManager::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(aController);
|
||||
|
||||
// AVRCP doesn't require connecting. We just set the remote address here.
|
||||
@ -479,7 +479,7 @@ BluetoothAvrcpManager::Disconnect(BluetoothProfileController* aController)
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!mController);
|
||||
|
||||
mDeviceAddress.Truncate();
|
||||
mDeviceAddress.Clear();
|
||||
mController = aController;
|
||||
SetConnected(false);
|
||||
|
||||
@ -519,17 +519,19 @@ BluetoothAvrcpManager::OnDisconnect(const nsAString& aErrorStr)
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothAvrcpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel)
|
||||
BluetoothAvrcpManager::OnGetServiceChannel(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel)
|
||||
{ }
|
||||
|
||||
void
|
||||
BluetoothAvrcpManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
BluetoothAvrcpManager::OnUpdateSdpRecords(
|
||||
const BluetoothAddress& aDeviceAddress)
|
||||
{ }
|
||||
|
||||
void
|
||||
BluetoothAvrcpManager::GetAddress(nsAString& aDeviceAddress)
|
||||
BluetoothAvrcpManager::GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
aDeviceAddress = mDeviceAddress;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ private:
|
||||
|
||||
void PassthroughCmdNotification(int aId, int aKeyState) override;
|
||||
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
RefPtr<BluetoothProfileController> mController;
|
||||
|
||||
bool mAvrcpConnected;
|
||||
|
@ -1709,7 +1709,7 @@ public:
|
||||
, mDeviceAddr(aDeviceAddr)
|
||||
{
|
||||
MOZ_ASSERT(mServer);
|
||||
MOZ_ASSERT(mDeviceAddr != BluetoothAddress::ANY);
|
||||
MOZ_ASSERT(!mDeviceAddr.IsCleared());
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) override
|
||||
|
@ -91,7 +91,6 @@ BluetoothMapSmsManager::BluetoothMapSmsManager() : mMasConnected(false),
|
||||
mMnsConnected(false),
|
||||
mNtfRequired(false)
|
||||
{
|
||||
mDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
|
||||
BuildDefaultFolderStructure();
|
||||
}
|
||||
|
||||
@ -483,7 +482,7 @@ BluetoothMapSmsManager::IsConnected()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothMapSmsManager::GetAddress(nsAString& aDeviceAddress)
|
||||
BluetoothMapSmsManager::GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
return mMasSocket->GetAddress(aDeviceAddress);
|
||||
}
|
||||
@ -1235,7 +1234,7 @@ BluetoothMapSmsManager::OnSocketDisconnect(BluetoothSocket* aSocket)
|
||||
|
||||
// MAS socket is disconnected
|
||||
AfterMapSmsDisconnected();
|
||||
mDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
|
||||
mDeviceAddress.Clear();
|
||||
mMasSocket = nullptr;
|
||||
|
||||
Listen();
|
||||
@ -1255,22 +1254,23 @@ BluetoothMapSmsManager::Disconnect(BluetoothProfileController* aController)
|
||||
NS_IMPL_ISUPPORTS(BluetoothMapSmsManager, nsIObserver)
|
||||
|
||||
void
|
||||
BluetoothMapSmsManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothMapSmsManager::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
{
|
||||
MOZ_ASSERT(false);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothMapSmsManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel)
|
||||
BluetoothMapSmsManager::OnGetServiceChannel(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel)
|
||||
{
|
||||
MOZ_ASSERT(false);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothMapSmsManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
BluetoothMapSmsManager::OnUpdateSdpRecords(const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
MOZ_ASSERT(false);
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ private:
|
||||
// MNS OBEX session status. Set when MNS OBEX session is established.
|
||||
bool mMnsConnected;
|
||||
bool mNtfRequired;
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
unsigned int mRemoteMaxPacketLength;
|
||||
|
||||
// If a connection has been established, mMasSocket will be the socket
|
||||
|
@ -71,13 +71,13 @@ BEGIN_BLUETOOTH_NAMESPACE
|
||||
class BluetoothOppManager::SendFileBatch final
|
||||
{
|
||||
public:
|
||||
SendFileBatch(const nsAString& aDeviceAddress, Blob* aBlob)
|
||||
SendFileBatch(const BluetoothAddress& aDeviceAddress, Blob* aBlob)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
{
|
||||
mBlobs.AppendElement(aBlob);
|
||||
}
|
||||
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
nsTArray<RefPtr<Blob>> mBlobs;
|
||||
};
|
||||
|
||||
@ -209,9 +209,7 @@ BluetoothOppManager::BluetoothOppManager() : mConnected(false)
|
||||
, mSentFileLength(0)
|
||||
, mWaitingToSendPutFinal(false)
|
||||
, mCurrentBlobIndex(-1)
|
||||
{
|
||||
mDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
|
||||
}
|
||||
{ }
|
||||
|
||||
BluetoothOppManager::~BluetoothOppManager()
|
||||
{
|
||||
@ -276,7 +274,7 @@ BluetoothOppManager::Get()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::ConnectInternal(const nsAString& aDeviceAddress)
|
||||
BluetoothOppManager::ConnectInternal(const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@ -296,10 +294,7 @@ BluetoothOppManager::ConnectInternal(const nsAString& aDeviceAddress)
|
||||
|
||||
mNeedsUpdatingSdpRecords = true;
|
||||
|
||||
nsString uuid;
|
||||
BluetoothUuidHelper::GetString(BluetoothServiceClass::OBJECT_PUSH, uuid);
|
||||
|
||||
if (NS_FAILED(bs->GetServiceChannel(aDeviceAddress, uuid, this))) {
|
||||
if (NS_FAILED(bs->GetServiceChannel(aDeviceAddress, kObexObjectPush, this))) {
|
||||
OnSocketConnectError(mSocket);
|
||||
return;
|
||||
}
|
||||
@ -409,7 +404,7 @@ BluetoothOppManager::StartSendingNextFile()
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothOppManager::SendFile(const nsAString& aDeviceAddress,
|
||||
BluetoothOppManager::SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
BlobParent* aActor)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -421,7 +416,7 @@ BluetoothOppManager::SendFile(const nsAString& aDeviceAddress,
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothOppManager::SendFile(const nsAString& aDeviceAddress,
|
||||
BluetoothOppManager::SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
Blob* aBlob)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -435,7 +430,7 @@ BluetoothOppManager::SendFile(const nsAString& aDeviceAddress,
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::AppendBlobToSend(const nsAString& aDeviceAddress,
|
||||
BluetoothOppManager::AppendBlobToSend(const BluetoothAddress& aDeviceAddress,
|
||||
Blob* aBlob)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -1322,7 +1317,7 @@ BluetoothOppManager::IsConnected()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::GetAddress(nsAString& aDeviceAddress)
|
||||
BluetoothOppManager::GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
return mSocket->GetAddress(aDeviceAddress);
|
||||
}
|
||||
@ -1423,10 +1418,13 @@ BluetoothOppManager::FileTransferComplete()
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
NS_NAMED_LITERAL_STRING(type, "bluetooth-opp-transfer-complete");
|
||||
InfallibleTArray<BluetoothNamedValue> parameters;
|
||||
|
||||
AppendNamedValue(parameters, "address", mDeviceAddress);
|
||||
AppendNamedValue(parameters, "address", deviceAddressStr);
|
||||
AppendNamedValue(parameters, "success", mSuccessFlag);
|
||||
AppendNamedValue(parameters, "received", mIsServer);
|
||||
AppendNamedValue(parameters, "fileName", mFileName);
|
||||
@ -1441,10 +1439,13 @@ BluetoothOppManager::FileTransferComplete()
|
||||
void
|
||||
BluetoothOppManager::StartFileTransfer()
|
||||
{
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
NS_NAMED_LITERAL_STRING(type, "bluetooth-opp-transfer-start");
|
||||
InfallibleTArray<BluetoothNamedValue> parameters;
|
||||
|
||||
AppendNamedValue(parameters, "address", mDeviceAddress);
|
||||
AppendNamedValue(parameters, "address", deviceAddressStr);
|
||||
AppendNamedValue(parameters, "received", mIsServer);
|
||||
AppendNamedValue(parameters, "fileName", mFileName);
|
||||
AppendNamedValue(parameters, "fileLength", mFileLength);
|
||||
@ -1458,10 +1459,13 @@ BluetoothOppManager::StartFileTransfer()
|
||||
void
|
||||
BluetoothOppManager::UpdateProgress()
|
||||
{
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
NS_NAMED_LITERAL_STRING(type, "bluetooth-opp-update-progress");
|
||||
InfallibleTArray<BluetoothNamedValue> parameters;
|
||||
|
||||
AppendNamedValue(parameters, "address", mDeviceAddress);
|
||||
AppendNamedValue(parameters, "address", deviceAddressStr);
|
||||
AppendNamedValue(parameters, "received", mIsServer);
|
||||
AppendNamedValue(parameters, "processedLength", mSentFileLength);
|
||||
AppendNamedValue(parameters, "fileLength", mFileLength);
|
||||
@ -1472,10 +1476,13 @@ BluetoothOppManager::UpdateProgress()
|
||||
void
|
||||
BluetoothOppManager::ReceivingFileConfirmation()
|
||||
{
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
NS_NAMED_LITERAL_STRING(type, "bluetooth-opp-receiving-file-confirmation");
|
||||
InfallibleTArray<BluetoothNamedValue> parameters;
|
||||
|
||||
AppendNamedValue(parameters, "address", mDeviceAddress);
|
||||
AppendNamedValue(parameters, "address", deviceAddressStr);
|
||||
AppendNamedValue(parameters, "fileName", mFileName);
|
||||
AppendNamedValue(parameters, "fileLength", mFileLength);
|
||||
AppendNamedValue(parameters, "contentType", mContentType);
|
||||
@ -1574,7 +1581,7 @@ BluetoothOppManager::OnSocketDisconnect(BluetoothSocket* aSocket)
|
||||
}
|
||||
|
||||
AfterOppDisconnected();
|
||||
mDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
|
||||
mDeviceAddress.Clear();
|
||||
mSuccessFlag = false;
|
||||
|
||||
mSocket = nullptr;
|
||||
@ -1612,13 +1619,11 @@ BluetoothOppManager::AcquireSdcardMountLock()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel)
|
||||
BluetoothOppManager::OnGetServiceChannel(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel)
|
||||
{
|
||||
BluetoothUuid serviceUuid;
|
||||
StringToUuid(aServiceUuid, serviceUuid);
|
||||
|
||||
if (aChannel < 0) {
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
if (!bs || sInShutdown) {
|
||||
@ -1645,13 +1650,13 @@ BluetoothOppManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
}
|
||||
}
|
||||
|
||||
mSocket->Connect(aDeviceAddress, serviceUuid,
|
||||
mSocket->Connect(aDeviceAddress, aServiceUuid,
|
||||
BluetoothSocketType::RFCOMM, aChannel,
|
||||
false, true);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
BluetoothOppManager::OnUpdateSdpRecords(const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
if (!bs || sInShutdown) {
|
||||
@ -1659,17 +1664,14 @@ BluetoothOppManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
return;
|
||||
}
|
||||
|
||||
nsString uuid;
|
||||
BluetoothUuidHelper::GetString(BluetoothServiceClass::OBJECT_PUSH, uuid);
|
||||
|
||||
if (NS_FAILED(bs->GetServiceChannel(aDeviceAddress, uuid, this))) {
|
||||
if (NS_FAILED(bs->GetServiceChannel(aDeviceAddress, kObexObjectPush, this))) {
|
||||
OnSocketConnectError(mSocket);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothOppManager::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
{
|
||||
MOZ_ASSERT(false);
|
||||
|
@ -54,8 +54,8 @@ public:
|
||||
|
||||
bool Listen();
|
||||
|
||||
bool SendFile(const nsAString& aDeviceAddress, BlobParent* aActor);
|
||||
bool SendFile(const nsAString& aDeviceAddress, Blob* aBlob);
|
||||
bool SendFile(const BluetoothAddress& aDeviceAddress, BlobParent* aActor);
|
||||
bool SendFile(const BluetoothAddress& aDeviceAddress, Blob* aBlob);
|
||||
bool StopSendingFile();
|
||||
bool ConfirmReceivingFile(bool aConfirm);
|
||||
|
||||
@ -101,10 +101,10 @@ private:
|
||||
void NotifyAboutFileChange();
|
||||
bool AcquireSdcardMountLock();
|
||||
void SendObexData(uint8_t* aData, uint8_t aOpcode, int aSize);
|
||||
void AppendBlobToSend(const nsAString& aDeviceAddress, Blob* aBlob);
|
||||
void AppendBlobToSend(const BluetoothAddress& aDeviceAddress, Blob* aBlob);
|
||||
void DiscardBlobsToSend();
|
||||
bool ProcessNextBatch();
|
||||
void ConnectInternal(const nsAString& aDeviceAddress);
|
||||
void ConnectInternal(const BluetoothAddress& aDeviceAddress);
|
||||
|
||||
/**
|
||||
* Usually we won't get a full PUT packet in one operation, which means that
|
||||
@ -123,7 +123,7 @@ private:
|
||||
* Set when OBEX session is established.
|
||||
*/
|
||||
bool mConnected;
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
|
||||
/**
|
||||
* Remote information
|
||||
|
@ -100,7 +100,6 @@ BluetoothPbapManager::BluetoothPbapManager() : mPhonebookSizeRequired(false)
|
||||
, mConnected(false)
|
||||
, mRemoteMaxPacketLength(0)
|
||||
{
|
||||
mDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
|
||||
mCurrentPath.AssignLiteral("");
|
||||
}
|
||||
|
||||
@ -655,7 +654,7 @@ BluetoothPbapManager::IsConnected()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothPbapManager::GetAddress(nsAString& aDeviceAddress)
|
||||
BluetoothPbapManager::GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
return mSocket->GetAddress(aDeviceAddress);
|
||||
}
|
||||
@ -1013,7 +1012,7 @@ BluetoothPbapManager::OnSocketDisconnect(BluetoothSocket* aSocket)
|
||||
}
|
||||
|
||||
AfterPbapDisconnected();
|
||||
mDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
|
||||
mDeviceAddress.Clear();
|
||||
mSocket = nullptr;
|
||||
|
||||
Listen();
|
||||
@ -1033,22 +1032,24 @@ BluetoothPbapManager::Disconnect(BluetoothProfileController* aController)
|
||||
NS_IMPL_ISUPPORTS(BluetoothPbapManager, nsIObserver)
|
||||
|
||||
void
|
||||
BluetoothPbapManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothPbapManager::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
{
|
||||
MOZ_ASSERT(false);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothPbapManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel)
|
||||
BluetoothPbapManager::OnGetServiceChannel(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel)
|
||||
{
|
||||
MOZ_ASSERT(false);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothPbapManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
BluetoothPbapManager::OnUpdateSdpRecords(
|
||||
const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
MOZ_ASSERT(false);
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ private:
|
||||
* OBEX session status. Set when OBEX session is established
|
||||
*/
|
||||
bool mConnected;
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
|
||||
/**
|
||||
* Current phonebook path
|
||||
|
@ -902,15 +902,8 @@ BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal(
|
||||
}
|
||||
|
||||
// Get address of the connected device
|
||||
nsString addressString;
|
||||
profile->GetAddress(addressString);
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(addressString, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
profile->GetAddress(address);
|
||||
|
||||
// Append request of the connected device
|
||||
GetDeviceRequest request(1, aRunnable);
|
||||
@ -1105,11 +1098,8 @@ public:
|
||||
|
||||
// Signal error to profile manager
|
||||
|
||||
nsAutoString addressStr, uuidStr;
|
||||
AddressToString(mDeviceAddress, addressStr);
|
||||
UuidToString(mUuid, uuidStr);
|
||||
mGetRemoteServiceRecordArray[i].mManager->OnGetServiceChannel(
|
||||
addressStr, uuidStr, -1);
|
||||
mDeviceAddress, mUuid, -1);
|
||||
mGetRemoteServiceRecordArray.RemoveElementAt(i);
|
||||
}
|
||||
|
||||
@ -1139,25 +1129,16 @@ private:
|
||||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::GetServiceChannel(
|
||||
const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
BluetoothProfileManagerBase* aManager)
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
BluetoothUuid uuid;
|
||||
StringToUuid(aServiceUuid, uuid);
|
||||
|
||||
mGetRemoteServiceRecordArray.AppendElement(
|
||||
GetRemoteServiceRecordRequest(address, uuid, aManager));
|
||||
GetRemoteServiceRecordRequest(aDeviceAddress, aServiceUuid, aManager));
|
||||
|
||||
RefPtr<BluetoothResultHandler> res =
|
||||
new GetRemoteServiceRecordResultHandler(mGetRemoteServiceRecordArray,
|
||||
address, uuid);
|
||||
aDeviceAddress, aServiceUuid);
|
||||
|
||||
/* Stop discovery of remote devices here, because SDP operations
|
||||
* won't be performed while the adapter is in discovery mode.
|
||||
@ -1165,7 +1146,7 @@ BluetoothServiceBluedroid::GetServiceChannel(
|
||||
if (mDiscovering) {
|
||||
sBtInterface->CancelDiscovery(res);
|
||||
} else {
|
||||
sBtInterface->GetRemoteServiceRecord(address, uuid, res);
|
||||
sBtInterface->GetRemoteServiceRecord(aDeviceAddress, aServiceUuid, res);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -1213,9 +1194,7 @@ public:
|
||||
mGetRemoteServicesArray.RemoveElementAt(i);
|
||||
|
||||
// There's no error-signaling mechanism; just call manager
|
||||
nsAutoString addressStr;
|
||||
AddressToString(mDeviceAddress, addressStr);
|
||||
mManager->OnUpdateSdpRecords(addressStr);
|
||||
mManager->OnUpdateSdpRecords(mDeviceAddress);
|
||||
}
|
||||
|
||||
void CancelDiscovery() override
|
||||
@ -1244,21 +1223,15 @@ private:
|
||||
|
||||
bool
|
||||
BluetoothServiceBluedroid::UpdateSdpRecords(
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileManagerBase* aManager)
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mGetRemoteServicesArray.AppendElement(
|
||||
GetRemoteServicesRequest(address, aManager));
|
||||
GetRemoteServicesRequest(aDeviceAddress, aManager));
|
||||
|
||||
RefPtr<BluetoothResultHandler> res =
|
||||
new GetRemoteServicesResultHandler(mGetRemoteServicesArray,
|
||||
address, aManager);
|
||||
aDeviceAddress, aManager);
|
||||
|
||||
/* Stop discovery of remote devices here, because SDP operations
|
||||
* won't be performed while the adapter is in discovery mode.
|
||||
@ -1266,7 +1239,7 @@ BluetoothServiceBluedroid::UpdateSdpRecords(
|
||||
if (mDiscovering) {
|
||||
sBtInterface->CancelDiscovery(res);
|
||||
} else {
|
||||
sBtInterface->GetRemoteServices(address, res);
|
||||
sBtInterface->GetRemoteServices(aDeviceAddress, res);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1456,8 +1429,15 @@ BluetoothServiceBluedroid::ConnectDisconnect(
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aRunnable);
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
BluetoothProfileController* controller =
|
||||
new BluetoothProfileController(aConnect, aDeviceAddress, aRunnable,
|
||||
new BluetoothProfileController(aConnect, address, aRunnable,
|
||||
NextBluetoothProfileController,
|
||||
aServiceUuid, aCod);
|
||||
sControllerArray.AppendElement(controller);
|
||||
@ -1497,13 +1477,20 @@ BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
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
|
||||
// it for future use.
|
||||
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
if (!opp || !opp->SendFile(aDeviceAddress, aBlobParent)) {
|
||||
if (!opp || !opp->SendFile(deviceAddress, aBlobParent)) {
|
||||
DispatchReplyError(aRunnable, NS_LITERAL_STRING("SendFile failed"));
|
||||
return;
|
||||
}
|
||||
@ -1518,13 +1505,20 @@ BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
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
|
||||
// it for future use.
|
||||
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
if (!opp || !opp->SendFile(aDeviceAddress, aBlob)) {
|
||||
if (!opp || !opp->SendFile(deviceAddress, aBlob)) {
|
||||
DispatchReplyError(aRunnable, NS_LITERAL_STRING("SendFile failed"));
|
||||
return;
|
||||
}
|
||||
@ -2256,7 +2250,7 @@ BluetoothServiceBluedroid::RemoteDevicePropertiesNotification(
|
||||
}
|
||||
|
||||
if (index < mGetRemoteServicesArray.Length()) {
|
||||
mGetRemoteServicesArray[index].mManager->OnUpdateSdpRecords(bdAddrStr);
|
||||
mGetRemoteServicesArray[index].mManager->OnUpdateSdpRecords(aBdAddr);
|
||||
mGetRemoteServicesArray.RemoveElementAt(index);
|
||||
continue; // continue with outer loop
|
||||
}
|
||||
@ -2291,11 +2285,10 @@ BluetoothServiceBluedroid::RemoteDevicePropertiesNotification(
|
||||
(mGetRemoteServiceRecordArray[i].mUuid == p.mServiceRecord.mUuid)) {
|
||||
|
||||
// Signal channel to profile manager
|
||||
nsAutoString uuidStr;
|
||||
UuidToString(mGetRemoteServiceRecordArray[i].mUuid, uuidStr);
|
||||
|
||||
mGetRemoteServiceRecordArray[i].mManager->OnGetServiceChannel(
|
||||
bdAddrStr, uuidStr, p.mServiceRecord.mChannel);
|
||||
aBdAddr,
|
||||
mGetRemoteServiceRecordArray[i].mUuid,
|
||||
p.mServiceRecord.mChannel);
|
||||
|
||||
mGetRemoteServiceRecordArray.RemoveElementAt(i);
|
||||
break;
|
||||
|
@ -66,12 +66,12 @@ public:
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult
|
||||
GetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
GetServiceChannel(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
BluetoothProfileManagerBase* aManager);
|
||||
|
||||
virtual bool
|
||||
UpdateSdpRecords(const nsAString& aDeviceAddress,
|
||||
UpdateSdpRecords(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileManagerBase* aManager);
|
||||
|
||||
virtual nsresult
|
||||
|
@ -403,10 +403,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString addressStr;
|
||||
AddressToString(aBdAddress, addressStr);
|
||||
|
||||
mImpl->mConsumer->SetAddress(addressStr);
|
||||
mImpl->mConsumer->SetAddress(aBdAddress);
|
||||
mImpl->GetIOLoop()->PostTask(FROM_HERE,
|
||||
new AcceptTask(mImpl, fd.forget()));
|
||||
}
|
||||
@ -593,7 +590,6 @@ BluetoothSocket::BluetoothSocket(BluetoothSocketObserver* aObserver)
|
||||
MOZ_COUNT_CTOR_INHERITED(BluetoothSocket, DataSocket);
|
||||
|
||||
EnsureBluetoothSocketHalLoad();
|
||||
mDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
|
||||
}
|
||||
|
||||
BluetoothSocket::~BluetoothSocket()
|
||||
@ -625,10 +621,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString addressStr;
|
||||
AddressToString(aBdAddress, addressStr);
|
||||
|
||||
mImpl->mConsumer->SetAddress(addressStr);
|
||||
mImpl->mConsumer->SetAddress(aBdAddress);
|
||||
mImpl->GetIOLoop()->PostTask(FROM_HERE,
|
||||
new SocketConnectTask(mImpl, aFd));
|
||||
}
|
||||
@ -652,7 +645,7 @@ private:
|
||||
};
|
||||
|
||||
nsresult
|
||||
BluetoothSocket::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothSocket::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
BluetoothSocketType aType,
|
||||
int aChannel,
|
||||
@ -669,14 +662,8 @@ BluetoothSocket::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothSocketResultHandler* res = new ConnectSocketResultHandler(mImpl);
|
||||
SetCurrentResultHandler(res);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
sBluetoothSocketInterface->Connect(
|
||||
deviceAddress, aType,
|
||||
aDeviceAddress, aType,
|
||||
aServiceUuid, aChannel,
|
||||
aEncrypt, aAuth, res);
|
||||
|
||||
@ -684,7 +671,7 @@ BluetoothSocket::Connect(const nsAString& aDeviceAddress,
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothSocket::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothSocket::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
BluetoothSocketType aType,
|
||||
int aChannel,
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
BluetoothSocket(BluetoothSocketObserver* aObserver);
|
||||
~BluetoothSocket();
|
||||
|
||||
nsresult Connect(const nsAString& aDeviceAddress,
|
||||
nsresult Connect(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
BluetoothSocketType aType,
|
||||
int aChannel,
|
||||
@ -32,7 +32,7 @@ public:
|
||||
MessageLoop* aConsumerLoop,
|
||||
MessageLoop* aIOLoop);
|
||||
|
||||
nsresult Connect(const nsAString& aDeviceAddress,
|
||||
nsresult Connect(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
BluetoothSocketType aType,
|
||||
int aChannel,
|
||||
@ -60,12 +60,12 @@ public:
|
||||
*/
|
||||
void ReceiveSocketData(nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aBuffer);
|
||||
|
||||
inline void GetAddress(nsAString& aDeviceAddress)
|
||||
inline void GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
aDeviceAddress = mDeviceAddress;
|
||||
}
|
||||
|
||||
inline void SetAddress(const nsAString& aDeviceAddress)
|
||||
inline void SetAddress(const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
mDeviceAddress = aDeviceAddress;
|
||||
}
|
||||
@ -93,7 +93,7 @@ private:
|
||||
BluetoothSocketObserver* mObserver;
|
||||
BluetoothSocketResultHandler* mCurrentRes;
|
||||
DroidSocketImpl* mImpl;
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
@ -42,7 +42,7 @@ BluetoothHfpManager::Observe(nsISupports* aSubject,
|
||||
* BluetoothProfileManagerBase functions
|
||||
*/
|
||||
void
|
||||
BluetoothHfpManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothHfpManager::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
{
|
||||
MOZ_ASSERT(aController);
|
||||
@ -77,15 +77,16 @@ BluetoothHfpManager::OnDisconnect(const nsAString& aErrorStr)
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::GetAddress(nsAString& aDeviceAddress)
|
||||
BluetoothHfpManager::GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
aDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
|
||||
aDeviceAddress.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel)
|
||||
BluetoothHfpManager::OnGetServiceChannel(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel)
|
||||
{
|
||||
MOZ_ASSERT(false);
|
||||
}
|
||||
|
@ -602,8 +602,11 @@ BluetoothHfpManager::NotifyConnectionStateChanged(const nsAString& aType)
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
NS_ENSURE_TRUE_VOID(obs);
|
||||
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
if (NS_FAILED(obs->NotifyObservers(this, NS_ConvertUTF16toUTF8(aType).get(),
|
||||
mDeviceAddress.get()))) {
|
||||
deviceAddressStr.get()))) {
|
||||
BT_WARNING("Failed to notify observsers!");
|
||||
}
|
||||
|
||||
@ -621,7 +624,7 @@ BluetoothHfpManager::NotifyConnectionStateChanged(const nsAString& aType)
|
||||
return;
|
||||
}
|
||||
|
||||
DispatchStatusChangedEvent(eventName, mDeviceAddress, status);
|
||||
DispatchStatusChangedEvent(eventName, deviceAddressStr, status);
|
||||
|
||||
// Notify profile controller
|
||||
if (aType.EqualsLiteral(BLUETOOTH_HFP_STATUS_CHANGED_ID)) {
|
||||
@ -633,7 +636,7 @@ BluetoothHfpManager::NotifyConnectionStateChanged(const nsAString& aType)
|
||||
|
||||
OnConnect(EmptyString());
|
||||
} else if (mConnectionState == HFP_CONNECTION_STATE_DISCONNECTED) {
|
||||
mDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
|
||||
mDeviceAddress.Clear();
|
||||
if (mPrevConnectionState == HFP_CONNECTION_STATE_DISCONNECTED) {
|
||||
// Bug 979160: This implies the outgoing connection failure.
|
||||
// When the outgoing hfp connection fails, state changes to disconnected
|
||||
@ -699,15 +702,9 @@ BluetoothHfpManager::HandleVolumeChanged(nsISupports* aSubject)
|
||||
|
||||
// Only send volume back when there's a connected headset
|
||||
if (IsConnected()) {
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(mDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
|
||||
sBluetoothHfpInterface->VolumeControl(
|
||||
HFP_VOLUME_TYPE_SPEAKER, mCurrentVgs, deviceAddress,
|
||||
HFP_VOLUME_TYPE_SPEAKER, mCurrentVgs, mDeviceAddress,
|
||||
new VolumeControlResultHandler());
|
||||
}
|
||||
}
|
||||
@ -842,16 +839,10 @@ BluetoothHfpManager::SendCLCC(Call& aCall, int aIndex)
|
||||
callState = HFP_CALL_STATE_WAITING;
|
||||
}
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(mDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sBluetoothHfpInterface->ClccResponse(
|
||||
aIndex, aCall.mDirection, callState, HFP_CALL_MODE_VOICE,
|
||||
HFP_CALL_MPTY_TYPE_SINGLE, aCall.mNumber,
|
||||
aCall.mType, deviceAddress, new ClccResponseResultHandler());
|
||||
aCall.mType, mDeviceAddress, new ClccResponseResultHandler());
|
||||
}
|
||||
|
||||
class BluetoothHfpManager::FormattedAtResponseResultHandler final
|
||||
@ -870,14 +861,8 @@ BluetoothHfpManager::SendLine(const char* aMessage)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(mDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sBluetoothHfpInterface->FormattedAtResponse(
|
||||
aMessage, deviceAddress, new FormattedAtResponseResultHandler());
|
||||
aMessage, mDeviceAddress, new FormattedAtResponseResultHandler());
|
||||
}
|
||||
|
||||
class BluetoothHfpManager::AtResponseResultHandler final
|
||||
@ -896,14 +881,8 @@ BluetoothHfpManager::SendResponse(BluetoothHandsfreeAtResponse aResponseCode)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(mDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sBluetoothHfpInterface->AtResponse(
|
||||
aResponseCode, 0, deviceAddress, new AtResponseResultHandler());
|
||||
aResponseCode, 0, mDeviceAddress, new AtResponseResultHandler());
|
||||
}
|
||||
|
||||
class BluetoothHfpManager::PhoneStateChangeResultHandler final
|
||||
@ -1204,19 +1183,13 @@ BluetoothHfpManager::HandleBackendError()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(mDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mConnectionState != HFP_CONNECTION_STATE_DISCONNECTED) {
|
||||
ConnectionStateNotification(HFP_CONNECTION_STATE_DISCONNECTED,
|
||||
deviceAddress);
|
||||
mDeviceAddress);
|
||||
}
|
||||
|
||||
if (mAudioState != HFP_AUDIO_STATE_DISCONNECTED) {
|
||||
AudioStateNotification(HFP_AUDIO_STATE_DISCONNECTED, deviceAddress);
|
||||
AudioStateNotification(HFP_AUDIO_STATE_DISCONNECTED, mDeviceAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1240,13 +1213,7 @@ BluetoothHfpManager::ConnectSco()
|
||||
NS_ENSURE_TRUE(IsConnected() && !IsScoConnected(), false);
|
||||
NS_ENSURE_TRUE(sBluetoothHfpInterface, false);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(mDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sBluetoothHfpInterface->ConnectAudio(deviceAddress,
|
||||
sBluetoothHfpInterface->ConnectAudio(mDeviceAddress,
|
||||
new ConnectAudioResultHandler());
|
||||
|
||||
return true;
|
||||
@ -1269,13 +1236,7 @@ BluetoothHfpManager::DisconnectSco()
|
||||
NS_ENSURE_TRUE(IsScoConnected(), false);
|
||||
NS_ENSURE_TRUE(sBluetoothHfpInterface, false);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(mDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sBluetoothHfpInterface->DisconnectAudio(deviceAddress,
|
||||
sBluetoothHfpInterface->DisconnectAudio(mDeviceAddress,
|
||||
new DisconnectAudioResultHandler());
|
||||
|
||||
return true;
|
||||
@ -1307,7 +1268,7 @@ BluetoothHfpManager::OnConnectError()
|
||||
mController->NotifyCompletion(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
|
||||
|
||||
mController = nullptr;
|
||||
mDeviceAddress.Truncate();
|
||||
mDeviceAddress.Clear();
|
||||
}
|
||||
|
||||
class BluetoothHfpManager::ConnectResultHandler final
|
||||
@ -1332,7 +1293,7 @@ private:
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothHfpManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothHfpManager::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -1352,13 +1313,7 @@ BluetoothHfpManager::Connect(const nsAString& aDeviceAddress,
|
||||
mDeviceAddress = aDeviceAddress;
|
||||
mController = aController;
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(mDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sBluetoothHfpInterface->Connect(deviceAddress,
|
||||
sBluetoothHfpInterface->Connect(mDeviceAddress,
|
||||
new ConnectResultHandler(this));
|
||||
}
|
||||
|
||||
@ -1409,13 +1364,7 @@ BluetoothHfpManager::Disconnect(BluetoothProfileController* aController)
|
||||
|
||||
mController = aController;
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(mDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sBluetoothHfpInterface->Disconnect(deviceAddress,
|
||||
sBluetoothHfpInterface->Disconnect(mDeviceAddress,
|
||||
new DisconnectResultHandler(this));
|
||||
}
|
||||
|
||||
@ -1450,23 +1399,25 @@ BluetoothHfpManager::OnDisconnect(const nsAString& aErrorStr)
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
BluetoothHfpManager::OnUpdateSdpRecords(
|
||||
const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
// Bluedroid handles this part
|
||||
MOZ_ASSERT(false);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel)
|
||||
BluetoothHfpManager::OnGetServiceChannel(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel)
|
||||
{
|
||||
// Bluedroid handles this part
|
||||
MOZ_ASSERT(false);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::GetAddress(nsAString& aDeviceAddress)
|
||||
BluetoothHfpManager::GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
aDeviceAddress = mDeviceAddress;
|
||||
}
|
||||
@ -1487,7 +1438,7 @@ BluetoothHfpManager::ConnectionStateNotification(
|
||||
mConnectionState = aState;
|
||||
|
||||
if (aState == HFP_CONNECTION_STATE_SLC_CONNECTED) {
|
||||
AddressToString(aBdAddress, mDeviceAddress);
|
||||
mDeviceAddress = aBdAddress;
|
||||
NotifyConnectionStateChanged(
|
||||
NS_LITERAL_STRING(BLUETOOTH_HFP_STATUS_CHANGED_ID));
|
||||
|
||||
@ -1497,14 +1448,8 @@ BluetoothHfpManager::ConnectionStateNotification(
|
||||
NS_LITERAL_STRING(BLUETOOTH_HFP_STATUS_CHANGED_ID));
|
||||
|
||||
} else if (aState == HFP_CONNECTION_STATE_CONNECTED) {
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(mDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Once RFCOMM is connected, enable NREC before each new SLC connection
|
||||
NRECNotification(HFP_NREC_STARTED, deviceAddress);
|
||||
NRECNotification(HFP_NREC_STARTED, mDeviceAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1599,10 +1544,13 @@ BluetoothHfpManager::NRECNotification(BluetoothHandsfreeNRECState aNrec,
|
||||
|
||||
mNrecEnabled = static_cast<bool>(aNrec);
|
||||
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
// Notify audio manager
|
||||
if (NS_FAILED(obs->NotifyObservers(this,
|
||||
BLUETOOTH_HFP_NREC_STATUS_CHANGED_ID,
|
||||
mDeviceAddress.get()))) {
|
||||
deviceAddressStr.get()))) {
|
||||
BT_WARNING("Failed to notify bluetooth-hfp-nrec-status-changed observsers!");
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ private:
|
||||
bool mDialingRequestProcessed;
|
||||
bool mNrecEnabled;
|
||||
PhoneType mPhoneType;
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
nsString mMsisdn;
|
||||
nsString mOperatorName;
|
||||
|
||||
|
@ -132,11 +132,11 @@ BluetoothA2dpManager::HandleShutdown()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothA2dpManager::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(aController && !mController);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
@ -153,7 +153,10 @@ BluetoothA2dpManager::Connect(const nsAString& aDeviceAddress,
|
||||
mDeviceAddress = aDeviceAddress;
|
||||
mController = aController;
|
||||
|
||||
if (NS_FAILED(bs->SendSinkMessage(aDeviceAddress,
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(aDeviceAddress, deviceAddressStr);
|
||||
|
||||
if (NS_FAILED(bs->SendSinkMessage(deviceAddressStr,
|
||||
NS_LITERAL_STRING("Connect")))) {
|
||||
aController->NotifyCompletion(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
|
||||
return;
|
||||
@ -180,12 +183,15 @@ BluetoothA2dpManager::Disconnect(BluetoothProfileController* aController)
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(!mController);
|
||||
|
||||
mController = aController;
|
||||
|
||||
if (NS_FAILED(bs->SendSinkMessage(mDeviceAddress,
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
if (NS_FAILED(bs->SendSinkMessage(deviceAddressStr,
|
||||
NS_LITERAL_STRING("Disconnect")))) {
|
||||
aController->NotifyCompletion(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
|
||||
return;
|
||||
@ -249,14 +255,17 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||
MOZ_ASSERT(aSignal.value().type() ==
|
||||
BluetoothValue::TArrayOfBluetoothNamedValue);
|
||||
|
||||
const nsString& address = aSignal.path();
|
||||
const nsString& addressStr = aSignal.path();
|
||||
|
||||
BluetoothAddress address;
|
||||
StringToAddress(addressStr, address);
|
||||
|
||||
/**
|
||||
* Update sink property only if
|
||||
* - mDeviceAddress is empty (A2dp is disconnected), or
|
||||
* - this property change is from the connected sink.
|
||||
*/
|
||||
NS_ENSURE_TRUE_VOID(mDeviceAddress.IsEmpty() ||
|
||||
mDeviceAddress.Equals(address));
|
||||
NS_ENSURE_TRUE_VOID(mDeviceAddress.IsCleared() || mDeviceAddress == address);
|
||||
|
||||
const InfallibleTArray<BluetoothNamedValue>& arr =
|
||||
aSignal.value().get_ArrayOfBluetoothNamedValue();
|
||||
@ -329,7 +338,7 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||
|
||||
mA2dpConnected = false;
|
||||
NotifyConnectionStatusChanged();
|
||||
mDeviceAddress.Truncate();
|
||||
mDeviceAddress.Clear();
|
||||
OnDisconnect(EmptyString());
|
||||
break;
|
||||
default:
|
||||
@ -346,31 +355,34 @@ BluetoothA2dpManager::NotifyConnectionStatusChanged()
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
NS_ENSURE_TRUE_VOID(obs);
|
||||
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
if (NS_FAILED(obs->NotifyObservers(this,
|
||||
BLUETOOTH_A2DP_STATUS_CHANGED_ID,
|
||||
mDeviceAddress.get()))) {
|
||||
deviceAddressStr.get()))) {
|
||||
BT_WARNING("Failed to notify bluetooth-a2dp-status-changed observsers!");
|
||||
}
|
||||
|
||||
// Dispatch an event of status change
|
||||
DispatchStatusChangedEvent(
|
||||
NS_LITERAL_STRING(A2DP_STATUS_CHANGED_ID), mDeviceAddress, mA2dpConnected);
|
||||
NS_LITERAL_STRING(A2DP_STATUS_CHANGED_ID), deviceAddressStr, mA2dpConnected);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
BluetoothA2dpManager::OnGetServiceChannel(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
BluetoothA2dpManager::OnUpdateSdpRecords(const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::GetAddress(nsAString& aDeviceAddress)
|
||||
BluetoothA2dpManager::GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
aDeviceAddress = mDeviceAddress;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ private:
|
||||
void HandleShutdown();
|
||||
void NotifyConnectionStatusChanged();
|
||||
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
RefPtr<BluetoothProfileController> mController;
|
||||
|
||||
// A2DP data member
|
||||
|
@ -116,11 +116,11 @@ BluetoothAvrcpManager::HandleShutdown()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothAvrcpManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothAvrcpManager::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(aController && !mController);
|
||||
|
||||
mDeviceAddress = aDeviceAddress;
|
||||
@ -130,7 +130,7 @@ BluetoothAvrcpManager::Connect(const nsAString& aDeviceAddress,
|
||||
void
|
||||
BluetoothAvrcpManager::Disconnect(BluetoothProfileController* aController)
|
||||
{
|
||||
mDeviceAddress.Truncate();
|
||||
mDeviceAddress.Clear();
|
||||
OnDisconnect(EmptyString());
|
||||
}
|
||||
|
||||
@ -167,17 +167,18 @@ BluetoothAvrcpManager::OnDisconnect(const nsAString& aErrorStr)
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothAvrcpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel)
|
||||
BluetoothAvrcpManager::OnGetServiceChannel(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel)
|
||||
{ }
|
||||
|
||||
void
|
||||
BluetoothAvrcpManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
BluetoothAvrcpManager::OnUpdateSdpRecords(const BluetoothAddress& aDeviceAddress)
|
||||
{ }
|
||||
|
||||
void
|
||||
BluetoothAvrcpManager::GetAddress(nsAString& aDeviceAddress)
|
||||
BluetoothAvrcpManager::GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
aDeviceAddress = mDeviceAddress;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ private:
|
||||
void HandleShutdown();
|
||||
void NotifyConnectionStatusChanged();
|
||||
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
RefPtr<BluetoothProfileController> mController;
|
||||
|
||||
// AVRCP data member
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "BluetoothDBusService.h"
|
||||
#include "BluetoothA2dpManager.h"
|
||||
#include "BluetoothAvrcpManager.h"
|
||||
#include "BluetoothHashKeys.h"
|
||||
#include "BluetoothHfpManager.h"
|
||||
#include "BluetoothHidManager.h"
|
||||
#include "BluetoothOppManager.h"
|
||||
@ -357,7 +358,7 @@ static StaticAutoPtr<RawDBusConnection> sDBusConnection;
|
||||
// Keep the pairing requests.
|
||||
static unsigned int sIsPairing = 0;
|
||||
|
||||
static nsDataHashtable<nsStringHashKey, DBusMessage* >* sPairingReqTable;
|
||||
static nsDataHashtable<BluetoothAddressHashKey, DBusMessage* >* sPairingReqTable;
|
||||
|
||||
// The object path of the adapter that should
|
||||
// be updated after switching Bluetooth.
|
||||
@ -449,6 +450,16 @@ GetObjectPathFromAddress(const nsAString& aAdapterPath,
|
||||
return devicePath;
|
||||
}
|
||||
|
||||
static nsString
|
||||
GetObjectPathFromAddress(const nsAString& aAdapterPath,
|
||||
const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(aDeviceAddress, deviceAddressStr);
|
||||
|
||||
return GetObjectPathFromAddress(aAdapterPath, deviceAddressStr);
|
||||
}
|
||||
|
||||
static nsString
|
||||
GetAddressFromObjectPath(const nsAString& aObjectPath)
|
||||
{
|
||||
@ -466,6 +477,15 @@ GetAddressFromObjectPath(const nsAString& aObjectPath)
|
||||
return address;
|
||||
}
|
||||
|
||||
static void
|
||||
GetAddressFromObjectPath(const nsAString& aObjectPath,
|
||||
BluetoothAddress& aAddress)
|
||||
{
|
||||
DebugOnly<nsresult> rv =
|
||||
StringToAddress(GetAddressFromObjectPath(aObjectPath), aAddress);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
|
||||
static bool
|
||||
GetConnectedDevicesFilter(const BluetoothValue& aValue)
|
||||
{
|
||||
@ -1240,14 +1260,14 @@ AppendDeviceName(BluetoothSignal& aSignal)
|
||||
class SetPairingConfirmationTask : public Task
|
||||
{
|
||||
public:
|
||||
SetPairingConfirmationTask(const nsAString& aDeviceAddress,
|
||||
SetPairingConfirmationTask(const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mConfirm(aConfirm)
|
||||
, mRunnable(aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
}
|
||||
|
||||
void Run() override
|
||||
@ -1300,7 +1320,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
bool mConfirm;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
};
|
||||
@ -1486,8 +1506,9 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
nsString address =
|
||||
GetAddressFromObjectPath(NS_ConvertUTF8toUTF16(objectPath));
|
||||
BluetoothAddress address;
|
||||
GetAddressFromObjectPath(NS_ConvertUTF8toUTF16(objectPath), address);
|
||||
|
||||
sPairingReqTable->Put(address, msg);
|
||||
Task* task = new SetPairingConfirmationTask(address, true, nullptr);
|
||||
DispatchToDBusThread(task);
|
||||
@ -1512,8 +1533,11 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
|
||||
signal.value() = v;
|
||||
|
||||
if (isPairingReq) {
|
||||
sPairingReqTable->Put(
|
||||
GetAddressFromObjectPath(NS_ConvertUTF8toUTF16(objectPath)), msg);
|
||||
|
||||
BluetoothAddress address;
|
||||
GetAddressFromObjectPath(NS_ConvertUTF8toUTF16(objectPath), address);
|
||||
|
||||
sPairingReqTable->Put(address, msg);
|
||||
|
||||
// Increase ref count here because we need this message later.
|
||||
// It'll be unrefed when set*Internal() is called.
|
||||
@ -2084,7 +2108,7 @@ public:
|
||||
mConnection->Watch();
|
||||
|
||||
if (!sPairingReqTable) {
|
||||
sPairingReqTable = new nsDataHashtable<nsStringHashKey, DBusMessage* >;
|
||||
sPairingReqTable = new nsDataHashtable<BluetoothAddressHashKey, DBusMessage* >;
|
||||
}
|
||||
|
||||
sDBusConnection = mConnection.forget();
|
||||
@ -2278,7 +2302,7 @@ public:
|
||||
|
||||
private:
|
||||
static PLDHashOperator
|
||||
UnrefDBusMessage(const nsAString& key, DBusMessage* value, void* arg)
|
||||
UnrefDBusMessage(const BluetoothAddress& key, DBusMessage* value, void* arg)
|
||||
{
|
||||
dbus_message_unref(value);
|
||||
return PL_DHASH_NEXT;
|
||||
@ -2854,9 +2878,13 @@ BluetoothDBusService::GetConnectedDevicePropertiesInternal(
|
||||
}
|
||||
|
||||
if (profile->IsConnected()) {
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
profile->GetAddress(address);
|
||||
deviceAddresses.AppendElement(address);
|
||||
|
||||
nsAutoString addressStr;
|
||||
AddressToString(address, addressStr);
|
||||
|
||||
deviceAddresses.AppendElement(addressStr);
|
||||
}
|
||||
|
||||
BluetoothArrayOfDevicePropertiesReplyHandler* handler =
|
||||
@ -3139,12 +3167,12 @@ BluetoothDBusService::CreatePairedDeviceInternal(
|
||||
class RemoveDeviceTask : public Task
|
||||
{
|
||||
public:
|
||||
RemoveDeviceTask(const nsAString& aDeviceAddress,
|
||||
RemoveDeviceTask(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mRunnable(aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
@ -3188,7 +3216,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
const nsString mDeviceAddress;
|
||||
const BluetoothAddress mDeviceAddress;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
};
|
||||
|
||||
@ -3204,7 +3232,14 @@ BluetoothDBusService::RemoveDeviceInternal(const nsAString& aDeviceAddress,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Task* task = new RemoveDeviceTask(aDeviceAddress, aRunnable);
|
||||
BluetoothAddress deviceAddress;
|
||||
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
Task* task = new RemoveDeviceTask(deviceAddress, aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
||||
return NS_OK;
|
||||
@ -3213,14 +3248,14 @@ BluetoothDBusService::RemoveDeviceInternal(const nsAString& aDeviceAddress,
|
||||
class SetPinCodeTask : public Task
|
||||
{
|
||||
public:
|
||||
SetPinCodeTask(const nsAString& aDeviceAddress,
|
||||
SetPinCodeTask(const BluetoothAddress& aDeviceAddress,
|
||||
const nsACString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mPinCode(aPinCode)
|
||||
, mRunnable(aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
@ -3268,7 +3303,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const nsString mDeviceAddress;
|
||||
const BluetoothAddress mDeviceAddress;
|
||||
const nsCString mPinCode;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
};
|
||||
@ -3294,7 +3329,14 @@ BluetoothDBusService::SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
Task* task = new SetPinCodeTask(aDeviceAddress,
|
||||
BluetoothAddress deviceAddress;
|
||||
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
Task* task = new SetPinCodeTask(deviceAddress,
|
||||
NS_ConvertUTF16toUTF8(aPinCode),
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
@ -3303,14 +3345,14 @@ BluetoothDBusService::SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
class SetPasskeyTask : public Task
|
||||
{
|
||||
public:
|
||||
SetPasskeyTask(const nsAString& aDeviceAddress,
|
||||
SetPasskeyTask(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mPasskey(aPasskey)
|
||||
, mRunnable(aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
@ -3358,7 +3400,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
uint32_t mPasskey;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
};
|
||||
@ -3368,7 +3410,13 @@ BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
Task* task = new SetPasskeyTask(aDeviceAddress,
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
Task* task = new SetPasskeyTask(deviceAddress,
|
||||
aPasskey,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
@ -3382,7 +3430,13 @@ BluetoothDBusService::SetPairingConfirmationInternal(
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
Task* task = new SetPairingConfirmationTask(aDeviceAddress,
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
Task* task = new SetPairingConfirmationTask(deviceAddress,
|
||||
aConfirm,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
@ -3410,8 +3464,15 @@ ConnectDisconnect(bool aConnect, const nsAString& aDeviceAddress,
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aRunnable);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
BluetoothProfileController* controller =
|
||||
new BluetoothProfileController(aConnect, aDeviceAddress, aRunnable,
|
||||
new BluetoothProfileController(aConnect, deviceAddress, aRunnable,
|
||||
NextBluetoothProfileController,
|
||||
aServiceUuid, aCod);
|
||||
sControllerArray.AppendElement(controller);
|
||||
@ -3488,7 +3549,9 @@ public:
|
||||
MOZ_ASSERT(!aObjectPath.IsEmpty());
|
||||
MOZ_ASSERT(aManager);
|
||||
|
||||
mDeviceAddress = GetAddressFromObjectPath(aObjectPath);
|
||||
const nsString deviceAddressStr = GetAddressFromObjectPath(aObjectPath);
|
||||
|
||||
StringToAddress(deviceAddressStr, mDeviceAddress);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -3502,15 +3565,15 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
BluetoothProfileManagerBase* mManager;
|
||||
};
|
||||
|
||||
class OnGetServiceChannelRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
OnGetServiceChannelRunnable(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
OnGetServiceChannelRunnable(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel,
|
||||
BluetoothProfileManagerBase* aManager)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
@ -3518,8 +3581,8 @@ public:
|
||||
, mChannel(aChannel)
|
||||
, mManager(aManager)
|
||||
{
|
||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!aServiceUuid.IsEmpty());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(!aServiceUuid.IsCleared());
|
||||
MOZ_ASSERT(aManager);
|
||||
}
|
||||
|
||||
@ -3533,8 +3596,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
nsString mDeviceAddress;
|
||||
nsString mServiceUuid;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
BluetoothUuid mServiceUuid;
|
||||
int mChannel;
|
||||
BluetoothProfileManagerBase* mManager;
|
||||
};
|
||||
@ -3543,11 +3606,12 @@ class OnGetServiceChannelReplyHandler : public DBusReplyHandler
|
||||
{
|
||||
public:
|
||||
OnGetServiceChannelReplyHandler(
|
||||
const nsAString& aDeviceAddress, const nsAString& aServiceUUID,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUUID,
|
||||
BluetoothProfileManagerBase* aBluetoothProfileManager)
|
||||
: mDeviceAddress(aDeviceAddress),
|
||||
mServiceUUID(aServiceUUID),
|
||||
mBluetoothProfileManager(aBluetoothProfileManager)
|
||||
: mDeviceAddress(aDeviceAddress),
|
||||
mServiceUUID(aServiceUUID),
|
||||
mBluetoothProfileManager(aBluetoothProfileManager)
|
||||
{
|
||||
MOZ_ASSERT(mBluetoothProfileManager);
|
||||
}
|
||||
@ -3575,22 +3639,22 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
nsString mDeviceAddress;
|
||||
nsString mServiceUUID;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
BluetoothUuid mServiceUUID;
|
||||
BluetoothProfileManagerBase* mBluetoothProfileManager;
|
||||
};
|
||||
|
||||
class GetServiceChannelTask : public Task
|
||||
{
|
||||
public:
|
||||
GetServiceChannelTask(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUUID,
|
||||
GetServiceChannelTask(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUUID,
|
||||
BluetoothProfileManagerBase* aBluetoothProfileManager)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mServiceUUID(aServiceUUID)
|
||||
, mBluetoothProfileManager(aBluetoothProfileManager)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(mBluetoothProfileManager);
|
||||
}
|
||||
|
||||
@ -3602,14 +3666,17 @@ public:
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
MOZ_ASSERT(!sAdapterPath.IsEmpty());
|
||||
|
||||
nsString objectPath =
|
||||
const nsString objectPath =
|
||||
GetObjectPathFromAddress(sAdapterPath, mDeviceAddress);
|
||||
|
||||
RefPtr<OnGetServiceChannelReplyHandler> handler =
|
||||
new OnGetServiceChannelReplyHandler(mDeviceAddress, mServiceUUID,
|
||||
mBluetoothProfileManager);
|
||||
|
||||
nsCString serviceUUID = NS_ConvertUTF16toUTF8(mServiceUUID);
|
||||
nsAutoString serviceUuidStr;
|
||||
UuidToString(mServiceUUID, serviceUuidStr);
|
||||
|
||||
nsCString serviceUUID = NS_ConvertUTF16toUTF8(serviceUuidStr);
|
||||
const char* cstrServiceUUID = serviceUUID.get();
|
||||
|
||||
bool success = sDBusConnection->SendWithReply(
|
||||
@ -3626,14 +3693,14 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
nsString mDeviceAddress;
|
||||
nsString mServiceUUID;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
BluetoothUuid mServiceUUID;
|
||||
BluetoothProfileManagerBase* mBluetoothProfileManager;
|
||||
};
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::GetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUUID,
|
||||
BluetoothDBusService::GetServiceChannel(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUUID,
|
||||
BluetoothProfileManagerBase* aManager)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -3670,12 +3737,12 @@ BluetoothDBusService::GetServiceChannel(const nsAString& aDeviceAddress,
|
||||
class UpdateSdpRecordsTask : public Task
|
||||
{
|
||||
public:
|
||||
UpdateSdpRecordsTask(const nsAString& aDeviceAddress,
|
||||
UpdateSdpRecordsTask(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileManagerBase* aBluetoothProfileManager)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mBluetoothProfileManager(aBluetoothProfileManager)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(mBluetoothProfileManager);
|
||||
}
|
||||
|
||||
@ -3714,12 +3781,12 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
const nsString mDeviceAddress;
|
||||
const BluetoothAddress mDeviceAddress;
|
||||
BluetoothProfileManagerBase* mBluetoothProfileManager;
|
||||
};
|
||||
|
||||
bool
|
||||
BluetoothDBusService::UpdateSdpRecords(const nsAString& aDeviceAddress,
|
||||
BluetoothDBusService::UpdateSdpRecords(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileManagerBase* aManager)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -3738,13 +3805,19 @@ BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
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
|
||||
// it for future use.
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
nsAutoString errorStr;
|
||||
if (!opp || !opp->SendFile(aDeviceAddress, aBlobParent)) {
|
||||
if (!opp || !opp->SendFile(deviceAddress, aBlobParent)) {
|
||||
errorStr.AssignLiteral("Calling SendFile() failed");
|
||||
}
|
||||
|
||||
@ -3758,13 +3831,19 @@ BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
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
|
||||
// it for future use.
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
nsAutoString errorStr;
|
||||
if (!opp || !opp->SendFile(aDeviceAddress, aBlob)) {
|
||||
if (!opp || !opp->SendFile(deviceAddress, aBlob)) {
|
||||
errorStr.AssignLiteral("Calling SendFile() failed");
|
||||
}
|
||||
|
||||
@ -3855,7 +3934,7 @@ BluetoothDBusService::IsScoConnected(BluetoothReplyRunnable* aRunnable)
|
||||
class SendMetadataTask : public Task
|
||||
{
|
||||
public:
|
||||
SendMetadataTask(const nsAString& aDeviceAddress,
|
||||
SendMetadataTask(const BluetoothAddress& aDeviceAddress,
|
||||
const nsACString& aTitle,
|
||||
const nsACString& aArtist,
|
||||
const nsACString& aAlbum,
|
||||
@ -3872,7 +3951,7 @@ public:
|
||||
, mDuration(aDuration)
|
||||
, mRunnable(aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
@ -3931,7 +4010,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const nsString mDeviceAddress;
|
||||
const BluetoothAddress mDeviceAddress;
|
||||
const nsCString mTitle;
|
||||
const nsCString mArtist;
|
||||
const nsCString mAlbum;
|
||||
@ -3978,7 +4057,7 @@ BluetoothDBusService::SendMetaData(const nsAString& aTitle,
|
||||
UpdateNotification(ControlEventId::EVENT_TRACK_CHANGED, aMediaNumber);
|
||||
}
|
||||
|
||||
nsAutoString deviceAddress;
|
||||
BluetoothAddress deviceAddress;
|
||||
avrcp->GetAddress(deviceAddress);
|
||||
|
||||
Task* task = new SendMetadataTask(
|
||||
@ -4020,7 +4099,7 @@ PlayStatusStringToControlPlayStatus(const nsAString& aPlayStatus)
|
||||
class SendPlayStatusTask : public Task
|
||||
{
|
||||
public:
|
||||
SendPlayStatusTask(const nsAString& aDeviceAddress,
|
||||
SendPlayStatusTask(const BluetoothAddress& aDeviceAddress,
|
||||
int64_t aDuration,
|
||||
int64_t aPosition,
|
||||
ControlPlayStatus aPlayStatus,
|
||||
@ -4031,7 +4110,7 @@ public:
|
||||
, mPlayStatus(aPlayStatus)
|
||||
, mRunnable(aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
@ -4061,7 +4140,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const nsString mDeviceAddress;
|
||||
const BluetoothAddress mDeviceAddress;
|
||||
int64_t mDuration;
|
||||
int64_t mPosition;
|
||||
ControlPlayStatus mPlayStatus;
|
||||
@ -4114,7 +4193,7 @@ BluetoothDBusService::SendPlayStatus(int64_t aDuration,
|
||||
UpdateNotification(ControlEventId::EVENT_PLAYBACK_POS_CHANGED, aPosition);
|
||||
}
|
||||
|
||||
nsAutoString deviceAddress;
|
||||
BluetoothAddress deviceAddress;
|
||||
avrcp->GetAddress(deviceAddress);
|
||||
|
||||
Task* task = new SendPlayStatusTask(deviceAddress,
|
||||
@ -4143,7 +4222,7 @@ ControlCallback(DBusMessage* aMsg, void* aParam)
|
||||
class UpdatePlayStatusTask : public Task
|
||||
{
|
||||
public:
|
||||
UpdatePlayStatusTask(const nsAString& aDeviceAddress,
|
||||
UpdatePlayStatusTask(const BluetoothAddress& aDeviceAddress,
|
||||
int32_t aDuration,
|
||||
int32_t aPosition,
|
||||
ControlPlayStatus aPlayStatus)
|
||||
@ -4152,7 +4231,7 @@ public:
|
||||
, mPosition(aPosition)
|
||||
, mPlayStatus(aPlayStatus)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
}
|
||||
|
||||
void Run() override
|
||||
@ -4179,7 +4258,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const nsString mDeviceAddress;
|
||||
const BluetoothAddress mDeviceAddress;
|
||||
int32_t mDuration;
|
||||
int32_t mPosition;
|
||||
ControlPlayStatus mPlayStatus;
|
||||
@ -4198,7 +4277,7 @@ BluetoothDBusService::UpdatePlayStatus(uint32_t aDuration,
|
||||
MOZ_ASSERT(avrcp->IsConnected());
|
||||
MOZ_ASSERT(!sAdapterPath.IsEmpty());
|
||||
|
||||
nsAutoString deviceAddress;
|
||||
BluetoothAddress deviceAddress;
|
||||
avrcp->GetAddress(deviceAddress);
|
||||
|
||||
Task* task = new UpdatePlayStatusTask(deviceAddress,
|
||||
@ -4211,14 +4290,14 @@ BluetoothDBusService::UpdatePlayStatus(uint32_t aDuration,
|
||||
class UpdateNotificationTask : public Task
|
||||
{
|
||||
public:
|
||||
UpdateNotificationTask(const nsAString& aDeviceAddress,
|
||||
UpdateNotificationTask(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothDBusService::ControlEventId aEventId,
|
||||
uint64_t aData)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mEventId(aEventId)
|
||||
, mData(aData)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
}
|
||||
|
||||
void Run() override
|
||||
@ -4244,7 +4323,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const nsString mDeviceAddress;
|
||||
const BluetoothAddress mDeviceAddress;
|
||||
int16_t mEventId;
|
||||
int32_t mData;
|
||||
};
|
||||
@ -4261,7 +4340,7 @@ BluetoothDBusService::UpdateNotification(ControlEventId aEventId,
|
||||
MOZ_ASSERT(avrcp->IsConnected());
|
||||
MOZ_ASSERT(!sAdapterPath.IsEmpty());
|
||||
|
||||
nsAutoString deviceAddress;
|
||||
BluetoothAddress deviceAddress;
|
||||
avrcp->GetAddress(deviceAddress);
|
||||
|
||||
Task* task = new UpdateNotificationTask(deviceAddress, aEventId, aData);
|
||||
|
@ -78,12 +78,12 @@ public:
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
GetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
GetServiceChannel(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
BluetoothProfileManagerBase* aManager) override;
|
||||
|
||||
virtual bool
|
||||
UpdateSdpRecords(const nsAString& aDeviceAddress,
|
||||
UpdateSdpRecords(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileManagerBase* aManager) override;
|
||||
|
||||
virtual nsresult
|
||||
|
@ -525,8 +525,11 @@ BluetoothHfpManager::NotifyConnectionStatusChanged(const nsAString& aType)
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
NS_ENSURE_TRUE_VOID(obs);
|
||||
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
if (NS_FAILED(obs->NotifyObservers(this, NS_ConvertUTF16toUTF8(aType).get(),
|
||||
mDeviceAddress.get()))) {
|
||||
deviceAddressStr.get()))) {
|
||||
BT_WARNING("Failed to notify observsers!");
|
||||
}
|
||||
|
||||
@ -544,7 +547,7 @@ BluetoothHfpManager::NotifyConnectionStatusChanged(const nsAString& aType)
|
||||
return;
|
||||
}
|
||||
|
||||
DispatchStatusChangedEvent(eventName, mDeviceAddress, status);
|
||||
DispatchStatusChangedEvent(eventName, deviceAddressStr, status);
|
||||
}
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
@ -1107,7 +1110,7 @@ respond_with_ok:
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothHfpManager::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -1128,8 +1131,7 @@ BluetoothHfpManager::Connect(const nsAString& aDeviceAddress,
|
||||
return;
|
||||
}
|
||||
|
||||
nsString uuid;
|
||||
BluetoothUuidHelper::GetString(BluetoothServiceClass::HANDSFREE, uuid);
|
||||
const BluetoothUuid uuid(HANDSFREE);
|
||||
|
||||
if (NS_FAILED(bs->GetServiceChannel(aDeviceAddress, uuid, this))) {
|
||||
aController->NotifyCompletion(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
|
||||
@ -1866,7 +1868,7 @@ BluetoothHfpManager::OnSocketDisconnect(BluetoothSocket* aSocket)
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
BluetoothHfpManager::OnUpdateSdpRecords(const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
// UpdateSdpRecord() is not called so this callback function should not
|
||||
// be invoked.
|
||||
@ -1874,12 +1876,13 @@ BluetoothHfpManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel)
|
||||
BluetoothHfpManager::OnGetServiceChannel(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsCleared());
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
@ -1887,13 +1890,12 @@ BluetoothHfpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
if (aChannel < 0) {
|
||||
// If we can't find Handsfree server channel number on the remote device,
|
||||
// try to create HSP connection instead.
|
||||
nsString hspUuid;
|
||||
BluetoothUuidHelper::GetString(BluetoothServiceClass::HEADSET, hspUuid);
|
||||
const BluetoothUuid uuid(HEADSET);
|
||||
|
||||
if (aServiceUuid.Equals(hspUuid)) {
|
||||
if (aServiceUuid == uuid) {
|
||||
OnConnect(NS_LITERAL_STRING(ERR_SERVICE_CHANNEL_NOT_FOUND));
|
||||
} else if (NS_FAILED(bs->GetServiceChannel(aDeviceAddress,
|
||||
hspUuid, this))) {
|
||||
uuid, this))) {
|
||||
OnConnect(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
|
||||
} else {
|
||||
mIsHsp = true;
|
||||
@ -1963,7 +1965,7 @@ BluetoothHfpManager::IsConnected()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::GetAddress(nsAString& aDeviceAddress)
|
||||
BluetoothHfpManager::GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
return mSocket->GetAddress(aDeviceAddress);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ private:
|
||||
#ifdef MOZ_B2G_RIL
|
||||
bool mDialingRequestProcessed;
|
||||
#endif
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
#ifdef MOZ_B2G_RIL
|
||||
nsString mMsisdn;
|
||||
nsString mOperatorName;
|
||||
|
@ -71,13 +71,13 @@ namespace {
|
||||
class mozilla::dom::bluetooth::SendFileBatch
|
||||
{
|
||||
public:
|
||||
SendFileBatch(const nsAString& aDeviceAddress, Blob* aBlob)
|
||||
SendFileBatch(const BluetoothAddress& aDeviceAddress, Blob* aBlob)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
{
|
||||
mBlobs.AppendElement(aBlob);
|
||||
}
|
||||
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
nsTArray<RefPtr<Blob>> mBlobs;
|
||||
};
|
||||
|
||||
@ -209,9 +209,7 @@ BluetoothOppManager::BluetoothOppManager()
|
||||
, mWaitingToSendPutFinal(false)
|
||||
, mCurrentBlobIndex(-1)
|
||||
, mSocketType(static_cast<BluetoothSocketType>(0))
|
||||
{
|
||||
mConnectedDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
|
||||
}
|
||||
{ }
|
||||
|
||||
BluetoothOppManager::~BluetoothOppManager()
|
||||
{
|
||||
@ -260,7 +258,7 @@ BluetoothOppManager::Get()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::ConnectInternal(const nsAString& aDeviceAddress)
|
||||
BluetoothOppManager::ConnectInternal(const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@ -285,10 +283,8 @@ BluetoothOppManager::ConnectInternal(const nsAString& aDeviceAddress)
|
||||
|
||||
mNeedsUpdatingSdpRecords = true;
|
||||
|
||||
nsString uuid;
|
||||
BluetoothUuidHelper::GetString(BluetoothServiceClass::OBJECT_PUSH, uuid);
|
||||
|
||||
if (NS_FAILED(bs->GetServiceChannel(aDeviceAddress, uuid, this))) {
|
||||
auto rv = bs->GetServiceChannel(aDeviceAddress, kObexObjectPush, this);
|
||||
if (NS_FAILED(rv)) {
|
||||
OnSocketConnectError(mSocket);
|
||||
return;
|
||||
}
|
||||
@ -384,7 +380,7 @@ BluetoothOppManager::StartSendingNextFile()
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothOppManager::SendFile(const nsAString& aDeviceAddress,
|
||||
BluetoothOppManager::SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
BlobParent* aActor)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -396,7 +392,7 @@ BluetoothOppManager::SendFile(const nsAString& aDeviceAddress,
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothOppManager::SendFile(const nsAString& aDeviceAddress,
|
||||
BluetoothOppManager::SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
Blob* aBlob)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -410,7 +406,7 @@ BluetoothOppManager::SendFile(const nsAString& aDeviceAddress,
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::AppendBlobToSend(const nsAString& aDeviceAddress,
|
||||
BluetoothOppManager::AppendBlobToSend(const BluetoothAddress& aDeviceAddress,
|
||||
Blob* aBlob)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -1284,7 +1280,7 @@ BluetoothOppManager::IsConnected()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::GetAddress(nsAString& aDeviceAddress)
|
||||
BluetoothOppManager::GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
return mSocket->GetAddress(aDeviceAddress);
|
||||
}
|
||||
@ -1379,13 +1375,16 @@ BluetoothOppManager::FileTransferComplete()
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString connectedDeviceAddressStr;
|
||||
AddressToString(mConnectedDeviceAddress, connectedDeviceAddressStr);
|
||||
|
||||
nsString type, name;
|
||||
BluetoothValue v;
|
||||
InfallibleTArray<BluetoothNamedValue> parameters;
|
||||
type.AssignLiteral("bluetooth-opp-transfer-complete");
|
||||
|
||||
name.AssignLiteral("address");
|
||||
v = mConnectedDeviceAddress;
|
||||
v = connectedDeviceAddressStr;
|
||||
parameters.AppendElement(BluetoothNamedValue(name, v));
|
||||
|
||||
name.AssignLiteral("success");
|
||||
@ -1419,13 +1418,16 @@ BluetoothOppManager::FileTransferComplete()
|
||||
void
|
||||
BluetoothOppManager::StartFileTransfer()
|
||||
{
|
||||
nsAutoString connectedDeviceAddressStr;
|
||||
AddressToString(mConnectedDeviceAddress, connectedDeviceAddressStr);
|
||||
|
||||
nsString type, name;
|
||||
BluetoothValue v;
|
||||
InfallibleTArray<BluetoothNamedValue> parameters;
|
||||
type.AssignLiteral("bluetooth-opp-transfer-start");
|
||||
|
||||
name.AssignLiteral("address");
|
||||
v = mConnectedDeviceAddress;
|
||||
v = connectedDeviceAddressStr;
|
||||
parameters.AppendElement(BluetoothNamedValue(name, v));
|
||||
|
||||
name.AssignLiteral("received");
|
||||
@ -1455,13 +1457,16 @@ BluetoothOppManager::StartFileTransfer()
|
||||
void
|
||||
BluetoothOppManager::UpdateProgress()
|
||||
{
|
||||
nsAutoString connectedDeviceAddressStr;
|
||||
AddressToString(mConnectedDeviceAddress, connectedDeviceAddressStr);
|
||||
|
||||
nsString type, name;
|
||||
BluetoothValue v;
|
||||
InfallibleTArray<BluetoothNamedValue> parameters;
|
||||
type.AssignLiteral("bluetooth-opp-update-progress");
|
||||
|
||||
name.AssignLiteral("address");
|
||||
v = mConnectedDeviceAddress;
|
||||
v = connectedDeviceAddressStr;
|
||||
parameters.AppendElement(BluetoothNamedValue(name, v));
|
||||
|
||||
name.AssignLiteral("received");
|
||||
@ -1485,13 +1490,16 @@ BluetoothOppManager::UpdateProgress()
|
||||
void
|
||||
BluetoothOppManager::ReceivingFileConfirmation()
|
||||
{
|
||||
nsAutoString connectedDeviceAddressStr;
|
||||
AddressToString(mConnectedDeviceAddress, connectedDeviceAddressStr);
|
||||
|
||||
nsString type, name;
|
||||
BluetoothValue v;
|
||||
InfallibleTArray<BluetoothNamedValue> parameters;
|
||||
type.AssignLiteral("bluetooth-opp-receiving-file-confirmation");
|
||||
|
||||
name.AssignLiteral("address");
|
||||
v = mConnectedDeviceAddress;
|
||||
v = connectedDeviceAddressStr;
|
||||
parameters.AppendElement(BluetoothNamedValue(name, v));
|
||||
|
||||
name.AssignLiteral("fileName");
|
||||
@ -1614,7 +1622,7 @@ BluetoothOppManager::OnSocketDisconnect(BluetoothSocket* aSocket)
|
||||
}
|
||||
|
||||
AfterOppDisconnected();
|
||||
mConnectedDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
|
||||
mConnectedDeviceAddress.Clear();
|
||||
mSuccessFlag = false;
|
||||
|
||||
mSocket = nullptr;
|
||||
@ -1637,12 +1645,13 @@ BluetoothOppManager::Disconnect(BluetoothProfileController* aController)
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel)
|
||||
BluetoothOppManager::OnGetServiceChannel(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsCleared());
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
@ -1674,18 +1683,16 @@ BluetoothOppManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
BluetoothOppManager::OnUpdateSdpRecords(const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsCleared());
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
nsString uuid;
|
||||
BluetoothUuidHelper::GetString(BluetoothServiceClass::OBJECT_PUSH, uuid);
|
||||
|
||||
if (NS_FAILED(bs->GetServiceChannel(aDeviceAddress, uuid, this))) {
|
||||
auto rv = bs->GetServiceChannel(aDeviceAddress, kObexObjectPush, this);
|
||||
if (NS_FAILED(rv)) {
|
||||
OnSocketConnectError(mSocket);
|
||||
}
|
||||
}
|
||||
@ -1706,7 +1713,7 @@ BluetoothOppManager::AcquireSdcardMountLock()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothOppManager::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
{
|
||||
MOZ_ASSERT(false);
|
||||
|
@ -50,8 +50,8 @@ public:
|
||||
|
||||
bool Listen();
|
||||
|
||||
bool SendFile(const nsAString& aDeviceAddress, BlobParent* aActor);
|
||||
bool SendFile(const nsAString& aDeviceAddress, Blob* aBlob);
|
||||
bool SendFile(const BluetoothAddress& aDeviceAddress, BlobParent* aActor);
|
||||
bool SendFile(const BluetoothAddress& aDeviceAddress, Blob* aBlob);
|
||||
bool StopSendingFile();
|
||||
bool ConfirmReceivingFile(bool aConfirm);
|
||||
|
||||
@ -96,10 +96,10 @@ private:
|
||||
void NotifyAboutFileChange();
|
||||
bool AcquireSdcardMountLock();
|
||||
void SendObexData(uint8_t* aData, uint8_t aOpcode, int aSize);
|
||||
void AppendBlobToSend(const nsAString& aDeviceAddress, Blob* aBlob);
|
||||
void AppendBlobToSend(const BluetoothAddress& aDeviceAddress, Blob* aBlob);
|
||||
void DiscardBlobsToSend();
|
||||
bool ProcessNextBatch();
|
||||
void ConnectInternal(const nsAString& aDeviceAddress);
|
||||
void ConnectInternal(const BluetoothAddress& aDeviceAddress);
|
||||
|
||||
/**
|
||||
* Usually we won't get a full PUT packet in one operation, which means that
|
||||
@ -118,7 +118,7 @@ private:
|
||||
* Set when OBEX session is established.
|
||||
*/
|
||||
bool mConnected;
|
||||
nsString mConnectedDeviceAddress;
|
||||
BluetoothAddress mConnectedDeviceAddress;
|
||||
|
||||
/**
|
||||
* Remote information
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <fcntl.h>
|
||||
#include "BluetoothSocketObserver.h"
|
||||
#include "BluetoothUnixSocketConnector.h"
|
||||
#include "BluetoothUtils.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
|
||||
#include "nsXULAppAPI.h"
|
||||
@ -30,10 +31,10 @@ public:
|
||||
BluetoothSocketIO(MessageLoop* aConsumerLoop,
|
||||
MessageLoop* aIOLoop,
|
||||
BluetoothSocket* aConsumer,
|
||||
UnixSocketConnector* aConnector);
|
||||
BluetoothUnixSocketConnector* aConnector);
|
||||
~BluetoothSocketIO();
|
||||
|
||||
void GetSocketAddr(nsAString& aAddrStr) const;
|
||||
void GetSocketAddr(BluetoothAddress& aAddress) const;
|
||||
|
||||
BluetoothSocket* GetBluetoothSocket();
|
||||
DataSocket* GetDataSocket();
|
||||
@ -103,7 +104,7 @@ private:
|
||||
/**
|
||||
* Connector object used to create the connection we are currently using.
|
||||
*/
|
||||
nsAutoPtr<UnixSocketConnector> mConnector;
|
||||
nsAutoPtr<BluetoothUnixSocketConnector> mConnector;
|
||||
|
||||
/**
|
||||
* If true, do not requeue whatever task we're running
|
||||
@ -136,7 +137,7 @@ BluetoothSocket::BluetoothSocketIO::BluetoothSocketIO(
|
||||
MessageLoop* aConsumerLoop,
|
||||
MessageLoop* aIOLoop,
|
||||
BluetoothSocket* aConsumer,
|
||||
UnixSocketConnector* aConnector)
|
||||
BluetoothUnixSocketConnector* aConnector)
|
||||
: UnixSocketWatcher(aIOLoop)
|
||||
, DataSocketIO(aConsumerLoop)
|
||||
, mConsumer(aConsumer)
|
||||
@ -160,24 +161,22 @@ BluetoothSocket::BluetoothSocketIO::~BluetoothSocketIO()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothSocket::BluetoothSocketIO::GetSocketAddr(nsAString& aAddrStr) const
|
||||
BluetoothSocket::BluetoothSocketIO::GetSocketAddr(
|
||||
BluetoothAddress& aAddress) const
|
||||
{
|
||||
if (!mConnector) {
|
||||
NS_WARNING("No connector to get socket address from!");
|
||||
aAddrStr.Truncate();
|
||||
aAddress.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
nsCString addressString;
|
||||
nsresult rv = mConnector->ConvertAddressToString(
|
||||
*reinterpret_cast<const struct sockaddr*>(&mAddress), mAddressLength,
|
||||
addressString);
|
||||
nsresult rv = mConnector->ConvertAddress(
|
||||
*reinterpret_cast<const struct sockaddr*>(&mAddress), sizeof(mAddress),
|
||||
aAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
aAddrStr.Truncate();
|
||||
aAddress.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
aAddrStr.Assign(NS_ConvertUTF8toUTF16(addressString));
|
||||
}
|
||||
|
||||
BluetoothSocket*
|
||||
@ -579,24 +578,28 @@ BluetoothSocket::~BluetoothSocket()
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothSocket::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothSocket::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
BluetoothSocketType aType,
|
||||
int aChannel,
|
||||
bool aAuth, bool aEncrypt)
|
||||
{
|
||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsCleared());
|
||||
|
||||
nsAutoPtr<BluetoothUnixSocketConnector> connector(
|
||||
new BluetoothUnixSocketConnector(NS_ConvertUTF16toUTF8(aDeviceAddress),
|
||||
aType, aChannel, aAuth, aEncrypt));
|
||||
new BluetoothUnixSocketConnector(aDeviceAddress, aType, aChannel,
|
||||
aAuth, aEncrypt));
|
||||
|
||||
nsresult rv = Connect(connector);
|
||||
if (NS_FAILED(rv)) {
|
||||
nsAutoString addr;
|
||||
GetAddress(addr);
|
||||
BluetoothAddress address;
|
||||
GetAddress(address);
|
||||
|
||||
nsAutoString addressStr;
|
||||
AddressToString(address, addressStr);
|
||||
|
||||
BT_LOGD("%s failed. Current connected device address: %s",
|
||||
__FUNCTION__, NS_ConvertUTF16toUTF8(addr).get());
|
||||
__FUNCTION__, NS_ConvertUTF16toUTF8(addressStr).get());
|
||||
return rv;
|
||||
}
|
||||
connector.forget();
|
||||
@ -612,15 +615,19 @@ BluetoothSocket::Listen(const nsAString& aServiceName,
|
||||
bool aAuth, bool aEncrypt)
|
||||
{
|
||||
nsAutoPtr<BluetoothUnixSocketConnector> connector(
|
||||
new BluetoothUnixSocketConnector(NS_LITERAL_CSTRING(BLUETOOTH_ADDRESS_NONE),
|
||||
aType, aChannel, aAuth, aEncrypt));
|
||||
new BluetoothUnixSocketConnector(BluetoothAddress::ANY, aType,
|
||||
aChannel, aAuth, aEncrypt));
|
||||
|
||||
nsresult rv = Listen(connector);
|
||||
if (NS_FAILED(rv)) {
|
||||
nsAutoString addr;
|
||||
GetAddress(addr);
|
||||
BluetoothAddress address;
|
||||
GetAddress(address);
|
||||
|
||||
nsAutoString addressStr;
|
||||
AddressToString(address, addressStr);
|
||||
|
||||
BT_LOGD("%s failed. Current connected device address: %s",
|
||||
__FUNCTION__, NS_ConvertUTF16toUTF8(addr).get());
|
||||
__FUNCTION__, NS_ConvertUTF16toUTF8(addressStr).get());
|
||||
return rv;
|
||||
}
|
||||
connector.forget();
|
||||
@ -704,14 +711,15 @@ BluetoothSocket::Listen(BluetoothUnixSocketConnector* aConnector)
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothSocket::GetAddress(nsAString& aAddrStr)
|
||||
BluetoothSocket::GetAddress(BluetoothAddress& aAddress)
|
||||
{
|
||||
aAddrStr.Truncate();
|
||||
if (!mIO || GetConnectionStatus() != SOCKET_CONNECTED) {
|
||||
NS_WARNING("No socket currently open!");
|
||||
aAddress.Clear();
|
||||
return;
|
||||
}
|
||||
mIO->GetSocketAddr(aAddrStr);
|
||||
|
||||
mIO->GetSocketAddr(aAddress);
|
||||
}
|
||||
|
||||
// |DataSocket|
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
BluetoothSocket(BluetoothSocketObserver* aObserver);
|
||||
~BluetoothSocket();
|
||||
|
||||
nsresult Connect(const nsAString& aDeviceAddress,
|
||||
nsresult Connect(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
BluetoothSocketType aType,
|
||||
int aChannel,
|
||||
@ -105,9 +105,9 @@ public:
|
||||
/**
|
||||
* Get the current socket address.
|
||||
*
|
||||
* @param[out] aDeviceAddress Returns the address string.
|
||||
* @param[out] aDeviceAddress Returns the address.
|
||||
*/
|
||||
void GetAddress(nsAString& aDeviceAddress);
|
||||
void GetAddress(BluetoothAddress& aDeviceAddress);
|
||||
|
||||
// Methods for |DataSocket|
|
||||
//
|
||||
|
@ -43,12 +43,12 @@ static const int L2CAP_SO_RCVBUF = 400 * 1024; // 400 KB receive buffer
|
||||
static const int L2CAP_MAX_MTU = 65000;
|
||||
|
||||
BluetoothUnixSocketConnector::BluetoothUnixSocketConnector(
|
||||
const nsACString& aAddressString,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothSocketType aType,
|
||||
int aChannel,
|
||||
bool aAuth,
|
||||
bool aEncrypt)
|
||||
: mAddressString(aAddressString)
|
||||
: mAddress(aAddress)
|
||||
, mType(aType)
|
||||
, mChannel(aChannel)
|
||||
, mAuth(aAuth)
|
||||
@ -238,8 +238,7 @@ BluetoothUnixSocketConnector::CreateAddress(struct sockaddr& aAddress,
|
||||
struct sockaddr_rc* rc =
|
||||
reinterpret_cast<struct sockaddr_rc*>(&aAddress);
|
||||
rc->rc_family = AF_BLUETOOTH;
|
||||
nsresult rv = ConvertAddressString(mAddressString.get(),
|
||||
rc->rc_bdaddr);
|
||||
nsresult rv = ConvertAddress(mAddress, rc->rc_bdaddr);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
@ -253,8 +252,7 @@ BluetoothUnixSocketConnector::CreateAddress(struct sockaddr& aAddress,
|
||||
reinterpret_cast<struct sockaddr_l2*>(&aAddress);
|
||||
l2->l2_family = AF_BLUETOOTH;
|
||||
l2->l2_psm = mChannel;
|
||||
nsresult rv = ConvertAddressString(mAddressString.get(),
|
||||
l2->l2_bdaddr);
|
||||
nsresult rv = ConvertAddress(mAddress, l2->l2_bdaddr);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
@ -266,8 +264,7 @@ BluetoothUnixSocketConnector::CreateAddress(struct sockaddr& aAddress,
|
||||
struct sockaddr_sco* sco =
|
||||
reinterpret_cast<struct sockaddr_sco*>(&aAddress);
|
||||
sco->sco_family = AF_BLUETOOTH;
|
||||
nsresult rv = ConvertAddressString(mAddressString.get(),
|
||||
sco->sco_bdaddr);
|
||||
nsresult rv = ConvertAddress(mAddress, sco->sco_bdaddr);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
@ -284,20 +281,69 @@ BluetoothUnixSocketConnector::CreateAddress(struct sockaddr& aAddress,
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothUnixSocketConnector::ConvertAddressString(const char* aAddressString,
|
||||
bdaddr_t& aAddress)
|
||||
BluetoothUnixSocketConnector::ConvertAddress(const BluetoothAddress& aAddress,
|
||||
bdaddr_t& aBdAddr)
|
||||
{
|
||||
char* d = reinterpret_cast<char*>(aAddress.b) + 5;
|
||||
MOZ_ASSERT(MOZ_ARRAY_LENGTH(aBdAddr.b) == MOZ_ARRAY_LENGTH(aAddress.mAddr));
|
||||
|
||||
for (size_t i = 0; i < MOZ_ARRAY_LENGTH(aAddress.b); ++i) {
|
||||
char* endp;
|
||||
*d-- = strtoul(aAddressString, &endp, 16);
|
||||
MOZ_ASSERT(!(*endp != ':' && i != 5));
|
||||
aAddressString = endp + 1;
|
||||
/* read source address from end backwards */
|
||||
auto src = aAddress.mAddr + MOZ_ARRAY_LENGTH(aAddress.mAddr) - 1;
|
||||
|
||||
for (size_t i = 0ul; i < MOZ_ARRAY_LENGTH(aBdAddr.b); ++i) {
|
||||
aBdAddr.b[i] = *src--;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothUnixSocketConnector::ConvertAddress(const bdaddr_t& aBdAddr,
|
||||
BluetoothAddress& aAddress)
|
||||
{
|
||||
MOZ_ASSERT(MOZ_ARRAY_LENGTH(aBdAddr.b) == MOZ_ARRAY_LENGTH(aAddress.mAddr));
|
||||
|
||||
/* read source address from end backwards */
|
||||
auto src = aBdAddr.b + MOZ_ARRAY_LENGTH(aBdAddr.b) - 1;
|
||||
|
||||
for (size_t i = 0ul; i < MOZ_ARRAY_LENGTH(aAddress.mAddr); ++i) {
|
||||
aAddress.mAddr[i] = *src--;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothUnixSocketConnector::ConvertAddress(
|
||||
const struct sockaddr& aAddress, socklen_t aAddressLength,
|
||||
BluetoothAddress& aAddressOut)
|
||||
{
|
||||
MOZ_ASSERT(aAddress.sa_family == AF_BLUETOOTH);
|
||||
|
||||
switch (mType) {
|
||||
case BluetoothSocketType::RFCOMM: {
|
||||
const struct sockaddr_rc* rc =
|
||||
reinterpret_cast<const struct sockaddr_rc*>(&aAddress);
|
||||
return ConvertAddress(rc->rc_bdaddr, aAddressOut);
|
||||
}
|
||||
break;
|
||||
case BluetoothSocketType::SCO: {
|
||||
const struct sockaddr_sco* sco =
|
||||
reinterpret_cast<const struct sockaddr_sco*>(&aAddress);
|
||||
return ConvertAddress(sco->sco_bdaddr, aAddressOut);
|
||||
}
|
||||
break;
|
||||
case BluetoothSocketType::L2CAP:
|
||||
case BluetoothSocketType::EL2CAP: {
|
||||
const struct sockaddr_l2* l2 =
|
||||
reinterpret_cast<const struct sockaddr_l2*>(&aAddress);
|
||||
return ConvertAddress(l2->l2_bdaddr, aAddressOut);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_LOGR("Unknown socket type %d", static_cast<int>(mType));
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// |UnixSocketConnector|
|
||||
|
||||
nsresult
|
||||
|
@ -17,11 +17,15 @@ class BluetoothUnixSocketConnector final
|
||||
: public mozilla::ipc::UnixSocketConnector
|
||||
{
|
||||
public:
|
||||
BluetoothUnixSocketConnector(const nsACString& aAddressString,
|
||||
BluetoothUnixSocketConnector(const BluetoothAddress& aAddress,
|
||||
BluetoothSocketType aType,
|
||||
int aChannel, bool aAuth, bool aEncrypt);
|
||||
~BluetoothUnixSocketConnector();
|
||||
|
||||
nsresult ConvertAddress(const struct sockaddr& aAddress,
|
||||
socklen_t aAddressLength,
|
||||
BluetoothAddress& aAddressOut);
|
||||
|
||||
// Methods for |UnixSocketConnector|
|
||||
//
|
||||
|
||||
@ -45,14 +49,18 @@ public:
|
||||
nsresult Duplicate(UnixSocketConnector*& aConnector) override;
|
||||
|
||||
private:
|
||||
static nsresult ConvertAddress(const BluetoothAddress& aAddress,
|
||||
bdaddr_t& aBdAddr);
|
||||
|
||||
static nsresult ConvertAddress(const bdaddr_t& aBdAddr,
|
||||
BluetoothAddress& aAddress);
|
||||
|
||||
nsresult CreateSocket(int& aFd) const;
|
||||
nsresult SetSocketFlags(int aFd) const;
|
||||
nsresult CreateAddress(struct sockaddr& aAddress,
|
||||
socklen_t& aAddressLength) const;
|
||||
static nsresult ConvertAddressString(const char* aAddressString,
|
||||
bdaddr_t& aAddress);
|
||||
|
||||
nsCString mAddressString;
|
||||
BluetoothAddress mAddress;
|
||||
BluetoothSocketType mType;
|
||||
int mChannel;
|
||||
bool mAuth;
|
||||
|
@ -449,6 +449,15 @@ struct BluetoothAddress {
|
||||
operator=(ANY);
|
||||
}
|
||||
|
||||
/**
|
||||
* |IsCleared| returns true if the address doesn not contain a
|
||||
* specific value (i.e., it contains ANY).
|
||||
*/
|
||||
bool IsCleared() const
|
||||
{
|
||||
return operator==(ANY);
|
||||
}
|
||||
|
||||
/*
|
||||
* Getter and setter methods for the address parts. The figure
|
||||
* below illustrates the mapping to bytes; from LSB to MSB.
|
||||
|
@ -110,11 +110,11 @@ BluetoothHidManager::HandleShutdown()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHidManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothHidManager::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(aController && !mController);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
@ -131,7 +131,10 @@ BluetoothHidManager::Connect(const nsAString& aDeviceAddress,
|
||||
mDeviceAddress = aDeviceAddress;
|
||||
mController = aController;
|
||||
|
||||
if (NS_FAILED(bs->SendInputMessage(aDeviceAddress,
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
if (NS_FAILED(bs->SendInputMessage(deviceAddressStr,
|
||||
NS_LITERAL_STRING("Connect")))) {
|
||||
aController->NotifyCompletion(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
|
||||
return;
|
||||
@ -160,12 +163,15 @@ BluetoothHidManager::Disconnect(BluetoothProfileController* aController)
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(!mController);
|
||||
|
||||
mController = aController;
|
||||
|
||||
if (NS_FAILED(bs->SendInputMessage(mDeviceAddress,
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
if (NS_FAILED(bs->SendInputMessage(deviceAddressStr,
|
||||
NS_LITERAL_STRING("Disconnect")))) {
|
||||
aController->NotifyCompletion(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
|
||||
return;
|
||||
@ -241,31 +247,35 @@ BluetoothHidManager::NotifyStatusChanged()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsAutoString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
|
||||
NS_NAMED_LITERAL_STRING(type, BLUETOOTH_HID_STATUS_CHANGED_ID);
|
||||
InfallibleTArray<BluetoothNamedValue> parameters;
|
||||
|
||||
AppendNamedValue(parameters, "connected", mConnected);
|
||||
AppendNamedValue(parameters, "address", mDeviceAddress);
|
||||
AppendNamedValue(parameters, "address", deviceAddressStr);
|
||||
|
||||
BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHidManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel)
|
||||
BluetoothHidManager::OnGetServiceChannel(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel)
|
||||
{
|
||||
// Do nothing here as bluez acquires service channel and connects for us
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHidManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
BluetoothHidManager::OnUpdateSdpRecords(const BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
// Do nothing here as bluez acquires service channel and connects for us
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHidManager::GetAddress(nsAString& aDeviceAddress)
|
||||
BluetoothHidManager::GetAddress(BluetoothAddress& aDeviceAddress)
|
||||
{
|
||||
aDeviceAddress = mDeviceAddress;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ private:
|
||||
|
||||
// data member
|
||||
bool mConnected;
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
RefPtr<BluetoothProfileController> mController;
|
||||
};
|
||||
|
||||
|
@ -51,7 +51,7 @@ private:
|
||||
|
||||
BluetoothProfileController::BluetoothProfileController(
|
||||
bool aConnect,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable,
|
||||
BluetoothProfileControllerCallback aCallback,
|
||||
uint16_t aServiceUuid,
|
||||
@ -64,7 +64,7 @@ BluetoothProfileController::BluetoothProfileController(
|
||||
, mSuccess(false)
|
||||
, mProfilesIndex(-1)
|
||||
{
|
||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!aDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(aRunnable);
|
||||
MOZ_ASSERT(aCallback);
|
||||
|
||||
@ -230,7 +230,6 @@ void
|
||||
BluetoothProfileController::StartSession()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(mProfilesIndex == -1);
|
||||
MOZ_ASSERT(mTimer);
|
||||
|
||||
@ -285,7 +284,6 @@ void
|
||||
BluetoothProfileController::Next()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(mProfilesIndex < (int)mProfiles.Length());
|
||||
MOZ_ASSERT(mTimer);
|
||||
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
* aCod or disconnect all connected profiles.
|
||||
*/
|
||||
BluetoothProfileController(bool aConnect,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable,
|
||||
BluetoothProfileControllerCallback aCallback,
|
||||
uint16_t aServiceUuid,
|
||||
@ -139,7 +139,7 @@ private:
|
||||
bool IsBtServiceAvailable() const;
|
||||
|
||||
const bool mConnect;
|
||||
nsString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
BluetoothProfileControllerCallback mCallback;
|
||||
|
||||
|
@ -44,15 +44,15 @@ protected:
|
||||
class BluetoothProfileManagerBase : public nsIObserver
|
||||
{
|
||||
public:
|
||||
virtual void OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
virtual void OnGetServiceChannel(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel) = 0;
|
||||
virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) = 0;
|
||||
virtual void OnUpdateSdpRecords(const BluetoothAddress& aDeviceAddress) = 0;
|
||||
|
||||
/**
|
||||
* Return the address of the connected device.
|
||||
*/
|
||||
virtual void GetAddress(nsAString& aDeviceAddress) = 0;
|
||||
virtual void GetAddress(BluetoothAddress& aDeviceAddress) = 0;
|
||||
|
||||
/**
|
||||
* Return true if the profile is connected.
|
||||
@ -63,7 +63,7 @@ public:
|
||||
* Connect to a specific remote device. When it has been done, the
|
||||
* callback "OnConnect" will be invoked.
|
||||
*/
|
||||
virtual void Connect(const nsAString& aDeviceAddress,
|
||||
virtual void Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileController* aController) = 0;
|
||||
|
||||
/**
|
||||
@ -93,13 +93,14 @@ public:
|
||||
public: \
|
||||
NS_DECL_ISUPPORTS \
|
||||
NS_DECL_NSIOBSERVER \
|
||||
virtual void OnGetServiceChannel(const nsAString& aDeviceAddress, \
|
||||
const nsAString& aServiceUuid, \
|
||||
virtual void OnGetServiceChannel(const BluetoothAddress& aDeviceAddress, \
|
||||
const BluetoothUuid& aServiceUuid, \
|
||||
int aChannel) override; \
|
||||
virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) override; \
|
||||
virtual void GetAddress(nsAString& aDeviceAddress) override; \
|
||||
virtual void OnUpdateSdpRecords( \
|
||||
const BluetoothAddress& aDeviceAddress) override; \
|
||||
virtual void GetAddress(BluetoothAddress& aDeviceAddress) override; \
|
||||
virtual bool IsConnected() override; \
|
||||
virtual void Connect(const nsAString& aDeviceAddress, \
|
||||
virtual void Connect(const BluetoothAddress& aDeviceAddress, \
|
||||
BluetoothProfileController* aController) override; \
|
||||
virtual void Disconnect(BluetoothProfileController* aController) override; \
|
||||
virtual void OnConnect(const nsAString& aErrorStr) override; \
|
||||
|
@ -225,19 +225,19 @@ public:
|
||||
* Get corresponding service channel of specific service on remote device.
|
||||
* It's usually the very first step of establishing an outbound connection.
|
||||
*
|
||||
* @param aObjectPath Object path of remote device
|
||||
* @param aObjectPath Address of remote device
|
||||
* @param aServiceUuid UUID of the target service
|
||||
* @param aManager Instance which has callback function OnGetServiceChannel()
|
||||
*
|
||||
* @return NS_OK if the task begins, NS_ERROR_FAILURE otherwise
|
||||
*/
|
||||
virtual nsresult
|
||||
GetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
GetServiceChannel(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
BluetoothProfileManagerBase* aManager) = 0;
|
||||
|
||||
virtual bool
|
||||
UpdateSdpRecords(const nsAString& aDeviceAddress,
|
||||
UpdateSdpRecords(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileManagerBase* aManager) = 0;
|
||||
|
||||
virtual void
|
||||
|
@ -14,17 +14,6 @@
|
||||
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
|
||||
void
|
||||
BluetoothUuidHelper::GetString(BluetoothServiceClass aServiceClass,
|
||||
nsAString& aRetUuidStr)
|
||||
{
|
||||
aRetUuidStr.Truncate();
|
||||
|
||||
aRetUuidStr.AppendLiteral("0000");
|
||||
aRetUuidStr.AppendInt(aServiceClass, 16);
|
||||
aRetUuidStr.AppendLiteral("-0000-1000-8000-00805F9B34FB");
|
||||
}
|
||||
|
||||
BluetoothServiceClass
|
||||
BluetoothUuidHelper::GetBluetoothServiceClass(const nsAString& aUuidStr)
|
||||
{
|
||||
|
@ -16,15 +16,6 @@ class BluetoothProfileManagerBase;
|
||||
class BluetoothUuidHelper
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Get a 128-bit uuid string calculated from a 16-bit service class UUID and
|
||||
* BASE_UUID
|
||||
*
|
||||
* @param aServiceClassUuid 16-bit service class UUID
|
||||
* @param aRetUuidStr out parameter, 128-bit uuid string
|
||||
*/
|
||||
static void
|
||||
GetString(BluetoothServiceClass aServiceClassUuid, nsAString& aRetUuidStr);
|
||||
|
||||
/**
|
||||
* Convert a 128-bit uuid string to a value of BluetoothServiceClass
|
||||
|
@ -208,15 +208,15 @@ BluetoothServiceChildProcess::RemoveDeviceInternal(
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::GetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
BluetoothServiceChildProcess::GetServiceChannel(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
BluetoothProfileManagerBase* aManager)
|
||||
{
|
||||
MOZ_CRASH("This should never be called!");
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothServiceChildProcess::UpdateSdpRecords(const nsAString& aDeviceAddress,
|
||||
BluetoothServiceChildProcess::UpdateSdpRecords(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileManagerBase* aManager)
|
||||
{
|
||||
MOZ_CRASH("This should never be called!");
|
||||
|
@ -82,12 +82,12 @@ public:
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
GetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
GetServiceChannel(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
BluetoothProfileManagerBase* aManager) override;
|
||||
|
||||
virtual bool
|
||||
UpdateSdpRecords(const nsAString& aDeviceAddress,
|
||||
UpdateSdpRecords(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileManagerBase* aManager) override;
|
||||
|
||||
virtual void
|
||||
|
Loading…
x
Reference in New Issue
Block a user