From 0e41cb7262b2d756f527de91dc0e64991bbbfd4c Mon Sep 17 00:00:00 2001 From: ActiveLook-Dev Date: Fri, 27 Jan 2023 16:56:24 +0100 Subject: [PATCH 1/2] fix: Fix stackoverflow in very specific case --- .../core/ble/GlassesGattCallbackImpl.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ActiveLookSDK/src/main/java/com/activelook/activelooksdk/core/ble/GlassesGattCallbackImpl.java b/ActiveLookSDK/src/main/java/com/activelook/activelooksdk/core/ble/GlassesGattCallbackImpl.java index 0b56a0c..6cd1410 100644 --- a/ActiveLookSDK/src/main/java/com/activelook/activelooksdk/core/ble/GlassesGattCallbackImpl.java +++ b/ActiveLookSDK/src/main/java/com/activelook/activelooksdk/core/ble/GlassesGattCallbackImpl.java @@ -88,13 +88,21 @@ void reconnect(final BluetoothDevice device) { this.gatt = this.gattDelegate; } - private void optimizeMtu(final int optimalMtu) { - if (optimalMtu > this.mtu) { - if (!this.gatt.requestMtu(optimalMtu)) { - this.optimizeMtu(optimalMtu - 1); + private void optimizeMtu(int optimalMtu) { + while (optimalMtu > this.mtu) { + if (this.gatt.requestMtu(optimalMtu)) { + return; + } + optimalMtu = optimalMtu - 1; + } + int errorCount = 0; + while (!this.gatt.discoverServices()) { + errorCount = errorCount + 1; + if (errorCount > 10) { + this.unlockConnection(); + this.disconnect(); + return; } - } else if (!this.gatt.discoverServices()) { - this.optimizeMtu(optimalMtu); } } From ddde456a83d038bc9fb927102e6b922837372925 Mon Sep 17 00:00:00 2001 From: ActiveLook-Dev Date: Fri, 27 Jan 2023 16:59:36 +0100 Subject: [PATCH 2/2] bump version 4.4.1 --- CHANGELOG.md | 5 +++++ README.md | 2 +- build.gradle | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7740536..de5d937 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## Version 4.4.1 + +### Fixes +- Remove recursive call to avoid stackoverflow + ## Version 4.4.0 ### Breaking changes diff --git a/README.md b/README.md index afed93d..3a81718 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ You can add the dependency in your application by modifying the application `bui and add: ``` dependencies { - implementation 'com.github.activelook:android-sdk:v4.4.0' + implementation 'com.github.activelook:android-sdk:v4.4.1' } ``` diff --git a/build.gradle b/build.gradle index f521857..0156ec7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.sdkGroupId = "com.activelook" - ext.sdkVersionCode = 440 - ext.sdkVersionName = '4.4.0' + ext.sdkVersionCode = 441 + ext.sdkVersionName = '4.4.1' ext.kotlin_version = '1.6.21' repositories { google()