mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-02 23:12:57 +01:00
Mi Band 8: Fix watchface upload
This commit is contained in:
parent
27fba50283
commit
cab63b2c98
@ -276,21 +276,18 @@ public class XiaomiCharacteristic {
|
|||||||
final boolean encrypt = isEncrypted && authService.isEncryptionInitialized();
|
final boolean encrypt = isEncrypted && authService.isEncryptionInitialized();
|
||||||
|
|
||||||
if (encrypt) {
|
if (encrypt) {
|
||||||
currentPayload.setBytesToSend(authService.encrypt(currentPayload.getBytesToSend(), encryptedIndex));
|
currentPayload.setBytesToSend(authService.encrypt(currentPayload.getBytesToSend(), incrementNonce ? encryptedIndex : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldWriteChunked(currentPayload.getBytesToSend())) {
|
if (shouldWriteChunked(currentPayload.getBytesToSend())) {
|
||||||
if (encrypt) {
|
if (encrypt && incrementNonce) {
|
||||||
// Prepend encrypted index for the nonce
|
// Prepend encrypted index for the nonce
|
||||||
currentPayload.setBytesToSend(
|
currentPayload.setBytesToSend(
|
||||||
ByteBuffer.allocate(2 + currentPayload.getBytesToSend().length).order(ByteOrder.LITTLE_ENDIAN)
|
ByteBuffer.allocate(2 + currentPayload.getBytesToSend().length).order(ByteOrder.LITTLE_ENDIAN)
|
||||||
.putShort(encryptedIndex)
|
.putShort(encryptedIndex++)
|
||||||
.put(currentPayload.getBytesToSend())
|
.put(currentPayload.getBytesToSend())
|
||||||
.array()
|
.array()
|
||||||
);
|
);
|
||||||
if (incrementNonce) {
|
|
||||||
encryptedIndex++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("Sending {} - chunked", currentPayload.getTaskName());
|
LOG.debug("Sending {} - chunked", currentPayload.getTaskName());
|
||||||
@ -319,9 +316,10 @@ public class XiaomiCharacteristic {
|
|||||||
buf.put((byte) 2); // 2 for command
|
buf.put((byte) 2); // 2 for command
|
||||||
buf.put((byte) (encrypt ? 1 : 2));
|
buf.put((byte) (encrypt ? 1 : 2));
|
||||||
if (encrypt) {
|
if (encrypt) {
|
||||||
buf.putShort(encryptedIndex);
|
|
||||||
if (incrementNonce) {
|
if (incrementNonce) {
|
||||||
encryptedIndex++;
|
buf.putShort(encryptedIndex++);
|
||||||
|
} else {
|
||||||
|
buf.putShort((short) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf.put(currentPayload.getBytesToSend()); // it's already encrypted
|
buf.put(currentPayload.getBytesToSend()); // it's already encrypted
|
||||||
|
@ -244,6 +244,7 @@ public class XiaomiWatchfaceService extends AbstractXiaomiService implements Xia
|
|||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
setWatchface(fwHelper.getId());
|
setWatchface(fwHelper.getId());
|
||||||
|
requestWatchfaceList();
|
||||||
}
|
}
|
||||||
|
|
||||||
fwHelper = null;
|
fwHelper = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user