Loading src/com/android/launcher3/InvariantDeviceProfile.java +6 −5 Original line number Diff line number Diff line Loading @@ -250,11 +250,12 @@ public class InvariantDeviceProfile { * 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 gridName = getCurrentGridName(context); String newGridName = initGrid(context, gridName); if (!newGridName.equals(gridName)) { Log.d(TAG, "Restored grid is disabled : " + gridName String newGridName = initGrid(context, currentGridName); String newDbFile = dbFile; if (!newDbFile.equals(currentDbFile)) { Log.d(TAG, "Restored grid is disabled : " + currentGridName + ", migrating to: " + newGridName + ", removing all other grid db files"); for (String gridDbFile : LauncherFiles.GRID_DB_FILES) { Loading @@ -265,7 +266,7 @@ public class InvariantDeviceProfile { Log.d(TAG, "Removed old grid db file: " + gridDbFile); } } setCurrentGrid(context, gridName); setCurrentGrid(context, newGridName); } } Loading src/com/android/launcher3/LauncherBackupAgent.java +16 −0 Original line number Diff line number Diff line Loading @@ -8,8 +8,13 @@ import android.os.ParcelFileDescriptor; import com.android.launcher3.logging.FileLog; import com.android.launcher3.provider.RestoreDbTask; import java.io.File; import java.io.IOException; public class LauncherBackupAgent extends BackupAgent { private static final String TAG = "LauncherBackupAgent"; @Override public void onCreate() { super.onCreate(); Loading @@ -23,6 +28,17 @@ public class LauncherBackupAgent extends BackupAgent { // Doesn't do incremental backup/restore } @Override public void onRestoreFile(ParcelFileDescriptor data, long size, File destination, int type, long mode, long mtime) throws IOException { // Remove old files which might contain obsolete attributes like idp_grid_name in shared // preference that will obstruct backup's attribute from writing to shared preferences. if (destination.delete()) { FileLog.d("LauncherBackupAgent", "Removed obsolete file: " + destination); } super.onRestoreFile(data, size, destination, type, mode, mtime); } @Override public void onBackup( ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) { Loading src/com/android/launcher3/provider/RestoreDbTask.java +5 −1 Original line number Diff line number Diff line Loading @@ -79,11 +79,15 @@ public class RestoreDbTask { helper.createEmptyDB(helper.getWritableDatabase()); } // Obtain InvariantDeviceProfile first before setting pending to false, so // InvariantDeviceProfile won't switch to new grid when initializing. InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(context); // Set is pending to false irrespective of the result, so that it doesn't get // executed again. Utilities.getPrefs(context).edit().remove(RESTORED_DEVICE_TYPE).commit(); InvariantDeviceProfile.INSTANCE.get(context).reinitializeAfterRestore(context); idp.reinitializeAfterRestore(context); } private static boolean performRestore(Context context, DatabaseHelper helper) { Loading Loading
src/com/android/launcher3/InvariantDeviceProfile.java +6 −5 Original line number Diff line number Diff line Loading @@ -250,11 +250,12 @@ public class InvariantDeviceProfile { * 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 gridName = getCurrentGridName(context); String newGridName = initGrid(context, gridName); if (!newGridName.equals(gridName)) { Log.d(TAG, "Restored grid is disabled : " + gridName String newGridName = initGrid(context, currentGridName); String newDbFile = dbFile; if (!newDbFile.equals(currentDbFile)) { Log.d(TAG, "Restored grid is disabled : " + currentGridName + ", migrating to: " + newGridName + ", removing all other grid db files"); for (String gridDbFile : LauncherFiles.GRID_DB_FILES) { Loading @@ -265,7 +266,7 @@ public class InvariantDeviceProfile { Log.d(TAG, "Removed old grid db file: " + gridDbFile); } } setCurrentGrid(context, gridName); setCurrentGrid(context, newGridName); } } Loading
src/com/android/launcher3/LauncherBackupAgent.java +16 −0 Original line number Diff line number Diff line Loading @@ -8,8 +8,13 @@ import android.os.ParcelFileDescriptor; import com.android.launcher3.logging.FileLog; import com.android.launcher3.provider.RestoreDbTask; import java.io.File; import java.io.IOException; public class LauncherBackupAgent extends BackupAgent { private static final String TAG = "LauncherBackupAgent"; @Override public void onCreate() { super.onCreate(); Loading @@ -23,6 +28,17 @@ public class LauncherBackupAgent extends BackupAgent { // Doesn't do incremental backup/restore } @Override public void onRestoreFile(ParcelFileDescriptor data, long size, File destination, int type, long mode, long mtime) throws IOException { // Remove old files which might contain obsolete attributes like idp_grid_name in shared // preference that will obstruct backup's attribute from writing to shared preferences. if (destination.delete()) { FileLog.d("LauncherBackupAgent", "Removed obsolete file: " + destination); } super.onRestoreFile(data, size, destination, type, mode, mtime); } @Override public void onBackup( ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) { Loading
src/com/android/launcher3/provider/RestoreDbTask.java +5 −1 Original line number Diff line number Diff line Loading @@ -79,11 +79,15 @@ public class RestoreDbTask { helper.createEmptyDB(helper.getWritableDatabase()); } // Obtain InvariantDeviceProfile first before setting pending to false, so // InvariantDeviceProfile won't switch to new grid when initializing. InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(context); // Set is pending to false irrespective of the result, so that it doesn't get // executed again. Utilities.getPrefs(context).edit().remove(RESTORED_DEVICE_TYPE).commit(); InvariantDeviceProfile.INSTANCE.get(context).reinitializeAfterRestore(context); idp.reinitializeAfterRestore(context); } private static boolean performRestore(Context context, DatabaseHelper helper) { Loading