From 7b46e1145cc7dd020266ef4ed9689ae4be29cbda Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Thu, 4 Apr 2024 15:12:18 -0700 Subject: [PATCH] Set default grid when doing a backup and restore When restoring from a tablet because phones don't have the same table some issues can ocure because we setup a non valid grid, the correct thing is to setup a default. Bug: 325285743 Fix: 332964986 Flag: ACONFIG narrow_grid_restore enabled Test: BackupAndRestoreDBSelectionTest (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:df7d2b08614adfd19245577724588307ff439a7d) Merged-In: I28bf02e83dddf5ae84818d879a5e21600eddf67e Change-Id: I28bf02e83dddf5ae84818d879a5e21600eddf67e --- src/com/android/launcher3/InvariantDeviceProfile.java | 9 +++++++++ src/com/android/launcher3/provider/RestoreDbTask.java | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index ca10a572d2..2fd5ebd6d0 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -358,6 +358,15 @@ public class InvariantDeviceProfile { return displayOption.grid.name; } + /** + * @deprecated This is a temporary solution because on the backup and restore case we modify the + * IDP, this resets it. b/332974074 + */ + @Deprecated + public void reset(Context context) { + initGrid(context, getCurrentGridName(context)); + } + @VisibleForTesting public static String getDefaultGridName(Context context) { return new InvariantDeviceProfile().initGrid(context, null); diff --git a/src/com/android/launcher3/provider/RestoreDbTask.java b/src/com/android/launcher3/provider/RestoreDbTask.java index 99542f3fca..3a65f17800 100644 --- a/src/com/android/launcher3/provider/RestoreDbTask.java +++ b/src/com/android/launcher3/provider/RestoreDbTask.java @@ -126,6 +126,9 @@ public class RestoreDbTask { if (Flags.enableNarrowGridRestore()) { String oldPhoneFileName = idp.dbFile; 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); trySettingPreviousGidAsCurrent(context, idp, oldPhoneFileName); } else { idp.reinitializeAfterRestore(context);