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

Commit 7b24eee2 authored by Makoto Onuki's avatar Makoto Onuki Committed by android-build-merger
Browse files

Merge "SyncManager: Suppress WTF until ready to sync" into pi-dev am: 52279041

am: ebb190ce

Change-Id: I7dfd1b44f30d10d74b77e4db4157f0def6e69e9d
parents 1bb12521 ebb190ce
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ public final class ContentService extends IContentService.Stub {
    private SyncManager getSyncManager() {
        synchronized(mSyncManagerLock) {
            try {
                // Try to create the SyncManager, return null if it fails (e.g. the disk is full).
                // Try to create the SyncManager, return null if it fails (which it shouldn't).
                if (mSyncManager == null) mSyncManager = new SyncManager(mContext, mFactoryTest);
            } catch (SQLiteException e) {
                Log.e(TAG, "Can't create SyncManager", e);
@@ -199,7 +199,7 @@ public final class ContentService extends IContentService.Stub {
        final long identityToken = clearCallingIdentity();
        try {
            if (mSyncManager == null) {
                pw.println("No SyncManager created!  (Disk full?)");
                pw.println("SyncManager not available yet");
            } else {
                mSyncManager.dump(fd, pw, dumpAll);
            }
+7 −2
Original line number Diff line number Diff line
@@ -115,7 +115,10 @@ public class SyncJobService extends JobService {
            Slog.v(TAG, "onStopJob called " + params.getJobId() + ", reason: "
                    + params.getStopReason());
        }
        mLogger.log("onStopJob() ", mLogger.jobParametersToString(params));
        final boolean readyToSync = SyncManager.readyToSync();

        mLogger.log("onStopJob() ", mLogger.jobParametersToString(params),
                " readyToSync=", readyToSync);
        synchronized (mLock) {
            final int jobId = params.getJobId();
            mJobParamsMap.remove(jobId);
@@ -124,13 +127,15 @@ public class SyncJobService extends JobService {
            final long nowUptime = SystemClock.uptimeMillis();
            final long runtime = nowUptime - startUptime;


            if (startUptime == 0) {
                wtf("Job " + jobId + " start uptime not found: "
                        + " params=" + jobParametersToString(params));
            } else if (runtime > 60 * 1000) {
                // WTF if startSyncH() hasn't happened, *unless* onStopJob() was called too soon.
                // (1 minute threshold.)
                if (!mStartedSyncs.get(jobId)) {
                // Also don't wtf when it's not ready to sync.
                if (readyToSync && !mStartedSyncs.get(jobId)) {
                    wtf("Job " + jobId + " didn't start: "
                            + " startUptime=" + startUptime
                            + " nowUptime=" + nowUptime
+23 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ import android.util.Pair;
import android.util.Slog;

import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IBatteryStats;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
@@ -215,6 +216,10 @@ public class SyncManager {
    private static final int SYNC_ADAPTER_CONNECTION_FLAGS = Context.BIND_AUTO_CREATE
            | Context.BIND_NOT_FOREGROUND | Context.BIND_ALLOW_OOM_MANAGEMENT;

    /** Singleton instance. */
    @GuardedBy("SyncManager.class")
    private static SyncManager sInstance;

    private Context mContext;

    private static final AccountAndUser[] INITIAL_ACCOUNTS_ARRAY = new AccountAndUser[0];
@@ -571,6 +576,14 @@ public class SyncManager {
    }

    public SyncManager(Context context, boolean factoryTest) {
        synchronized (SyncManager.class) {
            if (sInstance == null) {
                sInstance = this;
            } else {
                Slog.wtf(TAG, "SyncManager instantiated multiple times");
            }
        }

        // Initialize the SyncStorageEngine first, before registering observers
        // and creating threads and so on; it may fail if the disk is full.
        mContext = context;
@@ -2850,6 +2863,16 @@ public class SyncManager {
        }
    }

    /**
     * @return whether the device is ready to run sync jobs.
     */
    public static boolean readyToSync() {
        synchronized (SyncManager.class) {
            return sInstance != null && sInstance.mProvisioned && sInstance.mBootCompleted
                    && sInstance.mJobServiceReady;
        }
    }

    /**
     * Handles SyncOperation Messages that are posted to the associated
     * HandlerThread.