mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 11:26:47 +01:00
Fossil HR: added inidividual notification IDs
This commit is contained in:
parent
b290e035f1
commit
ac1b1b0a7a
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user