Allow incomplete update JSONs
This commit is contained in:
parent
40b63bfebe
commit
53e51f1735
@ -21,6 +21,34 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> {
|
|||||||
showNotification = b;
|
showNotification = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getInt(JSONObject json, String name, int defValue) {
|
||||||
|
if (json == null)
|
||||||
|
return defValue;
|
||||||
|
try {
|
||||||
|
return json.getInt(name);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getString(JSONObject json, String name, String defValue) {
|
||||||
|
if (json == null)
|
||||||
|
return defValue;
|
||||||
|
try {
|
||||||
|
return json.getString(name);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONObject getJson(JSONObject json, String name) {
|
||||||
|
try {
|
||||||
|
return json.getJSONObject(name);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
MagiskManager mm = MagiskManager.get();
|
MagiskManager mm = MagiskManager.get();
|
||||||
@ -36,21 +64,29 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> {
|
|||||||
jsonStr = WebService.getString(mm.prefs.getString(Const.Key.CUSTOM_CHANNEL, ""));
|
jsonStr = WebService.getString(mm.prefs.getString(Const.Key.CUSTOM_CHANNEL, ""));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSONObject json;
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject(jsonStr);
|
json = new JSONObject(jsonStr);
|
||||||
JSONObject magisk = json.getJSONObject("magisk");
|
} catch (JSONException e) {
|
||||||
mm.remoteMagiskVersionString = magisk.getString("version");
|
return null;
|
||||||
mm.remoteMagiskVersionCode = magisk.getInt("versionCode");
|
}
|
||||||
mm.magiskLink = magisk.getString("link");
|
|
||||||
mm.magiskNoteLink = magisk.getString("note");
|
JSONObject magisk = getJson(json, "magisk");
|
||||||
JSONObject manager = json.getJSONObject("app");
|
mm.remoteMagiskVersionString = getString(magisk, "version", null);
|
||||||
mm.remoteManagerVersionString = manager.getString("version");
|
mm.remoteMagiskVersionCode = getInt(magisk, "versionCode", -1);
|
||||||
mm.remoteManagerVersionCode = manager.getInt("versionCode");
|
mm.magiskLink = getString(magisk, "link", null);
|
||||||
mm.managerLink = manager.getString("link");
|
mm.magiskNoteLink = getString(magisk, "note", null);
|
||||||
mm.managerNoteLink = manager.getString("note");
|
|
||||||
JSONObject uninstaller = json.getJSONObject("uninstaller");
|
JSONObject manager = getJson(json, "app");
|
||||||
mm.uninstallerLink = uninstaller.getString("link");
|
mm.remoteManagerVersionString = getString(manager, "version", null);
|
||||||
} catch (JSONException ignored) {}
|
mm.remoteManagerVersionCode = getInt(manager, "versionCode", -1);
|
||||||
|
mm.managerLink = getString(manager, "link", null);
|
||||||
|
mm.managerNoteLink = getString(manager, "note", null);
|
||||||
|
|
||||||
|
JSONObject uninstaller = getJson(json, "uninstaller");
|
||||||
|
mm.uninstallerLink = getString(uninstaller, "link", null);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user