Add some logging for failure to get recents
Bug: 177472267 Test: Presubmit Change-Id: I64a01ef076a58bc3118840ff3171177f61edc3f5
This commit is contained in:
parent
9cde419ee0
commit
0613af3587
|
@ -22,10 +22,12 @@ import android.annotation.TargetApi;
|
|||
import android.app.ActivityManager;
|
||||
import android.os.Build;
|
||||
import android.os.Process;
|
||||
import android.util.Log;
|
||||
import android.util.SparseBooleanArray;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.LooperExecutor;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
|
@ -51,6 +53,9 @@ public class RecentTasksList extends TaskStackChangeListener {
|
|||
|
||||
// The list change id, increments as the task list changes in the system
|
||||
private int mChangeId;
|
||||
// Whether we are currently updating the tasks in the background (up to when the result is
|
||||
// posted back on the main thread)
|
||||
private boolean mLoadingTasksInBackground;
|
||||
|
||||
private TaskLoadResult mResultsBg = INVALID_RESULT;
|
||||
private TaskLoadResult mResultsUi = INVALID_RESULT;
|
||||
|
@ -64,6 +69,11 @@ public class RecentTasksList extends TaskStackChangeListener {
|
|||
mActivityManagerWrapper.registerTaskStackListener(this);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public boolean isLoadingTasksInBackground() {
|
||||
return mLoadingTasksInBackground;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the task keys skipping any local cache.
|
||||
*/
|
||||
|
@ -83,6 +93,10 @@ public class RecentTasksList extends TaskStackChangeListener {
|
|||
* @return The change id of the current task list
|
||||
*/
|
||||
public synchronized int getTasks(boolean loadKeysOnly, Consumer<ArrayList<Task>> callback) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED, "getTasks: keysOnly=" + loadKeysOnly
|
||||
+ " callback=" + callback);
|
||||
}
|
||||
final int requestLoadId = mChangeId;
|
||||
if (mResultsUi.isValidForRequest(requestLoadId, loadKeysOnly)) {
|
||||
// The list is up to date, send the callback on the next frame,
|
||||
|
@ -90,22 +104,38 @@ public class RecentTasksList extends TaskStackChangeListener {
|
|||
if (callback != null) {
|
||||
// Copy synchronously as the changeId might change by next frame
|
||||
ArrayList<Task> result = copyOf(mResultsUi);
|
||||
mMainThreadExecutor.post(() -> callback.accept(result));
|
||||
mMainThreadExecutor.post(() -> {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED, "getTasks: no new tasks");
|
||||
}
|
||||
callback.accept(result);
|
||||
});
|
||||
}
|
||||
|
||||
return requestLoadId;
|
||||
}
|
||||
|
||||
// Kick off task loading in the background
|
||||
mLoadingTasksInBackground = true;
|
||||
UI_HELPER_EXECUTOR.execute(() -> {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED, "getTasks: loading in bg start");
|
||||
}
|
||||
if (!mResultsBg.isValidForRequest(requestLoadId, loadKeysOnly)) {
|
||||
mResultsBg = loadTasksInBackground(Integer.MAX_VALUE, requestLoadId, loadKeysOnly);
|
||||
}
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED, "getTasks: loading in bg end");
|
||||
}
|
||||
TaskLoadResult loadResult = mResultsBg;
|
||||
mMainThreadExecutor.execute(() -> {
|
||||
mLoadingTasksInBackground = false;
|
||||
mResultsUi = loadResult;
|
||||
if (callback != null) {
|
||||
ArrayList<Task> result = copyOf(mResultsUi);
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED, "getTasks: callback w/ bg results");
|
||||
}
|
||||
callback.accept(result);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -28,6 +28,8 @@ import android.os.Build;
|
|||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.launcher3.icons.IconProvider;
|
||||
import com.android.launcher3.util.Executors.SimpleThreadFactory;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
|
@ -101,6 +103,14 @@ public class RecentsModel extends TaskStackChangeListener {
|
|||
return mTaskList.isTaskListValid(changeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the task list is currently updating in the background
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public boolean isLoadingTasksInBackground() {
|
||||
return mTaskList.isLoadingTasksInBackground();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and returns the task key associated with the given task id.
|
||||
*
|
||||
|
|
|
@ -24,9 +24,11 @@ import android.app.ActivityManager.RunningTaskInfo;
|
|||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.statemanager.StateManager.StateListener;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.quickstep.FallbackActivityInterface;
|
||||
import com.android.quickstep.GestureState;
|
||||
import com.android.quickstep.RecentsActivity;
|
||||
|
@ -120,6 +122,10 @@ public class FallbackRecentsView extends RecentsView<RecentsActivity>
|
|||
// as well. This tile is never shown as we have setCurrentTaskHidden, but allows use to
|
||||
// track the index of the next task appropriately, as if we are switching on any other app.
|
||||
if (mHomeTaskInfo != null && mHomeTaskInfo.taskId == mRunningTaskId && !tasks.isEmpty()) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED,
|
||||
"FallbackRecentsView.applyLoadPlan: running task is home");
|
||||
}
|
||||
// Check if the task list has running task
|
||||
boolean found = false;
|
||||
for (Task t : tasks) {
|
||||
|
|
|
@ -72,6 +72,7 @@ import android.text.StaticLayout;
|
|||
import android.text.TextPaint;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.Log;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -104,6 +105,7 @@ import com.android.launcher3.compat.AccessibilityManagerCompat;
|
|||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.statehandlers.DepthController;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler.CurveProperties;
|
||||
import com.android.launcher3.util.DynamicResource;
|
||||
|
@ -823,6 +825,12 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
|||
}
|
||||
|
||||
protected void applyLoadPlan(ArrayList<Task> tasks) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED, "applyLoadPlan: taskCount=" + tasks.size());
|
||||
for (Task t : tasks) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED, "\t" + t);
|
||||
}
|
||||
}
|
||||
if (mPendingAnimation != null) {
|
||||
mPendingAnimation.addEndListener(success -> applyLoadPlan(tasks));
|
||||
return;
|
||||
|
@ -884,12 +892,21 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
|||
resetTaskVisuals();
|
||||
onTaskStackUpdated();
|
||||
updateEnabledOverlays();
|
||||
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED, "applyLoadPlan: taskViewCount="
|
||||
+ getTaskViewCount());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isModal() {
|
||||
return mTaskModalness > 0;
|
||||
}
|
||||
|
||||
public boolean isLoadingTasks() {
|
||||
return mModel.isLoadingTasksInBackground();
|
||||
}
|
||||
|
||||
private void removeTasksViewsAndClearAllButton() {
|
||||
for (int i = getTaskViewCount() - 1; i >= 0; i--) {
|
||||
removeView(getTaskViewAt(i));
|
||||
|
@ -900,6 +917,12 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
|||
}
|
||||
|
||||
public int getTaskViewCount() {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED, "getTaskViewCount:"
|
||||
+ " numChildren=" + getChildCount()
|
||||
+ " start=" + mTaskViewStartIndex
|
||||
+ " clearAll=" + indexOfChild(mClearAllButton));
|
||||
}
|
||||
int taskViewCount = getChildCount() - mTaskViewStartIndex;
|
||||
if (indexOfChild(mClearAllButton) != -1) {
|
||||
taskViewCount--;
|
||||
|
|
|
@ -42,6 +42,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
@ -55,6 +56,7 @@ import com.android.launcher3.tapl.LauncherInstrumentation;
|
|||
import com.android.launcher3.tapl.OverviewTask;
|
||||
import com.android.launcher3.tapl.TestHelpers;
|
||||
import com.android.launcher3.testcomponent.TestCommandReceiver;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.Wait;
|
||||
import com.android.launcher3.util.rule.FailureWatcher;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
|
@ -172,9 +174,15 @@ public class FallbackRecentsTest {
|
|||
|
||||
protected <T> T getFromRecents(Function<RecentsActivity, T> f) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return null;
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED, "getFromRecents");
|
||||
}
|
||||
Object[] result = new Object[1];
|
||||
Wait.atMost("Failed to get from recents", () -> MAIN_EXECUTOR.submit(() -> {
|
||||
RecentsActivity activity = RecentsActivity.ACTIVITY_TRACKER.getCreatedActivity();
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED, "activity=" + activity);
|
||||
}
|
||||
if (activity == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -200,8 +208,13 @@ public class FallbackRecentsTest {
|
|||
() -> mLauncher.getRecentTasks().size() >= 3, DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
|
||||
|
||||
BaseOverview overview = mLauncher.getBackground().switchToOverview();
|
||||
executeOnRecents(recents ->
|
||||
assertTrue("Don't have at least 3 tasks", getTaskCount(recents) >= 3));
|
||||
executeOnRecents(recents -> {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.GET_RECENTS_FAILED, "isLoading=" +
|
||||
recents.<RecentsView>getOverviewPanel().isLoadingTasks());
|
||||
}
|
||||
assertTrue("Don't have at least 3 tasks", getTaskCount(recents) >= 3);
|
||||
});
|
||||
|
||||
// Test flinging forward and backward.
|
||||
overview.flingForward();
|
||||
|
|
|
@ -107,4 +107,5 @@ public final class TestProtocol {
|
|||
public static final String NO_SWIPE_TO_HOME = "b/158017601";
|
||||
public static final String WORK_PROFILE_REMOVED = "b/159671700";
|
||||
public static final String TIS_NO_EVENTS = "b/180915942";
|
||||
public static final String GET_RECENTS_FAILED = "b/177472267";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue