From 35c7ea4049e5b416047e382dfb4d29d7eb06e5f1 Mon Sep 17 00:00:00 2001 From: hackoder Date: Sun, 15 Mar 2020 09:44:47 +0100 Subject: [PATCH] Set max limit on notification body (Fossil Hybrid HR). (#1820) Set max limit on notification body. --- .../fossil/notification/PlayNotificationRequest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil/notification/PlayNotificationRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil/notification/PlayNotificationRequest.java index 977c6e0d2..b3e0c9f09 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil/notification/PlayNotificationRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil/notification/PlayNotificationRequest.java @@ -19,6 +19,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fo import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; +import java.util.Arrays; import java.util.zip.CRC32; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter; @@ -57,7 +58,9 @@ public abstract class PlayNotificationRequest extends FilePutRequest { byte[] senderBytes = nullTerminatedSender.getBytes(charsetUTF8); String nullTerminatedMessage = StringUtils.terminateNull(message); byte[] messageBytes = nullTerminatedMessage.getBytes(charsetUTF8); - + if (messageBytes.length > 490) { + messageBytes = Arrays.copyOf(messageBytes, 490); + } short mainBufferLength = (short) (lengthBufferLength + uidLength + appBundleCRCLength + titleBytes.length + senderBytes.length + messageBytes.length); ByteBuffer mainBuffer = ByteBuffer.allocate(mainBufferLength);