Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d67fa72 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊 Committed by Jackeagle
Browse files

Updater: Fix json validator issues

parent c976064b
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -69,10 +69,8 @@ public class UpdatesCheckReceiver extends BroadcastReceiver {
        }

        final File json = Utils.getCachedUpdateList(context);
        boolean isValidatedJsonFile = JsonValidator.validateJsonFile(json);
        if (!isValidatedJsonFile && json.exists()) {
        if (json.exists() && !JsonValidator.validateJsonFile(json) && json.delete()) {
            Log.i(TAG, "Removing cached json file due validation failure");
            json.delete();
        }

        final SharedPreferences preferences =
@@ -110,8 +108,7 @@ public class UpdatesCheckReceiver extends BroadcastReceiver {
            @Override
            public void onSuccess(File destination) {
                try {
                    boolean isValidated = JsonValidator.validateJsonFile(jsonNew);
                    if (!isValidated) {
                    if (!JsonValidator.validateJsonFile(jsonNew)) {
                        Log.i(TAG, "Could not parse list, scheduling new check");
                        scheduleUpdatesCheck(context);
                        return;
+6 −4
Original line number Diff line number Diff line
@@ -69,10 +69,12 @@ public class JsonValidator {
            }
        } catch (IOException | JSONException e) {
            Log.i(TAG, "Unable to parse the json file:" + e);
        }
            return false;
        }

        return true;
    }

    public static boolean validateResponseObject(JSONObject responseObject) {
        List<String> missingRequiredFields = new ArrayList<>();
        List<String> missingOptionalFields = new ArrayList<>();
@@ -105,7 +107,7 @@ public class JsonValidator {
    }

    private static boolean isMainFieldValid(JSONObject jsonObject, String field) {
        if (!jsonObject.has(field) || jsonObject.isNull(field)) {
        if (!jsonObject.has(field)) {
            return false;
        }