From 12856a32b7616a55afb32fba6690eb3f43634065 Mon Sep 17 00:00:00 2001 From: Federico Baron Date: Thu, 30 Jan 2025 00:41:27 +0000 Subject: [PATCH] When doing the special case migration where cells shift up, only modify workspace items Fix: 393212285 Test: Verified DB values Flag: com.android.launcher3.one_grid_specs Change-Id: I6cd1d520a2128925664ff3ac65ec75c86a7fb54b --- .../launcher3/model/GridSizeMigrationDBController.java | 4 ++-- src/com/android/launcher3/model/GridSizeMigrationLogic.kt | 4 ++-- src/com/android/launcher3/provider/LauncherDbUtils.kt | 7 +++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/model/GridSizeMigrationDBController.java b/src/com/android/launcher3/model/GridSizeMigrationDBController.java index 9aff90e6e9..d256d1ba4c 100644 --- a/src/com/android/launcher3/model/GridSizeMigrationDBController.java +++ b/src/com/android/launcher3/model/GridSizeMigrationDBController.java @@ -24,7 +24,7 @@ import static com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET; import static com.android.launcher3.model.LoaderTask.SMARTSPACE_ON_HOME_SCREEN; import static com.android.launcher3.provider.LauncherDbUtils.copyTable; import static com.android.launcher3.provider.LauncherDbUtils.dropTable; -import static com.android.launcher3.provider.LauncherDbUtils.shiftTableByXCells; +import static com.android.launcher3.provider.LauncherDbUtils.shiftWorkspaceByXCells; import android.content.ComponentName; import android.content.ContentValues; @@ -143,7 +143,7 @@ public class GridSizeMigrationDBController { // We want to add the extra row(s) to the top of the screen, so we shift the grid // down. if (oneGridSpecs()) { - shiftTableByXCells( + shiftWorkspaceByXCells( target.getWritableDatabase(), (destDeviceState.getRows() - srcDeviceState.getRows()), TABLE_NAME); diff --git a/src/com/android/launcher3/model/GridSizeMigrationLogic.kt b/src/com/android/launcher3/model/GridSizeMigrationLogic.kt index fe99fb15e0..876919acf0 100644 --- a/src/com/android/launcher3/model/GridSizeMigrationLogic.kt +++ b/src/com/android/launcher3/model/GridSizeMigrationLogic.kt @@ -35,7 +35,7 @@ import com.android.launcher3.model.GridSizeMigrationDBController.DbReader import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction import com.android.launcher3.provider.LauncherDbUtils.copyTable import com.android.launcher3.provider.LauncherDbUtils.dropTable -import com.android.launcher3.provider.LauncherDbUtils.shiftTableByXCells +import com.android.launcher3.provider.LauncherDbUtils.shiftWorkspaceByXCells import com.android.launcher3.util.CellAndSpan import com.android.launcher3.util.GridOccupancy import com.android.launcher3.util.IntArray @@ -82,7 +82,7 @@ class GridSizeMigrationLogic { if (shouldMigrateToStrtictlyTallerGrid) { Log.d(TAG, "Migrating to strictly taller grid") if (oneGridSpecs()) { - shiftTableByXCells( + shiftWorkspaceByXCells( target.writableDatabase, (destDeviceState.rows - srcDeviceState.rows), TABLE_NAME, diff --git a/src/com/android/launcher3/provider/LauncherDbUtils.kt b/src/com/android/launcher3/provider/LauncherDbUtils.kt index 6f1d0dddaf..c92328d8a3 100644 --- a/src/com/android/launcher3/provider/LauncherDbUtils.kt +++ b/src/com/android/launcher3/provider/LauncherDbUtils.kt @@ -28,6 +28,7 @@ import android.os.UserManager import android.text.TextUtils import com.android.launcher3.LauncherAppState import com.android.launcher3.LauncherSettings +import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP import com.android.launcher3.Utilities import com.android.launcher3.icons.IconCache import com.android.launcher3.model.LoaderCursor @@ -132,8 +133,10 @@ object LauncherDbUtils { } @JvmStatic - fun shiftTableByXCells(db: SQLiteDatabase, x: Int, toTable: String) { - db.run { execSQL("UPDATE $toTable SET cellY = cellY + $x") } + fun shiftWorkspaceByXCells(db: SQLiteDatabase, x: Int, toTable: String) { + db.run { + execSQL("UPDATE $toTable SET cellY = cellY + $x WHERE container = $CONTAINER_DESKTOP") + } } /**