SyncManager: Dump per-source last sync time too.
Example:
Per Adapter History
:
mak...@gmail.com/com.google u0 [com.google.android.gms.people]
Per source last syncs:
OTHER Success: 2018-04-16 17:03:38 Failure: 2018-04-16 17:04:27
LOCAL Success: N/A Failure: N/A
POLL Success: N/A Failure: N/A
USER Success: N/A Failure: N/A
PERIODIC Success: N/A Failure: N/A
FEED Success: N/A Failure: N/A
Last syncs:
2018-04-16 17:04:27 io-error Source=OTHER Elapsed=0s Reason=AutoSync Extras=[]
2018-04-16 17:03:38 success Source=OTHER Elapsed=5s Reason=AutoSync Extras=[]
2018-04-16 17:03:20 success Source=OTHER Elapsed=3s Reason=AutoSync Extras=[]
Bug: 76035392
Change-Id: Id73cb10636897c4fe45caad5df13dca8b75381bd
Fixes: 76035392
Test: Manual test with dumpsys content with triggering various syncs
diff --git a/services/core/java/com/android/server/content/SyncStorageEngine.java b/services/core/java/com/android/server/content/SyncStorageEngine.java
index f54a9a0..6a343f8 100644
--- a/services/core/java/com/android/server/content/SyncStorageEngine.java
+++ b/services/core/java/com/android/server/content/SyncStorageEngine.java
@@ -128,8 +128,13 @@
public static final long NOT_IN_BACKOFF_MODE = -1;
- /** String names for the sync source types. */
- public static final String[] SOURCES = { "OTHER",
+ /**
+ * String names for the sync source types.
+ *
+ * KEEP THIS AND {@link SyncStatusInfo#SOURCE_COUNT} IN SYNC.
+ */
+ public static final String[] SOURCES = {
+ "OTHER",
"LOCAL",
"POLL",
"USER",
@@ -1231,12 +1236,7 @@
if (status.lastSuccessTime == 0 || status.lastFailureTime != 0) {
writeStatusNow = true;
}
- status.lastSuccessTime = lastSyncTime;
- status.lastSuccessSource = item.source;
- status.lastFailureTime = 0;
- status.lastFailureSource = -1;
- status.lastFailureMesg = null;
- status.initialFailureTime = 0;
+ status.setLastSuccess(item.source, lastSyncTime);
ds.successCount++;
ds.successTime += elapsedTime;
} else if (!MESG_CANCELED.equals(resultMessage)) {
@@ -1246,12 +1246,8 @@
status.totalStats.numFailures++;
status.todayStats.numFailures++;
- status.lastFailureTime = lastSyncTime;
- status.lastFailureSource = item.source;
- status.lastFailureMesg = resultMessage;
- if (status.initialFailureTime == 0) {
- status.initialFailureTime = lastSyncTime;
- }
+ status.setLastFailure(item.source, lastSyncTime, resultMessage);
+
ds.failureCount++;
ds.failureTime += elapsedTime;
} else {