always update itself last

When auto-updates are enabled, the app should update itself last, to ensure
that all of the other apps are completely updated before this app is killed
as part of the update process.

closes #1556
This commit is contained in:
Hans-Christoph Steiner 2019-04-09 23:08:39 +02:00
parent 272a0e3f27
commit d2fea72ed9

View File

@ -544,12 +544,27 @@ public class UpdateService extends JobIntentService {
}
}
/**
* Queues all apps needing update. If this app itself (e.g. F-Droid) needs
* to be updated, it is queued last.
*/
public static void autoDownloadUpdates(Context context) {
List<App> canUpdate = AppProvider.Helper.findCanUpdate(context, Schema.AppMetadataTable.Cols.ALL);
String packageName = context.getPackageName();
App updateLastApp = null;
Apk updateLastApk = null;
for (App app : canUpdate) {
if (TextUtils.equals(packageName, app.packageName)) {
updateLastApp = app;
updateLastApk = ApkProvider.Helper.findSuggestedApk(context, app);
continue;
}
Apk apk = ApkProvider.Helper.findSuggestedApk(context, app);
InstallManagerService.queue(context, app, apk);
}
if (updateLastApp != null && updateLastApk != null) {
InstallManagerService.queue(context, updateLastApp, updateLastApk);
}
}
private void showAppUpdatesNotification(List<App> canUpdate) {