mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 13:47:41 +00:00
Add incremental notifications plugin settings database upgrade
Summary: When upgrading the app to the version with the new privacy options (D17126), the app will crash with some error about missing a table in the Notifications Plugin database. This patch adds the table in onUpgrade in a proper way. Test Plan: - Build current app from master - Disable some apps in the Notifications plugin - Apply this patch (as well as its dependency, D17126) - The app should work, with your old settings, and now able to toggle privacy options! Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Differential Revision: https://phabricator.kde.org/D17521
This commit is contained in:
@@ -40,7 +40,7 @@ class AppDatabase {
|
||||
private static final String SETTINGS_NAME = "app_database";
|
||||
private static final String SETTINGS_KEY_ALL_ENABLED = "all_enabled";
|
||||
|
||||
private static final int DATABASE_VERSION = 4;
|
||||
private static final int DATABASE_VERSION = 5;
|
||||
private static final String DATABASE_NAME = "Applications";
|
||||
private static final String TABLE_ENABLED = "Applications";
|
||||
private static final String TABLE_PRIVACY = "PrivacyOpts";
|
||||
@@ -49,6 +49,14 @@ class AppDatabase {
|
||||
private static final String KEY_PRIVACY_OPTIONS = "privacyOptions";
|
||||
|
||||
|
||||
private static final String DATABASE_CREATE_ENABLED = "CREATE TABLE "
|
||||
+ TABLE_ENABLED + "(" + KEY_PACKAGE_NAME + " TEXT PRIMARY KEY NOT NULL, "
|
||||
+ KEY_IS_ENABLED + " INTEGER NOT NULL ); ";
|
||||
private static final String DATABASE_CREATE_PRIVACY_OPTS = "CREATE TABLE "
|
||||
+ TABLE_PRIVACY + "(" + KEY_PACKAGE_NAME + " TEXT PRIMARY KEY NOT NULL, "
|
||||
+ KEY_PRIVACY_OPTIONS + " INTEGER NOT NULL); ";
|
||||
|
||||
|
||||
private SQLiteDatabase ourDatabase;
|
||||
private DbHelper ourHelper;
|
||||
private SharedPreferences prefs;
|
||||
@@ -77,18 +85,15 @@ class AppDatabase {
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL("CREATE TABLE " + TABLE_ENABLED +
|
||||
"(" + KEY_PACKAGE_NAME + " TEXT PRIMARY KEY NOT NULL, " +
|
||||
KEY_IS_ENABLED + " INTEGER NOT NULL ); ");
|
||||
db.execSQL("CREATE TABLE " + TABLE_PRIVACY +
|
||||
"(" + KEY_PACKAGE_NAME + " TEXT PRIMARY KEY NOT NULL, " +
|
||||
KEY_PRIVACY_OPTIONS + " INTEGER NOT NULL); ");
|
||||
db.execSQL(DATABASE_CREATE_ENABLED);
|
||||
db.execSQL(DATABASE_CREATE_PRIVACY_OPTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int i, int i2) {
|
||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_ENABLED);
|
||||
onCreate(db);
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
if (oldVersion < 5) {
|
||||
db.execSQL(DATABASE_CREATE_PRIVACY_OPTS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user