"Manual sync" automatically triggered by calendar apps, which will ignore WiFi restrictions



  • Never trust user’s bugreports, they’re full of lies ;-/
    I tried again to find Google calendar doesn’t trigger the immediate sync. However, Contacts app does:

    08-16 21:15:04.627 29604 29683 V ContactSaveService: Saved contact. New URI: content://com.android.contacts/contacts/lookup/2985r49-4F314D4F/49
    08-16 21:15:04.647 29145 29685 I davdroid: [syncadapter.SyncAdapterService] com.android.contacts sync of Account {name=contacts.vcf (me pg), type=at.bitfire.davdroid.address_book} has been initiated
    08-16 21:15:04.647 29145 29685 I davdroid: 	PARAMETER #0 = upload
    08-16 21:15:04.709 29145 29685 I davdroid: [syncadapter.ContactsSyncAdapterService] Synchronizing address book: ...
    

    And then calendard sync also triggered:

    08-16 21:15:53.662 29145 29734 I davdroid: [syncadapter.SyncAdapterService] com.android.calendar sync of Account {name=me, type=bitfire.at.davdroid} has been initiated
    08-16 21:15:53.662 29145 29734 I davdroid: 	PARAMETER #0 = ignore_settings, force, sync_extra_update_client_status
    

    I have a hunch it was a retry from a previous failed sync during my testing. If so, it could also explain why I was seeing I/O error pop-ups when not at home, maybe a sync retry begun while I was at home but I didn’t see the I/O error before much later.

    That turns it from a bug report into a wishlist item: Add a setting to prevent random apps from initiating forced syncs.


  • developer

    @cal said in "Manual sync" automatically triggered by calendar apps:

    I tried again to find Google calendar doesn’t trigger the immediate sync. However, Contacts app does:

    08-16 21:15:04.627 29604 29683 V ContactSaveService: Saved contact. New URI: content://com.android.contacts/contacts/lookup/2985r49-4F314D4F/49
    08-16 21:15:04.647 29145 29685 I davdroid: [syncadapter.SyncAdapterService] com.android.contacts sync of Account {name=contacts.vcf (me pg), type=at.bitfire.davdroid.address_book} has been initiated
    08-16 21:15:04.647 29145 29685 I davdroid: 	PARAMETER #0 = upload
    08-16 21:15:04.709 29145 29685 I davdroid: [syncadapter.ContactsSyncAdapterService] Synchronizing address book: ...
    

    This sounds reasonable. Note there’s no SYNC_EXTRAS_MANUAL flag, so DAVdroid should skip the sync if the conditions (like WiFi name) are not met.

    And then calendard sync also triggered:

    08-16 21:15:53.662 29145 29734 I davdroid: [syncadapter.SyncAdapterService] com.android.calendar sync of Account {name=me, type=bitfire.at.davdroid} has been initiated
    08-16 21:15:53.662 29145 29734 I davdroid: 	PARAMETER #0 = ignore_settings, force, sync_extra_update_client_status
    

    I have a hunch it was a retry from a previous failed sync during my testing. If so, it could also explain why I was seeing I/O error pop-ups when not at home, maybe a sync retry begun while I was at home but I didn’t see the I/O error before much later.

    This would be a good explanation.

    That turns it from a bug report into a wishlist item: Add a setting to prevent random apps from initiating forced syncs.

    😉 Will you report it to Simple Calendar?



  • FWIW, when I came into the office I had another I/O error notification, debug log shown from the notification said it was from contacts sync. I don’t know why it tried to sync, while I was at home I synced after I made the experiments and then made no more changes.

    I think it’s not useful to file a bug for SimpleCalendar, a) because SYNC_EXTRAS_MANUAL + SYNC_EXTRAS_EXPEDITED is what the results of a web search on the topic recommend so other apps would probably do it similarly, and b) it still wouldn’t change DAVdroid behaviour for Contacts or other apps.

    What I would like is a setting in DAVdroid to ignore all application sync requests. It should only sync if I press the sync button in the DAVdroid UI.
    Initially I thought setting the sync interval to “only manually” would do it. Now I see sync interval and app request are two different concepts, but one could reuse the “only manually” setting to cover both.

    Maybe I’m the only one who wants that, let me know if you would still accept a patch?


  • developer

    @cal said in "Manual sync" automatically triggered by calendar apps:

    FWIW, when I came into the office I had another I/O error notification, debug log shown from the notification said it was from contacts sync.

    Which sync extras were set?

    I think it’s not useful to file a bug for SimpleCalendar, a) because SYNC_EXTRAS_MANUAL + SYNC_EXTRAS_EXPEDITED is what the results of a web search on the topic recommend so other apps would probably do it similarly,

    Can you provide those Web sites? SYNC_EXTRAS_MANUAL is well defined by the Android documentation.

    and b) it still wouldn’t change DAVdroid behaviour for Contacts or other apps.

    Seems like DAVdroid didn’t check sync conditions (in WiFi? etc.) for contacts syncs. Should be fixed with 80971c52. Shall I generate an APK for testing?



  • @rfc2822 said in "Manual sync" automatically triggered by calendar apps / Contacts sync doesn't check sync conditions:

    Which sync extras were set?

    The debug info didn’t show it, and on work didn’t have time to check logcat.

    Can you provide those Web sites? SYNC_EXTRAS_MANUAL is well defined by the Android documentation.

    E.g.
    https://catinean.com/2014/08/03/force-your-syncadapter-to-sync/

    Seems like DAVdroid didn’t check sync conditions (in WiFi? etc.) for contacts syncs. Should be fixed with 80971c52. Shall I generate an APK for testing?

    Now the check seems to be duplicated, check lines 46 and 65.

    In my initial posting I said radicale is running intermittently, meaning I manually run it when I want to make a backup. Thus the Wifi sync restrictions are not enough for me.


  • developer

    @cal said in "Manual sync" automatically triggered by calendar apps / Contacts sync doesn't check sync conditions:

    Which sync extras were set?

    The debug info didn’t show it, and on work didn’t have time to check logcat.

    Debug info show them as “parameter 0” like here:

    08-16 21:15:04.647 29145 29685 I davdroid: [syncadapter.SyncAdapterService] com.android.contacts sync of Account {name=contacts.vcf (me pg), type=at.bitfire.davdroid.address_book} has been initiated
    08-16 21:15:04.647 29145 29685 I davdroid: 	PARAMETER #0 = upload
    

    E.g.
    https://catinean.com/2014/08/03/force-your-syncadapter-to-sync/

    From there:

    SYNC_EXTRAS_MANUAL - forces a manual sync ignoring any settings

    However, keep in mind that syncing on demand and requesting an immediate sync is a rather inefficient use of SyncAdapter because it bypasses all the network and power use optimisations. This solution should be used with extra care and only in situations when you are sure you want to perform an immediate on demand sync.

    This is exactly how I understand it. If an “immediate on-demand sync” is requested, DAVdroid will perform it.

    Now the check seems to be duplicated, check lines 46 and 65.

    Reverted because of my own stupidness.

    In my initial posting I said radicale is running intermittently, meaning I manually run it when I want to make a backup. Thus the Wifi sync restrictions are not enough for me.

    Now I finally understand. I have never seen this use case before so it took me some time.

    DAVdroid is intended for permanent synchronization, not as a backup tool. I suggest to

    • either let radicale running (why not?) or
    • just ignore the I/O error notifications? They’re minimum priority so that they don’t appear in the notification bar, and you can also turn them off in Android (especially the respective channel on Android 8+ ).


  • @rfc2822 said in "Manual sync" automatically triggered by calendar apps:

    Debug info show them as “parameter 0” like here:

    I mean the debug info that pops up if one touches the I/O error notification, it only shows the Java traceback and some config info, but not the log.

    BTW, one can’t select and copy text from the debug info, and using the share button “copy to clipboard” action only copies a content URL.

    DAVdroid is intended for permanent synchronization, not as a backup tool. I suggest to

    Yes, I realize I want something that DAVdroid wasn’t intended to do. The question is if you would accept a patch that either

    1. adds a new “manual only” setting (ignore app sync requests)
    2. or changes behaviour to make “sync interval = manual only” to imply “ignore app sync requests”

    The latter is what I originally expected, and what I assume normal users who don’t know anything about how Android sync internally works would expect.


  • developer

    @cal said in "Manual sync" automatically triggered by calendar apps:

    BTW, one can’t select and copy text from the debug info, and using the share button “copy to clipboard” action only copies a content URL.

    DAVdroid generates a debug.txt which is accessible over a content URI (using FileProvider). Debug info is often too large for a simple string.

    If you want your “Copy to clipboard” app to read this URI and copy its content, this would have to be done in “Copy to clipboard”.

    Yes, I realize I want something that DAVdroid wasn’t intended to do. The question is if you would accept a patch that either

    1. adds a new “manual only” setting (ignore app sync requests)
    2. or changes behaviour to make “sync interval = manual only” to imply “ignore app sync requests”

    The latter is what I originally expected, and what I assume normal users who don’t know anything about how Android sync internally works would expect.

    Thanks for the offer! Currently, I’m not sure about this, because it’s another setting, which means even more complexity and maintenance and testing work.

    If other people need this feature, too, we will think about it. In the meanwhile, I suggest to … (see above).



  • OK, thanks for your responses and for the time you’ve taken. I hope someone else with the same desires will chime in. If not, then, well, good we’ve talked about it…

    Thanks for writing and maintaining DAVdroid!



  • FWIW, I found out my phone (Moto G5, still Android 7.0) does contact syncs when it feels like it:

    08-20 10:26:57.754  2902  2920 I ActivityManager: Start proc 15612:at.bitfire.davdroid:sync/u0a123 for service at.bitfire.davdroid/.syncadapter.ContactsSyncAdapterService
    08-20 10:26:57.814 15612 15612 I art     : Starting a blocking GC AddRemoveAppImageSpace
    08-20 10:26:57.817 15612 15612 W System  : ClassLoader referenced unknown path: /data/app/at.bitfire.davdroid-2/lib/arm
    08-20 10:26:57.900 15612 15612 I davdroid: Verbose logging: false; to file: false
    08-20 10:26:57.948 15612 15627 I davdroid: [PackageChangedReceiver] Package (un)installed; OpenTasks provider now available = true
    08-20 10:26:57.948 15612 15628 I davdroid: [syncadapter.SyncAdapterService] com.android.contacts sync of Account {name=contacts.vcf (me pg), type=at.bitfire.davdroid.address_book} has been initiated
    08-20 10:26:57.948 15612 15628 I davdroid: 	PARAMETER #0 = 
    08-20 10:26:58.001 15612 15628 I davdroid: [syncadapter.ContactsSyncAdapterService] Synchronizing address book: ...
    

    (fails and repeats at 10:43:32.718, 10:59:52.375 and 12:06:12.919)

    I’ts not clear what triggers this, sync interval in DAVdroid is set to manual and the phone was lying idle on the table when the sync started, I checked time and notifications sometimes but didn’t use Contacts app today.



  • @cal Hello, I experience the same problem. I have locally running a radicale Server to sync caldav and carddav. It is a small box running at my home and syncs the data. It is only reachable at home and not exposed to the internet for reasons.

    I have as well restricted davdroid only to sync when using wifi and a specific ssid.

    My Android 8.0 displays error messages in the notification area that it is not able to sync. This happens when the sync intervall is reached or I edit or create new calendar entries. This is annoying as I would guess that davdroid would ignore all sync requests from calendars and contacts when it is not using wifi and the ssid.

    I am in favor that davdroid would handle this case.

    Greetings,
    foobar.


  • developer

    @foobar Do you have multiple DAVdroid accounts?



  • I have only one davdroid account for caldav and carddav.



  • Another day, another log: Today my phone decided to do a calendar sync together with the contacts sync:

    08-21 13:27:19.404 19376 20008 I davdroid: [syncadapter.SyncAdapterService] com.android.calendar sync of Account {name=me, type=bitfire.at.davdroid} has been initiated
    08-21 13:27:19.404 19376 20008 I davdroid: 	PARAMETER #0 = ignore_settings, force, sync_extra_update_client_status
    

    Phone was laying idle on the desk, and I didn’t use calendar app today.


  • developer

    @cal Which apps do you have installed? Which calendar apps?

    Google doesn’t even know sync_extra_update_client_status… I have only fond this here: https://github.com/mmathys/gcalendar-source/blob/1ddd4ce3607496701f3fa3c46b874db23d88d3f2/smali/com/google/android/calendar/extensions/WhatsNewFactoryImpl.smali

    Seems like Google Calendar forces a “client status sync”, whatever this shall mean…

    What happens if you disable Google Calendar entirely (in Android / Apps) and use another calendar app, e.g. aCalendar+ or Business Calendar or Etar?



  • I am using the calendar app that came with my lg g6 android phone.

    It even tries to sync via davdroid (and davdroid getting the i/o-error) when on cellular even I restricted it to use only wifi with a specific ssid.


  • developer

    @foobar What happens if you disable the app that came with your phone entirely (in Android / Apps) and use another calendar app, e.g. aCalendar+ or Business Calendar or Etar?



  • @rfc2822 I am only using fdroid. So do you have any reccomendation for a free calendar.


  • developer

    @foobar For instance, Etar.



  • I cannot deactivate my calendar that came with the phone.



Maybe you're interested in these topics?

  • 1
  • 3
  • 11
  • 5
  • 1