summaryrefslogtreecommitdiffstats
path: root/src/android
Commit message (Collapse)AuthorAgeFilesLines
* Android: Avoid hanging in desc or char read during service discoveryAlex Blasche2017-07-181-4/+5
| | | | | | | | | | | If the last entry of a service is a descriptor or characteristic and the read attempt fails early (the read could not even be initiated) ensure that the discovery state machine properly exists. So far the exit was only ever triggered by a successful read or if the async callback for the read returned with an error or timed out. Change-Id: I495982a82819aab985bc91a7e63c530b52355d9d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Add ability to negotiate the MTU on BTLE AndroidAlex Blasche2017-07-181-29/+125
| | | | | | | | | | | | | | There are cases where peripherals use a larger MTU than the default MTU on Android. This forces the MTU negotiation to always been done once the service discovery has been done. This patch requires Android API v21 (or Android v5+). If the local Android version is below 5 this feature becomes a noop. The related bug cannot be addressed on Android version below 5.0. Task-number: QTBUG-61755 Change-Id: I6521b5dad05da5e3e533ef2af56ee649b1b79730 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Handle Android's BluetoothGatt.GATT_FAILURE in QLowEnergyControllerAlex Blasche2017-06-161-0/+2
| | | | | | | | | The above error code is the equivalent of Android's Unknown error. Therefore we map the code to QLowEnergyController::UnknownError. Task-number: QTBUG-61321 Change-Id: I614c1557c453cd5426f5fa0af69011c4e768657b Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Work around Android security permission bug when reading GATT fieldsAlex Blasche2017-04-251-2/+14
| | | | | | | | | | Android throws a security exception (BLUETOOTH_PRIVILEGED) when reading HID services. Since the permission is not available for 3rdparties this is never obtainable by apps. We need to skip over those cases. Task-number: QTBUG-59917 Change-Id: I09b55740287812b0697b857d7eb8a77190d36e44 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Merge remote-tracking branch 'origin/5.8' into 5.9v5.9.0-beta3Liang Qi2017-04-181-2/+2
|\ | | | | | | | | | | | | Conflicts: src/bluetooth/qbluetoothsocket_bluez.cpp Change-Id: I37e21b3c636a241a357bc81fc23da51303b94623
| * LE/Android: fix status code descriptions5.8Konstantin Ritt2017-04-101-2/+2
| | | | | | | | | | Change-Id: Iee2f8e02a926129dfdd1c82d0fa84dfbb45303d3 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | Fix detecting simple NFC tagsOleg Evseev2017-03-311-6/+9
| | | | | | | | | | | | | | | | | | Before this patch Qt NFC detects only NDEF tags and signals targetDetected/targetLost are never fired for simple tags Task-number: QTBUG-59455 Change-Id: Ic868b6d66f35f790f6aba0ec30afc96fa32a5b6a Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Oleg Evseev <ev.mipt@gmail.com>
* | Provide support for QLEService::writeDescriptor() on Android PeripheralAlex Blasche2017-02-061-0/+38
| | | | | | | | | | | | | | | | This permits the server itself to change descriptors at runtime. Change-Id: I5d60cfb1838ba83737cd748671520c7072201bc4 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | Allow using nfc when running as a serviceLars Schmertmann2017-01-271-11/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | With this change it will be possible to use a tag injected from outside when running as a service. Intent newIntent = new Intent(); newIntent.putExtra(NfcAdapter.EXTRA_TAG, tag); QtNative.onNewIntent(newIntent); Task-number: QTBUG-57646 Change-Id: I628d4357f023a0926e7d61914b39278342ac7161 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | Implement QLEService::writeCharacteristic() for Android peripheralAlex Blasche2017-01-271-4/+195
| | | | | | | | | | | | | | | | | | | | | | This includes the correct handling of client characteristic notifications (CCNs). As per Bluetooth spec this descriptor is unique for each device. If a characteristic was changed all chars with enabled CCNs are notified. CCN settings are even retained while the remote device is not connected. Change-Id: Iec612e6a5e70206a6be0263e10e615c26def7559 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | Avoid app crash on android when using nfc within a serviceLars Schmertmann2017-01-261-0/+2
| | | | | | | | | | Change-Id: I28a165c7b7503b1c8159dd0c46f3f7450e599c74 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | Fix a lot of minor issues in the new Android peripheral backendAlex Blasche2017-01-241-1/+1
| | | | | | | | | | | | 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-241-0/+4
| | | | | | | | | | Change-Id: I60e5bdce4256804754909c2538aebe581897e1e9 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Android: Implement QLEService::characteristicChanged() for peripheral modeAlex Blasche2017-01-241-1/+4
| | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2017-01-241-2/+35
|\| | | | | | | Change-Id: I9684e4cc76336250b235a261fdc8924a2ca70086
| * [REG] LE/Android: report ServiceDiscovered for an empty services as wellKonstantin Ritt2017-01-161-0/+6
| | | | | | | | | | | | | | | | a regression has been introduced by the service discoverer refactoring, causing an empty service to stuck in DiscoveringServices state for ever Change-Id: I1d339279e77f5409231d5fbd3677f9e2eb98a0a8 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
| * Improve likelyhood that BluetoothGatt.connectGatt succeedsAlex Blasche2017-01-131-2/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The dreaded GATT_ERROR 133 (0x85) is a long standing issue in Android. There have been continued efforts to reduce it up until Android N: https://code.google.com/p/android/issues/detail?id=192561 Tests have shown that the new BluetoothGatt.connectGatt() overload is much more reliable. Android v23+ gets some relief and Android v21+ gets unofficial/hidden relief. Reports indicate that error 133 is timeing related. While the new connectGatt() call seems to resolve this problem it is throwing the timeing related error 22 more proactively. Very quick connect()/disconnect()/connect() calls can cause the error. The patch adds a more specific error code handling for error 22 to provide some hints on what the user can do to prevent it. Task-number: QTBUG-56078 Change-Id: Ib14d503701cee7ea766247b712106302cba896f3 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Android: Implement descriptor and char read/write for peripheralAlex Blasche2017-01-231-5/+85
| | | | | | | | | | | | Change-Id: I0fed368384fbfd4e9e8be74b7a586cbf2ed10218 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-231-0/+24
| | | | | | | | | | | | | | | | | | | | 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/+27
| | | | | | | | | | | | Change-Id: Id2cabd9df7b5387fe5e6f1c898fe02e40f7c0a3d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | Android: Add access to BTLE connection parametersAlex Blasche2017-01-231-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unfortunately, Android only provides access to a very generic connection priority. The patch uses the minimalInterval() to determine the desired priority. Everything below 30ms is high priority and everything above 100ms is low priority. Every other value is balanced priority. QLowEnergyController::requestConnectionUpdate() was modified to permit access when the controller is connected, discovered or in the process of being discovered. The limiting factor is an existing physical connection. The documentation was updated to reflect Android's API limitations. [ChangeLog][QtBluetooth][Android] Added access to BTLE connection parameter settings. Task-number: QTBUG-53476 Change-Id: I3e22c65bd9598296a9219463dd05f0d9fc73599d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | Add ability to export basic service data and advertiseAlex Blasche2017-01-231-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | Advertisement data and Advertisement parameter in Qt are now connected to the Android/Java side. In addition the basic service structure is supported. Descriptors and char detail export are still missing. Change-Id: I941cba5e832d76ff7beca811d08a2148367c6bf5 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | Connect QtBluetoothLEServer class to Qt's QLowEnergyController APIAlex Blasche2017-01-231-16/+16
| | | | | | | | | | | | Change-Id: I4403a9d5c79fae2c6bbe9c478660ead01dc16fe4 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-2/+210
|/ | | | | | | | | | | | | 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>
* Add characteristic even if the read failsChristian Wassmuth2017-01-121-1/+6
| | | | | | | | | | | | | If during discovery the read of a characteristic fails, then this characteristic was not added to the service. This happens in a special case and not always, when we try to read from a notify only characteristic. Now the characteristic will be added even if the read fails. Task-number: QTBUG-58056 Change-Id: Ib802eeb66aeae92da690c296faf57331123353e6 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Prevents a nil exception, if a descriptor read fails during discoveryChristian Wassmuth2017-01-121-1/+2
| | | | | | | | | During discovery, if a descriptor read fails the current implementation tries to read from a nil bytearray. Now the bytearray is checked before access. Change-Id: Ic04809fa81c25c7abdd8a82a1ccefe43de7f5605 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Android/LE: handle GATT status 8 (link loss)Konstantin Ritt2017-01-021-0/+2
| | | | | | | | May occur relatively too often to remain unhandled Change-Id: I89b1255605a29d959635e8d1965e9596b591b305 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Add timeout handling for blocking GATT requestsAlex Blasche2016-12-071-14/+171
| | | | | | | | | | | | | | | Some GATT characteristics or descriptor do not respond when a request is being submitted. This can cause a staling of the service discovery process. This commit introduces a timeout handler which fires in such cases and ensures that service detail discovery continues with the next handle. Task-number: QTBUG-52692 Change-Id: I466e13c337f28ac944190ad3bd522ca018373b30 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Merge 5.8 into 5.8.0Oswald Buddenhagen2016-11-291-2/+2
|\ | | | | | | Change-Id: I1352bca5d8b8afee5e7c06fdb1172e5f3f9678b6
| * LE/Android: Pass list of advertised services found in scan recordAlex Blasche2016-11-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 the service discovery state machine for goodAlex Blasche2016-11-291-213/+158
| | | | | | | | | | | | | | | | | | | | | | | | Now service discovery runs via the read/write queue which was already in use for normal (read|write)(characteristic|descriptor) functionality. This reduces the to be locked code section as the queue is the only locked data structure. Task-number: QTBUG-52692 Change-Id: Ide8d697b88f0ed40f83dab608b8457f45db42271 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Java uses references in container - no need to set the items in placeAlex Blasche2016-11-291-8/+2
| | | | | | | | | | | | Task-number: QTBUG-52692 Change-Id: Id9fecd98a9031f2bcb561143b66b74ccea751db2 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Add more support for new queue based service discovery systemAlex Blasche2016-11-291-0/+76
| | | | | | | | | | | | | | | | The added functions are not yet hooked into the running code. Task-number: QTBUG-52692 Change-Id: I75faade55d68719d1da91348ed17c462942659ea Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Remove runningHandle variable to simplify Android backendAlex Blasche2016-11-291-81/+68
|/ | | | | | | | | | | | | | | The runningHandle variable keeps track of the same information as the GattEntry tables. We don't need two systems. This brings initial service discovery closer to the normal read/write queue system. Ultimately the goal is to merge the initial service discovery state machine and the read/write queue system into one. This reduces blocking issues and simplifies the implementation. Task-number: QTBUG-52692 Change-Id: Idd14212cb02e6c3737b5296adf1525ff7f7832a1 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Prepare QtNfc for Android Service supportAlex Blasche2016-08-311-3/+8
| | | | | | | | | It cannot really be fixed sind Android's NFC API requires Activity objects. We merely ensure that the service case is discovered early, reported accordingly and documented properly. Change-Id: If75856eea3da5c6283a3cb988daffd7a36cc02a7 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Make QtBluetooth Low Energy work when Qt runs as Android serviceAlex Blasche2016-08-031-5/+5
| | | | | Change-Id: Ic0814c3f5a65ce9ac9236c41397400fc42abb572 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Make Classic QtBluetooth work as an Android serviceAlex Blasche2016-08-031-10/+22
| | | | | Change-Id: Ibde0242b058f728fd7e060b37f427c208325db13 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Android: Use default API version (16)BogDan Vatra2016-03-171-1/+0
| | | | | Change-Id: I4d125bbe7f18cb77dffc3747f33bba2b63b1a87d Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Bluetooth LE: Add support for Signed Write command in the central role.Christian Kandeler2016-02-171-1/+3
| | | | | | Task-number: QTBUG-41175 Change-Id: I62d74236faf9161681306d952e409e23e0cea24d Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Updated license headersAntti Kokko2016-01-205-71/+101
| | | | | | | | | | 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>
* Merge QtNfc on Android into dev/Qt 5.6Alex Blasche2015-06-097-0/+195
|\ | | | | | | Change-Id: I18f2d2d75064dffc4f21c2a7034bb63fcc5008e6
| * Merge remote-tracking branch 'gerrit/5.5' into neardAlex Blasche2015-05-111-139/+276
| |\ | | | | | | | | | Change-Id: I066a9aca0120e7002c2506959bd80a08f96f4e65
| * | Add the feature to get the nfc intent that startet the appPeter Rustler2015-03-181-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To support this one have to add a AndroidManifest.xml file to the project. In that file an intent filter should be added to get nfc intents while in backround.. The corkboard example was extended to have an example for this new feature. Change-Id: I108afd88f9e5a548d62245591ebef11de8eb0d81 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
| * | Catch the exception for disableForegroundDispatch for AndroidPeter Rustler2015-03-181-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Android Nfc disableForegroundDispatch must be called while the activity is still in foreground. We catch the thrown exception if we do call disableForegroundDispatch while we are in background. Change-Id: I396ee3fcb7c7ea835d7d5ed2cb31bf0a8cabb0a8 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
| * | Adapt to the new "onResumePause" APIPeter Rustler2015-03-181-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Anroid the foreground activity get an onResume/onPause by implemmenting callbacks. This callback will be called from android when your activity go into foreground or background. In Nfc we need to know if we are the activity in foreground for calling enableForegroundDispatch. In Android this is mandatory. To support this callback an API was added in qtbase. This patch implement an listener of this API to get that events and use some logic to enable and disable foreground dispatch of nfc tags. Change-Id: Ibceed51c5d5905a28f01081027fdf5e0e8b4ef12 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
| * | Remove the throwing code in Nfc enableForegroundDispatch for AndroidPeter Rustler2015-03-041-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Android Nfc enableForegroundDispatch must not be called while the activity is not in foreground. We have no API in current Qt to know if we are in foreground. For that we would need to be informed when a onPause/onResume in the activity was called. Then we should enable the dispatch when in foreground and disable while we are not. This Patch removes the code that throw if we do it anyway. Change-Id: I3bff7ba3f23b5ef2665f4c7f164a0bacd3e1c2d2 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
| * | Update Digia headers to QtCompany headersAlex Blasche2015-03-021-22/+14
| | | | | | | | | | | | | | | Change-Id: Iacb162fd7254b8dee28a01dcb8fbdad257289ad3 Reviewed-by: Sergio Ahumada <sahumada@texla.cl>
| * | Merge branch 'dev' into neardAlex Blasche2015-02-264-28/+28
| |\ \ | | | | | | | | | | | | Change-Id: I2db4e121d3d6b3d44a5772262f685d99118c45eb
| * \ \ Merge branch 'dev' into neardAlex Blasche2015-02-024-15/+58
| |\ \ \ | | | | | | | | | | | | | | | Change-Id: I047b281e74f31ffec0c9f2ef29a0e73b94199c25
| * | | | Removed the listening for other tags than ndefPeter Rustler2015-02-021-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implementation of nfc for Android does not support other nfc tags than ndef. This patch removes the listening for other tag technologies. Change-Id: Id8303e50bd52d641b6de8d382e485ba7417e8c09 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>