Reindex on OTA and locale change

When the user gets an OTA or changes language, settings
will clear the database and reindex it.

Test: make RunSettingsRoboTests
Change-Id: I379ece86b2d41d673bbbffbcf947774f3ccd4cb9
Fixes: 36859162
This commit is contained in:
Matthew Fritze
2017-04-03 11:35:48 -07:00
parent bb994166cb
commit a0d03178d0
3 changed files with 145 additions and 42 deletions

View File

@@ -245,7 +245,7 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
return version;
}
public static void clearLocalesIndexed(Context context) {
public static void clearCachedIndexed(Context context) {
context.getSharedPreferences(INDEX, 0).edit().clear().commit();
}
@@ -257,8 +257,16 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
return context.getSharedPreferences(INDEX, 0).getBoolean(locale, false);
}
public static boolean isBuildIndexed(Context context, String buildNo) {
return context.getSharedPreferences(INDEX, 0).getBoolean(buildNo, false);
}
public static void setBuildIndexed(Context context, String buildNo) {
context.getSharedPreferences(INDEX, 0).edit().putBoolean(buildNo, true).commit();
}
private void dropTables(SQLiteDatabase db) {
clearLocalesIndexed(mContext);
clearCachedIndexed(mContext);
db.execSQL("DROP TABLE IF EXISTS " + Tables.TABLE_META_INDEX);
db.execSQL("DROP TABLE IF EXISTS " + Tables.TABLE_PREFS_INDEX);
db.execSQL("DROP TABLE IF EXISTS " + Tables.TABLE_SAVED_QUERIES);