Fixing the hotseat import logic

The import logic following the behavior: Improt everything and force
run GridMigrationTask to automatically remove broken icons.
This logic would fail for hotseat as the replacement happens before
the GridMigrationTask, which will not replace the broken targets
appropriately

The cl changes some logic only for hotseat import
> After import remove any broken icons/empty folders
> When adding default icons, only add as much icons as required. Since
GridMigrationTask uses weights, it sometimes removes imported icon, if
the hotseat size becomes too large.

Bug: 30909630
Change-Id: I6ca1f25dac81649794d81aaf82c3c38d1c918d91
This commit is contained in:
Sunny Goyal
2016-08-24 11:30:33 -07:00
parent 92cb84d4e5
commit d70ef24233
2 changed files with 41 additions and 10 deletions

View File

@@ -973,6 +973,26 @@ public class GridSizeMigrationTask {
return validPackages;
}
/**
* Removes any broken item from the hotseat.
* @return a map with occupied hotseat position set to non-null value.
*/
public static LongArrayMap<Object> removeBrokenHotseatItems(Context context) throws Exception {
GridSizeMigrationTask task = new GridSizeMigrationTask(context,
LauncherAppState.getInstance().getInvariantDeviceProfile(),
getValidPackages(context), Integer.MAX_VALUE, Integer.MAX_VALUE);
// Load all the valid entries
ArrayList<DbEntry> items = task.loadHotseatEntries();
// Delete any entry marked for deletion by above load.
task.applyOperations();
LongArrayMap<Object> positions = new LongArrayMap<>();
for (DbEntry item : items) {
positions.put(item.screenId, item);
}
return positions;
}
/**
* Task to run grid migration in multiple steps when the size difference is more than 1.
*/