kgmarsch / auto-update-apk-client

Automatically exported from code.google.com/p/auto-update-apk-client
0 stars 0 forks source link

checkUpdateTask downlaods new package on each update check. #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From what I read in the checkUpdateTask class, if a their is an update 
available, the app will always download the new package.  Even if it has 
successfully download it on the last check.  

(First gets "have update" from server, then HttpGets the file. I didn't see 
anything that prevents the download again.)

How about adding the MD5 checksum of the file as part of the "update required 
message".  Then the app can check to see if the file on the disk matches what 
is on the server, and skip the download.

(Our app is running in a bandwidth scarce environment, so each download counts.)

Original issue reported on code.google.com by diederik...@gmail.com on 3 Oct 2012 at 6:55

GoogleCodeExporter commented 9 years ago
When the checkUpdateTask asks for an update, it sends the MD5 sum of the last 
received update (or the current running file, if there were no updates yet). If 
the MD5 sum received from the application and the MD5 sum of the newest version 
on the server match, "no update" reply is sent back, preventing from 
downloading same files again and again.

This however works only if you keep the default setting for "Deploy update 
when:" as "MD5 has changed".

Original comment by lenik.terenin on 3 Oct 2012 at 7:31

GoogleCodeExporter commented 9 years ago
I see that the MD5_KEY is updated with the downloaded file path in 
checkUpdateTask.onPostExecute().  Also, as it is initialised to the MD5 
checksum of the ApplicationInfo.sourceDir 
http://developer.android.com/reference/android/content/pm/ApplicationInfo.html#p
ublicSourceDir of this package.

So if I understand the behaviour correctly: the first update will download the 
file, and populate the UPDATE_FILE string in the SharedPreferences.  Then the 
next time an update is checked, the new downloaded MD5 check sum will be 
submitted, and the server will respond with "no update".

I have an activity that is listening for an update from AutoUpdateApk, so that 
it can pop up a box to inform the user (our users need a louder indication than 
something in the notification bar).  After the first update signal, 
AUTOUPDATE_GOT_UPDATE, each subsequent  check for update will send to its 
observers AUTOUPDATE_NO_UPDATE (as the MD5 checksums should match).

So in the scenario where an update is available, but not enforced, the pop up 
will never be shown again.

Shouldn't there be another notification state? Say AUTOUPDATE_UPDATE_DOWNLOADED?

Original comment by diederik...@gmail.com on 3 Oct 2012 at 11:08

GoogleCodeExporter commented 9 years ago

Totally agree with you, thank you for your comment!

From now on (v1.7) we have two different notifications regarding updates:

AUTOUPDATE_GOT_UPDATE -- we have just received an update from the server
AUTOUPDATE_HAVE_UPDATE -- there's an update available for installation

When the update has just arrived, both notifications are sent. When user has 
restarted an application and there's already downloaded file, only the 
HAVE_UPDATE notification is sent to the Observer.

Original comment by lenik.terenin on 4 Oct 2012 at 8:17