From 7ba3a874a2ca44fbb44f3124ec792ce447e583e5 Mon Sep 17 00:00:00 2001 From: danielegobbetti Date: Mon, 25 Jan 2016 23:15:19 +0100 Subject: [PATCH 1/4] Message to activate Pebble Health, possibly. --- .../devices/pebble/PebbleProtocol.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index f0373381b..c7077c92b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -654,6 +654,38 @@ public class PebbleProtocol extends GBDeviceProtocol { return buf.array(); } + private byte[] encodeBlobdbActivateHealth() { + byte[] activityPreferences = new byte[] {0x61,0x63,0x74,0x69,0x76,0x69,0x74,0x79,0x50,0x72,0x65,0x66,0x65,0x72,0x65,0x6e,0x63,0x65,0x73}; + byte[] blob = new byte[] {0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02}; + int length = LENGTH_BLOBDB+3; + if (blob != null) { + length += blob.length + 2; + } + + ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + length); + + buf.order(ByteOrder.BIG_ENDIAN); + buf.putShort((short) length); + buf.putShort(ENDPOINT_BLOBDB); + + buf.order(ByteOrder.LITTLE_ENDIAN); + buf.put(BLOBDB_INSERT); + buf.putShort((short) mRandom.nextInt()); // token + buf.put((byte) 0x07); + buf.put((byte)activityPreferences.length); + //TODO: works this way, but perhaps should be reversed? + //buf.order(ByteOrder.BIG_ENDIAN); + buf.put(activityPreferences); + //buf.order(ByteOrder.LITTLE_ENDIAN); + + if (blob != null) { + buf.putShort((short) blob.length); + buf.put(blob); + } + + return buf.array(); + } + private byte[] encodeBlobDBClear(byte database) { final short LENGTH_BLOBDB_CLEAR = 4; ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_BLOBDB_CLEAR); From 666c53a1e4c86e0d9227de9388337ae5ab626fa3 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Tue, 26 Jan 2016 10:48:50 +0100 Subject: [PATCH 2/4] Pebble: make encodeBlobDB accept Strings and UUIDS as keys, use it for Heath activation --- .../devices/pebble/PebbleProtocol.java | 78 ++++++++++--------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index c7077c92b..87c0c3137 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -81,7 +81,7 @@ public class PebbleProtocol extends GBDeviceProtocol { static final byte BLOBDB_APP = 2; static final byte BLOBDB_REMINDER = 3; static final byte BLOBDB_NOTIFICATION = 4; - + static final byte BLOBDB_HEALTH = 7; // might also be some generic registry database static final byte BLOBDB_SUCCESS = 1; static final byte BLOBDB_GENERALFAILURE = 2; static final byte BLOBDB_INVALIDOPERATION = 3; @@ -216,7 +216,6 @@ public class PebbleProtocol extends GBDeviceProtocol { static final short LENGTH_APPFETCH = 2; static final short LENGTH_APPRUNSTATE = 17; - static final short LENGTH_BLOBDB = 21; static final short LENGTH_PING = 5; static final short LENGTH_PHONEVERSION = 17; static final short LENGTH_REMOVEAPP_2X = 17; @@ -623,9 +622,25 @@ public class PebbleProtocol extends GBDeviceProtocol { return buf.array(); } - private byte[] encodeBlobdb(UUID uuid, byte command, byte db, byte[] blob) { + private byte[] encodeBlobdb(Object key, byte command, byte db, byte[] blob) { + + int length = 5; + + int key_length; + if (key instanceof UUID) { + key_length = LENGTH_UUID; + } else if (key instanceof String) { + key_length = ((String) key).getBytes().length; + } else { + LOG.warn("unknown key type"); + return null; + } + if (key_length > 255) { + LOG.warn("key is too long"); + return null; + } + length += key_length; - int length = LENGTH_BLOBDB; if (blob != null) { length += blob.length + 2; } @@ -640,11 +655,17 @@ public class PebbleProtocol extends GBDeviceProtocol { buf.put(command); buf.putShort((short) mRandom.nextInt()); // token buf.put(db); - buf.put(LENGTH_UUID); - buf.order(ByteOrder.BIG_ENDIAN); - buf.putLong(uuid.getMostSignificantBits()); - buf.putLong(uuid.getLeastSignificantBits()); - buf.order(ByteOrder.LITTLE_ENDIAN); + + buf.put((byte) key_length); + if (key instanceof UUID) { + UUID uuid = (UUID) key; + buf.order(ByteOrder.BIG_ENDIAN); + buf.putLong(uuid.getMostSignificantBits()); + buf.putLong(uuid.getLeastSignificantBits()); + buf.order(ByteOrder.LITTLE_ENDIAN); + } else { + buf.put(((String) key).getBytes()); + } if (blob != null) { buf.putShort((short) blob.length); @@ -654,36 +675,17 @@ public class PebbleProtocol extends GBDeviceProtocol { return buf.array(); } - private byte[] encodeBlobdbActivateHealth() { - byte[] activityPreferences = new byte[] {0x61,0x63,0x74,0x69,0x76,0x69,0x74,0x79,0x50,0x72,0x65,0x66,0x65,0x72,0x65,0x6e,0x63,0x65,0x73}; - byte[] blob = new byte[] {0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02}; - int length = LENGTH_BLOBDB+3; - if (blob != null) { - length += blob.length + 2; + private byte[] encodeBlobdbActivateHealth(boolean activate) { + byte[] blob; + byte command; + if (activate) { + command = BLOBDB_INSERT; + blob = new byte[]{0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02}; + } else { + command = BLOBDB_DELETE; + blob = null; } - - ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + length); - - buf.order(ByteOrder.BIG_ENDIAN); - buf.putShort((short) length); - buf.putShort(ENDPOINT_BLOBDB); - - buf.order(ByteOrder.LITTLE_ENDIAN); - buf.put(BLOBDB_INSERT); - buf.putShort((short) mRandom.nextInt()); // token - buf.put((byte) 0x07); - buf.put((byte)activityPreferences.length); - //TODO: works this way, but perhaps should be reversed? - //buf.order(ByteOrder.BIG_ENDIAN); - buf.put(activityPreferences); - //buf.order(ByteOrder.LITTLE_ENDIAN); - - if (blob != null) { - buf.putShort((short) blob.length); - buf.put(blob); - } - - return buf.array(); + return encodeBlobdb("activityPreferences", command, BLOBDB_HEALTH, blob); } private byte[] encodeBlobDBClear(byte database) { From b9cb89ab8b2285f498663bcdd232f0aec0009bea Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Tue, 26 Jan 2016 23:05:54 +0100 Subject: [PATCH 3/4] Component diagram giving an overview (created with umbrello) --- app/src/main/assets/devintro.png | Bin 0 -> 15586 bytes app/src/main/assets/devintro.xmi | 175 +++++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100644 app/src/main/assets/devintro.png create mode 100644 app/src/main/assets/devintro.xmi diff --git a/app/src/main/assets/devintro.png b/app/src/main/assets/devintro.png new file mode 100644 index 0000000000000000000000000000000000000000..6fc1a5935225628c74997c0ea15d14aaf82fc86e GIT binary patch literal 15586 zcmc(`byOYQn83Hg(4BT!aqk1iG8E_@B3h0)Z^J*1$5>Lo==Ozi51 zEr|@q6&(XZkXsW4rg|dg|GiskS5xRZ4!%x@510GUrw16I)gDZ$$1hO&P@^^{j`({R zwrqxy;Mr03U>Wig=%!8$W0X^mvDMsw>nJT85SKqH<#bq8r&TA846XqZsE$58Mf466 zMIV?It>2S_6iJ#O#tWkYD<1_rWnEu^XLH$tWysy2u{O|aL4VYLd7dwTI1YUWQXUM^ z#REUFJG|E50{q)!ASW;LT7(LoU+Th5vHYqFDUvisjDHeDX2LUo0oBpB z(*FCS|IH2gU)sI@-O6aE_rDezLBu>%0xeMTt4%Phtf-_*DZ-aJNsyvl4qO9K`QMvi zH+$3oJxhP9=LgrdYB)yCjbYp(^%PD77M8jX<#UB%BUqq1ebk&g24+c1`eyfmUma#6 zNe7gl<3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) zE*lus)nHj8QOb4~zkT7XagZ+#!)`oQwdR%611c)qcKjY|Yua8RRkRh@t<;zG3uE|g zX<5#|=SgoT8y#pzK6vcn0xHFEndN4AWGiuZQH!5359ZL`7Fbq9C}zb>PbcAsBg-bZ zl2U+FOH?%BU2x^l?mIk{(0`wA9_c^YD!XwbqcBzg-=%elN=uE+HLi&i6-(SdSrlum zT#8y`!CMU@a@onulr$Up3ESFE)-i5v#buz$Vz~}P&~LOELIh_Zk}okYb$DFq8qI;| zEc(%F&0X~8!8b1M6EeX&qMQOWD=!T$E6}yH2WFuqHmFXWmiF|l*lb#wbAXzXDmO{4 ztiPfof+g4L-%!hc-xT|Qz@-yayax>#JY@-I3D9kT%`R + + + + umbrello uml modeller http://umbrello.kde.org + 1.6.9 + UnicodeUTF8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 33cf76172bf2b679c0480925ef011b7ec113501e Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Wed, 27 Jan 2016 23:00:44 +0100 Subject: [PATCH 4/4] Pebble: add hack to enable and maybe disable Health from the App Manager activity --- .../gadgetbridge/activities/AppManagerActivity.java | 9 ++++++++- .../service/devices/pebble/PebbleIoThread.java | 5 +++++ .../service/devices/pebble/PebbleProtocol.java | 7 +++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java index 19d07b165..172f5285c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java @@ -31,6 +31,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAppAdapter; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp; +import nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.PebbleProtocol; import nodomain.freeyourgadget.gadgetbridge.util.FileUtils; @@ -76,6 +77,7 @@ public class AppManagerActivity extends Activity { List systemApps = new ArrayList<>(); systemApps.add(new GBDeviceApp(UUID.fromString("4dab81a6-d2fc-458a-992c-7a1f3b96a970"), "Sports (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); systemApps.add(new GBDeviceApp(UUID.fromString("cf1e816a-9db0-4511-bbb8-f60c48ca8fac"), "Golf (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); + systemApps.add(new GBDeviceApp(PebbleProtocol.UUID_PEBBLE_HEALTH, "Health (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); return systemApps; } @@ -155,7 +157,7 @@ public class AppManagerActivity extends Activity { AdapterView.AdapterContextMenuInfo acmi = (AdapterView.AdapterContextMenuInfo) menuInfo; selectedApp = appList.get(acmi.position); - if (!selectedApp.isInCache()) { + if (!selectedApp.isInCache() && !PebbleProtocol.UUID_PEBBLE_HEALTH.equals(selectedApp.getUUID())) { menu.removeItem(R.id.appmanager_app_reinstall); } menu.setHeaderTitle(selectedApp.getName()); @@ -168,6 +170,11 @@ public class AppManagerActivity extends Activity { GBApplication.deviceService().onAppDelete(selectedApp.getUUID()); return true; case R.id.appmanager_app_reinstall: + if (PebbleProtocol.UUID_PEBBLE_HEALTH.equals(selectedApp.getUUID())) { + GBApplication.deviceService().onInstallApp(Uri.parse("fake://health")); + return true; + } + File cachePath; try { cachePath = new File(FileUtils.getExternalFilesDir().getPath() + "/pbw-cache/" + selectedApp.getUUID() + ".pbw"); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java index 3d0597e08..49165df49 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java @@ -570,6 +570,11 @@ public class PebbleIoThread extends GBDeviceIoThread { return; } + if (uri.equals(Uri.parse("fake://health"))) { + write(mPebbleProtocol.encodeActivateHealth(true)); + return; + } + String hwRev = gbDevice.getHardwareVersion(); String platformName; if (hwRev.startsWith("snowy")) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index 87c0c3137..d1e3fb13f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -343,11 +343,11 @@ public class PebbleProtocol extends GBDeviceProtocol { byte last_id = -1; private final ArrayList tmpUUIDS = new ArrayList<>(); + public static final UUID UUID_PEBBLE_HEALTH = UUID.fromString("36d8c6ed-4c83-4fa1-a9e2-8f12dc941f8c"); // FIXME: store somewhere else, this is also accessed by other code private static final UUID UUID_GBPEBBLE = UUID.fromString("61476764-7465-7262-6469-656775527a6c"); private static final UUID UUID_MORPHEUZ = UUID.fromString("5be44f1d-d262-4ea6-aa30-ddbec1e3cab2"); private static final UUID UUID_WHETHERNEAT = UUID.fromString("3684003b-a685-45f9-a713-abc6364ba051"); private static final UUID UUID_MISFIT = UUID.fromString("0b73b76a-cd65-4dc2-9585-aaa213320858"); - private static final UUID UUID_PEBBLE_HEALTH = UUID.fromString("36d8c6ed-4c83-4fa1-a9e2-8f12dc941f8c"); private static final UUID UUID_PEBBLE_TIMESTYLE = UUID.fromString("4368ffa4-f0fb-4823-90be-f754b076bdaa"); private static final UUID UUID_PEBSTYLE = UUID.fromString("da05e84d-e2a2-4020-a2dc-9cdcf265fcdd"); @@ -675,7 +675,7 @@ public class PebbleProtocol extends GBDeviceProtocol { return buf.array(); } - private byte[] encodeBlobdbActivateHealth(boolean activate) { + public byte[] encodeActivateHealth(boolean activate) { byte[] blob; byte command; if (activate) { @@ -1092,6 +1092,9 @@ public class PebbleProtocol extends GBDeviceProtocol { @Override public byte[] encodeAppDelete(UUID uuid) { if (isFw3x) { + if (UUID_PEBBLE_HEALTH.equals(uuid)) { + return encodeActivateHealth(false); + } return encodeBlobdb(uuid, BLOBDB_DELETE, BLOBDB_APP, null); } else { ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_REMOVEAPP_2X);