Loading bliss/src/foundation/e/bliss/utils/BlissDbUtils.kt +2 −15 Original line number Diff line number Diff line Loading @@ -54,25 +54,18 @@ object BlissDbUtils { private const val folderType = 2 @JvmStatic fun migrateDataFromDb(context: Context): Boolean { fun migrateDataFromDb(context: Context, dbHelper: DatabaseHelper): Boolean { // Check if old database exists val oldFile = context.getDatabasePath(oldDbName) if (!oldFile.exists()) return false // Current database details val currentDbName = InvariantDeviceProfile.INSTANCE[context].dbFile val rowCount = InvariantDeviceProfile.INSTANCE[context].numRows val columnCount = InvariantDeviceProfile.INSTANCE[context].numColumns val numFolderRows = InvariantDeviceProfile.INSTANCE[context].numFolderRows val numFolderColumns = InvariantDeviceProfile.INSTANCE[context].numFolderColumns // Init database helper classes val dbHelper = DatabaseHelper( context, currentDbName, UserCache.INSTANCE.get(context)::getSerialNumberForUser ) {} val oldDbHelper = BlissDbHelper(context, oldDbName) // Retrieve data from the old table Loading Loading @@ -233,10 +226,6 @@ object BlissDbUtils { } } // Update item id after migrating dbHelper.updateItemId() dbHelper.close() // Rename the database to old val newFile = context.getDatabasePath(oldDbName + "_old") oldFile.renameTo(newFile) Loading Loading @@ -276,14 +265,12 @@ object BlissDbUtils { val widgetInfo = appWidgetManager.getAppWidgetInfo(id) if (widgetInfo != null) { var provider: ComponentName = widgetInfo.provider widgetsInfoList.add( WidgetItems( id, height, order, provider, widgetInfo.provider, ) ) } Loading src/com/android/launcher3/model/ModelDbController.java +4 −3 Original line number Diff line number Diff line Loading @@ -640,10 +640,11 @@ public class ModelDbController { */ @WorkerThread public synchronized void loadDefaultFavoritesIfNecessary() { if (BlissDbUtils.migrateDataFromDb(mContext)) { if (BlissDbUtils.migrateDataFromDb(mContext, mOpenHelper)) { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); copyTable(db, Favorites.E_TABLE_NAME, db, Favorites.E_TABLE_NAME_ALL, mContext); copyTable(db, Favorites.E_TABLE_NAME_ALL, db, Favorites.E_TABLE_NAME, mContext); mOpenHelper.updateItemId(); clearFlagEmptyDbCreated(); return; } Loading Loading
bliss/src/foundation/e/bliss/utils/BlissDbUtils.kt +2 −15 Original line number Diff line number Diff line Loading @@ -54,25 +54,18 @@ object BlissDbUtils { private const val folderType = 2 @JvmStatic fun migrateDataFromDb(context: Context): Boolean { fun migrateDataFromDb(context: Context, dbHelper: DatabaseHelper): Boolean { // Check if old database exists val oldFile = context.getDatabasePath(oldDbName) if (!oldFile.exists()) return false // Current database details val currentDbName = InvariantDeviceProfile.INSTANCE[context].dbFile val rowCount = InvariantDeviceProfile.INSTANCE[context].numRows val columnCount = InvariantDeviceProfile.INSTANCE[context].numColumns val numFolderRows = InvariantDeviceProfile.INSTANCE[context].numFolderRows val numFolderColumns = InvariantDeviceProfile.INSTANCE[context].numFolderColumns // Init database helper classes val dbHelper = DatabaseHelper( context, currentDbName, UserCache.INSTANCE.get(context)::getSerialNumberForUser ) {} val oldDbHelper = BlissDbHelper(context, oldDbName) // Retrieve data from the old table Loading Loading @@ -233,10 +226,6 @@ object BlissDbUtils { } } // Update item id after migrating dbHelper.updateItemId() dbHelper.close() // Rename the database to old val newFile = context.getDatabasePath(oldDbName + "_old") oldFile.renameTo(newFile) Loading Loading @@ -276,14 +265,12 @@ object BlissDbUtils { val widgetInfo = appWidgetManager.getAppWidgetInfo(id) if (widgetInfo != null) { var provider: ComponentName = widgetInfo.provider widgetsInfoList.add( WidgetItems( id, height, order, provider, widgetInfo.provider, ) ) } Loading
src/com/android/launcher3/model/ModelDbController.java +4 −3 Original line number Diff line number Diff line Loading @@ -640,10 +640,11 @@ public class ModelDbController { */ @WorkerThread public synchronized void loadDefaultFavoritesIfNecessary() { if (BlissDbUtils.migrateDataFromDb(mContext)) { if (BlissDbUtils.migrateDataFromDb(mContext, mOpenHelper)) { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); copyTable(db, Favorites.E_TABLE_NAME, db, Favorites.E_TABLE_NAME_ALL, mContext); copyTable(db, Favorites.E_TABLE_NAME_ALL, db, Favorites.E_TABLE_NAME, mContext); mOpenHelper.updateItemId(); clearFlagEmptyDbCreated(); return; } Loading