summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Avoid recursion during QBluetoothDeviceDiscoveryAgent::stop()Alex Blasche2017-08-041-0/+3
| | | | | | | | | | | | | | | | | | QBluetoothDeviceDiscoveryAgent (DDA) is deleted by QBluetoothServiceDiscoveryAgent (SDA) once it receives an error or SDA is instructed to stop() the discovery process. Currently, this triggers at least two calls to the DDA's stop() function. In addition, if stop() generates an error the error call itself will call back to DDA:stop(). Therefore it create an endless loop back. This is at least true for the Android devices mentioned in the related bug report. This patch ensures that the main logic of Android's DDA::stop() is not called more than once. Further more SDA disconnects from DDA's signals to avoid a potential endless loop. Any error in DDA is not of relevance to the surrounding SDA instance anymore. Task-number: QTBUG-60131 Change-Id: I1df16f2b0896928833aa2ced75c43d4642b4fba3 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Continuously emit deviceDiscovered() signal during never-ending dev discoveryAlex Blasche2017-06-291-1/+1
| | | | | | | | | | | | If the user chooses to do a BTLE device discovery with QBluetoothDeviceDiscoveryAgent::setLowEnergyDiscoveryTimeout being set to 0, we should continuously emit the deviceDiscovered() signal and not only once per device. This patch checks the timeout value before triggering the duplication detection for deviceDiscovered() signals. Task-number: QTBUG-57847 Change-Id: I0e43b779a89b918640fe3d812d2500ed0a016cc3 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Android: Fix incorrect device search type bit flag testAlex Blasche2017-01-121-1/+3
| | | | | | | | | | | We are testing bit flags and don't require a logical AND. [ChangeLog][QtBluetooth][Android] Fixed incorrect bit flag test. This caused QBluetoothDeviceDiscoveryAgent to always request Location permissions even when only a classic device search is needed. Change-Id: I6d6bd63da9a002bcec430e1ce90d0f13d153fe9c Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Do not request an unnessessary dangerous rightLars Schmertmann2017-01-121-1/+2
| | | | | | | | | | | | | Bluetooth LE discovery needs ACCESS_COARSE_LOCATION permission since android 6.0. In the manifest file it is possible use it by "<uses-permission-sdk-23 android:name="ACCESS_COARSE_LOCATION" />" in general. But the bluetooth LE discovery requests it for every android version. This change enables the request for android > 6.0 only (API-Level >=23). Task-number: QTBUG-58085 Change-Id: I78ad2fe83eb16eaf45813137335f85c7b3930992 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-11-281-0/+8
|\ | | | | | | | | | | | | Conflicts: src/bluetooth/osx/osxbtledeviceinquiry.mm Change-Id: Iefec1aafcb81174b0e1e257246ded08841bf3259
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-11-241-0/+8
| |\ | | | | | | | | | Change-Id: Iab12802d94e2ced8b358cbeb3e70ce37d0eeec2b
| | * Android: Fix crash in QBluetoothDeviceDiscoveryAgent ctor due to Java exceptionAndré Klitzing2016-11-041-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In general BluetoothAdapter.getDefaultAdapter should not throw an exception. If the device does not support Bluetooth the function should return a null reference only. However some devices throw a RuntimeException as well. Specially the smartphone HTC 10! Even that phone supports Bluetooth. So we need to catch it to prevent unwinding of the stack. This fix is a sibling of 669b427653f8f708269431917f720f7e76680191. Task-number: QTBUG-45066 Change-Id: I6d5f71e5cc988eed02ae35665b6ef6c9e8769868 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | | Check Location permissions before running LE scan on AndroidAlex Blasche2016-09-211-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch requires new private API in QtCore to handle responses when requesting Location permissions. Task-number: QTBUG-55035 Change-Id: I3a6434b9d2d4f66094ed2a4f59667665bd0a905c Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* | | Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-09-191-5/+12
|\| | | | | | | | | | | Change-Id: Ia2ce8bf47d9156c550f5360b1422b50313854338
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-09-161-5/+12
| |\| | | | | | | | | | Change-Id: I3eec9a22565585d4fc40831d609a3083ce99a52c
| | * Android: Avoid newDevice signal spamming in QBluetoothDeviceDiscoveryAgentAlex Blasche2016-08-011-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SDP based scans and LE scans can find the saame device (address) with different device names. This is caused by the fact that different channels are used to retrieve the information. Those two channels can advertise different device names. Before this patch the first entry was added to the list of discovered devices. When the second entry with different name came about, the entry was never added to the list of discovered devices. Nevertheless the deviceDiscovered() signal was triggered each time. This lead to a situation where application which were listening to the signal only never noticed the duplicated entries and showed a new discovered device each time the address matched but not the remainder of the device info. This problem was made worse by the fact that the LE scan on Android continues to fire the new device discovered signal once per second. This patch distinguishes devices with the same address but different names. They are treated as separate entries now. Change-Id: I77259a888708309338110831e86bb7ce9253f2a6 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* | | Android: Support for individual btle/classic device searchAlex Blasche2016-07-131-10/+37
| | | | | | | | | | | | | | | | | | Task-number: QTBUG-46253 Change-Id: Ia0189228df5d219eff9e8b92cfa242bd0f28beb3 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* | | Permit selection of discovery mode (btle vs classic)Alex Blasche2016-07-131-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change introduces the new API but does not yet implement the specific selection. In any case BlueZ does not need any specific implementation as classic and BTLE devices are found using the same method. iOS does not need any specific implementation as it only supports BTLE discovery. Task-number: QTBUG-46253 Change-Id: Ie6365966091effe5f3a68f8a283657c7cb43b692 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
* | | Android: Allow to set BTLE device search timeoutAlex Blasche2016-06-171-3/+6
| | | | | | | | | | | | | | | | | | Task-number: QTBUG-53012 Change-Id: I282cb76871eec857b6df8001f9f726ee4ce91e29 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
* | | Add BTLE device discovery timeout APIAlex Blasche2016-06-151-0/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | This timeout adjusts the BTLE device discovery. Some BTLE devices require some time to show up in such a search. In general the platforms use open ended search methodologies as their own usage pattern for BTLE device discovery too. So far Qt Bluetooth limited the time through a hardcoded value which the API user could not adjust. Task-number: QTBUG-53012 Change-Id: Ia37cebd4015b438db998c6b4a265f563c1a2f89f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* | Merge remote-tracking branch 'gerrit/5.6' into 5.7Alex Blasche2016-06-091-0/+2
|\| | | | | | | Change-Id: Id8dffff9bb75db396aabf6da2a3acb78505a6476
| * Android: Don't progress device search when BTLE search is not supportedAlex Blasche2016-06-011-0/+2
| | | | | | | | | | | | | | | | | | This happens when the Android device does not support BTLE. Previously the device search agent progressed even when it claimed that it was done already. Change-Id: If14df70bba02703f5feb8bc9c0569f596defede9 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-05-191-1/+1
|\| | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: Ia9bc69bf68eb40ceb9bd5bd63d96ab4dece43c00
| * Increase the BTLE scan timeout to 25sAlex Blasche2016-05-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | It seems that some BTLE devices require more than 10s to be found. This timeout change increases the chances to find slow remote devices. The user has to cancel if he doesn't want to wait the full 25s. Task-number: QTBUG-53012 Change-Id: Id9bafbe09528619ac6dff17c33322ef90beb8829 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Updated license headersAntti Kokko2016-01-201-15/+21
|/ | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I856c13e2a6d4d12c46e1286b0ca1c092ee4608f8 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Android: Fix crashing QBluetoothDeviceDiscoveryAgent on Androids <v18v5.5.0-rc1v5.5.0Alex Blasche2015-06-101-0/+1
| | | | | | | | | | | | | | | | The new BTLE aware device discovery crashes due to a wrong internal activity state. The device discovery emits finished() signal when the SDP discovery finishes. It does not continue with BTLE scans oin Android releases 4.1.x or earlier. The signal emission causes the classes dtor to run. In turn the dtor calls stop() because the activity flag still indicates a running device scan which emits error(), which calls the classes dtor and the entire loop continues until a stack overflow is caused. Task-number: QTBUG-46588 Change-Id: If7e4af6773c6063cee11f59e0b0db477fea0c003 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
* Bugfix Andoid Bluetooth coreConfiguration data in discoveredDevicesPeter Rustler2015-05-081-2/+2
| | | | | | | | | | | | | | | | | | | | In current implementation of processDiscoveredDevices, if we receive the same device again with different coreConfiguration, the device will be just replaced. In Android there are 2 ways to scan for bluetooth devices. One is the scan for all bluetooth devices (including LE) and one for scanning just LE devices. Currently they are used both, which means we receive dual devices multiple times. Depending of the arrival in time of the QBluetoothDeviceInfo the coreConfiguration is different. In the List of discovered devices this lead to devices reported as LE only or classic only which is wrong. If the Application calls discoveredDevices() it will get a list with wrong coreConfiguration. This patch update the coreConfiguration of the QBluetoothDeviceInfo in list. Change-Id: I312544ca513503c5d6b31a1ca0cfbe530c0be911 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
* Update copyright headersJani Heikkinen2015-02-161-7/+7
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I3822a6484e8f7a420330de1cb1aeb0c3d1cf41b7 Reviewed-by: Sergio Ahumada <sahumada@texla.cl>
* Convert qRegisterMetaType<T>(const char*) to qRegisterMetaType<T>()Alex Blasche2015-01-281-1/+1
| | | | | | | | | | | | | | | This is much safer and cleaner. [ChangeLog][QtBluetooth][Important Behavior Changes] Q_DECLARE_METATYPE added for QBluetoothServiceDiscoveryAgent::Error, QBluetoothSocket::SocketState, QBluetoothSocket::SocketError and QBluetoothDeviceInfo. This breaks source compatibility if application code has defined the above metatypes already. The applications Q_DECLARE_METATYPE must be removed to fix the compile error. Change-Id: I1c7cb1ee25832b7e5337c9aca6f36b21e8caf22e Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Add QBLuetoothDeviceDiscoveryAgent::UnsupportedPlatformErrorAlex Blasche2014-10-301-1/+0
| | | | | | | | | | | | | | | | | iOS does not support classic Bluetooth device discovery. However since iOS 5.0 it is possible to search for Bluetooth Low Energy devices. On pre 5.0 devices tLE scan is not possible and this error enum is going to be used. In addition the enum is utilized by the default backend which is used on unsupported Bluetooth platforms. [ChangeLog][QtBluetooth][QBluetoothDeviceDiscoveryAgent] A new UnsupportedPlatformError enum value added. Change-Id: I74b85782ba1e8ac55798171151b364d5dc0aa79f Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Android: Add BluetoothLE device scanAlex Blasche2014-10-281-26/+107
| | | | | | Change-Id: Ibbb1e9f141d494327082aebaf9e34ffe44039115 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Android: Don't add the same device twice to DeviceDiscovery resultsAlex Blasche2014-10-171-0/+15
| | | | | | | | In particular this happens when scanning for BTLE devices Change-Id: Ia75ba6f510e4e47a92992638f5bb919072fceb13 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Update license headers and add new licensesJani Heikkinen2014-08-241-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I7a8b8b787fcae9a178794364efdefe1021d10b1b Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Bluez5 support for QBluetoothDeviceDiscoveryAlex Blasche2014-05-091-2/+3
| | | | | | | Task-number: QTBUG-32085 Change-Id: I31ae0dc9f0d09f3979797eb95eb87ed7bd181ae3 Reviewed-by: Oleg Shparber <trollixx@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Fix coding style in QBluetoothOleg Shparber2014-04-231-20/+25
| | | | | | | | Affected: QBluetooth, QBluetoothAddress, QBluetoothDeviceDiscoveryAgent, QBluetoothDeviceInfo, QBluetoothHostInfo, QBluetoothLocalDevice Change-Id: Ia5af61f87eafecfba56b75fa61b81014cdd38960 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Android: Fix crashes due to concurrency issuesAlex Blasche2014-03-111-1/+4
| | | | | | | | | | | | | | | BroadcastReceiver.onReceive() is executed in the main thread whereas the Qt classes are in a different thread. This created issues whereby Java's qtObject pointer was reset by the Qt classes/thread but onReceive still trying to access the same object later on. In most cases the Qt classes using BroadcastReceiver were half way through their object tear down. This patch fixes the problem by guarding qtObject against concurrent thread access and ensures that the qtObject pointer is reset before the object tear down starts. Change-Id: Iab97b0af8e10686d97419ac8504f2fe69e9536f3 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Normalize signal & slot signaturesAlex Blasche2014-02-271-2/+2
| | | | | | Change-Id: I81fd5cc89d88e4527778c6aed4cddeb0648dd812 Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Adjust strings for translationAlex Blasche2014-02-131-5/+5
| | | | | | | | This includes unification of error messages, fixes for spelling mistakes, hints for translators and other forms of simplifications. Change-Id: Idd0e01614b24ff2d19133f0d19d49649d59e3f57 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
* Port QtBluetooth to AndroidAlex Blasche2014-02-131-0/+205
This is a feature merge to dev targeting Qt 5.3. Known issues: -QTBUG-36754: QBluetoothServer::close() crashes -QTBUG-36763: QBluetothTransferManager port to Android not possible -QTBUG-36764: Improve QBluetoothLocalDevice::connectedDevices() -QTBUG-36810: Remove direct use of Android action strings The above issues and some other minor TODO's will be addressed until final release time. Task-number: QTBUG-33792 [ChangeLog][QtBluetooth][Android] QtBluetooth has been ported to Android. Change-Id: I31ba83e3b7d6aa68e7258b7e43235de7d1a6e68a Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>