OneGrid Grid Option Updates
Bug: 330900048 Flag: com.android.launcher3.one_grid_specs Test: n/a Change-Id: I919195dbc7ac78c3be42f0f9d7620193a24d7e99
This commit is contained in:
1 parent
5c9a48d5ed
commit
ebc10c9ecc
9 files changed
+200
-48
No files matched your search
@@ -20,6 +20,7 @@ import static android.util.Base64.NO_PADDING;
|
||||
import static android.util.Base64.NO_WRAP;
|
||||
|
||||
import static com.android.launcher3.DefaultLayoutParser.RES_PARTNER_DEFAULT_LAYOUT;
|
||||
import static com.android.launcher3.LauncherPrefs.DB_FILE;
|
||||
import static com.android.launcher3.LauncherPrefs.NO_DB_FILES_RESTORED;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE;
|
||||
@@ -128,16 +129,20 @@ public class ModelDbController {
|
||||
|
||||
private synchronized void createDbIfNotExists() {
|
||||
if (mOpenHelper == null) {
|
||||
mOpenHelper = createDatabaseHelper(false /* forMigration */);
|
||||
String dbFile = LauncherPrefs.get(mContext).get(DB_FILE);
|
||||
if (dbFile.isEmpty()) {
|
||||
dbFile = InvariantDeviceProfile.INSTANCE.get(mContext).dbFile;
|
||||
}
|
||||
mOpenHelper = createDatabaseHelper(false /* forMigration */, dbFile);
|
||||
printDBs("before: ");
|
||||
RestoreDbTask.restoreIfNeeded(mContext, this);
|
||||
printDBs("after: ");
|
||||
}
|
||||
}
|
||||
|
||||
protected DatabaseHelper createDatabaseHelper(boolean forMigration) {
|
||||
protected DatabaseHelper createDatabaseHelper(boolean forMigration, String dbFile) {
|
||||
boolean isSandbox = mContext instanceof SandboxContext;
|
||||
String dbName = isSandbox ? null : InvariantDeviceProfile.INSTANCE.get(mContext).dbFile;
|
||||
String dbName = isSandbox ? null : dbFile;
|
||||
|
||||
// Set the flag for empty DB
|
||||
Runnable onEmptyDbCreateCallback = forMigration ? () -> { }
|
||||
@@ -364,7 +369,7 @@ public class ModelDbController {
|
||||
InvariantDeviceProfile idp = LauncherAppState.getIDP(mContext);
|
||||
DatabaseHelper oldHelper = mOpenHelper;
|
||||
mOpenHelper = (mContext instanceof SandboxContext) ? oldHelper
|
||||
: createDatabaseHelper(true /* forMigration */);
|
||||
: createDatabaseHelper(true, new DeviceGridState(idp).getDbFile());
|
||||
try {
|
||||
// This is the current grid we have, given by the mContext
|
||||
DeviceGridState srcDeviceState = new DeviceGridState(mContext);
|
||||
@@ -388,7 +393,6 @@ public class ModelDbController {
|
||||
* Migrates the DB if needed. If the migration failed, it clears the DB.
|
||||
*/
|
||||
public void tryMigrateDB(@Nullable LauncherRestoreEventLogger restoreEventLogger) {
|
||||
|
||||
if (!migrateGridIfNeeded()) {
|
||||
if (restoreEventLogger != null) {
|
||||
if (LauncherPrefs.get(mContext).get(NO_DB_FILES_RESTORED)) {
|
||||
@@ -438,7 +442,7 @@ public class ModelDbController {
|
||||
}
|
||||
DatabaseHelper oldHelper = mOpenHelper;
|
||||
mOpenHelper = (mContext instanceof SandboxContext) ? oldHelper
|
||||
: createDatabaseHelper(true /* forMigration */);
|
||||
: createDatabaseHelper(true /* forMigration */, targetDbName);
|
||||
try {
|
||||
// This is the current grid we have, given by the mContext
|
||||
DeviceGridState srcDeviceState = new DeviceGridState(mContext);
|
||||
|
||||
Reference in new issue
Block a user