| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
to make the code less error prone
Change-Id: I429bf367c9d44f24356f4ee70c0f6045b0557604
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
|
|
|
|
|
| |
Change-Id: Id45e5ed41bf97dc9940c5047e4e7a046e65d62bd
Reviewed-by: Thiemo van Engelen <tvanengelen@victronenergy.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The Android API that is available to write to a characteristic requires
the user to first set the new value of the characteristic and then tell
Android to write the value to the device. If the phone processes an
incoming change for this same characteristic in between the setting of
the value and the actual write, it could happen that the characteristic
gets the incoming value and that incoming value is then sent to the
connected device. Something similar could occur for the incoming change
as the received value is not passed in the callback but it is set on the
characteristic and the user is expected to read the received value from
the characteristic.
To prevent these problems, a new connectGatt function that takes a
Handler as extra argument was added to SDK v26. The callbacks are then
always executed via this handler and thus on the associated handler
thread. If the user also performs all writes on this thread, the
described race condition can no longer occur.
This could have solved the problems, but Android 8.0 contained a race
condition in the callback part because it set the value of the
characteristic before passing the callback to the handler, still
allowing the same race condition for incoming changed. This was fixed in
Android 8.1.
This commit causes the code to use a Handler and the new connectGatt
function if it is running on SDK >= 27, which is associated with Android
8.1.
For older SDK versions, a different solution is implemented. In this
case, a temporary BluetoothGattCharacteristic is instantiated that can
hold the value to be written. This way, the write can no longer
interfere with changes that are being received. To instantiate the
BluetoothGattCharacteristic, a private constructor is invoked using
reflection. This private constructor is needed as only this constructor
allows to create an instance that has the required information for
Android to be able to write to the charatceristic (such as the
associated service and instanceId). This is also the reason why this
solution cannot be used on newer SDK's as this constructor is
blacklisted and a warning box will be shown when reflection is used to
get a reference to it. Because a temporary BluetoothGattCharacteristic
is instantiated that holds the written value, it is necessary to store
the value that was written and pass that in the callback.
More information on these Android issues and solution direction can be
found here:
https://stackoverflow.com/questions/38922639/how-could-i-achieve-maximum-thread-safety-with-a-read-write-ble-gatt-characteris
https://medium.com/@martijn.van.welie/making-android-ble-work-part-3-117d3a8aee23
Change-Id: I5a9eda501a20933e37f758a3114bf71ec3e7cfd4
Reviewed-by: Thiemo van Engelen <tvanengelen@victronenergy.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
|
|
|
|
|
|
|
|
|
|
|
| |
Calling stopLeScan() causes a runtime exception.
The patch prevents a crash due to the exception and progresses
as if nothing has happened. An action that turned off the
internal Bluetooth device has stopped a runnung discovery anyway.
Fixes: QTBUG-67482
Change-Id: Iff377884c50cafa1f74dafe73e0acbb31b13e9bb
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The BTLE server can disconnect by own choice and by remotely initiated
disconnect. Often the app might want to readvertise the same service
right after the disconnect. Such a readvertisement fails when the
BluetoothGattServer instance is not recreated, before calling
BluetoothGattServer.addService(). In the case of remote disconnects
we never recreated the BluetoothGattServer instance therefore the
readvertisement always failed. This patch fixes the issue by ensureing
the previous instance is properly discarded.
Change-Id: I39380ee6f1f39bd71a5b73ec82bb786b3e199665
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
|
|\
| |
| |
| |
| |
| |
| | |
Conflicts:
src/bluetooth/doc/src/bluetooth-index.qdoc
Change-Id: If353b4ac63c72d6f94415e1349a206ade4ceb52e
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
leDescriptorRead() serves two pruposes. Firstly, it informs Qt of the
value/result of the read operation. During service discovery it is also
used to inform Qt that a descriptor was found. This info is used
to build up the internal data structure representing the service, its
characteristics and its descriptors.
If we have a non-readable descriptor the read failed (as expected)
and Qt was never informed about the existence of the descriptor. During
service discovery the primary purpose is to inform about the existence
of a descriptor though.
This patch ensures the notification comes through and we accept the fact
that the passed value is not known.
Fixes: QTBUG-78201
Change-Id: Id73a27c90905cb769f1cd168b48299d580587594
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
when Android receives GATT_INSUFFICIENT_AUTHORIZATION or GATT_INSUFFICIENT_ENCRYPTION,
it breaks connection with fair reason GATT_CONN_TERMINATE_LOCAL_HOST,
which shadows the original GATT_INSUFFICIENT_ENCRYPTION from the user.
As we didn't see Android closing connection with GATT_CONN_TERMINATE_LOCAL_HOST
in cases other than described above, naively treat it like AuthorizationError
Change-Id: I43a19c9eaf793a595765850938d757a09324a545
Reviewed-by: Evgeniy Gagarin <eeiaao@gmail.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
|/
|
|
|
|
|
|
|
|
|
|
| |
The new API requires Android SDK v21 or higher and Qt 5.13 just raised
the minimum API version to 21. The PendingIntent version of the same API
cannot be used yet as it requires v24+.
Fixes: QTBUG-67482
Change-Id: Ided02e36796ef66f0244934ef67262f1e6f69b8c
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Andrew Dolby <andrewdolby@gmail.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
|
|
|
|
|
|
|
| |
Call to includedServices() from Qt side after unexpected disconnection
leads to NullPointerException due to unchecked member access. Fix that!
Change-Id: Iae89801d7af86d5a3f34ebba9eb2ea12da252cd2
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
|
|
|
|
| |
Change-Id: I2202fa305f4c50e97ae7701096b2f8e0bb9b3daf
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Method enableForegroundDispatch and disableForegroundDispatch is not
implemented on some WearOS devices and will throw an exception.
Let's check if the NFC feature exists.
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at org.qtproject.qt5.android.bindings.QtApplication.invokeDelegateMethod(QtApplication.java:157)
at org.qtproject.qt5.android.bindings.QtApplication.invokeDelegate(QtApplication.java:146)
at org.qtproject.qt5.android.bindings.QtActivity.onResume(QtActivity.java:626)
at com.governikus.ausweisapp2.MainActivity.onResume(MainActivity.java:139)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1355)
at android.app.Activity.performResume(Activity.java:7117)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3556)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3621)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1638)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.UnsupportedOperationException
at android.nfc.NfcAdapter.enableForegroundDispatch(NfcAdapter.java:1315)
at org.qtproject.qt5.android.nfc.QtNfc$1.run(QtNfc.java:135)
at android.app.Activity.runOnUiThread(Activity.java:6184)
at org.qtproject.qt5.android.nfc.QtNfc.start(QtNfc.java:111)
at org.qtproject.qt5.android.QtNative.updateApplicationState(Native Method)
at org.qtproject.qt5.android.QtNative.setApplicationState(QtNative.java:260)
at org.qtproject.qt5.android.QtActivityDelegate.onResume(QtActivityDelegate.java:1098)
... 16 more
See: https://stackoverflow.com/questions/48437854/huawei-watch-2-nfc-feature-not-available-android-wear-2-0
Change-Id: I0e2cad3dce1c3c0a2ea2545fcc6731e2621cdc38
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
|
|
|
|
|
|
|
| |
c8e6dae2d9749179327df460755282cf5102e902 introduced this requirement.
Change-Id: If0b20a666d6dad999db05dfe311b0ed75aa333ff
Reviewed-by: Lars Schmertmann <lars.schmertmann@governikus.de>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
|
|
|
|
|
|
|
| |
To avoid polling of the NFC adapter state
a signal is added to the QNearFieldManager.
Change-Id: If9e1e8025cca2deb1338fa7db255ebe171cab823
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
|\
| |
| |
| | |
Change-Id: Ia496130e0d71a85670af3ca1cadf81c71d3c2462
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The patch fixes the obvious problem of the crash. The question is however
what might have caused entries to be empty. The only theoretical explanation
is the remote device being disconnected (which resets most internal data).
Task-number: QTBUG-65826
Change-Id: I6b3509248f795d9cee5dcfe0c6e0caf06405b4e4
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
|
|\|
| |
| |
| | |
Change-Id: I1cb008cda8abe9a4167f3f62f003583141d217c1
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This patch addresses two bugs. Firstly it ensures that the correct Java
function is executed when disconectFromDevice() is called on Android
peripheral.
Secondly, it turned out that calling disconnectFromDevice() while a
connection to a central exists and restarting the advertisement
resulted in a non-functional QLEController instance because
BluetoothGattServer was not properly restarted. As a side effects
the controller's state tracking stopped as well.
Change-Id: I98851fc974ceff2a1fcb03fe754dbda9c4aba271
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
|
|\|
| |
| |
| | |
Change-Id: Ib695b1c1e59904f65bf60f0fe9878483e608e737
|
| |
| |
| |
| |
| |
| |
| |
| | |
The values were never obtained on the Java side.
Task-number: QTBUG-67651
Change-Id: Ifceb124b07cf505c4e96fe7ba9d58364b3923c3a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
|
|/
|
|
|
|
|
|
| |
Add API method isSupported to allow to check if the device supports NFC
Task-number: QTBUG-62169
Change-Id: I4ff7f06348ecc902e66ee79bdd8abde672578904
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This removes the pre-dexed JAR files activated by the absence of the
bundled_jar_file CONFIG option, as versions of Android >= 5 no longer
support this deployment mechanism.
Now, the "bundled" JARs simply become normal JARs containing class
files, and are neither activated by a bundled_jar_file CONFIG entry nor
do they have a -bundled suffix in the file's base name.
Task-number: QTBUG-62995
Change-Id: Ifc13542ff71844da7e80cefe9ff51e3d7cdfc830
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
|
|\
| |
| |
| | |
Change-Id: Ida3681a873698f22c28bc60230ca0c49d2a9d25f
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
|/
|
|
|
| |
Change-Id: Iaaa79b2f14e7abd5d849895301ed404efa079f07
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|\
| |
| |
| |
| |
| |
| | |
Conflicts:
src/bluetooth/qbluetoothsocket_bluez.cpp
Change-Id: I37e21b3c636a241a357bc81fc23da51303b94623
|
| |
| |
| |
| |
| | |
Change-Id: Iee2f8e02a926129dfdd1c82d0fa84dfbb45303d3
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| | |
Change-Id: I28a165c7b7503b1c8159dd0c46f3f7450e599c74
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
| |
| |
| |
| |
| |
| | |
Change-Id: I3aa89926c5237ee8da18b73f66f0c7a321a83c91
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
| |
| |
| |
| |
| | |
Change-Id: I60e5bdce4256804754909c2538aebe581897e1e9
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
|\|
| |
| |
| | |
Change-Id: I9684e4cc76336250b235a261fdc8924a2ca70086
|
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| | |
Change-Id: I0fed368384fbfd4e9e8be74b7a586cbf2ed10218
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| | |
Change-Id: Id2cabd9df7b5387fe5e6f1c898fe02e40f7c0a3d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| | |
Change-Id: I4403a9d5c79fae2c6bbe9c478660ead01dc16fe4
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
|
|/
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|