Pebble: store appKeys in .json also.

Rumour says someone needs it soon...
This commit is contained in:
Andreas Shimokawa 2016-02-27 11:39:50 +01:00
parent ac8d7bee5f
commit c449181083
2 changed files with 22 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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;
}
}
public JSONObject getAppKeysJSON() {
return mAppKeys;
}
}