diff --git a/F-Droid/src/org/fdroid/fdroid/FDroidApp.java b/F-Droid/src/org/fdroid/fdroid/FDroidApp.java index 538bd041b..68ecd85c8 100644 --- a/F-Droid/src/org/fdroid/fdroid/FDroidApp.java +++ b/F-Droid/src/org/fdroid/fdroid/FDroidApp.java @@ -164,7 +164,8 @@ public class FDroidApp extends Application { // e.g. if we crashed/ran out of battery half way through responding // to a package installed intent. It doesn't really matter where // we put this in the bootstrap process, because it runs on a different - // thread. In fact, we may as well start early for this reason. + // thread, which will be delayed by some seconds to avoid an error where + // the database is locked due to the database updater. InstalledAppCacheUpdater.updateInBackground(getApplicationContext()); // If the user changes the preference to do with filtering rooted apps, diff --git a/F-Droid/src/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java b/F-Droid/src/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java index a1fbaa790..d86640da8 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java +++ b/F-Droid/src/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java @@ -76,7 +76,7 @@ public class InstalledAppCacheUpdater { } protected void startBackgroundWorker() { - new Worker().execute(); + new PostponedWorker().execute(); } /** @@ -156,10 +156,18 @@ public class InstalledAppCacheUpdater { return ops; } - private class Worker extends AsyncTask { + /** + * Waits 5 seconds before beginning to update cache of installed apps. + * This is due to a bug where the database was locked as F-Droid was starting, + * which caused a crash. + */ + private class PostponedWorker extends AsyncTask { @Override protected Boolean doInBackground(Void... params) { + try { + Thread.sleep(10000); + } catch (InterruptedException e) {} return update(); }