summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2017-04-07 12:55:39 +0200
committerAlex Blasche <alexander.blasche@qt.io>2017-04-25 09:09:33 +0000
commit417f3c3c2ca8df7b10f7fd3d9679b01b5e235c64 (patch)
tree4a5c76ec723f92812f2e3c03657e26999f9d60df
parentca9ad4f3f6af2394b23dae288c1ef2b2faaa8141 (diff)
Work around Android security permission bug when reading GATT fields
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>
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java
index 59ed0992..35680c82 100644
--- a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java
+++ b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java
@@ -1261,12 +1261,24 @@ public class QtBluetoothLE {
boolean result;
switch (nextJob.entry.type) {
case Characteristic:
- result = mBluetoothGatt.readCharacteristic(nextJob.entry.characteristic);
+ try {
+ result = mBluetoothGatt.readCharacteristic(nextJob.entry.characteristic);
+ } catch (java.lang.SecurityException se) {
+ // QTBUG-59917 -> HID services cause problems since Android 5.1
+ se.printStackTrace();
+ result = false;
+ }
if (!result)
return true; // skip
break;
case Descriptor:
- result = mBluetoothGatt.readDescriptor(nextJob.entry.descriptor);
+ try {
+ result = mBluetoothGatt.readDescriptor(nextJob.entry.descriptor);
+ } catch (java.lang.SecurityException se) {
+ // QTBUG-59917 -> HID services cause problems since Android 5.1
+ se.printStackTrace();
+ result = false;
+ }
if (!result)
return true; // skip
break;