Prevent bad grid configuration by making sure RestoreDbTask updates IDP correctly.

IPD#reset() was resetting the internal IDP dbFile to the factory default instead of current grid/db

This lead to LoaderTask and grid migration creating an empty DB for the wrong grid size, while the restored DB remained unused. Leading to an empty home screen because an empty DB file was used.

Bug: 377510898
Flag: EXEMPT bugfix
Test: manually testing backup & restore with various grid sizes
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:3eec1895edab17b713e8148dcfe763083e99c185)
Merged-In: I709201e484afb8f12a4fde21198d2c5793d89ca1
Change-Id: I709201e484afb8f12a4fde21198d2c5793d89ca1
This commit is contained in:
Charlie Anderson
2024-12-11 22:11:09 +00:00
committed by Android Build Coastguard Worker
parent 12ef2f5123
commit be55d969ff
@@ -245,10 +245,6 @@ public class InvariantDeviceProfile implements SafeCloseable {
@TargetApi(23)
private InvariantDeviceProfile(Context context) {
String gridName = getCurrentGridName(context);
FileLog.d(TAG, "New InvariantDeviceProfile, before initGrid(): "
+ "gridName:" + gridName
+ ", LauncherPrefs GRID_NAME:" + LauncherPrefs.get(context).get(GRID_NAME)
+ ", LauncherPrefs DB_FILE:" + LauncherPrefs.get(context).get(DB_FILE));
initGrid(context, gridName);
DisplayController.INSTANCE.get(context).setPriorityListener(
(displayContext, info, flags) -> {
@@ -353,6 +349,11 @@ public class InvariantDeviceProfile implements SafeCloseable {
}
private String initGrid(Context context, String gridName) {
FileLog.d(TAG, "Before initGrid:"
+ "gridName:" + gridName
+ ", dbFile:" + dbFile
+ ", LauncherPrefs GRID_NAME:" + LauncherPrefs.get(context).get(GRID_NAME)
+ ", LauncherPrefs DB_FILE:" + LauncherPrefs.get(context).get(DB_FILE));
Info displayInfo = DisplayController.INSTANCE.get(context).getInfo();
List<DisplayOption> allOptions = getPredefinedDeviceProfiles(
context,
@@ -378,8 +379,9 @@ public class InvariantDeviceProfile implements SafeCloseable {
}
initGrid(context, displayInfo, displayOption);
FileLog.d(TAG, "initGrid: "
FileLog.d(TAG, "After initGrid:"
+ "gridName:" + gridName
+ ", dbFile:" + dbFile
+ ", LauncherPrefs GRID_NAME:" + LauncherPrefs.get(context).get(GRID_NAME)
+ ", LauncherPrefs DB_FILE:" + LauncherPrefs.get(context).get(DB_FILE));
return displayOption.grid.name;
@@ -397,7 +399,7 @@ public class InvariantDeviceProfile implements SafeCloseable {
*/
@Deprecated
public void reset(Context context) {
initGrid(context, getDefaultGridName(context));
initGrid(context, getCurrentGridName(context));
}
@VisibleForTesting