From 29658259fae87cbc69b247c936c2e67df9e25926 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 29 Jan 2018 22:59:13 +0100 Subject: [PATCH] force clean index update when underlying OS is upgraded Things like permission support, locales, etc. can change when Android is updated. So the database should be rebuilt from scratch with a fresh download of the indexes. closes #780 --- app/src/main/java/org/fdroid/fdroid/FDroidApp.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/org/fdroid/fdroid/FDroidApp.java b/app/src/main/java/org/fdroid/fdroid/FDroidApp.java index 03518b11d..18fc3d916 100644 --- a/app/src/main/java/org/fdroid/fdroid/FDroidApp.java +++ b/app/src/main/java/org/fdroid/fdroid/FDroidApp.java @@ -27,6 +27,7 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothManager; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; @@ -415,6 +416,13 @@ public class FDroidApp extends Application { // find and process provisions if any. Provisioner.scanAndProcess(getApplicationContext()); + + // if the underlying OS version has changed, then fully rebuild the database + SharedPreferences atStartTime = getSharedPreferences("at-start-time", Context.MODE_PRIVATE); + if (Build.VERSION.SDK_INT != atStartTime.getInt("build-version", Build.VERSION.SDK_INT)) { + UpdateService.forceUpdateRepo(this); + } + atStartTime.edit().putInt("build-version", Build.VERSION.SDK_INT).apply(); } /**