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

Commit c9c13af1 authored by Makoto Onuki's avatar Makoto Onuki Committed by Automerger Merge Worker
Browse files

Merge "Reduce WTFs in SyncManager" into rvc-qpr-dev am: 16206cbc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12392670

Change-Id: I4cf7d0237fa4cf4105875dfca496a979966a02f8
parents bf854624 16206cbc
Loading
Loading
Loading
Loading
+13 −4
Original line number 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 SYNC_LOOP_WAKE_LOCK = "SyncLoopWakeLock";

    private static final boolean USE_WTF_FOR_ACCOUNT_ERROR = false;

    private static final int SYNC_OP_STATE_VALID = 0;
    // "1" used to include errors 3, 4 and 5 but now it's split up.
@@ -3446,7 +3447,7 @@ public class SyncManager {
                if (isLoggable) {
                    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;
            }
            // Drop this sync request if it isn't syncable.
@@ -3456,14 +3457,14 @@ public class SyncManager {
                    Slog.v(TAG, "    Dropping sync operation: "
                            + "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;
            }
            if (state == AuthorityInfo.NOT_SYNCABLE) {
                if (isLoggable) {
                    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;
            }

@@ -3482,12 +3483,20 @@ public class SyncManager {
                if (isLoggable) {
                    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_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) {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Slog.v(TAG, "dispatchSyncOperation: we are going to sync " + op);