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
2021-10-15 21:16:48 +01:00
committed by Alex Chau
parent f75725830a
commit 953eb8041e
5 changed files with 13 additions and 62 deletions

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);