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 fb204e9e..d513c5de 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 @@ -410,7 +410,7 @@ public class PebbleIoThread extends GBDeviceIoThread { if (mPebbleProtocol.isFw3x && mForceUntested) { if (appId == 0) { // only install metadata - not the binaries - write(mPebbleProtocol.encodeInstallMetadata(app.getUUID(), app.getName(), mPBWReader.getAppVersion(), mPBWReader.getSdkVersion())); + write(mPebbleProtocol.encodeInstallMetadata(app.getUUID(), app.getName(), mPBWReader.getAppVersion(), mPBWReader.getSdkVersion(), mPBWReader.getIconId())); GB.toast("To finish installation please start the watchapp on your Pebble", 5, GB.INFO); } else { // this came from an app fetch request, so do the real stuff @@ -418,7 +418,7 @@ public class PebbleIoThread extends GBDeviceIoThread { mInstallSlot = appId; mInstallState = PebbleAppInstallState.START_INSTALL; - writeInstallApp(mPebbleProtocol.encodeGetTime()); // EVIL HACK see hack above + writeInstallApp(mPebbleProtocol.encodeAppFetchAck()); } } else { mIsInstalling = true; 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 017be70d..a463ff41 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 @@ -175,6 +175,7 @@ public class PebbleProtocol extends GBDeviceProtocol { static final short LENGTH_PREFIX = 4; static final short LENGTH_SIMPLEMESSAGE = 1; + static final short LENGTH_APPFETCH = 2; static final short LENGTH_APPRUNSTATE = 17; static final short LENGTH_PING = 5; static final short LENGTH_PHONEVERSION = 17; @@ -470,7 +471,7 @@ public class PebbleProtocol extends GBDeviceProtocol { return buf.array(); } - public byte[] encodeInstallMetadata(UUID uuid, String appName, short appVersion, short sdkVersion) { + public byte[] encodeInstallMetadata(UUID uuid, String appName, short appVersion, short sdkVersion, int iconId) { // Calculate length first final short BLOBDB_LENGTH = 23; final short METADATA_LENGTH = 126; @@ -501,7 +502,7 @@ public class PebbleProtocol extends GBDeviceProtocol { buf.putLong(uuid.getMostSignificantBits()); // watchapp uuid buf.putLong(uuid.getLeastSignificantBits()); buf.order(ByteOrder.LITTLE_ENDIAN); - buf.putInt(1); // icon_id + buf.putInt(iconId); buf.putShort(appVersion); buf.putShort(sdkVersion); buf.put((byte) 0); // app_face_bgcolor @@ -511,6 +512,17 @@ public class PebbleProtocol extends GBDeviceProtocol { return buf.array(); } + public byte[] encodeAppFetchAck() { + ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_APPFETCH); + buf.order(ByteOrder.BIG_ENDIAN); + buf.putShort(LENGTH_APPFETCH); + buf.putShort(ENDPOINT_APPFETCH); + buf.put((byte) 0x01); + buf.put((byte) 0x01); + + return buf.array(); + } + public byte[] encodeGetTime() { return encodeSimpleMessage(ENDPOINT_TIME, TIME_GETTIME); }