1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 02:25:50 +01:00

Fossil Hybrid HR: Show app versions

This commit is contained in:
Arjan Schrijver 2022-07-04 17:12:41 +02:00
parent 6625437a5f
commit 951772626c
6 changed files with 15 additions and 8 deletions

View File

@ -122,11 +122,12 @@ public abstract class AbstractAppManagerFragment extends Fragment {
for (int i = 0; i < appCount; i++) { for (int i = 0; i < appCount; i++) {
String appName = intent.getStringExtra("app_name" + i); String appName = intent.getStringExtra("app_name" + i);
String appCreator = intent.getStringExtra("app_creator" + i); String appCreator = intent.getStringExtra("app_creator" + i);
String appVersion = intent.getStringExtra("app_version" + i);
UUID uuid = UUID.fromString(intent.getStringExtra("app_uuid" + i)); UUID uuid = UUID.fromString(intent.getStringExtra("app_uuid" + i));
GBDeviceApp.Type appType = GBDeviceApp.Type.values()[intent.getIntExtra("app_type" + i, 0)]; GBDeviceApp.Type appType = GBDeviceApp.Type.values()[intent.getIntExtra("app_type" + i, 0)];
Bitmap previewImage = getAppPreviewImage(uuid.toString()); Bitmap previewImage = getAppPreviewImage(uuid.toString());
GBDeviceApp app = new GBDeviceApp(uuid, appName, appCreator, "", appType, previewImage); GBDeviceApp app = new GBDeviceApp(uuid, appName, appCreator, appVersion, appType, previewImage);
app.setOnDevice(true); app.setOnDevice(true);
if (filterApp(app)) { if (filterApp(app)) {
appList.add(app); appList.add(app);

View File

@ -47,7 +47,7 @@ public class FossilAppWriter {
this.mContext = context; this.mContext = context;
if (this.mContext == null) throw new AssertionError("context cannot be null"); if (this.mContext == null) throw new AssertionError("context cannot be null");
this.version = version; this.version = version;
if (!this.version.matches("^[0-9]\\.[0-9]\\.[0-9]\\.[0-9]$")) throw new AssertionError("Version must be in x.x.x.x format"); if (!this.version.matches("^[0-9]\\.[0-9]$")) throw new AssertionError("Version must be in x.x format");
this.code = code; this.code = code;
if (this.code.size() == 0) throw new AssertionError("At least one code file InputStream must be supplied"); if (this.code.size() == 0) throw new AssertionError("At least one code file InputStream must be supplied");
this.icons = icons; this.icons = icons;
@ -75,10 +75,12 @@ public class FossilAppWriter {
int offsetFileEnd = offsetConfig + configData.length; int offsetFileEnd = offsetConfig + configData.length;
ByteArrayOutputStream filePart = new ByteArrayOutputStream(); ByteArrayOutputStream filePart = new ByteArrayOutputStream();
filePart.write(0x1); // 1 = watchface, 2 = app
String[] versionParts = this.version.split("\\."); String[] versionParts = this.version.split("\\.");
for (String versionPart : versionParts) { for (String versionPart : versionParts) {
filePart.write(Integer.valueOf(versionPart).byteValue()); filePart.write(Integer.valueOf(versionPart).byteValue());
} }
filePart.write(0x0);
filePart.write(intToLEBytes(0)); filePart.write(intToLEBytes(0));
filePart.write(intToLEBytes(0)); filePart.write(intToLEBytes(0));
filePart.write(intToLEBytes(offsetCode)); filePart.write(intToLEBytes(offsetCode));

View File

@ -135,7 +135,9 @@ public class FossilFileReader {
buf.order(ByteOrder.LITTLE_ENDIAN); buf.order(ByteOrder.LITTLE_ENDIAN);
buf.position(8); // skip file handle and version buf.position(8); // skip file handle and version
int fileSize = buf.getInt(); int fileSize = buf.getInt();
foundVersion = (int)buf.get() + "." + (int)buf.get() + "." + (int)buf.get() + "." + (int)buf.get(); buf.get(); // 1 = watchface, 2 = app
foundVersion = (int)buf.get() + "." + (int)buf.get();
buf.get(); // unknown
mAppKeys.put("version", foundVersion); mAppKeys.put("version", foundVersion);
buf.position(buf.position() + 8); // skip null bytes buf.position(buf.position() + 8); // skip null bytes
jerryStart = buf.getInt(); jerryStart = buf.getInt();

View File

@ -211,7 +211,7 @@ public class HybridHRWatchfaceFactory {
} catch (JSONException e) { } catch (JSONException e) {
LOG.warn("Could not generate configuration", e); LOG.warn("Could not generate configuration", e);
} }
FossilAppWriter appWriter = new FossilAppWriter(context, "1.2.0.0", code, icons, layout, displayName, config); FossilAppWriter appWriter = new FossilAppWriter(context, "1.0", code, icons, layout, displayName, config);
return appWriter.getWapp(); return appWriter.getWapp();
} }

View File

@ -334,6 +334,7 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
for (int i = 0; i < appCount; i++) { for (int i = 0; i < appCount; i++) {
appInfoIntent.putExtra("app_name" + i, appInfoEvent.apps[i].getName()); appInfoIntent.putExtra("app_name" + i, appInfoEvent.apps[i].getName());
appInfoIntent.putExtra("app_creator" + i, appInfoEvent.apps[i].getCreator()); appInfoIntent.putExtra("app_creator" + i, appInfoEvent.apps[i].getCreator());
appInfoIntent.putExtra("app_version" + i, appInfoEvent.apps[i].getVersion());
appInfoIntent.putExtra("app_uuid" + i, appInfoEvent.apps[i].getUUID().toString()); appInfoIntent.putExtra("app_uuid" + i, appInfoEvent.apps[i].getUUID().toString());
appInfoIntent.putExtra("app_type" + i, appInfoEvent.apps[i].getType().ordinal()); appInfoIntent.putExtra("app_type" + i, appInfoEvent.apps[i].getType().ordinal());
} }

View File

@ -38,10 +38,11 @@ public class ApplicationsListRequest extends FileLookupAndGetRequest{
buffer.get(); // null byte buffer.get(); // null byte
byte handle = buffer.get(); byte handle = buffer.get();
int hash = buffer.getInt(); int hash = buffer.getInt();
String version = String.format( buffer.get(); // unknown
"%d.%d.%d.%d", int version_minor = buffer.get();
buffer.get(), buffer.get(), buffer.get(), buffer.get() int version_major = buffer.get();
); buffer.get(); // unknown
String version = String.format("%d.%d", version_major, version_minor);
applicationInfos.add(new ApplicationInformation( applicationInfos.add(new ApplicationInformation(
name, name,
version, version,