Fix grid previewing so it matches the applied layout

Bug: 392019771
Flag: com.android.systemui.shared.new_customization_picker_ui
Test: tested manually
Change-Id: If0fdd130d4278222b0b6ec2787aa7d6d56fc4b2f
This commit is contained in:
Federico Baron committed 2025-02-24 11:54:26 -08:00
1 parent b716d19362
commit 45fe4733fb
3 files changed
+4 -29

No files matched your search

@@ -80,7 +80,6 @@ import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction;
import com.android.launcher3.provider.RestoreDbTask;
import com.android.launcher3.util.IOUtils;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.MainThreadInitializedObject.SandboxContext;
import com.android.launcher3.util.Partner;
import com.android.launcher3.widget.LauncherWidgetHolder;
@@ -143,14 +142,11 @@ public class ModelDbController {
}
protected DatabaseHelper createDatabaseHelper(boolean forMigration, String dbFile) {
boolean isSandbox = mContext instanceof SandboxContext;
String dbName = isSandbox ? null : dbFile;
// Set the flag for empty DB
Runnable onEmptyDbCreateCallback = forMigration ? () -> { }
: () -> LauncherPrefs.get(mContext).putSync(getEmptyDbCreatedKey(dbName).to(true));
: () -> LauncherPrefs.get(mContext).putSync(getEmptyDbCreatedKey(dbFile).to(true));
DatabaseHelper databaseHelper = new DatabaseHelper(mContext, dbName,
DatabaseHelper databaseHelper = new DatabaseHelper(mContext, dbFile,
this::getSerialNumberForUser, onEmptyDbCreateCallback);
// Table creation sometimes fails silently, which leads to a crash loop.
// This way, we will try to create a table every time after crash, so the device
@@ -380,8 +376,7 @@ public class ModelDbController {
.filter(dbName -> mContext.getDatabasePath(dbName).exists())
.collect(Collectors.toList());
mOpenHelper = (mContext instanceof SandboxContext) ? oldHelper
: createDatabaseHelper(true, new DeviceGridState(idp).getDbFile());
mOpenHelper = createDatabaseHelper(true, new DeviceGridState(idp).getDbFile());
try {
// This is the current grid we have, given by the mContext
DeviceGridState srcDeviceState = new DeviceGridState(mContext);
@@ -462,8 +457,7 @@ public class ModelDbController {
List<String> existingDBs = LauncherFiles.GRID_DB_FILES.stream()
.filter(dbName -> mContext.getDatabasePath(dbName).exists())
.collect(Collectors.toList());
mOpenHelper = (mContext instanceof SandboxContext) ? oldHelper
: createDatabaseHelper(true /* forMigration */, targetDbName);
mOpenHelper = createDatabaseHelper(true /* forMigration */, targetDbName);
try {
// This is the current grid we have, given by the mContext
DeviceGridState srcDeviceState = new DeviceGridState(mContext);
@@ -763,10 +757,6 @@ public class ModelDbController {
* string will be "EMPTY_DATABASE_CREATED@minimal.db".
*/
private ConstantItem<Boolean> getEmptyDbCreatedKey(String dbName) {
if (mContext instanceof SandboxContext) {
return LauncherPrefs.nonRestorableItem(EMPTY_DATABASE_CREATED,
false /* default value */, EncryptionType.ENCRYPTED);
}
String key = TextUtils.equals(dbName, LauncherFiles.LAUNCHER_DB)
? EMPTY_DATABASE_CREATED : EMPTY_DATABASE_CREATED + "@" + dbName;
return LauncherPrefs.backedUpItem(key, false /* default value */, EncryptionType.ENCRYPTED);