Restore hotseat when user turns off suggestions immediately after migration

- Creates a backup table `hybrid_hotseat_restore` and copies current workspace layout before hotseat migration
- restores to back up when user turns off suggestions and launcher receives empty predicted items
- deletes hybrid_hotseat_restore table if there's a layout change

Test: Manual
Bug: 157688471
Change-Id: Iaf7ddb33799493d36dbcd12408b57224162221d9
This commit is contained in:
Samuel Fufa
2020-05-29 14:47:42 -07:00
parent bc374cf7f2
commit f667a1352d
8 changed files with 163 additions and 5 deletions
@@ -127,6 +127,32 @@ public class GridBackupTable {
return mRestoredHotseatSize;
}
/**
* Creates a new table and populates with copy of Favorites.TABLE_NAME
*/
public void createCustomBackupTable(String tableName) {
long profileId = UserCache.INSTANCE.get(mContext).getSerialNumberForUser(
Process.myUserHandle());
copyTable(mDb, Favorites.TABLE_NAME, tableName, profileId);
encodeDBProperties(0);
}
/**
*
* Restores the contents of a custom table to Favorites.TABLE_NAME
*/
public void restoreFromCustomBackupTable(String tableName, boolean dropAfterUse) {
if (!tableExists(mDb, tableName)) {
return;
}
long userSerial = UserCache.INSTANCE.get(mContext).getSerialNumberForUser(
Process.myUserHandle());
copyTable(mDb, tableName, Favorites.TABLE_NAME, userSerial);
if (dropAfterUse) {
dropTable(mDb, tableName);
}
}
/**
* Copy valid grid entries from one table to another.
*/