Loading src/com/android/launcher3/Launcher.java +4 −2 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ import android.widget.Toast; import com.android.launcher3.DropTarget.DragObject; import com.android.launcher3.accessibility.LauncherAccessibilityDelegate; import com.android.launcher3.allapps.AllAppsContainerView; import com.android.launcher3.allapps.AllAppsStore; import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.anim.PropertyListBuilder; Loading Loading @@ -2241,8 +2242,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } mPendingExecutor = executor; if (!isInState(ALL_APPS)) { mAppsView.getAppsStore().setDeferUpdates(true); mPendingExecutor.execute(() -> mAppsView.getAppsStore().setDeferUpdates(false)); mAppsView.getAppsStore().enableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW); mPendingExecutor.execute(() -> mAppsView.getAppsStore().disableDeferUpdates( AllAppsStore.DEFER_UPDATES_NEXT_DRAW)); } executor.attachTo(this); Loading src/com/android/launcher3/allapps/AllAppsContainerView.java +3 −2 Original line number Diff line number Diff line Loading @@ -628,11 +628,12 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo final boolean result = super.dispatchTouchEvent(ev); switch (ev.getActionMasked()) { case MotionEvent.ACTION_DOWN: if (result) mAllAppsStore.setDeferUpdates(true); if (result) mAllAppsStore.enableDeferUpdates( AllAppsStore.DEFER_UPDATES_USER_INTERACTION); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mAllAppsStore.setDeferUpdates(false); mAllAppsStore.disableDeferUpdates(AllAppsStore.DEFER_UPDATES_USER_INTERACTION); break; } return result; Loading src/com/android/launcher3/allapps/AllAppsStore.java +21 −10 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Set; import java.util.function.Consumer; import java.util.function.Predicate; Loading @@ -38,12 +37,19 @@ import java.util.function.Predicate; */ public class AllAppsStore { // Defer updates flag used to defer all apps updates to the next draw. public static final int DEFER_UPDATES_NEXT_DRAW = 1 << 0; // Defer updates flag used to defer all apps updates while the user interacts with all apps. public static final int DEFER_UPDATES_USER_INTERACTION = 1 << 1; // Defer updates flag used to defer all apps updates by a test's request. public static final int DEFER_UPDATES_TEST = 1 << 2; private PackageUserKey mTempKey = new PackageUserKey(null, null); private final HashMap<ComponentKey, AppInfo> mComponentToAppMap = new HashMap<>(); private final List<OnUpdateListener> mUpdateListeners = new ArrayList<>(); private final ArrayList<ViewGroup> mIconContainers = new ArrayList<>(); private boolean mDeferUpdates = false; private int mDeferUpdatesFlags = 0; private boolean mUpdatePending = false; public Collection<AppInfo> getApps() { Loading @@ -62,15 +68,20 @@ public class AllAppsStore { return mComponentToAppMap.get(key); } public void setDeferUpdates(boolean deferUpdates) { if (mDeferUpdates != deferUpdates) { mDeferUpdates = deferUpdates; public void enableDeferUpdates(int flag) { mDeferUpdatesFlags |= flag; } if (!mDeferUpdates && mUpdatePending) { public void disableDeferUpdates(int flag) { mDeferUpdatesFlags &= ~flag; if (mDeferUpdatesFlags == 0 && mUpdatePending) { notifyUpdate(); mUpdatePending = false; } } public int getDeferUpdatesFlags() { return mDeferUpdatesFlags; } /** Loading @@ -95,7 +106,7 @@ public class AllAppsStore { private void notifyUpdate() { if (mDeferUpdates) { if (mDeferUpdatesFlags != 0) { mUpdatePending = true; return; } Loading src/com/android/launcher3/testing/TestInformationHandler.java +30 −0 Original line number Diff line number Diff line Loading @@ -23,9 +23,13 @@ import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherState; import com.android.launcher3.MainThreadExecutor; import com.android.launcher3.R; import com.android.launcher3.allapps.AllAppsStore; import com.android.launcher3.util.ResourceBasedOverride; import java.util.concurrent.ExecutionException; public class TestInformationHandler implements ResourceBasedOverride { public static TestInformationHandler newInstance(Context context) { Loading Loading @@ -77,6 +81,32 @@ public class TestInformationHandler implements ResourceBasedOverride { case TestProtocol.REQUEST_DISABLE_DEBUG_TRACING: TestProtocol.sDebugTracing = false; break; case TestProtocol.REQUEST_FREEZE_APP_LIST: new MainThreadExecutor().execute(() -> mLauncher.getAppsView().getAppsStore().enableDeferUpdates( AllAppsStore.DEFER_UPDATES_TEST)); break; case TestProtocol.REQUEST_UNFREEZE_APP_LIST: new MainThreadExecutor().execute(() -> mLauncher.getAppsView().getAppsStore().disableDeferUpdates( AllAppsStore.DEFER_UPDATES_TEST)); break; case TestProtocol.REQUEST_APP_LIST_FREEZE_FLAGS: { try { final int deferUpdatesFlags = new MainThreadExecutor().submit(() -> mLauncher.getAppsView().getAppsStore().getDeferUpdatesFlags()).get(); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, deferUpdatesFlags); } catch (ExecutionException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } break; } } return response; } Loading src/com/android/launcher3/testing/TestProtocol.java +5 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ public final class TestProtocol { } public static final String TEST_INFO_RESPONSE_FIELD = "response"; public static final String REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT = "home-to-overview-swipe-height"; public static final String REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT = Loading @@ -65,6 +66,10 @@ public final class TestProtocol { "all-apps-to-overview-swipe-height"; public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT = "home-to-all-apps-swipe-height"; public static final String REQUEST_FREEZE_APP_LIST = "freeze-app-list"; public static final String REQUEST_UNFREEZE_APP_LIST = "unfreeze-app-list"; public static final String REQUEST_APP_LIST_FREEZE_FLAGS = "app-list-freeze-flags"; public static boolean sDebugTracing = false; public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing"; public static final String REQUEST_DISABLE_DEBUG_TRACING = "disable-debug-tracing"; Loading Loading
src/com/android/launcher3/Launcher.java +4 −2 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ import android.widget.Toast; import com.android.launcher3.DropTarget.DragObject; import com.android.launcher3.accessibility.LauncherAccessibilityDelegate; import com.android.launcher3.allapps.AllAppsContainerView; import com.android.launcher3.allapps.AllAppsStore; import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.anim.PropertyListBuilder; Loading Loading @@ -2241,8 +2242,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } mPendingExecutor = executor; if (!isInState(ALL_APPS)) { mAppsView.getAppsStore().setDeferUpdates(true); mPendingExecutor.execute(() -> mAppsView.getAppsStore().setDeferUpdates(false)); mAppsView.getAppsStore().enableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW); mPendingExecutor.execute(() -> mAppsView.getAppsStore().disableDeferUpdates( AllAppsStore.DEFER_UPDATES_NEXT_DRAW)); } executor.attachTo(this); Loading
src/com/android/launcher3/allapps/AllAppsContainerView.java +3 −2 Original line number Diff line number Diff line Loading @@ -628,11 +628,12 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo final boolean result = super.dispatchTouchEvent(ev); switch (ev.getActionMasked()) { case MotionEvent.ACTION_DOWN: if (result) mAllAppsStore.setDeferUpdates(true); if (result) mAllAppsStore.enableDeferUpdates( AllAppsStore.DEFER_UPDATES_USER_INTERACTION); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mAllAppsStore.setDeferUpdates(false); mAllAppsStore.disableDeferUpdates(AllAppsStore.DEFER_UPDATES_USER_INTERACTION); break; } return result; Loading
src/com/android/launcher3/allapps/AllAppsStore.java +21 −10 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Set; import java.util.function.Consumer; import java.util.function.Predicate; Loading @@ -38,12 +37,19 @@ import java.util.function.Predicate; */ public class AllAppsStore { // Defer updates flag used to defer all apps updates to the next draw. public static final int DEFER_UPDATES_NEXT_DRAW = 1 << 0; // Defer updates flag used to defer all apps updates while the user interacts with all apps. public static final int DEFER_UPDATES_USER_INTERACTION = 1 << 1; // Defer updates flag used to defer all apps updates by a test's request. public static final int DEFER_UPDATES_TEST = 1 << 2; private PackageUserKey mTempKey = new PackageUserKey(null, null); private final HashMap<ComponentKey, AppInfo> mComponentToAppMap = new HashMap<>(); private final List<OnUpdateListener> mUpdateListeners = new ArrayList<>(); private final ArrayList<ViewGroup> mIconContainers = new ArrayList<>(); private boolean mDeferUpdates = false; private int mDeferUpdatesFlags = 0; private boolean mUpdatePending = false; public Collection<AppInfo> getApps() { Loading @@ -62,15 +68,20 @@ public class AllAppsStore { return mComponentToAppMap.get(key); } public void setDeferUpdates(boolean deferUpdates) { if (mDeferUpdates != deferUpdates) { mDeferUpdates = deferUpdates; public void enableDeferUpdates(int flag) { mDeferUpdatesFlags |= flag; } if (!mDeferUpdates && mUpdatePending) { public void disableDeferUpdates(int flag) { mDeferUpdatesFlags &= ~flag; if (mDeferUpdatesFlags == 0 && mUpdatePending) { notifyUpdate(); mUpdatePending = false; } } public int getDeferUpdatesFlags() { return mDeferUpdatesFlags; } /** Loading @@ -95,7 +106,7 @@ public class AllAppsStore { private void notifyUpdate() { if (mDeferUpdates) { if (mDeferUpdatesFlags != 0) { mUpdatePending = true; return; } Loading
src/com/android/launcher3/testing/TestInformationHandler.java +30 −0 Original line number Diff line number Diff line Loading @@ -23,9 +23,13 @@ import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherState; import com.android.launcher3.MainThreadExecutor; import com.android.launcher3.R; import com.android.launcher3.allapps.AllAppsStore; import com.android.launcher3.util.ResourceBasedOverride; import java.util.concurrent.ExecutionException; public class TestInformationHandler implements ResourceBasedOverride { public static TestInformationHandler newInstance(Context context) { Loading Loading @@ -77,6 +81,32 @@ public class TestInformationHandler implements ResourceBasedOverride { case TestProtocol.REQUEST_DISABLE_DEBUG_TRACING: TestProtocol.sDebugTracing = false; break; case TestProtocol.REQUEST_FREEZE_APP_LIST: new MainThreadExecutor().execute(() -> mLauncher.getAppsView().getAppsStore().enableDeferUpdates( AllAppsStore.DEFER_UPDATES_TEST)); break; case TestProtocol.REQUEST_UNFREEZE_APP_LIST: new MainThreadExecutor().execute(() -> mLauncher.getAppsView().getAppsStore().disableDeferUpdates( AllAppsStore.DEFER_UPDATES_TEST)); break; case TestProtocol.REQUEST_APP_LIST_FREEZE_FLAGS: { try { final int deferUpdatesFlags = new MainThreadExecutor().submit(() -> mLauncher.getAppsView().getAppsStore().getDeferUpdatesFlags()).get(); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, deferUpdatesFlags); } catch (ExecutionException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } break; } } return response; } Loading
src/com/android/launcher3/testing/TestProtocol.java +5 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ public final class TestProtocol { } public static final String TEST_INFO_RESPONSE_FIELD = "response"; public static final String REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT = "home-to-overview-swipe-height"; public static final String REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT = Loading @@ -65,6 +66,10 @@ public final class TestProtocol { "all-apps-to-overview-swipe-height"; public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT = "home-to-all-apps-swipe-height"; public static final String REQUEST_FREEZE_APP_LIST = "freeze-app-list"; public static final String REQUEST_UNFREEZE_APP_LIST = "unfreeze-app-list"; public static final String REQUEST_APP_LIST_FREEZE_FLAGS = "app-list-freeze-flags"; public static boolean sDebugTracing = false; public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing"; public static final String REQUEST_DISABLE_DEBUG_TRACING = "disable-debug-tracing"; Loading