Add two panel home support for page binding logic

There's a logic which prioritizes the binding for the
current page and defers the other pages' binding.
If two panel home is enabled, we want to bind both pages
together. LauncherPageRestoreHelper has been created to
contain the logic for persisting restoring and calculating
which pages to load immediately.

Test: manual + run LauncherPageRestoreHelperTest robo test
Bug: 174464691
Change-Id: I57ac3f7150303b95b272e922f44bda26f9d5ce2a
This commit is contained in:
Andras Kloczl
2021-05-14 12:21:30 +02:00
parent f3649f5e98
commit 55edfe55f7
17 changed files with 499 additions and 85 deletions

View File

@@ -26,12 +26,12 @@ import static org.robolectric.Shadows.shadowOf;
import android.os.Process;
import com.android.launcher3.PagedView;
import com.android.launcher3.model.BgDataModel.Callbacks;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.shadows.ShadowLooperExecutor;
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.LauncherLayoutBuilder;
import com.android.launcher3.util.LauncherModelHelper;
import com.android.launcher3.util.LooperExecutor;
@@ -92,7 +92,7 @@ public class ModelMultiCallbacksTest {
// Add a new callback
cb1.reset();
MyCallbacks cb2 = spy(MyCallbacks.class);
cb2.mPageToBindSync = 2;
cb2.mPageToBindSync = IntSet.wrap(2);
mModelHelper.getModel().addCallbacksAndLoad(cb2);
waitForLoaderAndTempMainThread();
@@ -178,16 +178,16 @@ public class ModelMultiCallbacksTest {
private abstract static class MyCallbacks implements Callbacks {
final List<ItemInfo> mItems = new ArrayList<>();
int mPageToBindSync = 0;
int mPageBoundSync = PagedView.INVALID_PAGE;
IntSet mPageToBindSync = IntSet.wrap(0);
IntSet mPageBoundSync = new IntSet();
ViewOnDrawExecutor mDeferredExecutor;
AppInfo[] mAppInfos;
MyCallbacks() { }
@Override
public void onPageBoundSynchronously(int page) {
mPageBoundSync = page;
public void onPagesBoundSynchronously(IntSet pages) {
mPageBoundSync = pages;
}
@Override
@@ -206,13 +206,13 @@ public class ModelMultiCallbacksTest {
}
@Override
public int getPageToBindSynchronously() {
public IntSet getPagesToBindSynchronously() {
return mPageToBindSync;
}
public void reset() {
mItems.clear();
mPageBoundSync = PagedView.INVALID_PAGE;
mPageBoundSync = new IntSet();
mDeferredExecutor = null;
mAppInfos = null;
}