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

Commit 92afa5aa authored by Alon Albert's avatar Alon Albert Committed by Android (Google) Code Review
Browse files

Merge "COnvert sync error to int"

parents fde19b10 5c113fab
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;