mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 18:15:49 +01:00
Pebble: Do not hardcode icon id for metadata installation, properly acknowledge app fetch requests
This commit is contained in:
parent
a4f5524f6e
commit
6af0bb2754
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user