summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/android
Commit message (Collapse)AuthorAgeFilesLines
* Fix concurrent access to QBluetoothSocket::canReadLine() on AndroidAlex Blasche2017-06-292-0/+7
| | | | | | | | | | | | | | | | | | | | | On Android, the socket's read buffer is managed in the Java thread. QBluetoothSocket::canReadLine() is public API (most likely) being called by in the main Qt thread though. The function directly called into the Java buffer instance without proper locking. This can create race conditions. Starting with this patch canReadLine() calls another QBluetoothSocketPrivate indirection to allow a platform specific implementation. This affects WinRT, BlueZ and the dummy backend too. This is not an issue on macOS as its implementation of QBluetoothSocket is separate and does not have to deal with multiple QBluetoothSocketPrivate implementations. Task-number: QTBUG-58190 Task-number: QTBUG-60830 Change-Id: Idae19f1aee6f809699d36519b01a3c68ad9c563d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Remove last qdoc warning from qtconnectivityAlex Blasche2017-06-141-1/+1
| | | | | | | | | | | src/bluetooth/android/devicediscoverybroadcastreceiver.cpp:240: warning: Cannot tie this documentation to anything [I found a /*! ... */ comment, but there was no topic command (e.g., '\fn', '\page') in the comment and no function definition following the comment.] The file referenced in the warning does not contribute to the QtBluetooth documentation. The patch removes qdoc annotation from the file. Change-Id: Ie5699d79a12e5fc1851a924adbf50ebcb5059454 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Fix a lot of minor issues in the new Android peripheral backendAlex Blasche2017-01-241-2/+2
| | | | | | Change-Id: I3aa89926c5237ee8da18b73f66f0c7a321a83c91 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Android: Implement QLEService::descriptorWritten() signals for peripheralAlex Blasche2017-01-243-0/+27
| | | | | Change-Id: I60e5bdce4256804754909c2538aebe581897e1e9 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Android: Implement QLEService::characteristicChanged() for peripheral modeAlex Blasche2017-01-243-0/+27
| | | | | | | | | Emits the above signal when the remote client successfully updates a characteristic. Change-Id: I236b1f92b682028bc10be798192f46bffc981101 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Android: Keep track of peripheral advertisement errorsAlex Blasche2017-01-233-0/+18
| | | | | | | | | | If advertisement fails then we drop back into the unconnected state and provide a more detailed error message for individual advertisement errors. Change-Id: Ic9de02b456409cd1a2dec11e53c884fe368ae267 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Android: Implement QLEC::stateChanged() notificationAlex Blasche2017-01-231-0/+10
| | | | | | Change-Id: Id2cabd9df7b5387fe5e6f1c898fe02e40f7c0a3d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Android: Beginnings of Android Bluetooth Peripheral supportAlex Blasche2017-01-232-6/+13
| | | | | | | | | | | | | Focus is on the Java side of things. The Gatt server & LE advertiser can be started and stopped. This patch builds the foundation for future changes. The C++ side is only very rudimentary and a lot of debugging helper are left inside the new code sections. Change-Id: Ic56da3ec6471ccb438fc2088fbf5eeb3053d5cf1 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* LE/Android: Fix crash due to references leakKonstantin Ritt2016-12-301-1/+4
| | | | | | | | | | in f945ffc90f8f11d73dc87f2d82bb2d246d446e71, a very basic scanRecord parser has been added, which calls GetByteArrayElements without releasing the elemnts, causing JNI core exception > E/dalvikvm: Failed adding to JNI pinned array ref table (1023 entries) Change-Id: I272593c232f0c87c1983f1f568aa6c3599d44253 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* LE/Android: Pass list of advertised services found in scan recordAlex Blasche2016-11-116-12/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the advertising packet (scan record) received from BLE devices during scanning on Android devices is ignored. Consequently, the serviceUuids() method of the QBluetoothDeviceInfo class returns an empty list for BLE devices. However, this list provides important information needed by clients to identify whether a given device is of interest. This changeset implements parsing of the scan record received from the Android Bluetooth layer. The Java byte array is passed over JNI to the C++ adapter classes, where it's parsed to find any service UUIDs being advertised by the device. Parsing the scan record ourselves is required for compatibility (Qt uses "old-style" LE scan API from Android api level 18.) All found UUIDs are added to a list which is subsequently passed to the user of the QBluetoothDeviceDiscoveryAgent class via the deviceDiscovered(QBluetoothDeviceInfo&) signal. Note: not all Android devices pass the full advertisement data. The service UUID list may be empty in those cases. [ChangeLog][QtBluetooth][Android] Parse list of advertised services found in LE scan record and pass them to API client via QBluetoothDeviceInfo::serviceUuids() Task-number: QTBUG-56625 Change-Id: I253f1b841c7b15b3bbabc9e478de87c81979815e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Remove not needed Log output from Android Device DiscoveryAlex Blasche2016-11-071-1/+0
| | | | | Change-Id: Ibe1871578394fa1e0f039425036ab0dd5223be49 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-09-161-11/+298
|\ | | | | | | Change-Id: I3eec9a22565585d4fc40831d609a3083ce99a52c
| * Android: Device discovery doesn't provide major & minor device class infoAlex Blasche2016-08-011-11/+298
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QBluetoothDeviceDiscoveryAgent did not extract the QBluetoothDeviceInfo::majorDeviceClass() and QBluetoothDeviceInfo::minorDeviceClass() information. The Android API provides info for all major device classes. However not each major device class has its set of API for the minor device class information. Caching is applied to match Android major device class values against their matching Qt enum. When a matching entry is found, the value is added to the cache. In principle, the mechanism is applied for minor device class values. However since there are many many more minor device class fields, the caching is a bit more proactive. The patch will proactively read and cache all minor device class values for a given major device class. This avoids a large overhead of very long if..else if...else if..else statements. Change-Id: I26a6c29c6f5dca6d4f3b4b25902cda03a10ae5de Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* | Make QtBluetooth Low Energy work when Qt runs as Android serviceAlex Blasche2016-08-031-2/+2
| | | | | | | | | | Change-Id: Ic0814c3f5a65ce9ac9236c41397400fc42abb572 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* | Make Classic QtBluetooth work as an Android serviceAlex Blasche2016-08-032-4/+6
| | | | | | | | | | Change-Id: Ibde0242b058f728fd7e060b37f427c208325db13 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-011-0/+5
|\| | | | | | | Change-Id: I64352b6cc066255972874e2f9c28abff35f0d613
| * Make sure JNI_OnLoad is not called more than onceBogDan Vatra2016-07-201-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Since Android 5.0 Google introduce a nasty bug[1] which calls JNI_OnLoad more than once. Basically every time when a library is loaded JNI_OnLoad is called if found, but it calls *again* JNI_OnLoad of its .so dependencies! [1] Workaround https://code.google.com/p/android/issues/detail?id=215069 Change-Id: I2894dd24afa9c51582f20ab44d83e9ce86751716 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-02-162-2/+2
|\| | | | | | | | | | | | | | | Conflicts: .qmake.conf src/bluetooth/qlowenergycontroller_bluez.cpp Change-Id: I00f45a2a22a045e7836f2caeb76cc5599ced6279
| * Android: Fix QBluetoothSocket::bytesAvailable()Alex Blasche2016-01-072-2/+2
| | | | | | | | | | | | | | Task-number: QTBUG-50345 Change-Id: I721b98f9b6ccff2a987a6c477d08902332ce848c Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Updated license headersAntti Kokko2016-01-2016-231/+327
|/ | | | | | | | | | 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>
* Fix trivial typosKonstantin Ritt2015-12-041-1/+1
| | | | | | | | | Braodcast -> Broadcast subsequemtly -> subsequently discovred -> discovered Change-Id: I1e9d83bb0b33ad15da1f05d8a7cdd8ba82232f42 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Add missing "We mean it" comments to private headers.Friedemann Kleint2015-10-091-0/+11
| | | | | Change-Id: I4e78a2b263fb779253556201fd20fe47a2afc58e Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Port from Q_ENUMS to new macro Q_ENUMKonstantin Ritt2015-06-231-2/+0
| | | | | | | | | | | Remove Q_ENUMS in favor of the new Q_ENUM macro which provides registration as meta enum and a debug stream operator. Register some enums via Q_ENUM to improve debug output and types auto-registration. Change-Id: I31c9535a2de7da1783b4ec967612c02a57cb62ff Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Android: Implement error reporting for char & desc readingAlex Blasche2015-04-153-0/+20
| | | | | | Change-Id: I5652075b4fde4d4927e86f5394baf176f263104f Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-1616-112/+112
| | | | | | | | | 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>
* Merge remote-tracking branch 'gerrit/5.4' into devAlex Blasche2015-02-111-2/+2
|\ | | | | | | Change-Id: Ia70c3fe64e2ffcb27181bf912b06e6af59d2bc92
| * Android: Enable pairing for Android v15+Alex Blasche2015-02-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The required API became public in Android v19 which is what was used as check so far. However the same API was already privately provided since Android v15. THis patch ensures that older Android versions can create pairing requests too. This patch was provided by George Najarian. Task-number: QTBUG-43757 Change-Id: I0f38e538a972341a6acf719098f1010e52b639b7 Reviewed-by: BogDan Vatra <bogdan@kde.org> Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
* | Convert qRegisterMetaType<T>(const char*) to qRegisterMetaType<T>()Alex Blasche2015-01-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Android: characteristic changed notification supportAlex Blasche2014-11-243-0/+26
| | | | | | | | | | | | Change-Id: I4c50df7d758390989c2e2127f7646e5d2dc34712 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Support for QLEService::writeDescriptor() on AndroidAlex Blasche2014-11-143-0/+32
| | | | | | | | | | | | Change-Id: I1c7f0491506c6f0512d097a419660c5f5e7fb144 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Support for QLEService::writeCharacteristic() on AndroidAlex Blasche2014-11-123-0/+32
| | | | | | | | | | | | | | | | Currently only the WriteWithResponse mode works and has been tested. Change-Id: I7947b67f737f5878a01704c09d3a9a532a41b820 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Avoid one large memory allocation per read descriptor/characteristicAlex Blasche2014-11-111-16/+6
| | | | | | | | | | | | | | | | | | We directly allocate into the QByteArray which continues to manage the memory for us. Change-Id: I39cd314a3cc9fcfd6bcf28836e0222d6d9a4f04f Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | The service->characteristic->descriptor tree becomes available in QtAlex Blasche2014-11-113-16/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the same time this fixes bugs the following bugs: 1.) Non-readable characteristics were not visible 2.) Crashes when descriptor/characteristic values were empty 3.) QLEService::discoverServiceDetails always finished with an UnknownError Missing/incorrect are still service details such as included services and the service type (which currently always defaults to primary service). Change-Id: Id73013a3784cd3c3f632102f13f5459ab37e95a6 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Propagate Charactereristic data to Qt layerAlex Blasche2014-11-103-1/+46
| | | | | | | | | | | | | | | | | | Although this makes the lowenergyscanner example functionally complete, descriptor data and service meta data are still not accessable via the Qt API. Change-Id: Ifb84010b4fea054357c07424ac30116d1e4f9de0 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Majority of service detail discovery code on AndroidAlex Blasche2014-11-103-0/+20
| | | | | | | | | | | | | | | | | | | | Primarily the change adds the required data structures and interfaces on the Java side. What is missing is the reporting of the discovery details back to Qt. Change-Id: I37f2e17bb0f87b4c526f1b43a933b9b09b22be72 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Discover BTLE services on remote device on AndroidAlex Blasche2014-11-043-2/+22
| | | | | | | | | | | | Change-Id: Ia39e2ad21b0e84cb16a355337370ba82a11b75d0 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | Android: Add ability to (dis)connect to BTLE devices on AndroidAlex Blasche2014-11-044-2/+197
| | | | | | | | | | | | | | | | and keep tracking the connection state Change-Id: If4d05fa18c78802ae06096884fba78eed123e77f Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | Android: Add BluetoothLE device scanAlex Blasche2014-10-286-46/+95
| | | | | | | | | | | | Change-Id: Ibbb1e9f141d494327082aebaf9e34ffe44039115 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | Android: Determine the Bluetooth type of the remote deviceAlex Blasche2014-10-281-0/+58
|/ | | | | | | | This requires Android version 18 or higher. Change-Id: I62495721ab888e48a7fdecb7d95c35d461904046 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Merge remote-tracking branch 'origin/5.3' into 5.4Frederik Gladhorn2014-08-287-0/+78
|\ | | | | | | | | | | | | Conflicts: src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp Change-Id: Ie8bf1903f9c7c1ccd5b05a3f97049ae0882b88b8
| * Add missing private headers warningSamuel Gaist2014-08-187-0/+78
| | | | | | | | | | Change-Id: I0f079a9b1b45bd2d2e946e06d7688f299a9c3fc3 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | Update license headers and add new licensesJani Heikkinen2014-08-2414-252/+140
|/ | | | | | | | | - 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>
* Fix uncategorised usage of qWarning().Alex Blasche2014-05-091-2/+2
| | | | | Change-Id: Iee8b8e619f1679fe9b6e8aed47d05f7414417043 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
* Fix discovery hanging in unrecoverable state due to incorrect error handlingAlex Blasche2014-04-161-1/+5
| | | | | | | | | | | | | | | | | The discovery of services happens in a sequentiali per-device order. Once the first device's services were found, the results are processed and the discovery is started on the next device. Unfortunately if the search didn't create any results due to the remote device refusing the SDP discovery or because the given remote Bluetooth address was not valid, the discovery agent didn't continue with the next device. Now the error handling ensures that the discovery process is continued with the next device (if there is any). Task-number: QTBUG-38362 Change-Id: Ie27bbc5327eadc4bcc31b589227c51dc4fa2c7c1 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
* Android: Fix crashes due to concurrency issuesAlex Blasche2014-03-112-6/+2
| | | | | | | | | | | | | | | 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>
* Android: Don't directly use java field valuesAlex Blasche2014-03-113-25/+44
| | | | | | | | | Action strings were previously converted. This patch fixes all non-action fields. Task-number: QTBUG-36810 Change-Id: I4011c619e900dcb4137c6552046f0342327a7288 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android: Don't directly use the action string values but refer to the fields.Alex Blasche2014-03-118-57/+260
| | | | | | | | | | | | | This increases the robustness of the code since the field value is not an implementation detail. In addition we guard the action field lookup against fields which have been introduced later than the standard SDK version 10 supported by Qt. Task-number: QTBUG-36810 Change-Id: Ib6582e77202d40aaf116fe8dfa81562d89367ea2 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Fix crash when interrupting QBluetoothSocket's input stream threadAlex Blasche2014-02-273-78/+81
| | | | | | | | | | | | The previous QThread did not always properly resume when InputStream.read() was interrupted by BluetoothSocket.close(). This patch converts the QThread to a Java thread which works as the Android API docs suggested. Task-number: QTBUG-37061 Change-Id: Id6ac9b57a28f3b532cbe49ff1dfdc9d1e6432aaa Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Android: Fix crash in QBluetoothServer::close()Alex Blasche2014-02-273-137/+122
| | | | | | | | | | | | | | Java's BluetoothSocketServer.accept() is meant to be interrupted via BluetoothSocketServer.close(). Unfortunately if the surrounding thread is a QThread the returning accept call crashes the thread. This does not happen if it is a Java Thread. This commit changes the server's private backend to a Java thread. Task-number: QTBUG-36754 Change-Id: I5aacc5444bbcd1275a11743b6aa04d2b11a5b22b Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Port QtBluetooth to AndroidAlex Blasche2014-02-1314-0/+1533
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>