Page 1 of 1

Condition - Account Sync - To get sync status

Posted: 24 Oct 2017 07:57
by Automagician.gaurav
Hi Martin,

Can we get the sync status from the system?
For example if I want to know if sync is initiated, or running or complete for a particular account-service combination (ex Google-contacts)?

Can this be done?

Re: Condition - Account Sync - To get sync status

Posted: 25 Oct 2017 19:58
by Martin
Hi,

There's currently no way to check if a sync is actively running at the moment. There's only a condition Auto Sync Enabled to check if auto sync is enabled for a particular Account/Authority.
How would you like to use this feature? Would a condition be enough or would a trigger be more appropriate to be informed as soon as a sync starts/ends?

Regards,
Martin

Re: Condition - Account Sync - To get sync status

Posted: 25 Oct 2017 22:19
by Automagician.gaurav
Hi Martin,

Thanks for replying.

I have a flow which turns on sync when I plug in my phone.

I just want to be able to know that sync is complete before I turn it off again (to save battery).

I also want to sync some of the services on my phone every other hour, like emails. But the time taken by the sync to complete is inconsistent, majorly due to network issues. (Yep this is an issue in India). So I cannot just turn it off after say 10 minutes.

So..if you can create a trigger, for every start / stop of Sync
OR
If you can create a condition to check the status of synchronisation
OR
Suggest me any other way to access the last time a particular account / service was Synced successfully

It will work..

Thanks

Re: Condition - Account Sync - To get sync status

Posted: 26 Oct 2017 13:25
by Desmanto
I would say trigger is better, something like "Sync finished". There is no general broadcast for sync finished. I look at stackoverflow, there are some code to detect the syncadapter has finished the sync.

If it is a condition, we have to loop over to check again every several minutes. We can't get the exact time the sync finished. The flow will run too many times just to check.

Using trigger, the event is instant so there will be no delay and no need to loop. In case we still need it as condition, we can make it using the trigger. Set a global_is_syncing to 1 at the beginning of sync, then check this using expression. If the sync finish, use script to set it to 0. That way we can create our own condition from the trigger if needed. So trigger is better, since the sync finished should be an event, not a state.

As for "Sync Started", I don't know if it is possible. But if it is, then it will one pair with "Sync finished", just like app task started and ended pair.

Re: Condition - Account Sync - To get sync status

Posted: 27 Oct 2017 19:24
by Martin
I think that a trigger to detect sync started and sync ended should be possible however the documentation provided by Google is very incomplete so there might be unpleasant surprises...
I add it to the list of features to check the feasibility.

If you just want to sync once, you could also turn off auto-sync completely and use action Request Sync to force a manual sync without turning the auto sync on at all.

Regards,
Martin

Re: Condition - Account Sync - To get sync status

Posted: 27 Oct 2017 23:49
by Automagician.gaurav
Martin, Thanks a lot for replying.
I changed it so it just requests sync once now without turning on the Auto sync. And that serves my purpose for now.

So now its
Plugged in --> Auto Sync on
Plugged out --> Auto Sync off

Manual Sync every hour when not plugged in. ☺️

Thanks again

Re: Condition - Account Sync - To get sync status

Posted: 30 Oct 2017 04:21
by aseel
I think so right ?