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

Commit 5c113fab authored by Alon Albert's avatar Alon Albert
Browse files

COnvert sync error to int

Bug: 8152259
Change-Id: I99fc99f70796c70ec0566c40ba350e10c36b90b7
parent a2cd828b
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -193,6 +193,23 @@ public abstract class ContentResolver {
        return SYNC_ERROR_NAMES[error - 1];
    }

    /** @hide */
    public static int syncErrorStringToInt(String error) {
        for (int i = 0, n = SYNC_ERROR_NAMES.length; i < n; i++) {
            if (SYNC_ERROR_NAMES[i].equals(error)) {
                return i + 1;
            }
        }
        if (error != null) {
            try {
                return Integer.parseInt(error);
            } catch (NumberFormatException e) {
                Log.d(TAG, "error parsing sync error: " + error);
            }
        }
        return 0;
    }

    public static final int SYNC_OBSERVER_TYPE_SETTINGS = 1<<0;
    public static final int SYNC_OBSERVER_TYPE_PENDING = 1<<1;
    public static final int SYNC_OBSERVER_TYPE_ACTIVE = 1<<2;
+6 −7
Original line number Diff line number Diff line
@@ -51,15 +51,14 @@ public class SyncStatusInfo implements Parcelable {
    }

    public int getLastFailureMesgAsInt(int def) {
        try {
            if (lastFailureMesg != null) {
                return Integer.parseInt(lastFailureMesg);
            }
        } catch (NumberFormatException e) {
            Log.d(TAG, "error parsing lastFailureMesg of " + lastFailureMesg, e);
        }
        final int i = ContentResolver.syncErrorStringToInt(lastFailureMesg);
        if (i > 0) {
            return i;
        } else {
            Log.d(TAG, "Unknown lastFailureMesg:" + lastFailureMesg);
            return def;
        }
    }

    public int describeContents() {
        return 0;