mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-26 16:41:43 +01:00
Mi Band 6: Make new auth protocol a setting for now
This commit is contained in:
parent
2c06e5d39c
commit
44fcd454a0
@ -254,7 +254,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
needsAuth = false;
|
needsAuth = false;
|
||||||
characteristicChunked2021Write = getCharacteristic(HuamiService.UUID_CHARACTERISTIC_CHUNKEDTRANSFER_2021_WRITE);
|
characteristicChunked2021Write = getCharacteristic(HuamiService.UUID_CHARACTERISTIC_CHUNKEDTRANSFER_2021_WRITE);
|
||||||
characteristicChunked2021Read = getCharacteristic(HuamiService.UUID_CHARACTERISTIC_CHUNKEDTRANSFER_2021_READ);
|
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();
|
new InitOperation2021(authenticate, authFlags, cryptFlags, this, builder).perform();
|
||||||
} else {
|
} else {
|
||||||
new InitOperation(authenticate, authFlags, cryptFlags, this, builder).perform();
|
new InitOperation(authenticate, authFlags, cryptFlags, this, builder).perform();
|
||||||
|
@ -146,7 +146,7 @@ public class InitOperation2021 extends InitOperation {
|
|||||||
huamiSupport.setInitialized(builder);
|
huamiSupport.setInitialized(builder);
|
||||||
huamiSupport.performImmediately(builder);
|
huamiSupport.performImmediately(builder);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("faild initializing device", e);
|
LOG.error("failed initializing device", e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -161,17 +161,13 @@ public class InitOperation2021 extends InitOperation {
|
|||||||
lastSequenceNumber = sequenceNumber;
|
lastSequenceNumber = sequenceNumber;
|
||||||
if (reassembleBuffer_pointer == reassembleBuffer_expectedBytes) {
|
if (reassembleBuffer_pointer == reassembleBuffer_expectedBytes) {
|
||||||
System.arraycopy(reassembleBuffer, 0, remoteRandom, 0, 16);
|
System.arraycopy(reassembleBuffer, 0, remoteRandom, 0, 16);
|
||||||
LOG.info("remoteRandom: " + GB.hexdump(remoteRandom));
|
|
||||||
System.arraycopy(reassembleBuffer, 16, remotePublicEC, 0, 48);
|
System.arraycopy(reassembleBuffer, 16, remotePublicEC, 0, 48);
|
||||||
LOG.info("remotePublicEC: " + GB.hexdump(remotePublicEC));
|
|
||||||
sharedEC = ecdh_generate_shared(privateEC, remotePublicEC);
|
sharedEC = ecdh_generate_shared(privateEC, remotePublicEC);
|
||||||
LOG.info("sharedEC: " + GB.hexdump(sharedEC));
|
|
||||||
|
|
||||||
byte[] secretKey = getSecretKey();
|
byte[] secretKey = getSecretKey();
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
finalSharedSessionAES[i] = (byte) (sharedEC[i + 8] ^ secretKey[i]);
|
finalSharedSessionAES[i] = (byte) (sharedEC[i + 8] ^ secretKey[i]);
|
||||||
}
|
}
|
||||||
LOG.info("sharedSessionAES: " + GB.hexdump(finalSharedSessionAES));
|
|
||||||
try {
|
try {
|
||||||
byte[] encryptedRandom1 = encryptAES(remoteRandom, secretKey);
|
byte[] encryptedRandom1 = encryptAES(remoteRandom, secretKey);
|
||||||
byte[] encryptedRandom2 = encryptAES(remoteRandom, finalSharedSessionAES);
|
byte[] encryptedRandom2 = encryptAES(remoteRandom, finalSharedSessionAES);
|
||||||
|
@ -219,6 +219,8 @@
|
|||||||
<string name="pref_display_add_device_fab">Connect new device button</string>
|
<string name="pref_display_add_device_fab">Connect new device button</string>
|
||||||
<string name="pref_display_add_device_fab_on">Always visible</string>
|
<string name="pref_display_add_device_fab_on">Always visible</string>
|
||||||
<string name="pref_display_add_device_fab_off">Visible only if no device is added</string>
|
<string name="pref_display_add_device_fab_off">Visible only if no device is added</string>
|
||||||
|
<string name="pref_title_huami_force_new_protocol">New Auth Protocol</string>
|
||||||
|
<string name="pref_summary_huami_force_new_protocol">Enable if your device no longer connects after a firmware upgrade</string>
|
||||||
<!-- HPlus Preferences -->
|
<!-- HPlus Preferences -->
|
||||||
<string name="pref_title_unit_system">Units</string>
|
<string name="pref_title_unit_system">Units</string>
|
||||||
<string name="pref_title_timeformat">Time format</string>
|
<string name="pref_title_timeformat">Time format</string>
|
||||||
|
@ -28,4 +28,9 @@
|
|||||||
android:key="language"
|
android:key="language"
|
||||||
android:summary="%s"
|
android:summary="%s"
|
||||||
android:title="@string/pref_title_language" />
|
android:title="@string/pref_title_language" />
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="force_new_protocol"
|
||||||
|
android:summary="@string/pref_summary_huami_force_new_protocol"
|
||||||
|
android:title="@string/pref_title_huami_force_new_protocol" />
|
||||||
</androidx.preference.PreferenceScreen>
|
</androidx.preference.PreferenceScreen>
|
||||||
|
Loading…
Reference in New Issue
Block a user