Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4649b0f authored by Sebastián Franco's avatar Sebastián Franco Committed by Android (Google) Code Review
Browse files

Merge "Refactor migrateGridIfNeeded to pass the grid states and make it easier...

Merge "Refactor migrateGridIfNeeded to pass the grid states and make it easier for unit testing" into main
parents 92900544 c3ffd41f
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -105,12 +105,10 @@ public class GridSizeMigrationUtil {
     */
    public static boolean migrateGridIfNeeded(
            @NonNull Context context,
            @NonNull InvariantDeviceProfile idp,
            @NonNull DeviceGridState srcDeviceState,
            @NonNull DeviceGridState destDeviceState,
            @NonNull DatabaseHelper target,
            @NonNull SQLiteDatabase source) {

        DeviceGridState srcDeviceState = new DeviceGridState(context);
        DeviceGridState destDeviceState = new DeviceGridState(idp);
        if (!needsToMigrate(srcDeviceState, destDeviceState)) {
            return true;
        }
+6 −2
Original line number Diff line number Diff line
@@ -308,8 +308,12 @@ public class ModelDbController {
        mOpenHelper = (mContext instanceof SandboxContext) ? oldHelper
                : createDatabaseHelper(true /* forMigration */);
        try {
            return GridSizeMigrationUtil.migrateGridIfNeeded(mContext, idp, mOpenHelper,
                   oldHelper.getWritableDatabase());
            // This is the current grid we have, given by the mContext
            DeviceGridState srcDeviceState = new DeviceGridState(mContext);
            // This is the state we want to migrate to that is given by the idp
            DeviceGridState destDeviceState = new DeviceGridState(idp);
            return GridSizeMigrationUtil.migrateGridIfNeeded(mContext, srcDeviceState,
                    destDeviceState, mOpenHelper, oldHelper.getWritableDatabase());
        } catch (Exception e) {
            FileLog.e(TAG, "Failed to migrate grid", e);
            return false;