Loading services/core/java/com/android/server/content/ContentService.java +2 −2 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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); } Loading services/core/java/com/android/server/content/SyncJobService.java +7 −2 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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 Loading services/core/java/com/android/server/content/SyncManager.java +23 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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]; Loading Loading @@ -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; Loading Loading @@ -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. Loading Loading
services/core/java/com/android/server/content/ContentService.java +2 −2 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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); } Loading
services/core/java/com/android/server/content/SyncJobService.java +7 −2 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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 Loading
services/core/java/com/android/server/content/SyncManager.java +23 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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]; Loading Loading @@ -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; Loading Loading @@ -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. Loading