Merge "Adding more properties in LaunchCookie, instead of just itemId This allows better matching of items who do not have a fixed id" into main

This commit is contained in:
Sunny Goyal
2024-09-10 07:33:41 +00:00
committed by Android (Google) Code Review
8 changed files with 85 additions and 79 deletions
@@ -56,7 +56,6 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_BACK_SWIPE_HOME_A
import static com.android.launcher3.config.FeatureFlags.ENABLE_SCRIM_FOR_APP_LAUNCH;
import static com.android.launcher3.config.FeatureFlags.KEYGUARD_ANIMATION;
import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY;
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.testing.shared.TestProtocol.WALLPAPER_OPEN_ANIMATION_FINISHED_MESSAGE;
import static com.android.launcher3.util.DisplayController.isTransientTaskbar;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
@@ -138,8 +137,8 @@ import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.DynamicResource;
import com.android.launcher3.util.ObjectWrapper;
import com.android.launcher3.util.RunnableList;
import com.android.launcher3.util.StableViewInfo;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.FloatingIconView;
import com.android.launcher3.views.ScrimView;
@@ -174,6 +173,7 @@ import com.android.wm.shell.startingsurface.IStartingWindowListener;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -434,7 +434,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
*/
private void addLaunchCookie(IBinder cookie, ItemInfo info, ActivityOptions options) {
if (cookie == null) {
cookie = mLauncher.getLaunchCookie(info);
cookie = StableViewInfo.toLaunchCookie(info);
}
if (cookie != null) {
@@ -1433,20 +1433,12 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
// Find the associated item info for the launch cookie (if available), note that predicted
// apps actually have an id of -1, so use another default id here
final ArrayList<IBinder> launchCookies = runningTaskTarget.taskInfo.launchCookies == null
? new ArrayList<>()
final List<IBinder> launchCookies = runningTaskTarget.taskInfo.launchCookies == null
? Collections.EMPTY_LIST
: runningTaskTarget.taskInfo.launchCookies;
int launchCookieItemId = NO_MATCHING_ID;
for (IBinder cookie : launchCookies) {
Integer itemId = ObjectWrapper.unwrap(cookie);
if (itemId != null) {
launchCookieItemId = itemId;
break;
}
}
return mLauncher.getFirstMatchForAppClose(launchCookieItemId, packageName,
return mLauncher.getFirstMatchForAppClose(
StableViewInfo.fromLaunchCookies(launchCookies), packageName,
UserHandle.of(runningTaskTarget.taskInfo.userId), true /* supportsAllAppsState */);
}
@@ -34,6 +34,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.StableViewInfo;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
/** Provides a Quickstep specific animation when launching an activity from an app widget. */
@@ -69,8 +70,8 @@ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler {
.getActivityLaunchOptions(hostView);
Object itemInfo = hostView.getTag();
IBinder launchCookie = null;
if (itemInfo instanceof ItemInfo) {
launchCookie = mLauncher.getLaunchCookie((ItemInfo) itemInfo);
if (itemInfo instanceof ItemInfo info) {
launchCookie = StableViewInfo.toLaunchCookie(info);
activityOptions.options.setLaunchCookie(launchCookie);
}
if (Utilities.ATLEAST_S && !pendingIntent.isActivity()) {
@@ -41,7 +41,6 @@ import static com.android.launcher3.config.FeatureFlags.enableSplitContextually;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SPLIT_SELECTION_EXIT_HOME;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SPLIT_SELECTION_EXIT_INTERRUPTED;
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.popup.QuickstepSystemShortcut.getSplitSelectShortcutByPosition;
import static com.android.launcher3.popup.SystemShortcut.APP_INFO;
import static com.android.launcher3.popup.SystemShortcut.BUBBLE_SHORTCUT;
@@ -83,7 +82,6 @@ import android.hardware.display.DisplayManager;
import android.media.permission.SafeCloseable;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IRemoteCallback;
import android.os.SystemProperties;
import android.os.Trace;
@@ -1232,43 +1230,6 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
mSplitWithKeyboardShortcutController.enterStageSplit(leftOrTop);
}
/**
* Return a new launch cookie for the activity launch if supported.
*
* @param info the item info for the launch
*/
public IBinder getLaunchCookie(ItemInfo info) {
if (info == null) {
return null;
}
switch (info.container) {
case Favorites.CONTAINER_DESKTOP:
case Favorites.CONTAINER_HOTSEAT:
case Favorites.CONTAINER_PRIVATESPACE:
// Fall through and continue it's on the workspace (we don't support swiping back
// to other containers like all apps or the hotseat predictions (which can change)
break;
default:
if (info.container >= 0) {
// Also allow swiping to folders
break;
}
// Reset any existing launch cookies associated with the cookie
return ObjectWrapper.wrap(NO_MATCHING_ID);
}
switch (info.itemType) {
case Favorites.ITEM_TYPE_APPLICATION:
case Favorites.ITEM_TYPE_DEEP_SHORTCUT:
case Favorites.ITEM_TYPE_APPWIDGET:
// Fall through and continue if it's an app, shortcut, or widget
break;
default:
// Reset any existing launch cookies associated with the cookie
return ObjectWrapper.wrap(NO_MATCHING_ID);
}
return ObjectWrapper.wrap(new Integer(info.id));
}
@Override
public void onDisplayInfoChanged(Context context, DisplayController.Info info, int flags) {
super.onDisplayInfoChanged(context, info, flags);
@@ -20,7 +20,6 @@ import static com.android.app.animation.Interpolators.LINEAR;
import static com.android.launcher3.Flags.enableScalingRevealHomeAnimation;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.Utilities.mapBoundToRange;
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION;
import static com.android.launcher3.views.FloatingIconView.getFloatingIconView;
@@ -42,7 +41,7 @@ import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.ObjectWrapper;
import com.android.launcher3.util.StableViewInfo;
import com.android.launcher3.views.ClipIconView;
import com.android.launcher3.views.FloatingIconView;
import com.android.launcher3.views.FloatingView;
@@ -301,18 +300,7 @@ public class LauncherSwipeHandlerV2 extends AbsSwipeUpHandler<
return null;
}
// Find the associated item info for the launch cookie (if available), note that predicted
// apps actually have an id of -1, so use another default id here
int launchCookieItemId = NO_MATCHING_ID;
for (IBinder cookie : launchCookies) {
Integer itemId = ObjectWrapper.unwrap(cookie);
if (itemId != null) {
launchCookieItemId = itemId;
break;
}
}
return mContainer.getFirstMatchForAppClose(launchCookieItemId,
return mContainer.getFirstMatchForAppClose(StableViewInfo.fromLaunchCookies(launchCookies),
sourceTaskView.getFirstTask().key.getComponent().getPackageName(),
UserHandle.of(sourceTaskView.getFirstTask().key.userId),
false /* supportsAllAppsState */);