Loading services/core/java/com/android/server/content/SyncLogger.java +12 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,13 @@ public class SyncLogger { public void dumpAll(PrintWriter pw) { } /** * @return whether log is enabled or not. */ public boolean enabled() { return false; } /** * Actual implementation which is only used on userdebug/eng builds (by default). */ Loading Loading @@ -134,6 +141,11 @@ public class SyncLogger { mLogPath = new File(Environment.getDataSystemDirectory(), "syncmanager-log"); } @Override public boolean enabled() { return true; } private void handleException(String message, Exception e) { if (!mErrorShown) { Slog.e(TAG, message, e); Loading services/core/java/com/android/server/content/SyncManager.java +59 −17 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.TrafficStats; import android.os.BatteryStats; import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; Loading Loading @@ -461,6 +462,7 @@ public class SyncManager { continue; } if (opx.key.equals(opy.key)) { mLogger.log("Removing duplicate sync: ", opy); mJobScheduler.cancel(opy.jobId); } } Loading @@ -473,6 +475,8 @@ public class SyncManager { if (mJobScheduler != null) { return; } final long token = Binder.clearCallingIdentity(); try { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.d(TAG, "initializing JobScheduler object."); } Loading @@ -481,17 +485,47 @@ public class SyncManager { mJobSchedulerInternal = LocalServices.getService(JobSchedulerInternal.class); // Get all persisted syncs from JobScheduler List<JobInfo> pendingJobs = mJobScheduler.getAllPendingJobs(); int numPersistedPeriodicSyncs = 0; int numPersistedOneshotSyncs = 0; for (JobInfo job : pendingJobs) { SyncOperation op = SyncOperation.maybeCreateFromJobExtras(job.getExtras()); if (op != null) { if (!op.isPeriodic) { if (op.isPeriodic) { numPersistedPeriodicSyncs++; } else { numPersistedOneshotSyncs++; // Set the pending status of this EndPoint to true. Pending icon is // shown on the settings activity. mSyncStorageEngine.markPending(op.target, true); } } } if (mLogger.enabled()) { mLogger.log("Connected to JobScheduler: " + numPersistedPeriodicSyncs + " periodic syncs " + numPersistedOneshotSyncs + " oneshot syncs."); } cleanupJobs(); if ((numPersistedPeriodicSyncs == 0) && likelyHasPeriodicSyncs()) { Slog.wtf(TAG, "Device booted with no persisted periodic syncs."); } } finally { Binder.restoreCallingIdentity(token); } } /** * @return whether the device most likely has some periodic syncs. */ private boolean likelyHasPeriodicSyncs() { try { return AccountManager.get(mContext).getAccountsByType("com.google").length > 0; } catch (Throwable th) { // Just in case. } return false; } private JobScheduler getJobScheduler() { Loading Loading @@ -1085,10 +1119,12 @@ public class SyncManager { } private void removeSyncsForAuthority(EndPoint info) { mLogger.log("removeSyncsForAuthority: ", info); verifyJobScheduler(); List<SyncOperation> ops = getAllPendingSyncs(); for (SyncOperation op: ops) { if (op.target.matchesSpec(info)) { mLogger.log("canceling: ", op); getJobScheduler().cancel(op.jobId); } } Loading Loading @@ -1634,6 +1670,7 @@ public class SyncManager { } private void onUserRemoved(int userId) { mLogger.log("onUserRemoved: u", userId); updateRunningAccounts(null /* Don't sync any target */); // Clean up the storage engine database Loading Loading @@ -2926,6 +2963,9 @@ public class SyncManager { Slog.v(TAG, acc.toString()); } } if (mLogger.enabled()) { mLogger.log("updateRunningAccountsH: ", Arrays.toString(mRunningAccounts)); } if (mBootCompleted) { doDatabaseCleanup(); } Loading Loading @@ -2957,6 +2997,7 @@ public class SyncManager { List<SyncOperation> ops = getAllPendingSyncs(); for (SyncOperation op: ops) { if (!containsAccountAndUser(allAccounts, op.target.account, op.target.userId)) { mLogger.log("canceling: ", op); getJobScheduler().cancel(op.jobId); } } Loading Loading @@ -3075,6 +3116,7 @@ public class SyncManager { "removePeriodicSyncInternalH"); runSyncFinishedOrCanceledH(null, asc); } mLogger.log("removePeriodicSyncInternalH-canceling: ", op); getJobScheduler().cancel(op.jobId); } } Loading Loading
services/core/java/com/android/server/content/SyncLogger.java +12 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,13 @@ public class SyncLogger { public void dumpAll(PrintWriter pw) { } /** * @return whether log is enabled or not. */ public boolean enabled() { return false; } /** * Actual implementation which is only used on userdebug/eng builds (by default). */ Loading Loading @@ -134,6 +141,11 @@ public class SyncLogger { mLogPath = new File(Environment.getDataSystemDirectory(), "syncmanager-log"); } @Override public boolean enabled() { return true; } private void handleException(String message, Exception e) { if (!mErrorShown) { Slog.e(TAG, message, e); Loading
services/core/java/com/android/server/content/SyncManager.java +59 −17 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.TrafficStats; import android.os.BatteryStats; import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; Loading Loading @@ -461,6 +462,7 @@ public class SyncManager { continue; } if (opx.key.equals(opy.key)) { mLogger.log("Removing duplicate sync: ", opy); mJobScheduler.cancel(opy.jobId); } } Loading @@ -473,6 +475,8 @@ public class SyncManager { if (mJobScheduler != null) { return; } final long token = Binder.clearCallingIdentity(); try { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.d(TAG, "initializing JobScheduler object."); } Loading @@ -481,17 +485,47 @@ public class SyncManager { mJobSchedulerInternal = LocalServices.getService(JobSchedulerInternal.class); // Get all persisted syncs from JobScheduler List<JobInfo> pendingJobs = mJobScheduler.getAllPendingJobs(); int numPersistedPeriodicSyncs = 0; int numPersistedOneshotSyncs = 0; for (JobInfo job : pendingJobs) { SyncOperation op = SyncOperation.maybeCreateFromJobExtras(job.getExtras()); if (op != null) { if (!op.isPeriodic) { if (op.isPeriodic) { numPersistedPeriodicSyncs++; } else { numPersistedOneshotSyncs++; // Set the pending status of this EndPoint to true. Pending icon is // shown on the settings activity. mSyncStorageEngine.markPending(op.target, true); } } } if (mLogger.enabled()) { mLogger.log("Connected to JobScheduler: " + numPersistedPeriodicSyncs + " periodic syncs " + numPersistedOneshotSyncs + " oneshot syncs."); } cleanupJobs(); if ((numPersistedPeriodicSyncs == 0) && likelyHasPeriodicSyncs()) { Slog.wtf(TAG, "Device booted with no persisted periodic syncs."); } } finally { Binder.restoreCallingIdentity(token); } } /** * @return whether the device most likely has some periodic syncs. */ private boolean likelyHasPeriodicSyncs() { try { return AccountManager.get(mContext).getAccountsByType("com.google").length > 0; } catch (Throwable th) { // Just in case. } return false; } private JobScheduler getJobScheduler() { Loading Loading @@ -1085,10 +1119,12 @@ public class SyncManager { } private void removeSyncsForAuthority(EndPoint info) { mLogger.log("removeSyncsForAuthority: ", info); verifyJobScheduler(); List<SyncOperation> ops = getAllPendingSyncs(); for (SyncOperation op: ops) { if (op.target.matchesSpec(info)) { mLogger.log("canceling: ", op); getJobScheduler().cancel(op.jobId); } } Loading Loading @@ -1634,6 +1670,7 @@ public class SyncManager { } private void onUserRemoved(int userId) { mLogger.log("onUserRemoved: u", userId); updateRunningAccounts(null /* Don't sync any target */); // Clean up the storage engine database Loading Loading @@ -2926,6 +2963,9 @@ public class SyncManager { Slog.v(TAG, acc.toString()); } } if (mLogger.enabled()) { mLogger.log("updateRunningAccountsH: ", Arrays.toString(mRunningAccounts)); } if (mBootCompleted) { doDatabaseCleanup(); } Loading Loading @@ -2957,6 +2997,7 @@ public class SyncManager { List<SyncOperation> ops = getAllPendingSyncs(); for (SyncOperation op: ops) { if (!containsAccountAndUser(allAccounts, op.target.account, op.target.userId)) { mLogger.log("canceling: ", op); getJobScheduler().cancel(op.jobId); } } Loading Loading @@ -3075,6 +3116,7 @@ public class SyncManager { "removePeriodicSyncInternalH"); runSyncFinishedOrCanceledH(null, asc); } mLogger.log("removePeriodicSyncInternalH-canceling: ", op); getJobScheduler().cancel(op.jobId); } } Loading