Skip to content

Sync only once wifi continues after connection switch to mobile #1166

Closed

Description

@tobiasKaminsky

As @AndyScherzinger reported (#41 (comment)):
One issue I had with the wifi upload on my vacation was that the sync started being on wifi (as it should) but went on after I lost the wifi connection and further uploaded the files and thus impacted my data plan (being in a foreign country) pretty heavily with no possibility to cancel the uploads (I know their is already an issue opened for cancellations)

Activity

  1. tobiasKaminsky commented on Sep 20, 2015

    @tobiasKaminsky
    ContributorAuthor

    @AndyScherzinger:
    Imho a "simple" solution would be to check before every file if "wifi only" is activated and wifi connected and then upload the next file and else to stop (or pause).

  2. tobiasKaminsky commented on Sep 20, 2015

    @tobiasKaminsky
    ContributorAuthor

    Additionally the upload must receive a broadcast intent if the connection switches from wifi to mobile data and cancel the current and future upload.

  3. AndyScherzinger commented on Sep 20, 2015

    @AndyScherzinger
    Contributor

    Jepp, agreeing on the solution! :)

  4. AndyScherzinger commented on Oct 7, 2015

    @AndyScherzinger
    Contributor

    any knowledge on where this would need to be implemented in actual code base?

  5. tobiasKaminsky commented on Oct 7, 2015

    @tobiasKaminsky
    ContributorAuthor

    In InstantUploadBroadcastReceiver, function handleConnectivityAction

  6. AndyScherzinger commented on Oct 7, 2015

    @AndyScherzinger
    Contributor

    Hmm

        if (!intent.hasExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY)
                && isOnline(context)
                && (!instantPictureUploadViaWiFiOnly(context) || (instantPictureUploadViaWiFiOnly(context) == isConnectedViaWiFi(context) == true))) {
    

    --> checks the connection (type) but then simply starts uploading, then comes the loop:

    Cursor c = db.getAwaitingFiles();
    if (c.moveToFirst()) {
    do {

    So the code checks the connection and if it is appropriate starts uploading without ever checking the precondition (connectivity + user settings) again. So I guess we would have to kind of duplicate the check and also do this check an the beginning of each loop iteration.

  7. AndyScherzinger commented on Oct 7, 2015

    @AndyScherzinger
    Contributor

    One thing I am not sure of is the reference to context. Would it be possible that context somehow gets terminated by Android's life cycle system and at some point in time when using it for checking for the wifi connection the code would crash? (I am not that firm with Android and weak/strong references and the context's life cycle when being used in a receiver instance)

  8. tobiasKaminsky commented on Oct 7, 2015

    @tobiasKaminsky
    ContributorAuthor
    1. point: you are right. Within the loop there must be an additional check. This is easy and I did it locally.
      But the problem is to cancel the current upload. This can be do via FileUploader.cancel(account).
      Unfortunenately I could not managed it to get a reference to FileUploader in the BroadcastReceiver.
      Therefore I gave up :/

    Regarding context: I hope not. I think they stay intact as long as the app lives...

  9. AndyScherzinger commented on Oct 7, 2015

    @AndyScherzinger
    Contributor

    Not sure how to solve the second issue adhoc but wouldn't the first part (stop at least after the currently uploaded file) be an improvement compared to today.

    So the other part "cancel an upload of a file during wifi connection lost" could be solved at another point in time on another opened issue. Standard case would be photos and/or videos I guess and at least for the photo use case (which probably is the main one) this would already help quite a lot.

  10. tobiasKaminsky commented on Oct 7, 2015

    @tobiasKaminsky
    ContributorAuthor

    @AndyScherzinger Yes, but it would better to solve both, I thin.
    I am on IRC, if you want to discuss it.

  11. tobiasKaminsky commented on Oct 7, 2015

    @tobiasKaminsky
    ContributorAuthor

    @AndyScherzinger PR is in #1191.
    Maybe you can test it?

  12. AndyScherzinger commented on Oct 7, 2015

    @AndyScherzinger
    Contributor

    Nice! Did you find a solution? :)

  13. AndyScherzinger commented on Oct 7, 2015

    @AndyScherzinger
    Contributor

    I'll see if I can test drive it tomorrow during the day or in the evening!

  14. AndyScherzinger commented on Oct 7, 2015

    @AndyScherzinger
    Contributor

    Assuming we have a reconnect to another wifi, would the upload restart?

  15. tobiasKaminsky commented on Oct 7, 2015

    @tobiasKaminsky
    ContributorAuthor

    The upload starts again.
    But if it tries to resume the failed file or continues with the next one, I cannot say.
    But I would bet, that it does not retry :/

  16. ghost added this to the 1.9-current milestone on Nov 23, 2015
  17. ghost removed this from the 1.9-current milestone on Nov 23, 2015
  18. masensio commented on Feb 19, 2016

    @masensio

    Now #1191 is merged on master.
    I think that PR fixes this issue, so I'll close it.

    Thanks @tobiasKaminsky and @AndyScherzinger

  19. added this to the milestone on Feb 19, 2016
  20. changed the title [-]Sync only one wifi continues after connection switch to mobile[/-] [+]Sync only once wifi continues after connection switch to mobile[/+] on Mar 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions