Sync not happening when app process is not running

141 Views Asked by At

I have scheduled a sync using SyncAdapter that runs for every 1hour. Post the first successful sync (time t1), I closed the app. After one hour, the sync had been canceled by SyncManager and did not run.

Used adb shell dumpsys content to know the last successful sync and the next sync time. Last successful time was still pointing to the first sync time (t1) and the next sync time got updated to the next polling time (t1 + 2hrs).

From logs, able to see that the SyncManager had canceled the sync

W SyncManager: Detected sync making no progress for startTime ...
PERIODIC Reason=Periodic (period=1h00m00s). cancelling.

From source code of SyncManager isSyncNotUsingNetworkH, this happens if the bytes transfered is less than 10bytes. https://android.googlesource.com/platform/frameworks/base.git/+/master/services/core/java/com/android/server/content/SyncManager.java#3076

When will this condition be valid? I want the sync to happen even if app process is not running.

0

There are 0 best solutions below