summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2019-07-03 20:47:48 +0300
committerKonstantin Ritt <ritt.ks@gmail.com>2019-07-08 13:42:43 +0000
commitad7cf667faa49521482b1a73d7732479adc4a70f (patch)
tree606cfda63f37716daeebe63de4d7045047331580
parenta39f1357cc79cab9a0d7ea28986486b47b203422 (diff)
LE/Android: better use of recently introduced AuthorizationError
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>
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java4
1 files changed, 3 insertions, 1 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 9f10c32a..c6ffbbf4 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
@@ -229,7 +229,6 @@ public class QtBluetoothLE {
case BluetoothGatt.GATT_FAILURE: // Android's equivalent of "do not know what error it is"
errorCode = 1; break; //QLowEnergyController::UnknownError
case 8: // BLE_HCI_CONNECTION_TIMEOUT
- case 22: // BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION
Log.w(TAG, "Connection Error: Try to delay connect() call after previous activity");
errorCode = 5; break; //QLowEnergyController::ConnectionError
case 19: // BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION
@@ -238,6 +237,9 @@ public class QtBluetoothLE {
Log.w(TAG, "The remote host closed the connection");
errorCode = 7; //QLowEnergyController::RemoteHostClosedError
break;
+ case 22: // BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION
+ // Internally, Android maps PIN_OR_KEY_MISSING to GATT_CONN_TERMINATE_LOCAL_HOST
+ errorCode = 8; break; //QLowEnergyController::AuthorizationError
default:
Log.w(TAG, "Unhandled error code on connectionStateChanged: " + status + " " + newState);
errorCode = status; break; //TODO deal with all errors