mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-03 17:02:13 +01:00
Merge branch 'master' into appmanager-fragments
This commit is contained in:
commit
65ac4b364f
@ -96,23 +96,35 @@ public class PBWReader {
|
|||||||
String platformDir = "";
|
String platformDir = "";
|
||||||
|
|
||||||
if (!uri.toString().endsWith(".pbz")) {
|
if (!uri.toString().endsWith(".pbz")) {
|
||||||
platformDir = platform + "/";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* for aplite and basalt it is possible to install 2.x apps which have no subfolder
|
* for aplite and basalt it is possible to install 2.x apps which have no subfolder
|
||||||
* we still prefer the subfolders if present.
|
* we still prefer the subfolders if present.
|
||||||
* chalk needs to be its subfolder
|
* chalk needs to be its subfolder
|
||||||
*/
|
*/
|
||||||
if (platform.equals("aplite") || platform.equals("basalt") || platform.equals("diorite")) {
|
String[] platformDirs;
|
||||||
boolean hasPlatformDir = false;
|
switch (platform) {
|
||||||
|
case "basalt":
|
||||||
|
platformDirs = new String[]{"basalt/"};
|
||||||
|
break;
|
||||||
|
case "chalk":
|
||||||
|
platformDirs = new String[]{"chalk/"};
|
||||||
|
break;
|
||||||
|
case "diorite":
|
||||||
|
platformDirs = new String[]{"diorite/", "aplite/"};
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
platformDirs = new String[]{"aplite/"};
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String dir : platformDirs) {
|
||||||
InputStream afin = new BufferedInputStream(cr.openInputStream(uri));
|
InputStream afin = new BufferedInputStream(cr.openInputStream(uri));
|
||||||
|
|
||||||
ZipInputStream zis = new ZipInputStream(afin);
|
ZipInputStream zis = new ZipInputStream(afin);
|
||||||
ZipEntry ze;
|
ZipEntry ze;
|
||||||
try {
|
try {
|
||||||
while ((ze = zis.getNextEntry()) != null) {
|
while ((ze = zis.getNextEntry()) != null) {
|
||||||
if (ze.getName().startsWith(platformDir)) {
|
if (ze.getName().startsWith(dir)) {
|
||||||
hasPlatformDir = true;
|
platformDir = dir;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,13 +132,13 @@ public class PBWReader {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasPlatformDir) {
|
|
||||||
platformDir = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (platform.equals("chalk") && platformDir.equals("")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOG.info("using platformdir: '" + platformDir + "'");
|
||||||
String appName = null;
|
String appName = null;
|
||||||
String appCreator = null;
|
String appCreator = null;
|
||||||
String appVersion = null;
|
String appVersion = null;
|
||||||
|
@ -69,7 +69,7 @@ public class AppMessageHandlerMisfit extends AppMessageHandler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mPebbleProtocol.isFw3x) {
|
if (mPebbleProtocol.mFwMajor < 3) {
|
||||||
timestamp -= SimpleTimeZone.getDefault().getOffset(timestamp * 1000L) / 1000;
|
timestamp -= SimpleTimeZone.getDefault().getOffset(timestamp * 1000L) / 1000;
|
||||||
}
|
}
|
||||||
Date startDate = new Date((long) timestamp * 1000L);
|
Date startDate = new Date((long) timestamp * 1000L);
|
||||||
|
@ -296,7 +296,7 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
|||||||
if (mPBWReader.isFirmware()) {
|
if (mPBWReader.isFirmware()) {
|
||||||
writeInstallApp(mPebbleProtocol.encodeInstallFirmwareComplete());
|
writeInstallApp(mPebbleProtocol.encodeInstallFirmwareComplete());
|
||||||
finishInstall(false);
|
finishInstall(false);
|
||||||
} else if (mPBWReader.isLanguage() || mPebbleProtocol.isFw3x) {
|
} else if (mPBWReader.isLanguage() || mPebbleProtocol.mFwMajor >= 3) {
|
||||||
finishInstall(false); // FIXME: dont know yet how to detect success
|
finishInstall(false); // FIXME: dont know yet how to detect success
|
||||||
} else {
|
} else {
|
||||||
writeInstallApp(mPebbleProtocol.encodeAppRefresh(mInstallSlot));
|
writeInstallApp(mPebbleProtocol.encodeAppRefresh(mInstallSlot));
|
||||||
@ -614,7 +614,7 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
|||||||
writeInstallApp(mPebbleProtocol.encodeGetTime());
|
writeInstallApp(mPebbleProtocol.encodeGetTime());
|
||||||
} else {
|
} else {
|
||||||
GBDeviceApp app = mPBWReader.getGBDeviceApp();
|
GBDeviceApp app = mPBWReader.getGBDeviceApp();
|
||||||
if (mPebbleProtocol.isFw3x && !mPBWReader.isLanguage()) {
|
if (mPebbleProtocol.mFwMajor >= 3 && !mPBWReader.isLanguage()) {
|
||||||
if (appId == 0) {
|
if (appId == 0) {
|
||||||
// only install metadata - not the binaries
|
// only install metadata - not the binaries
|
||||||
write(mPebbleProtocol.encodeInstallMetadata(app.getUUID(), app.getName(), mPBWReader.getAppVersion(), mPBWReader.getSdkVersion(), mPBWReader.getFlags(), mPBWReader.getIconId()));
|
write(mPebbleProtocol.encodeInstallMetadata(app.getUUID(), app.getName(), mPBWReader.getAppVersion(), mPBWReader.getSdkVersion(), mPBWReader.getFlags(), mPBWReader.getIconId()));
|
||||||
|
@ -262,7 +262,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
|
|
||||||
private static final Random mRandom = new Random();
|
private static final Random mRandom = new Random();
|
||||||
|
|
||||||
boolean isFw3x = false;
|
int mFwMajor = 3;
|
||||||
boolean mForceProtocol = false;
|
boolean mForceProtocol = false;
|
||||||
GBDeviceEventScreenshot mDevEventScreenshot = null;
|
GBDeviceEventScreenshot mDevEventScreenshot = null;
|
||||||
int mScreenshotRemaining = -1;
|
int mScreenshotRemaining = -1;
|
||||||
@ -453,12 +453,12 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Long ts = System.currentTimeMillis();
|
Long ts = System.currentTimeMillis();
|
||||||
if (!isFw3x) {
|
if (mFwMajor < 3) {
|
||||||
ts += (SimpleTimeZone.getDefault().getOffset(ts));
|
ts += (SimpleTimeZone.getDefault().getOffset(ts));
|
||||||
}
|
}
|
||||||
ts /= 1000;
|
ts /= 1000;
|
||||||
|
|
||||||
if (isFw3x) {
|
if (mFwMajor >= 3) {
|
||||||
// 3.x notification
|
// 3.x notification
|
||||||
return encodeBlobdbNotification(id, (int) (ts & 0xffffffffL), title, subtitle, notificationSpec.body, notificationSpec.sourceName, hasHandle, notificationSpec.type, notificationSpec.cannedReplies);
|
return encodeBlobdbNotification(id, (int) (ts & 0xffffffffL), title, subtitle, notificationSpec.body, notificationSpec.sourceName, hasHandle, notificationSpec.type, notificationSpec.cannedReplies);
|
||||||
} else if (mForceProtocol || notificationSpec.type != NotificationType.EMAIL) {
|
} else if (mForceProtocol || notificationSpec.type != NotificationType.EMAIL) {
|
||||||
@ -500,7 +500,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
long ts = System.currentTimeMillis();
|
long ts = System.currentTimeMillis();
|
||||||
long ts_offset = (SimpleTimeZone.getDefault().getOffset(ts));
|
long ts_offset = (SimpleTimeZone.getDefault().getOffset(ts));
|
||||||
ByteBuffer buf;
|
ByteBuffer buf;
|
||||||
if (isFw3x) {
|
if (mFwMajor >= 3) {
|
||||||
String timezone = SimpleTimeZone.getDefault().getID();
|
String timezone = SimpleTimeZone.getDefault().getID();
|
||||||
short length = (short) (LENGTH_SETTIME + timezone.getBytes().length + 3);
|
short length = (short) (LENGTH_SETTIME + timezone.getBytes().length + 3);
|
||||||
buf = ByteBuffer.allocate(LENGTH_PREFIX + length);
|
buf = ByteBuffer.allocate(LENGTH_PREFIX + length);
|
||||||
@ -1194,7 +1194,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] encodeAppInfoReq() {
|
public byte[] encodeAppInfoReq() {
|
||||||
if (isFw3x) {
|
if (mFwMajor >= 3) {
|
||||||
return null; // can't do this on 3.x :(
|
return null; // can't do this on 3.x :(
|
||||||
}
|
}
|
||||||
return encodeSimpleMessage(ENDPOINT_APPMANAGER, APPMANAGER_GETUUIDS);
|
return encodeSimpleMessage(ENDPOINT_APPMANAGER, APPMANAGER_GETUUIDS);
|
||||||
@ -1202,7 +1202,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] encodeAppStart(UUID uuid, boolean start) {
|
public byte[] encodeAppStart(UUID uuid, boolean start) {
|
||||||
if (isFw3x) {
|
if (mFwMajor >= 3) {
|
||||||
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_APPRUNSTATE);
|
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_APPRUNSTATE);
|
||||||
buf.order(ByteOrder.BIG_ENDIAN);
|
buf.order(ByteOrder.BIG_ENDIAN);
|
||||||
buf.putShort(LENGTH_APPRUNSTATE);
|
buf.putShort(LENGTH_APPRUNSTATE);
|
||||||
@ -1221,7 +1221,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] encodeAppDelete(UUID uuid) {
|
public byte[] encodeAppDelete(UUID uuid) {
|
||||||
if (isFw3x) {
|
if (mFwMajor >= 3) {
|
||||||
if (UUID_PEBBLE_HEALTH.equals(uuid)) {
|
if (UUID_PEBBLE_HEALTH.equals(uuid)) {
|
||||||
return encodeActivateHealth(false);
|
return encodeActivateHealth(false);
|
||||||
}
|
}
|
||||||
@ -1317,7 +1317,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
/* pebble specific install methods */
|
/* pebble specific install methods */
|
||||||
public byte[] encodeUploadStart(byte type, int app_id, int size, String filename) {
|
public byte[] encodeUploadStart(byte type, int app_id, int size, String filename) {
|
||||||
short length;
|
short length;
|
||||||
if (isFw3x && (type != PUTBYTES_TYPE_FILE)) {
|
if (mFwMajor >= 3 && (type != PUTBYTES_TYPE_FILE)) {
|
||||||
length = LENGTH_UPLOADSTART_3X;
|
length = LENGTH_UPLOADSTART_3X;
|
||||||
type |= 0b10000000;
|
type |= 0b10000000;
|
||||||
} else {
|
} else {
|
||||||
@ -1336,7 +1336,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
buf.putInt(size);
|
buf.putInt(size);
|
||||||
buf.put(type);
|
buf.put(type);
|
||||||
|
|
||||||
if (isFw3x && (type != PUTBYTES_TYPE_FILE)) {
|
if (mFwMajor >= 3 && (type != PUTBYTES_TYPE_FILE)) {
|
||||||
buf.putInt(app_id);
|
buf.putInt(app_id);
|
||||||
} else {
|
} else {
|
||||||
// slot
|
// slot
|
||||||
@ -1724,7 +1724,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
int id;
|
int id;
|
||||||
long uuid_high = 0;
|
long uuid_high = 0;
|
||||||
long uuid_low = 0;
|
long uuid_low = 0;
|
||||||
if (isFw3x) {
|
if (mFwMajor >= 3) {
|
||||||
buf.order(ByteOrder.BIG_ENDIAN);
|
buf.order(ByteOrder.BIG_ENDIAN);
|
||||||
uuid_high = buf.getLong();
|
uuid_high = buf.getLong();
|
||||||
uuid_low = buf.getLong();
|
uuid_low = buf.getLong();
|
||||||
@ -1792,9 +1792,9 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GBDeviceEventSendBytes sendBytesAck = null;
|
GBDeviceEventSendBytes sendBytesAck = null;
|
||||||
if (isFw3x || needsAck2x) {
|
if (mFwMajor >= 3 || needsAck2x) {
|
||||||
sendBytesAck = new GBDeviceEventSendBytes();
|
sendBytesAck = new GBDeviceEventSendBytes();
|
||||||
if (isFw3x) {
|
if (mFwMajor >= 3) {
|
||||||
sendBytesAck.encodedBytes = encodeActionResponse(new UUID(uuid_high, uuid_low), icon_id, caption);
|
sendBytesAck.encodedBytes = encodeActionResponse(new UUID(uuid_high, uuid_low), icon_id, caption);
|
||||||
} else {
|
} else {
|
||||||
sendBytesAck.encodedBytes = encodeActionResponse2x(id, action, 6, caption);
|
sendBytesAck.encodedBytes = encodeActionResponse2x(id, action, 6, caption);
|
||||||
@ -2040,9 +2040,8 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
buf.get(tmp, 0, 32);
|
buf.get(tmp, 0, 32);
|
||||||
|
|
||||||
versionCmd.fwVersion = new String(tmp).trim();
|
versionCmd.fwVersion = new String(tmp).trim();
|
||||||
if (versionCmd.fwVersion.startsWith("v3")) {
|
|
||||||
isFw3x = true;
|
mFwMajor = versionCmd.fwVersion.charAt(1);
|
||||||
}
|
|
||||||
|
|
||||||
buf.get(tmp, 0, 9);
|
buf.get(tmp, 0, 9);
|
||||||
int hwRev = buf.get() + 8;
|
int hwRev = buf.get() + 8;
|
||||||
|
Loading…
Reference in New Issue
Block a user