summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Link applicable manual tests against permission plugin on macOSJuha Vuolle2023-04-042-0/+15
| | | | | | | | | | As a temporary workaround (see QTBUG-112212) Task-number: QTBUG-112215 Task-number: QTBUG-112212 Change-Id: Iae6f94e4d208e829993a0af136d21522ca819eb1 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add permission request to bttestui manual test applicationJuha Vuolle2023-04-042-0/+31
| | | | | | | | | | | In addition add temporary workaround for linking against the permission plugin on macOS Task-number: QTBUG-112215 Task-number: QTBUG-112212 Change-Id: Idbd8c4cbdfc58893dc23147379265030cefc2aee Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Add permission request to bluetoothtestdevice manual test applicationJuha Vuolle2023-04-042-4/+34
| | | | | | | | | | | | | | In addition: - Add temporary workaround for linking against the permission plugin on macOS - Use QGuiApplication also on macOS. This is required with permissions until the underlying event dispatcher is changed to Core Foundation's dispatcher also for QCoreApplication Task-number: QTBUG-112215 Task-number: QTBUG-112212 Change-Id: I3d30766aa52846994e23746ed3f65518c02384ea Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QBluetoothUuid - add platform-specific conversion functionsTimur Pocheptsov2023-04-032-0/+22
| | | | | | | | | | | | | Namely: fromCBUUID and toCBUUID, similar to fromNSUUID and toNSUUID that we already have. [ChangeLog][QtBluetooth] Add CoreBluetooth-specific conversion to QBluetoothUuid class, to get CBUUID out of QBluetoothUuid and convert CBUUID to QBluetoothUuid. Fixes: QTBUG-112303 Change-Id: I4ca0b13395b4346f7c830a0e042a16f976998a33 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* CMake: Fix btscanner manual test to work on macOSJuha Vuolle2023-03-271-30/+26
| | | | | | | | | | | | | | | Because it's a manual test now instead of an example, use qt_internal_add_manual_test. Remove the code bits that were needed for examples. Enable uic. Manually link to the darwin permission plugin because that's not done automatically for tests yet when targeting macOS. Pick-to: 6.5 6.5.0 Task-number: QTBUG-104754 Task-number: QTBUG-112212 Change-Id: Id4176f60118a4d3dcca96df56d53f9243a50174d Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* BtScanner example: move to manual testsIvan Solovev2023-03-2111-0/+669
| | | | | | | | | | | | | | | | | | | | | | | The example mostly shows the usage of QBluetooth{Device,Service}DiscoveryAgent classes, which is also illustrated by other examples. Move it, because it's not fully functional on mobile platforms (because it's widget based). Do not remove it completely, because it might still be useful for doing Classic device scan. Also implement some improvements while on it: * fix CMakeLists.txt by using qt_standard_project_setup() and PRIVATE linking * fix memory leak in DeviceDiscoveryDialog * rework the code to use Qt parent-child model instead of manually deleting objects where possible * fix includes * fix forward declarations Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: Ie4bc9e25ccdda6d5f5de2f57528df349c71cdc12 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Update the remaining (manual) tests to use the Permissions APITimur Pocheptsov2023-03-032-0/+51
| | | | | | | Otherwise, they will refuse to work with Bluetooth. Change-Id: Iaf5c6726b609a280e0611cfecaea485ccfa38804 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QtBluetooth: port the code to the new permissions API (CoreBluetooth)Timur Pocheptsov2023-02-243-8/+115
| | | | | | | | | | | | | | | | | | | | | We only _check_ if permissions were granted, leaving it up to an application to _request_ permissions. If permission status is not 'Granted', we bail out ealy setting MissionPermissionsError. QLowEnergyController::init is now a no-op for Darwin, because it's OK to create a peripheral/central and no need to set any error yet. Autotests require minor adjustments - they were already passing if BT is off, as it is on CI (checking Bluetooth local device and its status), but if BT is somewhere on, tests can try to scan or connect not having permissions granted - for this we adjust the tests, using permission API. [ChangeLog][Important Behavior Changes][QtBluetooth][Darwin] Do not request permissions implicitly, only check them and leave it to applications to request permissions explicitly. Task-number: QTBUG-109964 Change-Id: I95c04744e979614ffb6d992da2e279e86b272679 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* QBluetoothUuid: remove quint128 supportThiago Macieira2023-02-151-12/+0
| | | | | | | | | | | | | | | | Only kept for in removed_api.cpp for binary compatibility. [ChangeLog][QtBluetooth] The undocumented quint128 was removed from QtBluetooth. This affects the QBluetoothUuid constructor and the toUInt128() method. QUuid has support for an integer quint128 on certain 64-bit platforms (all except MSVC) with a constructor and a getter of the same name, so this change is mostly source-compatible, so long as the application code doesn't attempt to treat this type as a structure. For cross-platform support, use QUuid::Id128Bytes. Change-Id: Id8e48e8f498c4a029619fffd1728c34931ac525e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QBluetoothUuid: switch from quint128 to QUuid::Id128BytesThiago Macieira2023-02-132-17/+14
| | | | | | | | | | | | This is now supported by the QUuid class directly instead of being an invention of QBluetoothUuid on top. Additionally, as a trivial structure of 16 bytes in size, it should be passed by value, not by const-ref. The BluezUint128 type is used where the 128 bits of data aren't a UUID (like the Connection Signature Resolving Key). Change-Id: Id8e48e8f498c4a029619fffd1728c1af9149a561 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Fix the broken test after the retirement of qt_parse_all_argumentsAmir Masoud Abdol2023-01-203-3/+3
| | | | | | | | | | As we are now processing the arguments with cmake_parse_arguments(PARSE_ARGV, we don't need to pass the escape characters anymore. Task-number: QTBUG-99238 Change-Id: I08f96a44c99a77ff11892bb0eb78c04549aca2ef Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Remove flaky part of the Bluetooth MTU manual testJuha Vuolle2023-01-191-5/+0
| | | | | | | | Previously this has been flaky at least on Darwin, and now also on Android 13. Change-Id: Ibb47850569e5b6c7af5f5149c0041c9df8a72045 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Android LE Peripheral: properly update characteristic and descriptor local ↵Ivan Solovev2023-01-183-0/+203
| | | | | | | | | | | | | | | | values Android backend did not update the serivice's characteristic and descriptor values after executing writeCharacteristic/writeDescriptor. As a result, the connected central saw the correct updated value, while local request still returned the old value. This patch fixes it by properly updating the local values when the write operations complete successfully. Pick-to: 6.5 Change-Id: Ie09299b6c72bbf92ab6c824c3ca23f0136f0457e Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Bluez DBus peripheral add support for extended propertiesJuha Vuolle2022-12-071-1/+10
| | | | | | | Task-number: QTBUG-107511 Change-Id: Ia94262a29457489f8b7d5ffd2f5b50f943eb4b21 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Improve bluetooth manual test supportJuha Vuolle2022-12-075-120/+403
| | | | | | | | | | | | | | | This is a preparatory commit for adding the Bluez DBus peripheral role support. Aim is to improve the manual test coverage: add large descriptor writes, ability to set advertising data multiple times, add more services, characteristics etc. Also adjust the large attribute size so that it works with bluez dbus. Task-number: QTBUG-107510 Change-Id: I5f22880349606feb4f61032b78c62b990329eb69 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Bluez DBus advertising support (BT LE)Juha Vuolle2022-12-071-1/+12
| | | | | | Fixes: QTBUG-107509 Change-Id: I6e26cbc0502cdc65eb6af20bfeb481f0b62ff386 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* QBluetoothUuid: simplify one attribute creationThiago Macieira2022-11-281-1/+1
| | | | | | | QUuid can create ID128 strings on its own. Change-Id: Id8e48e8f498c4a029619fffd1728938a1b70e4a0 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* tst_QBluetoothUuid: replace macros with lambdasThiago Macieira2022-11-281-43/+41
| | | | | Change-Id: Id8e48e8f498c4a029619fffd172893902e3d3f96 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* [Darwin BTLE] Fix service discovery timeout assertJuha Vuolle2022-10-131-0/+7
| | | | | | | | | | | | | | | | | | | | | | If BT LE service discovery times out, an assert activates. This happens due to the following sequence: - DarwinBTCentralManager gets a timeout from service discovery watcher, which leads to 'emit notifier->CBManagerError()' - The handler QLowEnergyControllerPrivateDarwin::_q_CBManagerError() sets state to 'Connected' - A bit later the DarwinBTCentralManager emits a serviceDiscoveryFinished() signal, whose handler QLowEnergyControllerPrivateDarwin::_q_serviceDiscoveryFinished() asserts because state is no longer 'Discovering' Either the assert needs to be changed to an early return, or the service discovery should not send the finished() signal after it has emitted an error. Fixes: QTBUG-106039 Change-Id: Ibff31332524a2c7d20dced7b3af7af5a424db0ef Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Port from container::count() and length() to size() - V4Marc Mutz2022-10-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'. Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9 Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-068-16/+16
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I9ace956ba9ee596ddf820623957f2d476036c5ed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-0610-92/+92
| | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: If19e46acd9ceccaa8af43bf02c5ba30f52163108 Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
* Skip few Bluetooth autotests on Android emulatorJuha Vuolle2022-09-276-49/+86
| | | | | | | | | | | | | | | | | This is to unblock Android-12 emulator deployment on CI which, unlike the earlier emulators, has a bluetooth emulation. This means that the emulator triggers permission confirmation dialogues which would timeout on CI. This commit replaces the 1ef066bf7d7a67d1b381443b9ecfa60f9204aca8, which attempted to solve the issue by compile-time configuration. Pick-to: 6.2 6.3 6.4 Task-number: QTBUG-106614 Change-Id: Idc155bb8617802054d6ab19993f5417cc254f16e Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Clear previous bluetooth device/service discovery errors on restartJuha Vuolle2022-09-203-0/+27
| | | | | | | | | | | | | | | | | | | | An example of the problem is when discovery is first tried while bluetooth is OFF, and one gets the corresponding error. Then the bluetooth is switched ON, and the discovery is restarted successfully. However in this case the error() still remains as "power OFF" error instead of "no error", which is misleading. With device discovery agent the clearing is done at each individual backend, rather than at the common public class start(). This is due to the pending cancel/start logic, which we probably shouldn't interfere with by clearing errors amidst pending operation. The Darwin backend already cleared the error in its start(), and with this commit the intent is to add similar clearing to the Android/Bluez/Win. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-104473 Change-Id: I713590a26eb2b8d4ee7873f3fe84e63e504523df Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Fix failing BT LE autotest on CI & RHEL 9Juha Vuolle2022-09-191-0/+18
| | | | | | | | | | | | It appears that with RHEL 9 on CI there is no bluez dbus. This means that the older kernel ATT interface is used instead. With that there is an error already at construction time if there is no local adapter available (QLowEnergyControllerPrivateBluez::init()) Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-106282 Change-Id: I8ecab26440a2b533c4d641c31d2345b46b95427e Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Add Android support for BT LE RSSI readJuha Vuolle2022-09-135-6/+213
| | | | | | | | | In addition add manual and autotest support Fixes: QTBUG-69747 Change-Id: I253b8ea7d3dd5b3e2dce65b83c31363673c931b8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Skip parts of Bluetooth autotests on Android 12+ emulatorJuha Vuolle2022-08-305-20/+23
| | | | | | | | | | | | | | | | | | | | | | | | | The CI uses Android emulator for running bluetooth tests for Android. Up until Android 12 the emulator didn't have a bluetooth and only the bluetooth parts which don't require actual bluetooth were tested. This is similar to other platforms' bluetooth testing on CI. The Android 12 emulator introduces a Bluetooth emulation. This causes trouble when running tests on CI, as using bluetooth triggers end-user dialogues, and consequently test cases time out waiting for them. This commit skips the problematic parts when tests are built for Android in CI environment. This way the developers and testers can still run the full bluetooth tests locally without need for manually removing the skips. Pick-to: 6.4 6.3 6.2 Fixes: QTBUG-105803 Fixes: QTBUG-105808 Change-Id: I20bac041c3a4a0b83058482305dc735122d4c489 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add tst_qlowenergycontroller_device::testRepeatedCharacteristicsWrite()Ivan Solovev2022-08-262-0/+157
| | | | | | | | | | | | | | | ... and its counterpart in bluetoothtestdevice. The client side generates multiple writes to the same characteristics. The server side, when receiving each new value, copies it to the notifying characteristic, which sends notification back to the clien. In this way the client can verify that all writes were completed successfully and in the right order. Fixes: QTBUG-105556 Pick-to: 6.4 6.3 6.2 Change-Id: Id5ba5b00527a01903b3730733188065c1cc6a94e Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
* Bluetooth Windows: refactor getNativeCharacteristicIvan Solovev2022-08-261-2/+6
| | | | | | | | | | | | | | | | | | | | | ... to get rid of await() call. The function now requests the characteristics asynchronously and executes a custom callback, passing the selected characteristic as a parameter. After that the refactoring is quite simple: we put all the code after the getNativeCharacteristic() call into a lambda, and pass this lambda as a last parameter of the updated method. As a drive-by: improve tst_qlowenergycontroller_device::testNotificationAndIndication() stability by adding QTest::qWait() calls after disabling notification and indication, like it is done in other places. Task-number: QTBUG-105556 Pick-to: 6.4 6.3 6.2 Change-Id: I1164bbc677d3549ef930243fd645eed344e27b7c Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-2330-30/+30
| | | | | | | Task-number: QTBUG-105718 Change-Id: I8df2954bb61e0dc2a89f48c056b10a4bab395e0b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Android: skip tst_qbluetooth{device,service}discoveryagent failing casesAssam Boudjelthia2022-08-182-0/+12
| | | | | | | | | | This fails on Android 12 in CI. Task-number: QTBUG-105803 Pick-to: 6.4 6.3 6.2 Change-Id: Ib3bc224bfe1a4207c638b4f8a0b8043cb8ab2339 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-2725-33/+33
| | | | | Change-Id: I178b945cfc563bc3e0c9c01c63f54f0cba4552d9 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Android: skip some bluetooth test cases that fail on Android 12 CIAssam Boudjelthia2022-07-142-0/+23
| | | | | | | | | | | | | Android 12 sends popups to user about operations in bluetooth like enbaling or disabling or scanning for devices, and these popops will wait for user action. On CI or in qtconnectivity we don't wait for those so some tests are either failing or timing out. This patch skips the tests on Android 12+. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-104914 Change-Id: Ibadaf3a4d67170e33dcdcbe836c6d1a2e8a55c23 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Add license headers to cmake filesLucie Gérard2022-07-0830-0/+90
| | | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: Ic31d264037cb00d72436d585820e45e4ccac5c60 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-1042-1290/+86
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: Ifc22d8ae24532e9a1093ca613ed6590a1992bc39 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add Bluetooth LE functionality to bttestuiJuha Vuolle2022-06-096-249/+946
| | | | | | | | | | | | | | | | | | | | | | | | Bttestui is a manual bluetooth test application with which one can manually test different bluetooth features. This commit adds Low Energy support for the application. The support is logically simple and flat meaning that it does not on purpose implement automated state flows. Rather one can manually trigger each action and modify them locally as needed for testing purposes. The commit adds base support for both central and peripheral roles and their basic functionalities: discovery, advertisement, read and write. In addition few changes: - Make the main.qml flickable to be able to use on small screens - Remove QML import numbering - Add nullptr checks in some of the functions, sometimes it is intentional to eg. disable localDevice creation Fixes: QTBUG-103827 Change-Id: I57c88912803eab8e777c9e6ef3bcaa5401709381 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Build bttestui as standalone applicationIvan Solovev2022-06-091-16/+46
| | | | | | | | | At least for testing on Android it's easier to have an out-of-tree build. Task-number: QTBUG-103827 Change-Id: I4f89a1c96d65542a1317a6f223f8bd00720ef3cb Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
* Use the new "permissions error" code on macOSJuha Vuolle2022-05-301-0/+12
| | | | | | | | | | | | | | | | | | | | | | Qt 6.4 introduces new error code for permission errors (QTBUG-102373). This commit makes use of the new error code. This consists of two parts: 1) If the bluetooth permission key is missing from the application's Info.plist and we know it's needed => permission error. This is limited to Low Energy because classic bluetooth does not need it on macOS, and iOS does not support classic bluetooth. If the key is missing, it is an application development/deployment error and we should not make too many of these checks - few places is enough. 2) At runtime the platform prompts for bluetooth permission and the user may disallow it => permission error. Amends: d58d134d25695dd044fc13d57a4d754b1dfb4e4a Fixes: QTBUG-103388 Change-Id: I96de202e9ac8c33e51bc126389f62091d03eab70 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Close socket descriptor when QBluetoothSocketBluez is destroyedJuha Vuolle2022-05-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | There are two private QBluetoothSocket backends on Linux: - QBluetoothSocketBluez is native linux socket implementation It is always used by the linux QBluetoothServer, and by QBluetoothSocket if Bluez version is < 5.46 - QBluetoothSocketBluezDbus used by QBluetoothSocket when Bluez >= 5.46 Leaving the native socket unclosed leaks the resource and eventually we may run out of descriptors. This is reproducible by creating and destroying QBluetoothServer instances in a loop. As a related drive-by: - Fix bluetooth socket autotest version check. DBus socket is used with bluez 5.46+ (for clarity: DBus lowenergycontroller is used with bluez 5.42+). This is needed for the test to pass with Bluez < 5.46 - Add a clarifying comment on socket close() Fixes: QTBUG-103067 Pick-to: 5.15 6.2 6.3 Change-Id: Idc38c743be09e559ea82bf09c2f9e44e4b80d666 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Introduce error codes for missing permissionsIvan Solovev2022-05-191-0/+2
| | | | | | | | | | | | | | | | | Some operating systems might request special permissions while working with Bluetooth. Previously if the permissions were missing, we were returning an UnknownError, and the error description, when available, was not very good as well. [ChangeLog][QtBluetooth] Various error enums are extended with new error codes that represent missing permissions error. Error descriptions are also updated, when available. This patch also applies new error codes to Android implementation. Fixes: QTBUG-102373 Change-Id: I247371de6b1eb8d39f0f99c50269d2b1f3bf21c2 Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
* Revise bluetooth hostmode autotest to pass on Android 12Juha Vuolle2022-05-171-8/+20
| | | | | | | | | | | On Android 12 device it seems that the Connectable/Discoverable hostmode is governed by the UI bluetooth visibility setting. This commit makes the test pass and assumes the visibility setting is 'true'. Fixes: QTBUG-102874 Change-Id: Ic772cb4e5a76cef7b512b5d87f2f8842599d1fd5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Android bluetooth local device always to use "Paired"Juha Vuolle2022-05-171-1/+7
| | | | | | | | | | | | | | | | | | QBluetoothLocalDevice on Android doesn't distinguish between "AuthorizedPaired" and "Paired" but regresses to "Paired". This commit changes one place where the code echoes back whatever pairing mode the user requested, instead of "Paired". This caused the sent pairingFinished() signal to have different value than what a call to pairingStatus() gives. In addition this commit fixes the related autotest when run in "manual mode" ie. the BT_TEST_DEVICE and live counterpart device is used. Task-number: QTBUG-102874 Change-Id: I24c76b03ad1d0b27b8afeaf94f146393e4547712 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QtNfc: Get rid of NearFieldTarget classIevgenii Meshcheriakov2022-05-161-1/+1
| | | | | | | | | | Use QNearFieldTarget class directly after making QNearFieldManagerPrivateImpl a friend. Task-number: QTBUG-103357 Change-Id: I3488c7c23e3a050f3f74cbd3edd39e39bf851ea8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Tests: Use REQUIRED COMPONENTS where applicableKai Köhne2022-05-132-3/+3
| | | | | Change-Id: I86a47d41ec14182303c93dd665d170d0bff94ac9 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Windows: implement the missing APIs for QBluetoothLocalDeviceIvan Solovev2022-05-121-0/+56
| | | | | | | | | | | | | | | | [ChangeLog][QBluetoothLocalDevice][Windows] Add support for correctly emitting deviceConnected() and deviceDisconnected() signals, as well as return a valid list of connectedDevices(). The implementation has one assumption - it considers that Windows always has only one local adapter available. This is correct for now, and is unlikely to change, but we need to keep it in mind. Fixes: QTBUG-98942 Change-Id: If7c5ce2237a60754965f485d8fe54159f071a3f0 Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Remove unsupported Android bluetooth codepathsJuha Vuolle2022-05-121-2/+2
| | | | | | | | | | | | | | | Minimum Android level supported on Qt 6 is Android 6 / API Level 23. This commit removes older unsupported code in order to simplify. This concerns primarily: - sdkVersion() checks - Java reflections (API availability was uncertain) Task-number: QTBUG-102497 Pick-to: 6.2 6.3 Change-Id: Ia90248a0a8f8e32130b8394998c2676c97a02eb5 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Replace deprecated bluetooth disable/enable methods on AndroidJuha Vuolle2022-05-071-26/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Starting from Android 13 (API level 33) the BluetoothAdapter enable() and disable() methods have been deprecated. In addition both methods are strongly discouraged as they do not necessarily trigger a permission dialogue to turn the bluetooth ON/OFF. The methods are replaced with preferred 'action requests' which are available since API level 5 and have the benefit of triggering a user dialogue when powering Bluetooth ON/OFF. The calls to these replacing APIs are surrounded by sdkVersion checks with one exception: it appears that the old enable() call does not work well when performing a multi-state transition from Discoverable => PoweredOff => Connectable. The replacing API fairs better there and hence it is replaced unconditionally. Elsewhere the sdkVersion check is for >= 31 in order to be able to test with devices available at the moment (API level 31 corresponds with Android 12). As a drive-by few related code changes: - handle hostmode enum in a switch-case instead of if-elseif - rename the opaque tokens and setConnectable() method in the broadcast receiver to better reflect their role Fixes: QTBUG-102442 Pick-to: 5.15 6.2 6.3 Change-Id: I5d9395ce9e5ecd28b1f8e2f37d13e8aea7cfcdd3 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Bluetooth pairing mode improvements on WindowsJuha Vuolle2022-05-021-3/+6
| | | | | | | | | | | | | | | | | | | | Windows QBluetoothLocalDevice does not distinguish between "Paired" and "AuthorizedPaired" pairing modes as there does not seem to be APIs to do it. The current implementation has few shortcomings addressed by this commit: - Document the behavior - Use the actual pairing mode as signal value instead of using what was requested. On current implementation the "pairingFinished()" signal and "pairingStatus()" method call may give different values - Perform pairing/unparing only if this could mean a change; requesting 'Paired' is same as requesting 'AuthorizedPaired' Fixes: QTBUG-102412 Change-Id: I57801744432978c70cfdba5e58e8f85acfab92f2 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* tst_qbluetoothdevicediscoveryagent to reliably pass on AndroidJuha Vuolle2022-04-221-27/+42
| | | | | | | | | | | | | | | | | | | | | | | Android backend is sometimes unable to cancel the device discovery right after issuing the stop(). The Qt backend code is prepared for this and instead does a pending cancel (cancels later) and emits an error. Based on testing this happens sometimes on an Android 10 device, and often on an Android 12 device. This behavior difference causes the autotest to fail and this commit introduces a small delay between start() and stop() to remove this behavioral difference. Notably this commit does not accommodate the potential behavior difference because the test function itself would become unreasonably complex. As a drive-by simplify the wait loops and convert numeric QVERIFYs to QCOMPAREs to give the actual number if something failed. Pick-to: 6.2 6.3 Change-Id: Iae3d0ebfaae59660af80bed906da5098e4b899d1 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
* Enable tst_qbluetoothlocaldevice pairing test function on WindowsJuha Vuolle2022-04-201-8/+6
| | | | | | | | | | | | | | | | | Improved support for QBluetoothLocalDevice on Windows was added in 6.3. Also make the test function's powerOn a bit more robust and change QCOMPARE into their correct semantical order (actual vs expected) NB. the test function does not currently pass on Windows if one sets the BT_TEST_DEVICE environment variable (= another device and manual interaction used). It seems an actual code bug to be fixed with another commit (see QTBUG-102412). Amends 43c01fbe3f2a74d83a10c3fec4d25fc9342f7544 Pick-to: 6.3 Change-Id: Ic9963d99d2b701d70945f7a32de12508dc2f3502 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>