mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-25 16:15:55 +01:00
Mi Watch Lite: more small fixes for non-encrypted path
This commit is contained in:
parent
b103b4f3e4
commit
a19318c5bd
@ -140,7 +140,7 @@ public class XiaomiCharacteristic {
|
|||||||
if (chunk == numChunks) {
|
if (chunk == numChunks) {
|
||||||
sendChunkEndAck();
|
sendChunkEndAck();
|
||||||
|
|
||||||
if (authService != null) {
|
if (isEncrypted) {
|
||||||
// chunks are always encrypted if an auth service is available
|
// chunks are always encrypted if an auth service is available
|
||||||
handler.handle(authService.decrypt(chunkBuffer.toByteArray()));
|
handler.handle(authService.decrypt(chunkBuffer.toByteArray()));
|
||||||
} else {
|
} else {
|
||||||
@ -157,9 +157,10 @@ public class XiaomiCharacteristic {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case 0:
|
case 0:
|
||||||
// Chunked start request
|
// Chunked start request
|
||||||
final byte one = buf.get(); // ?
|
final byte messageEncrypted = buf.get();
|
||||||
if (one != 1) {
|
byte expectedResult = (byte) (isEncrypted ? 1 : 0);
|
||||||
LOG.warn("Chunked start request: expected 1, got {}", one);
|
if (messageEncrypted != expectedResult) {
|
||||||
|
LOG.warn("Chunked start request: expected {}, got {}", expectedResult, messageEncrypted);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
numChunks = buf.getShort();
|
numChunks = buf.getShort();
|
||||||
@ -258,7 +259,7 @@ public class XiaomiCharacteristic {
|
|||||||
buf.putShort((short) 0);
|
buf.putShort((short) 0);
|
||||||
buf.put((byte) 0);
|
buf.put((byte) 0);
|
||||||
buf.put((byte) (isEncrypted ? 1 : 0));
|
buf.put((byte) (isEncrypted ? 1 : 0));
|
||||||
buf.putShort((short) Math.max(1,Math.round(currentSending.length / 247.0)));
|
buf.putShort((short) Math.max(1, Math.round(currentSending.length / 247.0)));
|
||||||
|
|
||||||
final TransactionBuilder builder = mSupport.createTransactionBuilder("send chunked start");
|
final TransactionBuilder builder = mSupport.createTransactionBuilder("send chunked start");
|
||||||
builder.write(bluetoothGattCharacteristic, buf.array());
|
builder.write(bluetoothGattCharacteristic, buf.array());
|
||||||
|
Loading…
Reference in New Issue
Block a user