Merge "Add testing for GridMigration." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
bbdcade30d
@@ -53,6 +53,13 @@ public class DeviceGridState implements Comparable<DeviceGridState> {
|
||||
private final @DeviceType int mDeviceType;
|
||||
private final String mDbFile;
|
||||
|
||||
public DeviceGridState(int columns, int row, int numHotseat, int deviceType, String dbFile) {
|
||||
mGridSizeString = String.format(Locale.ENGLISH, "%d,%d", columns, row);
|
||||
mNumHotseat = numHotseat;
|
||||
mDeviceType = deviceType;
|
||||
mDbFile = dbFile;
|
||||
}
|
||||
|
||||
public DeviceGridState(InvariantDeviceProfile idp) {
|
||||
mGridSizeString = String.format(Locale.ENGLISH, "%d,%d", idp.numColumns, idp.numRows);
|
||||
mNumHotseat = idp.numDatabaseHotseatIcons;
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
@@ -94,6 +95,15 @@ public class GridSizeMigrationUtil {
|
||||
return needsToMigrate;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static List<DbEntry> readAllEntries(SQLiteDatabase db, String tableName,
|
||||
Context context) {
|
||||
DbReader dbReader = new DbReader(db, tableName, context, getValidPackages(context));
|
||||
List<DbEntry> result = dbReader.loadAllWorkspaceEntries();
|
||||
result.addAll(dbReader.loadHotseatEntries());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* When migrating the grid, we copy the table
|
||||
* {@link LauncherSettings.Favorites#TABLE_NAME} from {@code source} into
|
||||
@@ -654,7 +664,7 @@ public class GridSizeMigrationUtil {
|
||||
}
|
||||
}
|
||||
|
||||
protected static class DbEntry extends ItemInfo implements Comparable<DbEntry> {
|
||||
public static class DbEntry extends ItemInfo implements Comparable<DbEntry> {
|
||||
|
||||
private String mIntent;
|
||||
private String mProvider;
|
||||
|
||||
Reference in New Issue
Block a user