mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 05:45:37 +00:00
Bug 1105308: Cleanup non-shared functions in BlueZ' BluetoothUtils.{cpp,h}, r=btian
This patch moves functions out of BlueZ' BluetoothUtils.{cpp,h} that are specific to this backend.
This commit is contained in:
parent
0fd8a33278
commit
5af2a5023b
@ -392,6 +392,37 @@ BluetoothDBusService::~BluetoothDBusService()
|
|||||||
sGetPropertyMonitor = nullptr;
|
sGetPropertyMonitor = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static nsString
|
||||||
|
GetObjectPathFromAddress(const nsAString& aAdapterPath,
|
||||||
|
const nsAString& aDeviceAddress)
|
||||||
|
{
|
||||||
|
// The object path would be like /org/bluez/2906/hci0/dev_00_23_7F_CB_B4_F1,
|
||||||
|
// and the adapter path would be the first part of the object path, according
|
||||||
|
// to the example above, it's /org/bluez/2906/hci0.
|
||||||
|
nsString devicePath(aAdapterPath);
|
||||||
|
devicePath.AppendLiteral("/dev_");
|
||||||
|
devicePath.Append(aDeviceAddress);
|
||||||
|
devicePath.ReplaceChar(':', '_');
|
||||||
|
return devicePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
static nsString
|
||||||
|
GetAddressFromObjectPath(const nsAString& aObjectPath)
|
||||||
|
{
|
||||||
|
// The object path would be like /org/bluez/2906/hci0/dev_00_23_7F_CB_B4_F1,
|
||||||
|
// and the adapter path would be the first part of the object path, according
|
||||||
|
// to the example above, it's /org/bluez/2906/hci0.
|
||||||
|
nsString address(aObjectPath);
|
||||||
|
int addressHead = address.RFind("/") + 5;
|
||||||
|
|
||||||
|
MOZ_ASSERT(addressHead + BLUETOOTH_ADDRESS_LENGTH == (int)address.Length());
|
||||||
|
|
||||||
|
address.Cut(0, addressHead);
|
||||||
|
address.ReplaceChar('_', ':');
|
||||||
|
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
GetConnectedDevicesFilter(const BluetoothValue& aValue)
|
GetConnectedDevicesFilter(const BluetoothValue& aValue)
|
||||||
{
|
{
|
||||||
|
@ -690,6 +690,28 @@ BluetoothHfpManager::HandleShutdown()
|
|||||||
sBluetoothHfpManager = nullptr;
|
sBluetoothHfpManager = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BluetoothHfpManager::ParseAtCommand(const nsACString& aAtCommand,
|
||||||
|
const int aStart,
|
||||||
|
nsTArray<nsCString>& aRetValues)
|
||||||
|
{
|
||||||
|
int length = aAtCommand.Length();
|
||||||
|
int begin = aStart;
|
||||||
|
|
||||||
|
for (int i = aStart; i < length; ++i) {
|
||||||
|
// Use ',' as separator
|
||||||
|
if (aAtCommand[i] == ',') {
|
||||||
|
nsCString tmp(nsDependentCSubstring(aAtCommand, begin, i - begin));
|
||||||
|
aRetValues.AppendElement(tmp);
|
||||||
|
|
||||||
|
begin = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCString tmp(nsDependentCSubstring(aAtCommand, begin));
|
||||||
|
aRetValues.AppendElement(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
// Virtual function of class SocketConsumer
|
// Virtual function of class SocketConsumer
|
||||||
void
|
void
|
||||||
BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
|
BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
|
||||||
|
@ -132,6 +132,9 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void ParseAtCommand(const nsACString& aAtCommand, const int aStart,
|
||||||
|
nsTArray<nsCString>& aRetValues);
|
||||||
|
|
||||||
class CloseScoTask;
|
class CloseScoTask;
|
||||||
class GetVolumeTask;
|
class GetVolumeTask;
|
||||||
#ifdef MOZ_B2G_RIL
|
#ifdef MOZ_B2G_RIL
|
||||||
|
@ -71,37 +71,6 @@ SetJsObject(JSContext* aContext,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsString
|
|
||||||
GetObjectPathFromAddress(const nsAString& aAdapterPath,
|
|
||||||
const nsAString& aDeviceAddress)
|
|
||||||
{
|
|
||||||
// The object path would be like /org/bluez/2906/hci0/dev_00_23_7F_CB_B4_F1,
|
|
||||||
// and the adapter path would be the first part of the object path, according
|
|
||||||
// to the example above, it's /org/bluez/2906/hci0.
|
|
||||||
nsString devicePath(aAdapterPath);
|
|
||||||
devicePath.AppendLiteral("/dev_");
|
|
||||||
devicePath.Append(aDeviceAddress);
|
|
||||||
devicePath.ReplaceChar(':', '_');
|
|
||||||
return devicePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsString
|
|
||||||
GetAddressFromObjectPath(const nsAString& aObjectPath)
|
|
||||||
{
|
|
||||||
// The object path would be like /org/bluez/2906/hci0/dev_00_23_7F_CB_B4_F1,
|
|
||||||
// and the adapter path would be the first part of the object path, according
|
|
||||||
// to the example above, it's /org/bluez/2906/hci0.
|
|
||||||
nsString address(aObjectPath);
|
|
||||||
int addressHead = address.RFind("/") + 5;
|
|
||||||
|
|
||||||
MOZ_ASSERT(addressHead + BLUETOOTH_ADDRESS_LENGTH == (int)address.Length());
|
|
||||||
|
|
||||||
address.Cut(0, addressHead);
|
|
||||||
address.ReplaceChar('_', ':');
|
|
||||||
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BroadcastSystemMessage(const nsAString& aType,
|
BroadcastSystemMessage(const nsAString& aType,
|
||||||
const InfallibleTArray<BluetoothNamedValue>& aData)
|
const InfallibleTArray<BluetoothNamedValue>& aData)
|
||||||
@ -154,27 +123,6 @@ DispatchBluetoothReply(BluetoothReplyRunnable* aRunnable,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ParseAtCommand(const nsACString& aAtCommand, const int aStart,
|
|
||||||
nsTArray<nsCString>& aRetValues)
|
|
||||||
{
|
|
||||||
int length = aAtCommand.Length();
|
|
||||||
int begin = aStart;
|
|
||||||
|
|
||||||
for (int i = aStart; i < length; ++i) {
|
|
||||||
// Use ',' as separator
|
|
||||||
if (aAtCommand[i] == ',') {
|
|
||||||
nsCString tmp(nsDependentCSubstring(aAtCommand, begin, i - begin));
|
|
||||||
aRetValues.AppendElement(tmp);
|
|
||||||
|
|
||||||
begin = i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCString tmp(nsDependentCSubstring(aAtCommand, begin));
|
|
||||||
aRetValues.AppendElement(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DispatchStatusChangedEvent(const nsAString& aType,
|
DispatchStatusChangedEvent(const nsAString& aType,
|
||||||
const nsAString& aAddress,
|
const nsAString& aAddress,
|
||||||
|
@ -21,13 +21,6 @@ SetJsObject(JSContext* aContext,
|
|||||||
const BluetoothValue& aValue,
|
const BluetoothValue& aValue,
|
||||||
JS::Handle<JSObject*> aObj);
|
JS::Handle<JSObject*> aObj);
|
||||||
|
|
||||||
nsString
|
|
||||||
GetObjectPathFromAddress(const nsAString& aAdapterPath,
|
|
||||||
const nsAString& aDeviceAddress);
|
|
||||||
|
|
||||||
nsString
|
|
||||||
GetAddressFromObjectPath(const nsAString& aObjectPath);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BroadcastSystemMessage(const nsAString& aType,
|
BroadcastSystemMessage(const nsAString& aType,
|
||||||
const InfallibleTArray<BluetoothNamedValue>& aData);
|
const InfallibleTArray<BluetoothNamedValue>& aData);
|
||||||
@ -37,10 +30,6 @@ DispatchBluetoothReply(BluetoothReplyRunnable* aRunnable,
|
|||||||
const BluetoothValue& aValue,
|
const BluetoothValue& aValue,
|
||||||
const nsAString& aErrorStr);
|
const nsAString& aErrorStr);
|
||||||
|
|
||||||
void
|
|
||||||
ParseAtCommand(const nsACString& aAtCommand, const int aStart,
|
|
||||||
nsTArray<nsCString>& aRetValues);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DispatchStatusChangedEvent(const nsAString& aType,
|
DispatchStatusChangedEvent(const nsAString& aType,
|
||||||
const nsAString& aDeviceAddress,
|
const nsAString& aDeviceAddress,
|
||||||
|
Loading…
Reference in New Issue
Block a user