mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-25 00:30:37 +02:00
Fossil Hybrid HR: Correctly truncate notification body when too long
The original truncation code caused the null termination of the string to be dropped, leading to several weird issues on the watch, including empty notification bodies and firmware crashes.
This commit is contained in:
parent
824d75ccc0
commit
82b3e0d963
@ -61,11 +61,11 @@ public abstract class PlayNotificationRequest extends FilePutRequest {
|
||||
byte[] titleBytes = nullTerminatedTitle.getBytes(charsetUTF8);
|
||||
String nullTerminatedSender = StringUtils.terminateNull(sender);
|
||||
byte[] senderBytes = nullTerminatedSender.getBytes(charsetUTF8);
|
||||
if (message.length() > 475) {
|
||||
message = message.substring(0, 475);
|
||||
}
|
||||
String nullTerminatedMessage = StringUtils.terminateNull(message);
|
||||
byte[] messageBytes = nullTerminatedMessage.getBytes(charsetUTF8);
|
||||
if (messageBytes.length > 490) {
|
||||
messageBytes = Arrays.copyOf(messageBytes, 475);
|
||||
}
|
||||
short mainBufferLength = (short) (lengthBufferLength + uidLength + appBundleCRCLength + titleBytes.length + senderBytes.length + messageBytes.length);
|
||||
|
||||
ByteBuffer mainBuffer = ByteBuffer.allocate(mainBufferLength);
|
||||
|
Loading…
Reference in New Issue
Block a user