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

Commit 16206cbc authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Reduce WTFs in SyncManager" into rvc-qpr-dev

parents 3743d552 9bb99247
Loading
Loading
Loading
Loading
+13 −4
Original line number Original line Diff line number Diff line
@@ -210,6 +210,7 @@ public class SyncManager {
    private static final String HANDLE_SYNC_ALARM_WAKE_LOCK = "SyncManagerHandleSyncAlarm";
    private static final String HANDLE_SYNC_ALARM_WAKE_LOCK = "SyncManagerHandleSyncAlarm";
    private static final String SYNC_LOOP_WAKE_LOCK = "SyncLoopWakeLock";
    private static final String SYNC_LOOP_WAKE_LOCK = "SyncLoopWakeLock";


    private static final boolean USE_WTF_FOR_ACCOUNT_ERROR = false;


    private static final int SYNC_OP_STATE_VALID = 0;
    private static final int SYNC_OP_STATE_VALID = 0;
    // "1" used to include errors 3, 4 and 5 but now it's split up.
    // "1" used to include errors 3, 4 and 5 but now it's split up.
@@ -3446,7 +3447,7 @@ public class SyncManager {
                if (isLoggable) {
                if (isLoggable) {
                    Slog.v(TAG, "    Dropping sync operation: account doesn't exist.");
                    Slog.v(TAG, "    Dropping sync operation: account doesn't exist.");
                }
                }
                Slog.wtf(TAG, "SYNC_OP_STATE_INVALID: account doesn't exist.");
                logAccountError("SYNC_OP_STATE_INVALID: account doesn't exist.");
                return SYNC_OP_STATE_INVALID_NO_ACCOUNT;
                return SYNC_OP_STATE_INVALID_NO_ACCOUNT;
            }
            }
            // Drop this sync request if it isn't syncable.
            // Drop this sync request if it isn't syncable.
@@ -3456,14 +3457,14 @@ public class SyncManager {
                    Slog.v(TAG, "    Dropping sync operation: "
                    Slog.v(TAG, "    Dropping sync operation: "
                            + "isSyncable == SYNCABLE_NO_ACCOUNT_ACCESS");
                            + "isSyncable == SYNCABLE_NO_ACCOUNT_ACCESS");
                }
                }
                Slog.wtf(TAG, "SYNC_OP_STATE_INVALID_NO_ACCOUNT_ACCESS");
                logAccountError("SYNC_OP_STATE_INVALID_NO_ACCOUNT_ACCESS");
                return SYNC_OP_STATE_INVALID_NO_ACCOUNT_ACCESS;
                return SYNC_OP_STATE_INVALID_NO_ACCOUNT_ACCESS;
            }
            }
            if (state == AuthorityInfo.NOT_SYNCABLE) {
            if (state == AuthorityInfo.NOT_SYNCABLE) {
                if (isLoggable) {
                if (isLoggable) {
                    Slog.v(TAG, "    Dropping sync operation: isSyncable == NOT_SYNCABLE");
                    Slog.v(TAG, "    Dropping sync operation: isSyncable == NOT_SYNCABLE");
                }
                }
                Slog.wtf(TAG, "SYNC_OP_STATE_INVALID: NOT_SYNCABLE");
                logAccountError("SYNC_OP_STATE_INVALID: NOT_SYNCABLE");
                return SYNC_OP_STATE_INVALID_NOT_SYNCABLE;
                return SYNC_OP_STATE_INVALID_NOT_SYNCABLE;
            }
            }


@@ -3482,12 +3483,20 @@ public class SyncManager {
                if (isLoggable) {
                if (isLoggable) {
                    Slog.v(TAG, "    Dropping sync operation: disallowed by settings/network.");
                    Slog.v(TAG, "    Dropping sync operation: disallowed by settings/network.");
                }
                }
                Slog.wtf(TAG, "SYNC_OP_STATE_INVALID: disallowed by settings/network");
                logAccountError("SYNC_OP_STATE_INVALID: disallowed by settings/network");
                return SYNC_OP_STATE_INVALID_SYNC_DISABLED;
                return SYNC_OP_STATE_INVALID_SYNC_DISABLED;
            }
            }
            return SYNC_OP_STATE_VALID;
            return SYNC_OP_STATE_VALID;
        }
        }


        private void logAccountError(String message) {
            if (USE_WTF_FOR_ACCOUNT_ERROR) {
                Slog.wtf(TAG, message);
            } else {
                Slog.e(TAG, message);
            }
        }

        private boolean dispatchSyncOperation(SyncOperation op) {
        private boolean dispatchSyncOperation(SyncOperation op) {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Slog.v(TAG, "dispatchSyncOperation: we are going to sync " + op);
                Slog.v(TAG, "dispatchSyncOperation: we are going to sync " + op);