From c44918108389d290efc774492979e2e6d8ad2c96 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 27 Feb 2016 11:39:50 +0100 Subject: [PATCH] Pebble: store appKeys in .json also. Rumour says someone needs it soon... --- .../devices/pebble/PBWInstallHandler.java | 12 +++++++++++- .../gadgetbridge/devices/pebble/PBWReader.java | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 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 1619467b8..4071c83df 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 @@ -3,6 +3,8 @@ package nodomain.freeyourgadget.gadgetbridge.devices.pebble; import android.content.Context; import android.net.Uri; +import org.json.JSONException; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -158,10 +160,18 @@ public class PBWInstallHandler implements InstallHandler { } try { LOG.info(app.getJSON().toString()); - writer.write(app.getJSON().toString()); + JSONObject appJSON = app.getJSON(); + JSONObject appKeysJSON = mPBWReader.getAppKeysJSON(); + if (appKeysJSON != null) { + appJSON.put("appKeys", appKeysJSON); + } + writer.write(appJSON.toString()); + writer.close(); } catch (IOException e) { LOG.error("Failed to write to output file: " + e.getMessage(), e); + } catch (JSONException e) { + LOG.error(e.getMessage(), e); } } 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 ad8f6e118..e463dd443 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 @@ -58,6 +58,8 @@ public class PBWReader { private int mIconId; private int mFlags; + private JSONObject mAppKeys = null; + public PBWReader(Uri uri, Context context, String platform) throws FileNotFoundException { this.uri = uri; cr = context.getContentResolver(); @@ -201,6 +203,10 @@ public class PBWReader { appCreator = json.getString("companyName"); appVersion = json.getString("versionLabel"); appUUID = UUID.fromString(json.getString("uuid")); + if (json.has("appKeys")) { + mAppKeys = json.getJSONObject("appKeys"); + LOG.info("found appKeys:" + mAppKeys.toString()); + } } catch (JSONException e) { isValid = false; e.printStackTrace(); @@ -317,4 +323,8 @@ public class PBWReader { public int getIconId() { return mIconId; } -} \ No newline at end of file + + public JSONObject getAppKeysJSON() { + return mAppKeys; + } +}