1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +01: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,17 +135,20 @@ public class PebbleUtils {
JSONObject knownKeys = PebbleUtils.getAppConfigurationKeys(uuid); JSONObject knownKeys = PebbleUtils.getAppConfigurationKeys(uuid);
SparseArray<String> appKeysMap = new SparseArray<>(); 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) { if (knownKeys == null || msg == null) {
msg = "[]"; msg = "[]";
} } else {
String inKey, outKey;
//knownKeys contains "name"->"index", we need to reverse that //knownKeys contains "name"->"index", we need to reverse that
for (Iterator<String> key = knownKeys.keys(); key.hasNext(); ) { for (Iterator<String> key = knownKeys.keys(); key.hasNext(); ) {
inKey = key.next(); inKey = key.next();
appKeysMap.put(knownKeys.optInt(inKey), inKey); appKeysMap.put(knownKeys.optInt(inKey), inKey);
} }
}
try { try {
JSONArray incoming = new JSONArray(msg); JSONArray incoming = new JSONArray(msg);