From b761e9834e9fbf49c2cade7a37dbc3fa53900472 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Fri, 15 Mar 2024 17:31:20 -0700 Subject: [PATCH] Launch overview instance of app for taskbar in Overview * This only works for fullscreen tasks, app pairs aren't properly launching yet * We re-layer the leash to be above launcher since live tiles are originally below * The new task comes in from TaskAnimationManager#onTaskAppeared Bug: 316485863 Test: Tested w/ tapping fullscreen apps in overview when their thumbnail is scrolled off screen. Animation occurs for both live tile and thumbnail Change-Id: I5a3c079244a1517becb845ce25ff9f4e671383b1 --- .../taskbar/TaskbarActivityContext.java | 25 ++++++++++++++++--- .../android/quickstep/views/RecentsView.java | 2 ++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 5f69a9c709..52098af618 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -17,6 +17,7 @@ package com.android.launcher3.taskbar; import static android.content.pm.PackageManager.FEATURE_PC; import static android.os.Trace.TRACE_TAG_APP; +import static android.view.Display.DEFAULT_DISPLAY; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; @@ -1214,7 +1215,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { .handleAppPairLaunchInApp((AppPairIcon) launchingIconView, itemInfos); } else { // Tapped a single app, nothing complicated here. - startItemInfoActivity(itemInfos.get(0)); + startItemInfoActivity(itemInfos.get(0), null /*foundTask*/); } } @@ -1255,19 +1256,37 @@ public class TaskbarActivityContext extends BaseTaskbarContext { recents.getSplitSelectController().getAppPairsController().launchAppPair( (AppPairIcon) launchingIconView); } else { - startItemInfoActivity(itemInfos.get(0)); + startItemInfoActivity(itemInfos.get(0), foundTask); } } ); } - private void startItemInfoActivity(ItemInfo info) { + /** + * Starts an activity with the information provided by the "info" param. However, if + * taskInRecents is present, it will prioritize re-launching an existing instance via + * {@link ActivityManagerWrapper#startActivityFromRecents(int, ActivityOptions)} + */ + private void startItemInfoActivity(ItemInfo info, @Nullable Task taskInRecents) { Intent intent = new Intent(info.getIntent()) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: taskbarAppIcon"); if (info.user.equals(Process.myUserHandle())) { // TODO(b/216683257): Use startActivityForResult for search results that require it. + if (taskInRecents != null) { + // Re launch instance from recents + ActivityOptionsWrapper opts = getActivityLaunchOptions(null, info); + opts.options.setLaunchDisplayId( + getDisplay() == null ? DEFAULT_DISPLAY : getDisplay().getDisplayId()); + if (ActivityManagerWrapper.getInstance() + .startActivityFromRecents(taskInRecents.key, opts.options)) { + mControllers.uiController.getRecentsView() + .addSideTaskLaunchCallback(opts.onEndCallback); + return; + } + } + startActivity(intent); } else { getSystemService(LauncherApps.class).startMainActivity( diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 2ead7a6f52..af1dd3a921 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1270,6 +1270,8 @@ public abstract class RecentsView= 0; --i) { showTransaction.getTransaction().show(apps[i].leash); + showTransaction.forSurface(apps[i].leash).setLayer( + Integer.MAX_VALUE - 1000 + apps[i].prefixOrderIndex); } surfaceApplier.scheduleApply(showTransaction); }