Merge changes I0ad8d5c2,I04815313 into main
* changes: Do not defer All Apps updates with async inflation. Add logs for the app binding flow.
This commit is contained in:
committed by
Android (Google) Code Review
commit
cb724aeb2b
@@ -95,7 +95,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
|
||||
synchronouslyBoundPages = boundPages
|
||||
pagesToBindSynchronously = LIntSet()
|
||||
clearPendingBinds()
|
||||
if (!launcher.isInState(LauncherState.ALL_APPS)) {
|
||||
if (!launcher.isInState(LauncherState.ALL_APPS) && !Flags.enableWorkspaceInflation()) {
|
||||
launcher.appsView.appsStore.enableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW)
|
||||
pendingTasks.add {
|
||||
launcher.appsView.appsStore.disableDeferUpdates(
|
||||
|
||||
@@ -575,6 +575,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
}
|
||||
|
||||
protected void rebindAdapters(boolean force) {
|
||||
Log.d(TAG, "rebindAdapters: force: " + force);
|
||||
if (mSearchTransitionController.isRunning()) {
|
||||
mRebindAdaptersAfterSearchAnimation = true;
|
||||
return;
|
||||
@@ -583,6 +584,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
|
||||
boolean showTabs = shouldShowTabs();
|
||||
if (showTabs == mUsingTabs && !force) {
|
||||
Log.d(TAG, "rebindAdapters: Not needed.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -678,6 +680,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
}
|
||||
|
||||
private void replaceAppsRVContainer(boolean showTabs) {
|
||||
Log.d(TAG, "replaceAppsRVContainer: showTabs: " + showTabs);
|
||||
for (int i = AdapterHolder.MAIN; i <= AdapterHolder.WORK; i++) {
|
||||
AdapterHolder adapterHolder = mAH.get(i);
|
||||
if (adapterHolder.mRecyclerView != null) {
|
||||
@@ -711,7 +714,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
|
||||
mWorkManager.reset();
|
||||
post(() -> mAH.get(AdapterHolder.WORK).applyPadding());
|
||||
|
||||
} else {
|
||||
mWorkManager.detachWorkUtilityViews();
|
||||
mViewPager = null;
|
||||
@@ -1017,6 +1019,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
|
||||
@VisibleForTesting
|
||||
public void onAppsUpdated() {
|
||||
Log.d(TAG, "onAppsUpdated; number of apps: " + mAllAppsStore.getApps().length);
|
||||
mHasWorkApps = Stream.of(mAllAppsStore.getApps())
|
||||
.anyMatch(mWorkManager.getItemInfoMatcher());
|
||||
mHasPrivateApps = Stream.of(mAllAppsStore.getApps())
|
||||
|
||||
@@ -20,6 +20,7 @@ import static com.android.launcher3.model.data.AppInfo.EMPTY_ARRAY;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@@ -53,6 +54,7 @@ import java.util.function.Predicate;
|
||||
*/
|
||||
public class AllAppsStore<T extends Context & ActivityContext> {
|
||||
|
||||
private static final String TAG = "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 by a test's request.
|
||||
@@ -102,6 +104,7 @@ public class AllAppsStore<T extends Context & ActivityContext> {
|
||||
public void setApps(@Nullable AppInfo[] apps, int flags, Map<PackageUserKey, Integer> map,
|
||||
boolean shouldPreinflate) {
|
||||
mApps = apps == null ? EMPTY_ARRAY : apps;
|
||||
Log.d(TAG, "setApps: apps.length=" + mApps.length);
|
||||
mModelFlags = flags;
|
||||
notifyUpdate();
|
||||
mPackageUserKeytoUidMap = map;
|
||||
@@ -159,10 +162,12 @@ public class AllAppsStore<T extends Context & ActivityContext> {
|
||||
|
||||
public void enableDeferUpdates(int flag) {
|
||||
mDeferUpdatesFlags |= flag;
|
||||
Log.d(TAG, "enableDeferUpdates: " + flag + " mDeferUpdatesFlags=" + mDeferUpdatesFlags);
|
||||
}
|
||||
|
||||
public void disableDeferUpdates(int flag) {
|
||||
mDeferUpdatesFlags &= ~flag;
|
||||
Log.d(TAG, "disableDeferUpdates: " + flag + " mDeferUpdatesFlags=" + mDeferUpdatesFlags);
|
||||
if (mDeferUpdatesFlags == 0 && mUpdatePending) {
|
||||
notifyUpdate();
|
||||
mUpdatePending = false;
|
||||
@@ -171,6 +176,9 @@ public class AllAppsStore<T extends Context & ActivityContext> {
|
||||
|
||||
public void disableDeferUpdatesSilently(int flag) {
|
||||
mDeferUpdatesFlags &= ~flag;
|
||||
Log.d(TAG, "disableDeferUpdatesSilently: " + flag
|
||||
+ " mDeferUpdatesFlags=" + mDeferUpdatesFlags);
|
||||
|
||||
}
|
||||
|
||||
public int getDeferUpdatesFlags() {
|
||||
@@ -179,9 +187,11 @@ public class AllAppsStore<T extends Context & ActivityContext> {
|
||||
|
||||
private void notifyUpdate() {
|
||||
if (mDeferUpdatesFlags != 0) {
|
||||
Log.d(TAG, "notifyUpdate: deferring update");
|
||||
mUpdatePending = true;
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "notifyUpdate: notifying listeners");
|
||||
for (OnUpdateListener listener : mUpdateListeners) {
|
||||
listener.onAppsUpdated();
|
||||
}
|
||||
|
||||
@@ -323,8 +323,10 @@ public class BaseLauncherBinder {
|
||||
Executor pendingExecutor = pendingTasks::add;
|
||||
|
||||
RunnableList onCompleteSignal = new RunnableList();
|
||||
onCompleteSignal.add(() -> Log.d(TAG, "Calling onCompleteSignal"));
|
||||
|
||||
if (enableWorkspaceInflation() && inflater != null) {
|
||||
Log.d(TAG, "Starting async inflation");
|
||||
MODEL_EXECUTOR.execute(() -> {
|
||||
inflateAsyncAndBind(otherWorkspaceItems, inflater, pendingExecutor);
|
||||
inflateAsyncAndBind(otherAppWidgets, inflater, pendingExecutor);
|
||||
@@ -335,6 +337,7 @@ public class BaseLauncherBinder {
|
||||
MAIN_EXECUTOR.execute(onCompleteSignal::executeAllAndDestroy);
|
||||
});
|
||||
} else {
|
||||
Log.d(TAG, "Starting sync inflation");
|
||||
bindItemsInChunks(otherWorkspaceItems, ITEMS_CHUNK, pendingExecutor);
|
||||
bindItemsInChunks(otherAppWidgets, 1, pendingExecutor);
|
||||
setupPendingBind(currentScreenIds, pendingExecutor);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.launcher3.util;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnAttachStateChangeListener;
|
||||
import android.view.ViewTreeObserver.OnDrawListener;
|
||||
@@ -32,6 +33,7 @@ import java.util.function.Consumer;
|
||||
public class ViewOnDrawExecutor implements OnDrawListener, Runnable,
|
||||
OnAttachStateChangeListener {
|
||||
|
||||
private static final String TAG = "ViewOnDrawExecutor";
|
||||
private final RunnableList mTasks;
|
||||
private final Consumer<ViewOnDrawExecutor> mOnClearCallback;
|
||||
private View mAttachedView;
|
||||
@@ -88,7 +90,10 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable,
|
||||
* Executes all tasks immediately
|
||||
*/
|
||||
public void markCompleted() {
|
||||
if (!mCancelled) {
|
||||
if (mCancelled) {
|
||||
Log.d(TAG, "markCompleted ignored: cancelled");
|
||||
} else {
|
||||
Log.d(TAG, "markCompleted: executing tasks");
|
||||
mTasks.executeAllAndDestroy();
|
||||
}
|
||||
mCompleted = true;
|
||||
@@ -101,6 +106,7 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable,
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
Log.d(TAG, "Cancelling tasks");
|
||||
mCancelled = true;
|
||||
markCompleted();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user