From 8f26e042b2efb4038d379f23814a7935cb4328c2 Mon Sep 17 00:00:00 2001 From: fbaron Date: Tue, 5 Nov 2024 11:06:02 -0800 Subject: [PATCH] Remove flags that are no longer necessary Flag: EXEMPT code cleanup Test: GridSizeMigrationTest Bug: b/325286145, b/325285743 Change-Id: I056021c299b56a186b754b94b33509d0b01816e0 --- .../launcher3/InvariantDeviceProfile.java | 30 ------------------- .../model/GridSizeMigrationDBController.java | 2 -- .../launcher3/model/GridSizeMigrationLogic.kt | 2 +- .../launcher3/provider/RestoreDbTask.java | 21 +++++-------- 4 files changed, 9 insertions(+), 46 deletions(-) diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 7acba753ff..1b38695acf 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -52,7 +52,6 @@ import androidx.core.content.res.ResourcesCompat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.icons.DotRenderer; -import com.android.launcher3.logging.FileLog; import com.android.launcher3.model.DeviceGridState; import com.android.launcher3.provider.RestoreDbTask; import com.android.launcher3.testing.shared.ResourceUtils; @@ -303,35 +302,6 @@ public class InvariantDeviceProfile implements SafeCloseable { DisplayController.INSTANCE.executeIfCreated(dc -> dc.setPriorityListener(null)); } - /** - * Reinitialize the current grid after a restore, where some grids might now be disabled. - */ - public void reinitializeAfterRestore(Context context) { - String currentGridName = getCurrentGridName(context); - String currentDbFile = dbFile; - String newGridName = initGrid(context, currentGridName); - String newDbFile = dbFile; - FileLog.d(TAG, "Reinitializing grid after restore." - + " currentGridName=" + currentGridName - + ", currentDbFile=" + currentDbFile - + ", newGridName=" + newGridName - + ", newDbFile=" + newDbFile); - if (!newDbFile.equals(currentDbFile)) { - FileLog.d(TAG, "Restored grid is disabled : " + currentGridName - + ", migrating to: " + newGridName - + ", removing all other grid db files"); - for (String gridDbFile : LauncherFiles.GRID_DB_FILES) { - if (gridDbFile.equals(currentDbFile)) { - continue; - } - if (context.getDatabasePath(gridDbFile).delete()) { - FileLog.d(TAG, "Removed old grid db file: " + gridDbFile); - } - } - setCurrentGrid(context, newGridName); - } - } - public static String getCurrentGridName(Context context) { return LauncherPrefs.get(context).get(GRID_NAME); } diff --git a/src/com/android/launcher3/model/GridSizeMigrationDBController.java b/src/com/android/launcher3/model/GridSizeMigrationDBController.java index bad7577fc3..bef2e3b92e 100644 --- a/src/com/android/launcher3/model/GridSizeMigrationDBController.java +++ b/src/com/android/launcher3/model/GridSizeMigrationDBController.java @@ -38,7 +38,6 @@ import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; -import com.android.launcher3.Flags; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherPrefs; import com.android.launcher3.LauncherSettings; @@ -129,7 +128,6 @@ public class GridSizeMigrationDBController { } if (LauncherPrefs.get(context).get(IS_FIRST_LOAD_AFTER_RESTORE) - && Flags.enableGridMigrationFix() && srcDeviceState.getColumns().equals(destDeviceState.getColumns()) && srcDeviceState.getRows() < destDeviceState.getRows()) { Log.i("b/360462379", "Grid migration fix entry point."); diff --git a/src/com/android/launcher3/model/GridSizeMigrationLogic.kt b/src/com/android/launcher3/model/GridSizeMigrationLogic.kt index 9470abf11d..07316ef0ee 100644 --- a/src/com/android/launcher3/model/GridSizeMigrationLogic.kt +++ b/src/com/android/launcher3/model/GridSizeMigrationLogic.kt @@ -339,7 +339,7 @@ class GridSizeMigrationLogic { srcDeviceState: DeviceGridState, destDeviceState: DeviceGridState, ): Boolean { - return (isFirstLoad && Flags.enableGridMigrationFix()) && + return isFirstLoad && srcDeviceState.columns == destDeviceState.columns && srcDeviceState.rows < destDeviceState.rows } diff --git a/src/com/android/launcher3/provider/RestoreDbTask.java b/src/com/android/launcher3/provider/RestoreDbTask.java index 59c27af6da..8db981f26a 100644 --- a/src/com/android/launcher3/provider/RestoreDbTask.java +++ b/src/com/android/launcher3/provider/RestoreDbTask.java @@ -51,7 +51,6 @@ import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import androidx.annotation.WorkerThread; -import com.android.launcher3.Flags; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherFiles; @@ -124,18 +123,14 @@ public class RestoreDbTask { // executed again. LauncherPrefs.get(context).removeSync(RESTORE_DEVICE); - if (Flags.enableNarrowGridRestore()) { - DeviceGridState deviceGridState = new DeviceGridState(context); - String oldPhoneFileName = deviceGridState.getDbFile(); - List previousDbs = existingDbs(context); - removeOldDBs(context, oldPhoneFileName); - // The idp before this contains data about the old phone, after this it becomes the idp - // of the current phone. - idp.reset(context); - trySettingPreviousGridAsCurrent(context, idp, oldPhoneFileName, previousDbs); - } else { - idp.reinitializeAfterRestore(context); - } + DeviceGridState deviceGridState = new DeviceGridState(context); + String oldPhoneFileName = deviceGridState.getDbFile(); + List previousDbs = existingDbs(context); + removeOldDBs(context, oldPhoneFileName); + // The idp before this contains data about the old phone, after this it becomes the idp + // of the current phone. + idp.reset(context); + trySettingPreviousGridAsCurrent(context, idp, oldPhoneFileName, previousDbs); }