mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Mobile: do not BT Discover on Android (Q_OS_ANDROID vs Q_OS_LINUX)
This seems a very trivial commit, but it is not. It appears that on an Android build, with defined(Q_OS_ANDROID) the Q_OS_LINUX variable is also defined. This results in a very tricky discovery process: 1) the JNI stuff pulls the paired devices from the local BT controller, and 2) The QT discovry agent gets active BT devices. 1) is a static list, that is, not dependent on actual visual/discoverable BT devices; it is just cached data from the phone. 2) On Android, this results in a list of actively visible (paired and not paired) devices. On desktop, however (with QT/bluez BT stack) the QT discovery agent just gets the list of paired devices, so more or less equivalent to the situation described under 1) for Android. Ok, a long story, but just do not do a discovery on Android at all. Basically, we need the BT address, device name, and possibly a specific SPP service UUID. This are fixed and known for HW and Shearwater at this point, so there is no need for a (lengthy) discovery process, and making sure the the dive computer is discoverable at the moment the app wants to construct its data to show in the UI. So, the static list of paired devices is all we need. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ca59dbd40d
commit
a43cafa515
1 changed files with 2 additions and 2 deletions
|
@ -19,7 +19,7 @@ BTDiscovery::BTDiscovery(QObject *parent)
|
|||
localBtDevice.hostMode() == QBluetoothLocalDevice::HostConnectable) {
|
||||
btPairedDevices.clear();
|
||||
qDebug() << "localDevice " + localBtDevice.name() + " is valid, starting discovery";
|
||||
#if defined(Q_OS_LINUX)
|
||||
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
||||
discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
|
||||
connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &BTDiscovery::btDeviceDiscovered);
|
||||
discoveryAgent->start();
|
||||
|
@ -30,7 +30,7 @@ BTDiscovery::BTDiscovery(QObject *parent)
|
|||
for (int i = 0; i < btPairedDevices.length(); i++) {
|
||||
qDebug() << "Paired =" << btPairedDevices[i].name << btPairedDevices[i].address.toString();
|
||||
}
|
||||
#if defined(Q_OS_LINUX)
|
||||
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
||||
discoveryAgent->stop();
|
||||
#endif
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue