PEbble: add database parameter to encodeBlobDBClear(), minor cleanups

here
Andreas Shimokawa 2015-12-20 00:40:38 +01:00
parent 5026cf269f
commit 35c7ab6dde
1 changed files with 14 additions and 17 deletions

View File

@ -648,24 +648,23 @@ public class PebbleProtocol extends GBDeviceProtocol {
return buf.array(); return buf.array();
} }
//TODO: works for fw 3.8 but untested for anything else private byte[] encodeBlobDBClear(byte database) {
private byte[] encodeClearDB() { final short LENGTH_BLOBDB_CLEAR = 4;
int length = 4; ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_BLOBDB_CLEAR);
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + length);
buf.order(ByteOrder.BIG_ENDIAN); buf.order(ByteOrder.BIG_ENDIAN);
buf.putShort((short) length); buf.putShort(LENGTH_BLOBDB_CLEAR);
buf.putShort(ENDPOINT_BLOBDB); buf.putShort(ENDPOINT_BLOBDB);
buf.order(ByteOrder.LITTLE_ENDIAN); buf.order(ByteOrder.LITTLE_ENDIAN);
buf.put(BLOBDB_CLEAR); buf.put(BLOBDB_CLEAR);
buf.putShort((short) mRandom.nextInt()); // token buf.putShort((short) mRandom.nextInt()); // token
buf.put(BLOBDB_PIN); buf.put(database);
return buf.array(); return buf.array();
} }
public byte[] encodeTimelinePin(int id, int timestamp, short duration, int icon_id, String title) { private byte[] encodeTimelinePin(int id, int timestamp, short duration, int icon_id, String title) {
final short TIMELINE_PIN_LENGTH = 46; final short TIMELINE_PIN_LENGTH = 46;
icon_id |= 0x80000000; icon_id |= 0x80000000;
@ -1079,9 +1078,10 @@ public class PebbleProtocol extends GBDeviceProtocol {
} }
private byte[] encodePhoneVersion3x(byte os) { private byte[] encodePhoneVersion3x(byte os) {
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + 25); final short LENGTH_PHONEVERSION3X = 25;
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_PHONEVERSION3X);
buf.order(ByteOrder.BIG_ENDIAN); buf.order(ByteOrder.BIG_ENDIAN);
buf.putShort((short) 25); buf.putShort(LENGTH_PHONEVERSION3X);
buf.putShort(ENDPOINT_PHONEVERSION); buf.putShort(ENDPOINT_PHONEVERSION);
buf.put((byte) 0x01); buf.put((byte) 0x01);
buf.putInt(-1); //0xffffffff buf.putInt(-1); //0xffffffff
@ -1090,14 +1090,11 @@ public class PebbleProtocol extends GBDeviceProtocol {
buf.putInt(os); buf.putInt(os);
buf.put(PHONEVERSION_APPVERSION_MAGIC); buf.put(PHONEVERSION_APPVERSION_MAGIC);
buf.put((byte) 3); // major? buf.put((byte) 3); // major
buf.put((byte) 8); // minor? buf.put((byte) 8); // minor
buf.put((byte) 1); // patch? buf.put((byte) 1); // patch
buf.put((byte) 3); // ??? buf.order(ByteOrder.LITTLE_ENDIAN);
buf.put((byte) 0); // ??? buf.putLong(0x0000000000000003); //flags
buf.put((byte) 0); // ???
buf.put((byte) 0); // ???
buf.putInt(0); // ???
return buf.array(); return buf.array();
} }