1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-16 18:34:03 +02:00

Pebble: Iterate over knownKeys only if they are present.

Fixes #1027
This commit is contained in:
Daniele Gobbetti 2018-03-17 16:12:40 +01:00
parent 3e903362e6
commit d286f497f0

View File

@ -135,16 +135,19 @@ public class PebbleUtils {
JSONObject knownKeys = PebbleUtils.getAppConfigurationKeys(uuid);
SparseArray<String> appKeysMap = new SparseArray<>();
String inKey, outKey;
// TODO: The fact that knownKeys is null for the passed UUID means that the
// watchapp was installed by some other app, hence we cannot communicate with it.
// The user could be warned somehow.
if (knownKeys == null || msg == null) {
msg = "[]";
}
String inKey, outKey;
//knownKeys contains "name"->"index", we need to reverse that
for (Iterator<String> key = knownKeys.keys(); key.hasNext(); ) {
inKey = key.next();
appKeysMap.put(knownKeys.optInt(inKey), inKey);
} else {
//knownKeys contains "name"->"index", we need to reverse that
for (Iterator<String> key = knownKeys.keys(); key.hasNext(); ) {
inKey = key.next();
appKeysMap.put(knownKeys.optInt(inKey), inKey);
}
}
try {