diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil/notification/PlayCallNotificationRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil/notification/PlayCallNotificationRequest.java index 52dda71be..bab646123 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil/notification/PlayCallNotificationRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil/notification/PlayCallNotificationRequest.java @@ -6,9 +6,11 @@ import java.nio.ByteOrder; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter; public class PlayCallNotificationRequest extends PlayNotificationRequest { + private final static int MESSAGE_ID_CALL = 1; + public PlayCallNotificationRequest(String number, boolean callStart, FossilWatchAdapter adapter) { super(callStart ? 1 : 7, callStart ? 8 : 2, ByteBuffer.wrap(new byte[]{(byte) 0x80, (byte) 0x00, (byte) 0x59, (byte) 0xB7}).order(ByteOrder.LITTLE_ENDIAN).getInt(), - number, "Incoming Call", adapter); + number, "Incoming Call", MESSAGE_ID_CALL, adapter); } } 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 b3e0c9f09..04c2c7d64 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 @@ -28,24 +28,28 @@ import nodomain.freeyourgadget.gadgetbridge.util.StringUtils; public abstract class PlayNotificationRequest extends FilePutRequest { public PlayNotificationRequest(int notificationType, int flags, String packageName, FossilWatchAdapter adapter) { - super((short) 0x0900, createFile(notificationType, flags, packageName, packageName, packageName), adapter); + super((short) 0x0900, createFile(notificationType, flags, packageName, packageName, packageName, getCurrentMessageId()), adapter); } public PlayNotificationRequest(int notificationType, int flags, String packageName, String sender, String message, FossilWatchAdapter adapter) { - super((short) 0x0900, createFile(notificationType, flags, packageName, sender, message), adapter); + super((short) 0x0900, createFile(notificationType, flags, packageName, sender, message, getCurrentMessageId()), adapter); } - public PlayNotificationRequest(int notificationType, int flags, int packageCRC, String sender, String message, FossilWatchAdapter adapter) { - super((short) 0x0900, createFile(notificationType, flags, "whatever", sender, message, packageCRC), adapter); + public PlayNotificationRequest(int notificationType, int flags, int packageCRC, String sender, String message, int messageId, FossilWatchAdapter adapter) { + super((short) 0x0900, createFile(notificationType, flags, "whatever", sender, message, packageCRC, messageId), adapter); } - private static byte[] createFile(int notificationType, int flags, String packageName, String sender, String message){ + private static int getCurrentMessageId(){ + return (int) System.currentTimeMillis(); + } + + private static byte[] createFile(int notificationType, int flags, String packageName, String sender, String message, int messageId){ CRC32 crc = new CRC32(); crc.update(packageName.getBytes()); - return createFile(notificationType, flags, packageName, sender, message, (int)crc.getValue()); + return createFile(notificationType, flags, packageName, sender, message, (int)crc.getValue(), messageId); } - private static byte[] createFile(int notificationType, int flags, String title, String sender, String message, int packageCrc) { + private static byte[] createFile(int notificationType, int flags, String title, String sender, String message, int packageCrc, int messageId) { byte lengthBufferLength = (byte) 10; byte uidLength = (byte) 4; byte appBundleCRCLength = (byte) 4; @@ -77,7 +81,7 @@ public abstract class PlayNotificationRequest extends FilePutRequest { mainBuffer.put((byte) senderBytes.length); mainBuffer.put((byte) messageBytes.length); - mainBuffer.putInt(0); // messageId + mainBuffer.putInt(messageId); mainBuffer.putInt(packageCrc); mainBuffer.put(titleBytes); mainBuffer.put(senderBytes);