From 44fcd454a0286e28153c384a9d49418364585699 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 26 Aug 2021 10:33:33 +0200 Subject: [PATCH] Mi Band 6: Make new auth protocol a setting for now --- .../gadgetbridge/service/devices/huami/HuamiSupport.java | 2 +- .../service/devices/huami/operations/InitOperation2021.java | 6 +----- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/devicesettings_miband6.xml | 5 +++++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java index e26a1b536..1b3040fd9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java @@ -254,7 +254,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport { needsAuth = false; characteristicChunked2021Write = getCharacteristic(HuamiService.UUID_CHARACTERISTIC_CHUNKEDTRANSFER_2021_WRITE); characteristicChunked2021Read = getCharacteristic(HuamiService.UUID_CHARACTERISTIC_CHUNKEDTRANSFER_2021_READ); - if (characteristicChunked2021Write != null) { + if (characteristicChunked2021Write != null && GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean("force_new_protocol", false)) { new InitOperation2021(authenticate, authFlags, cryptFlags, this, builder).perform(); } else { new InitOperation(authenticate, authFlags, cryptFlags, this, builder).perform(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/InitOperation2021.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/InitOperation2021.java index 18205bbd6..04d5ce1aa 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/InitOperation2021.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/InitOperation2021.java @@ -146,7 +146,7 @@ public class InitOperation2021 extends InitOperation { huamiSupport.setInitialized(builder); huamiSupport.performImmediately(builder); } catch (Exception e) { - LOG.error("faild initializing device", e); + LOG.error("failed initializing device", e); } return true; } else { @@ -161,17 +161,13 @@ public class InitOperation2021 extends InitOperation { lastSequenceNumber = sequenceNumber; if (reassembleBuffer_pointer == reassembleBuffer_expectedBytes) { System.arraycopy(reassembleBuffer, 0, remoteRandom, 0, 16); - LOG.info("remoteRandom: " + GB.hexdump(remoteRandom)); System.arraycopy(reassembleBuffer, 16, remotePublicEC, 0, 48); - LOG.info("remotePublicEC: " + GB.hexdump(remotePublicEC)); sharedEC = ecdh_generate_shared(privateEC, remotePublicEC); - LOG.info("sharedEC: " + GB.hexdump(sharedEC)); byte[] secretKey = getSecretKey(); for (int i = 0; i < 16; i++) { finalSharedSessionAES[i] = (byte) (sharedEC[i + 8] ^ secretKey[i]); } - LOG.info("sharedSessionAES: " + GB.hexdump(finalSharedSessionAES)); try { byte[] encryptedRandom1 = encryptAES(remoteRandom, secretKey); byte[] encryptedRandom2 = encryptAES(remoteRandom, finalSharedSessionAES); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 761611996..1985e3460 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -219,6 +219,8 @@ Connect new device button Always visible Visible only if no device is added + New Auth Protocol + Enable if your device no longer connects after a firmware upgrade Units Time format diff --git a/app/src/main/res/xml/devicesettings_miband6.xml b/app/src/main/res/xml/devicesettings_miband6.xml index c63722450..d793dd747 100644 --- a/app/src/main/res/xml/devicesettings_miband6.xml +++ b/app/src/main/res/xml/devicesettings_miband6.xml @@ -28,4 +28,9 @@ android:key="language" android:summary="%s" android:title="@string/pref_title_language" /> +