phonegap / phonegap-plugin-contentsync

Download and cache remotely hosted content
Apache License 2.0
206 stars 98 forks source link

Clearing cache on Android device is ineffective. #167

Open noozoo opened 7 years ago

noozoo commented 7 years ago

@macdonst As mentioned privately. Nexus 6 with Android 7.0. If I first clean the cache and data of my app, then uninstall the app, and then reinstall it, I see the old javascript running when I inspect in Chrome://inspect.

Any workaround you know of would be helpful.

noozoo commented 7 years ago

Update. After clearing the cache and data, uninstalling, and then restarting my phone, the new code is in there.

aramando commented 7 years ago

It's almost certainly caused by Auto Backup for Apps. When reinstalling an app, its data is restored from a backup associated with your Google account. I started seeing this issue when I upgraded from a Nexus 5 running Android 6.0.1 to a OnePlus 3 on the same OS version, and still do with Android 7.0.

The solution is simply to clear the app data after you install the new version of the APK. You don't need to uninstall the existing version beforehand or restart the phone at any point.

You can prevent the behaviour by disabling Automatic restore in the system Backup & reset settings, or by putting the phone into flight mode so that it can't access the backup - but then you still have to either clear the app data or uninstall the existing APK to achieve the same result before installing and running the updated APK, so it achieves little and has obvious drawbacks.

noozoo commented 7 years ago

When you clear the cache or uninstall there ought to be an option to remove the backups, too. Something Google is working on, hopefully.

macdonst commented 7 years ago

@noozoo @aramando What do you guys think about changing the sync directory to the one returned by getNoBackupFilesDir? This lines up with iOS as it stores the sync data in a location that is not backed up to iCloud.

aramando commented 7 years ago

@macdonst I can't think of a reason not to.

noozoo commented 7 years ago

That will prevent that backup from happening for the app?

aramando commented 7 years ago

Presumably it would only prevent the backup of files copied from the app binary or downloaded from the remote content source (e.g. the AEM server), which I don't imagine would ever be required to be backed up (since they can just be re-copied/downloaded).

I suppose it could be made into a plugin config option, defaulting to storing files in no-backup location, but with the option to change that.

macdonst commented 7 years ago

@noozoo can you try the issue167 branch?

macdonst commented 7 years ago

@noozoo did you get a chance to test the issue167 branch?

noozoo commented 7 years ago

No it did not, sorry. A lot has happened, and as you know, we've been moved to other things.

macdonst commented 7 years ago

@noozoo is the ticket getting passed on to someone else to resolve?

noozoo commented 7 years ago

@macdonst I don't think we have a Jira ticket for this.

If you like I could create one and assign it to Rofe, but I don't know when it'll get looked at...

macdonst commented 7 years ago

@noozoo please do

noozoo commented 7 years ago

@macdonst Done: https://jira.corp.adobe.com/browse/CQ-4205539

noka03 commented 7 years ago

It looks like changing this location puts the sync'd files in a location that is very slow to read from when using the cordova-file-plugin rather than the read write location provided by cordova.file.dataDirectory which is reasonably fast.