Merge "Using original taskInfo to create the taskKey instead of fake data" into ub-launcher3-rvc-qpr-dev am: 054280dba4
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/12142606 Change-Id: I87b357e1ce4a30f255598d481ce99fee63ac9d9d
This commit is contained in:
commit
149758da21
|
@ -24,6 +24,7 @@ import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MOD
|
|||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.app.ActivityManager.RunningTaskInfo;
|
||||
import android.util.Log;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
|
@ -52,17 +53,17 @@ final class AppToOverviewAnimationProvider<T extends StatefulActivity<?>> extend
|
|||
|
||||
private final BaseActivityInterface<?, T> mActivityInterface;
|
||||
// The id of the currently running task that is transitioning to overview.
|
||||
private final int mTargetTaskId;
|
||||
private final RunningTaskInfo mTargetTask;
|
||||
private final RecentsAnimationDeviceState mDeviceState;
|
||||
|
||||
private T mActivity;
|
||||
private RecentsView mRecentsView;
|
||||
|
||||
AppToOverviewAnimationProvider(
|
||||
BaseActivityInterface<?, T> activityInterface, int targetTaskId,
|
||||
BaseActivityInterface<?, T> activityInterface, RunningTaskInfo targetTask,
|
||||
RecentsAnimationDeviceState deviceState) {
|
||||
mActivityInterface = activityInterface;
|
||||
mTargetTaskId = targetTaskId;
|
||||
mTargetTask = targetTask;
|
||||
mDeviceState = deviceState;
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ final class AppToOverviewAnimationProvider<T extends StatefulActivity<?>> extend
|
|||
* @param wasVisible true if it was visible before
|
||||
*/
|
||||
boolean onActivityReady(T activity, Boolean wasVisible) {
|
||||
activity.<RecentsView>getOverviewPanel().showCurrentTask(mTargetTaskId);
|
||||
activity.<RecentsView>getOverviewPanel().showCurrentTask(mTargetTask);
|
||||
AbstractFloatingView.closeAllOpenViews(activity, wasVisible);
|
||||
BaseActivityInterface.AnimationFactory factory = mActivityInterface.prepareRecentsUI(
|
||||
mDeviceState,
|
||||
|
@ -122,7 +123,8 @@ final class AppToOverviewAnimationProvider<T extends StatefulActivity<?>> extend
|
|||
wallpaperTargets, MODE_CLOSING);
|
||||
|
||||
// Use the top closing app to determine the insets for the animation
|
||||
RemoteAnimationTargetCompat runningTaskTarget = targets.findTask(mTargetTaskId);
|
||||
RemoteAnimationTargetCompat runningTaskTarget = mTargetTask == null ? null
|
||||
: targets.findTask(mTargetTask.taskId);
|
||||
if (runningTaskTarget == null) {
|
||||
Log.e(TAG, "No closing app");
|
||||
return pa.buildAnim();
|
||||
|
|
|
@ -421,7 +421,7 @@ public abstract class BaseSwipeUpHandlerV2<T extends StatefulActivity<?>, Q exte
|
|||
}
|
||||
|
||||
protected void notifyGestureAnimationStartToRecents() {
|
||||
mRecentsView.onGestureAnimationStart(mGestureState.getRunningTaskId());
|
||||
mRecentsView.onGestureAnimationStart(mGestureState.getRunningTask());
|
||||
}
|
||||
|
||||
private void launcherFrameDrawn() {
|
||||
|
|
|
@ -165,7 +165,7 @@ public class OverviewCommandHelper {
|
|||
mActivityInterface = mOverviewComponentObserver.getActivityInterface();
|
||||
mCreateTime = SystemClock.elapsedRealtime();
|
||||
mAnimationProvider = new AppToOverviewAnimationProvider<>(mActivityInterface,
|
||||
RecentsModel.getRunningTaskId(), mDeviceState);
|
||||
ActivityManagerWrapper.getInstance().getRunningTask(), mDeviceState);
|
||||
|
||||
// Preload the plan
|
||||
mRecentsModel.getTasks(null);
|
||||
|
|
|
@ -76,7 +76,7 @@ public class FallbackRecentsView extends RecentsView<RecentsActivity>
|
|||
*/
|
||||
public void onGestureAnimationStartOnHome(RunningTaskInfo homeTaskInfo) {
|
||||
mHomeTaskInfo = homeTaskInfo;
|
||||
onGestureAnimationStart(homeTaskInfo == null ? -1 : homeTaskInfo.taskId);
|
||||
onGestureAnimationStart(homeTaskInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,14 +107,15 @@ public class FallbackRecentsView extends RecentsView<RecentsActivity>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldAddDummyTaskView(int runningTaskId) {
|
||||
if (mHomeTaskInfo != null && mHomeTaskInfo.taskId == runningTaskId
|
||||
protected boolean shouldAddDummyTaskView(RunningTaskInfo runningTaskInfo) {
|
||||
if (mHomeTaskInfo != null && runningTaskInfo != null &&
|
||||
mHomeTaskInfo.taskId == runningTaskInfo.taskId
|
||||
&& getTaskViewCount() == 0) {
|
||||
// Do not add a dummy task if we are running over home with empty recents, so that we
|
||||
// show the empty recents message instead of showing a dummy task and later removing it.
|
||||
return false;
|
||||
}
|
||||
return super.shouldAddDummyTaskView(runningTaskId);
|
||||
return super.shouldAddDummyTaskView(runningTaskInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,6 +56,7 @@ import android.animation.ObjectAnimator;
|
|||
import android.animation.ValueAnimator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.RunningTaskInfo;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -135,6 +136,7 @@ import com.android.quickstep.util.TransformParams;
|
|||
import com.android.systemui.plugins.ResourceProvider;
|
||||
import com.android.systemui.shared.recents.IPinnedStackAnimationListener;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
import com.android.systemui.shared.recents.model.Task.TaskKey;
|
||||
import com.android.systemui.shared.recents.model.ThumbnailData;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
import com.android.systemui.shared.system.LauncherEventUtil;
|
||||
|
@ -147,7 +149,7 @@ import java.util.function.Consumer;
|
|||
/**
|
||||
* A list of recent tasks.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.P)
|
||||
@TargetApi(Build.VERSION_CODES.R)
|
||||
public abstract class RecentsView<T extends StatefulActivity> extends PagedView implements
|
||||
Insettable, TaskThumbnailCache.HighResLoadingState.HighResLoadingStateChangedCallback,
|
||||
InvariantDeviceProfile.OnIDPChangeListener, TaskVisualsChangeListener,
|
||||
|
@ -1039,10 +1041,10 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
|||
/**
|
||||
* Called when a gesture from an app is starting.
|
||||
*/
|
||||
public void onGestureAnimationStart(int runningTaskId) {
|
||||
public void onGestureAnimationStart(RunningTaskInfo runningTaskInfo) {
|
||||
// This needs to be called before the other states are set since it can create the task view
|
||||
mOrientationState.setGestureActive(true);
|
||||
showCurrentTask(runningTaskId);
|
||||
showCurrentTask(runningTaskInfo);
|
||||
setEnableFreeScroll(false);
|
||||
setEnableDrawingLiveTile(false);
|
||||
setRunningTaskHidden(true);
|
||||
|
@ -1120,8 +1122,8 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
|||
/**
|
||||
* Returns true if we should add a dummy taskView for the running task id
|
||||
*/
|
||||
protected boolean shouldAddDummyTaskView(int runningTaskId) {
|
||||
return getTaskView(runningTaskId) == null;
|
||||
protected boolean shouldAddDummyTaskView(RunningTaskInfo runningTaskInfo) {
|
||||
return runningTaskInfo != null && getTaskView(runningTaskInfo.taskId) == null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1130,8 +1132,8 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
|||
* All subsequent calls to reload will keep the task as the first item until {@link #reset()}
|
||||
* is called. Also scrolls the view to this task.
|
||||
*/
|
||||
public void showCurrentTask(int runningTaskId) {
|
||||
if (shouldAddDummyTaskView(runningTaskId)) {
|
||||
public void showCurrentTask(RunningTaskInfo runningTaskInfo) {
|
||||
if (shouldAddDummyTaskView(runningTaskInfo)) {
|
||||
boolean wasEmpty = getChildCount() == 0;
|
||||
// Add an empty view for now until the task plan is loaded and applied
|
||||
final TaskView taskView = mTaskViewPool.getView();
|
||||
|
@ -1141,10 +1143,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
|||
}
|
||||
// The temporary running task is only used for the duration between the start of the
|
||||
// gesture and the task list is loaded and applied
|
||||
mTmpRunningTask = new Task(new Task.TaskKey(runningTaskId, 0, new Intent(),
|
||||
new ComponentName(getContext(), getClass()), 0, 0), null, null, "", "", 0, 0,
|
||||
false, true, false, false, new ActivityManager.TaskDescription(), 0,
|
||||
new ComponentName("", ""), false);
|
||||
mTmpRunningTask = Task.from(new TaskKey(runningTaskInfo), runningTaskInfo, false);
|
||||
taskView.bind(mTmpRunningTask, mOrientationState);
|
||||
|
||||
// Measure and layout immediately so that the scroll values is updated instantly
|
||||
|
@ -1155,7 +1154,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
|||
}
|
||||
|
||||
boolean runningTaskTileHidden = mRunningTaskTileHidden;
|
||||
setCurrentTask(runningTaskId);
|
||||
setCurrentTask(runningTaskInfo == null ? -1 : runningTaskInfo.taskId);
|
||||
setCurrentPage(getRunningTaskIndex());
|
||||
setRunningTaskViewShowScreenshot(false);
|
||||
setRunningTaskHidden(runningTaskTileHidden);
|
||||
|
@ -1673,7 +1672,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
|||
: View.LAYOUT_DIRECTION_RTL);
|
||||
mClearAllButton.setRotation(mOrientationHandler.getDegreesRotated());
|
||||
mActivity.getDragLayer().recreateControllers();
|
||||
boolean isInLandscape = mOrientationState.getTouchRotation() != 0
|
||||
boolean isInLandscape = mOrientationState.getTouchRotation() != ROTATION_0
|
||||
|| mOrientationState.getRecentsActivityRotation() != ROTATION_0;
|
||||
mActionsView.updateHiddenFlags(HIDDEN_NON_ZERO_ROTATION,
|
||||
!mOrientationState.canRecentsActivityRotate() && isInLandscape);
|
||||
|
|
|
@ -17,6 +17,7 @@ package com.android.quickstep;
|
|||
|
||||
import static com.android.launcher3.util.LauncherUIHelper.doLayout;
|
||||
|
||||
import android.app.ActivityManager.RunningTaskInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
|
||||
|
@ -50,7 +51,7 @@ public class RecentsActivityTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRecets_showCurrentTask() {
|
||||
public void testRecents_showCurrentTask() {
|
||||
ActivityController<RecentsActivity> controller =
|
||||
Robolectric.buildActivity(RecentsActivity.class);
|
||||
|
||||
|
@ -58,7 +59,10 @@ public class RecentsActivityTest {
|
|||
doLayout(activity);
|
||||
|
||||
FallbackRecentsView frv = activity.getOverviewPanel();
|
||||
frv.showCurrentTask(22);
|
||||
|
||||
RunningTaskInfo dummyTask = new RunningTaskInfo();
|
||||
dummyTask.taskId = 22;
|
||||
frv.showCurrentTask(dummyTask);
|
||||
doLayout(activity);
|
||||
|
||||
ThumbnailData thumbnailData = new ThumbnailData();
|
||||
|
|
|
@ -92,15 +92,6 @@ public class RecentsModel extends TaskStackChangeListener {
|
|||
return mTaskList.getTasks(false /* loadKeysOnly */, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The task id of the running task, or -1 if there is no current running task.
|
||||
*/
|
||||
public static int getRunningTaskId() {
|
||||
ActivityManager.RunningTaskInfo runningTask =
|
||||
ActivityManagerWrapper.getInstance().getRunningTask();
|
||||
return runningTask != null ? runningTask.id : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the provided {@param changeId} is the latest recent tasks list id.
|
||||
*/
|
||||
|
@ -140,7 +131,9 @@ public class RecentsModel extends TaskStackChangeListener {
|
|||
}
|
||||
|
||||
// Keep the cache up to date with the latest thumbnails
|
||||
int runningTaskId = RecentsModel.getRunningTaskId();
|
||||
ActivityManager.RunningTaskInfo runningTask =
|
||||
ActivityManagerWrapper.getInstance().getRunningTask();
|
||||
int runningTaskId = runningTask != null ? runningTask.id : -1;
|
||||
mTaskList.getTaskKeys(mThumbnailCache.getCacheSize(), tasks -> {
|
||||
for (Task task : tasks) {
|
||||
if (task.key.id == runningTaskId) {
|
||||
|
|
Loading…
Reference in New Issue