mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 08:16:49 +00:00
Simplifying some test utility methods
Bug: 283821111 Test: Presubmit Flag: N/A Change-Id: I7b9690bc0cc53d097d26cd4f0ab2dd36ba88e1cb
This commit is contained in:
@@ -280,13 +280,29 @@ public class ModelDbController {
|
||||
mOpenHelper.getReadableDatabase(), Favorites.HYBRID_HOTSEAT_BACKUP_TABLE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Migrates the DB if needed. If the migration failed, it clears the DB.
|
||||
*/
|
||||
public void tryMigrateDB() {
|
||||
if (!migrateGridIfNeeded()) {
|
||||
Log.d(TAG, "Migration failed: resetting launcher database");
|
||||
createEmptyDB();
|
||||
LauncherPrefs.get(mContext).putSync(
|
||||
getEmptyDbCreatedKey(mOpenHelper.getDatabaseName()).to(true));
|
||||
|
||||
// Write the grid state to avoid another migration
|
||||
new DeviceGridState(LauncherAppState.getIDP(mContext)).writeToPrefs(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrates the DB if needed, and returns false if the migration failed
|
||||
* and DB needs to be cleared.
|
||||
* @return true if migration was success or ignored, false if migration failed
|
||||
* and the DB should be reset.
|
||||
*/
|
||||
public boolean migrateGridIfNeeded() {
|
||||
private boolean migrateGridIfNeeded() {
|
||||
createDbIfNotExists();
|
||||
InvariantDeviceProfile idp = LauncherAppState.getIDP(mContext);
|
||||
if (!GridSizeMigrationUtil.needsToMigrate(mContext, idp)) {
|
||||
|
||||
Reference in New Issue
Block a user