From 151f5b8e12fcb757bd69f6b3eed5ecbc080cee89 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Tue, 11 Aug 2015 12:47:23 +0200 Subject: [PATCH] Pebble: Choose binaries from basalt/ inside .pbw files for Pebble Time PBW installation is still unsupported on FW 3.x, these are just preparations --- .../devices/pebble/PBWInstallHandler.java | 2 +- .../gadgetbridge/devices/pebble/PBWReader.java | 13 +++++++++---- .../service/devices/pebble/PebbleIoThread.java | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWInstallHandler.java index 99abfbbe2..e2722f466 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWInstallHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWInstallHandler.java @@ -25,7 +25,7 @@ public class PBWInstallHandler implements InstallHandler { public PBWInstallHandler(Uri uri, Context context) { mContext = context; - mPBWReader = new PBWReader(uri, context); + mPBWReader = new PBWReader(uri, context, ""); // FIXME: we should know the platform here mUri = uri; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWReader.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWReader.java index c7b625efc..38fad20b0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWReader.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWReader.java @@ -51,7 +51,12 @@ public class PBWReader { private boolean isValid = false; private String hwRevision = null; - public PBWReader(Uri uri, Context context) { + public PBWReader(Uri uri, Context context, String platform) { + String platformDir = ""; + if (!platform.equals("aplite")) { + platformDir = platform + "/"; + } + this.uri = uri; cr = context.getContentResolver(); @@ -71,7 +76,7 @@ public class PBWReader { try { while ((ze = zis.getNextEntry()) != null) { String fileName = ze.getName(); - if (fileName.equals("manifest.json")) { + if (fileName.equals(platformDir + "manifest.json")) { long bytes = ze.getSize(); if (bytes > 8192) // that should be too much break; @@ -102,8 +107,8 @@ public class PBWReader { int size = jo.getInt("size"); long crc = jo.getLong("crc"); byte type = entry.getValue(); - pebbleInstallables.add(new PebbleInstallable(name, size, (int) crc, type)); - LOG.info("found file to install: " + name); + pebbleInstallables.add(new PebbleInstallable(platformDir + name, size, (int) crc, type)); + LOG.info("found file to install: " + platformDir + name); isValid = true; } catch (JSONException e) { // not fatal 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 0ace462f4..54e63c01e 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 @@ -377,7 +377,7 @@ public class PebbleIoThread extends GBDeviceIoThread { mIsInstalling = true; mInstallURI = uri; - mPBWReader = new PBWReader(mInstallURI, getContext()); + mPBWReader = new PBWReader(mInstallURI, getContext(), gbDevice.getHardwareVersion().equals("dvt") ? "basalt" : "aplite"); mPebbleInstallables = mPBWReader.getPebbleInstallables(); mCurrentInstallableIndex = 0;