Fix LauncherProvider newScreenId issue

Remove maxScreenId from LauncherProvider and whenever we need
a new screenId, query the database to calculate a new screenId.
Also converted and refactored AddWorkspaceItemsTaskTest
and added some extra test cases.

Test: manual & AddWorkspaceItemsTaskTest.kt
Bug: 199160559
Change-Id: I185f6823fed171d778af0130497f5ffaf89c0a70
This commit is contained in:
Andras Kloczl authored and Alex Chau committed 2021-11-12 19:56:07 +00:00
1 parent f75725830a
commit 953eb8041e
5 files changed
+13 -62

No files matched your search

+5 -5
View File
@@ -869,13 +869,13 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mWorkspaceScreens.remove(emptyScreenId);
mScreenOrder.removeValue(emptyScreenId);
int newScreenId = -1;
int newScreenId = LauncherSettings.Settings.call(getContext().getContentResolver(),
LauncherSettings.Settings.METHOD_NEW_SCREEN_ID)
.getInt(LauncherSettings.Settings.EXTRA_VALUE);
// Launcher database isn't aware of empty pages that are already bound, so we need to
// skip those IDs manually.
while (newScreenId == -1 || mWorkspaceScreens.containsKey(newScreenId)) {
newScreenId = LauncherSettings.Settings.call(getContext().getContentResolver(),
LauncherSettings.Settings.METHOD_NEW_SCREEN_ID)
.getInt(LauncherSettings.Settings.EXTRA_VALUE);
while (mWorkspaceScreens.containsKey(newScreenId)) {
newScreenId++;
}
mWorkspaceScreens.put(newScreenId, cl);