Adding support for backing up favorites table
Favorites table is copied as a separate table name during the first grid migration.
On subsequent migrations this backup table is used if it exists, otherwise new
backup is created. The backup table is also removed if there is any insert or
delete operation on the db (outside of the migration operation itself).
Bug: 111850268
Bug: 121048571
Change-Id: I6f02f4a355c369ee99d89430971be258f7516f6e
diff --git a/src/com/android/launcher3/LauncherSettings.java b/src/com/android/launcher3/LauncherSettings.java
index 79c8208..e248ba0 100644
--- a/src/com/android/launcher3/LauncherSettings.java
+++ b/src/com/android/launcher3/LauncherSettings.java
@@ -89,6 +89,11 @@
public static final String TABLE_NAME = "favorites";
/**
+ * Backup table created when when the favorites table is modified during grid migration
+ */
+ public static final String BACKUP_TABLE_NAME = "favorites_bakup";
+
+ /**
* The content:// style URL for this table
*/
public static final Uri CONTENT_URI = Uri.parse("content://" +
@@ -231,8 +236,13 @@
public static final String OPTIONS = "options";
public static void addTableToDb(SQLiteDatabase db, long myProfileId, boolean optional) {
+ addTableToDb(db, myProfileId, optional, TABLE_NAME);
+ }
+
+ public static void addTableToDb(SQLiteDatabase db, long myProfileId, boolean optional,
+ String tableName) {
String ifNotExists = optional ? " IF NOT EXISTS " : "";
- db.execSQL("CREATE TABLE " + ifNotExists + TABLE_NAME + " (" +
+ db.execSQL("CREATE TABLE " + ifNotExists + tableName + " (" +
"_id INTEGER PRIMARY KEY," +
"title TEXT," +
"intent TEXT," +
@@ -279,6 +289,10 @@
public static final String METHOD_REMOVE_GHOST_WIDGETS = "remove_ghost_widgets";
+ public static final String METHOD_NEW_TRANSACTION = "new_db_transaction";
+
+ public static final String METHOD_REFRESH_BACKUP_TABLE = "refresh_backup_table";
+
public static final String EXTRA_VALUE = "value";
public static Bundle call(ContentResolver cr, String method) {