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

Commit dc2dd882 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Fix bug #3395355 ("adb shell dumpsys content" should present human readable...

Fix bug #3395355 ("adb shell dumpsys content" should present human readable failure messages instead of error codes)

- add human readable error messages

Change-Id: Ib6937684e61aca80b2c3bc78fd67b93c3df61d17
parent 3a56ce3a
Loading
Loading
Loading
Loading
+34 −1
Original line number Diff line number Diff line
@@ -1128,12 +1128,45 @@ public class SyncManager implements OnAccountsUpdateListener {
                    pw.print(formatTime(status.initialFailureTime));
                    pw.print(" lastTime=");
                    pw.println(formatTime(status.lastFailureTime));
                    pw.print("      message: "); pw.println(status.lastFailureMesg);
                    int errCode = status.getLastFailureMesgAsInt(0);
                    pw.print("      message: "); pw.println(
                            getLastFailureMessage(errCode) + " (" + errCode + ")");
                }
            }
        }
    }

    private String getLastFailureMessage(int code) {
        switch (code) {
            case ContentResolver.SYNC_ERROR_SYNC_ALREADY_IN_PROGRESS:
                return "sync already in progress";

            case ContentResolver.SYNC_ERROR_AUTHENTICATION:
                return "authentication error";

            case ContentResolver.SYNC_ERROR_IO:
                return "I/O error";

            case ContentResolver.SYNC_ERROR_PARSE:
                return "parse error";

            case ContentResolver.SYNC_ERROR_CONFLICT:
                return "conflict error";

            case ContentResolver.SYNC_ERROR_TOO_MANY_DELETIONS:
                return "too many deletions error";

            case ContentResolver.SYNC_ERROR_TOO_MANY_RETRIES:
                return "too many retries error";

            case ContentResolver.SYNC_ERROR_INTERNAL:
                return "internal error";

            default:
                return "unknown";
        }
    }

    private void dumpTimeSec(PrintWriter pw, long time) {
        pw.print(time/1000); pw.print('.'); pw.print((time/100)%10);
        pw.print('s');