mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-27 10:07:32 +01:00
Pebble: commit missing PebbleProtocol changes for experimental notification dismissal
This commit is contained in:
parent
74e1598bf7
commit
c9ab10e7e8
@ -19,6 +19,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppManagementResult;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppManagementResult;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDismissNotification;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventScreenshot;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventScreenshot;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||||
@ -244,8 +245,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
return encodeBlobdbNotification((int) (ts & 0xffffffff), parts);
|
return encodeBlobdbNotification((int) (ts & 0xffffffff), parts);
|
||||||
} else if (mForceProtocol) {
|
} else if (mForceProtocol) {
|
||||||
// 2.x notification
|
// 2.x notification
|
||||||
String[] parts = {title, subtitle, body};
|
return encodeExtensibleNotification(id, (int) (ts & 0xffffffff), title, subtitle, body, type);
|
||||||
return encodeExtensibleNotification(id, (int) (ts & 0xffffffff), parts);
|
|
||||||
} else {
|
} else {
|
||||||
// 1.x notification on FW 2.X
|
// 1.x notification on FW 2.X
|
||||||
String[] parts = {title, body, ts.toString(), subtitle};
|
String[] parts = {title, body, ts.toString(), subtitle};
|
||||||
@ -289,11 +289,13 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
return encodeSetCallState("Where are you?", "Gadgetbridge", start ? GBCommand.CALL_INCOMING : GBCommand.CALL_END);
|
return encodeSetCallState("Where are you?", "Gadgetbridge", start ? GBCommand.CALL_INCOMING : GBCommand.CALL_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] encodeExtensibleNotification(int id, int timestamp, String[] parts) {
|
private static byte[] encodeExtensibleNotification(int id, int timestamp, String title, String subtitle, String body, byte type) {
|
||||||
|
String[] parts = {title, subtitle, body};
|
||||||
|
|
||||||
// Calculate length first
|
// Calculate length first
|
||||||
byte attributes_count = 0;
|
byte attributes_count = 0;
|
||||||
|
|
||||||
int length = 21;
|
int length = 21 + 17;
|
||||||
if (parts != null) {
|
if (parts != null) {
|
||||||
for (String s : parts) {
|
for (String s : parts) {
|
||||||
if (s == null || s.equals("")) {
|
if (s == null || s.equals("")) {
|
||||||
@ -321,7 +323,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
buf.putInt(timestamp);
|
buf.putInt(timestamp);
|
||||||
buf.put((byte) 0x01); // layout - ?
|
buf.put((byte) 0x01); // layout - ?
|
||||||
buf.put(attributes_count); // length attributes
|
buf.put(attributes_count); // length attributes
|
||||||
buf.put((byte) 0); // len actions - none so far
|
buf.put((byte) 1); // len actions - only dismiss
|
||||||
|
|
||||||
byte attribute_id = 0;
|
byte attribute_id = 0;
|
||||||
// Encode Pascal-Style Strings
|
// Encode Pascal-Style Strings
|
||||||
@ -340,17 +342,15 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ACTION
|
// ACTION
|
||||||
/*
|
|
||||||
buf.put((byte) 0x01);
|
buf.put((byte) 0x01);
|
||||||
buf.put((byte) 0x02);
|
buf.put((byte) 0x04);
|
||||||
buf.put((byte) 0x01);
|
buf.put((byte) 0x01);
|
||||||
|
|
||||||
String actionstring = "test";
|
String actionstring = "dismiss all";
|
||||||
|
|
||||||
buf.put((byte) 0x01);
|
buf.put((byte) 0x01);
|
||||||
buf.putShort((short) 4);
|
buf.putShort((short) actionstring.length());
|
||||||
buf.put(actionstring.getBytes(), 0, 4);
|
buf.put(actionstring.getBytes());
|
||||||
*/
|
|
||||||
return buf.array();
|
return buf.array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,6 +773,23 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GBDeviceEvent decodeResponseExtensibleNotifs(ByteBuffer buf, int length) {
|
||||||
|
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
|
|
||||||
|
byte command = buf.get();
|
||||||
|
if (command == 0x02) { // dismiss notification ?
|
||||||
|
int id = buf.getInt();
|
||||||
|
short unk = buf.getShort();
|
||||||
|
if (unk == 0x0001) {
|
||||||
|
GBDeviceEventDismissNotification devEvtDismissNotification = new GBDeviceEventDismissNotification();
|
||||||
|
devEvtDismissNotification.notificationID = id;
|
||||||
|
return devEvtDismissNotification;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GBDeviceEvent decodeResponse(byte[] responseData) {
|
public GBDeviceEvent decodeResponse(byte[] responseData) {
|
||||||
ByteBuffer buf = ByteBuffer.wrap(responseData);
|
ByteBuffer buf = ByteBuffer.wrap(responseData);
|
||||||
@ -997,6 +1014,9 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
case ENDPOINT_SCREENSHOT:
|
case ENDPOINT_SCREENSHOT:
|
||||||
devEvt = decodeResponseScreenshot(buf, length);
|
devEvt = decodeResponseScreenshot(buf, length);
|
||||||
break;
|
break;
|
||||||
|
case ENDPOINT_EXTENSIBLENOTIFS:
|
||||||
|
devEvt = decodeResponseExtensibleNotifs(buf, length);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user