From 080f9326aba2eda5d09399c4fa403b914b0aca96 Mon Sep 17 00:00:00 2001 From: Fengjiang Li Date: Wed, 12 Jul 2023 13:33:54 -0700 Subject: [PATCH 1/4] Handle nullable CellLayout when removing app icon from folder If CellLayout is null, instead of early return that will lead app icon not clickable, we should fallback to use Launcher as activity Fix: 290973455 Test: attached to video Change-Id: I10b03f3f41dd672116133af83ae8a5b066824d71 --- src/com/android/launcher3/Launcher.java | 7 ++++--- src/com/android/launcher3/folder/LauncherDelegate.java | 3 --- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index d85c384f6f..86e05d22d0 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1402,9 +1402,10 @@ public class Launcher extends StatefulActivity * @param info The data structure describing the shortcut. * @return A View inflated from layoutResId. */ - public View createShortcut(ViewGroup parent, WorkspaceItemInfo info) { - BubbleTextView favorite = (BubbleTextView) LayoutInflater.from(parent.getContext()) - .inflate(R.layout.app_icon, parent, false); + public View createShortcut(@Nullable ViewGroup parent, WorkspaceItemInfo info) { + BubbleTextView favorite = + (BubbleTextView) LayoutInflater.from(parent != null ? parent.getContext() : this) + .inflate(R.layout.app_icon, parent, false); favorite.applyFromWorkspaceItem(info); favorite.setOnClickListener(getItemOnClickListener()); favorite.setOnFocusChangeListener(mFocusHandler); diff --git a/src/com/android/launcher3/folder/LauncherDelegate.java b/src/com/android/launcher3/folder/LauncherDelegate.java index 7ac2472319..c06a0f3c53 100644 --- a/src/com/android/launcher3/folder/LauncherDelegate.java +++ b/src/com/android/launcher3/folder/LauncherDelegate.java @@ -94,9 +94,6 @@ public class LauncherDelegate { // folder CellLayout cellLayout = mLauncher.getCellLayout(info.container, mLauncher.getCellPosMapper().mapModelToPresenter(info).screenId); - if (cellLayout == null) { - return; - } finalItem = info.contents.remove(0); newIcon = mLauncher.createShortcut(cellLayout, finalItem); mLauncher.getModelWriter().addOrMoveItemInDatabase(finalItem, From 52d9d9780fb5a83302dd6fb3d875635a2ee57e1c Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Wed, 12 Jul 2023 12:46:53 -0700 Subject: [PATCH 2/4] Creating a correctly populated mOccupied grid when reordering on foldables On ag/21680045 I copy the previous mOccupied but the right thing to do is to create a new one with all the views information. Some test stoped running inadvertently that's why we didn't catch this issue. There is a separate cl with the test to ensure we can catch it later on. Fix: 289584301 Test: ReorderWidgets Change-Id: I27b5a6e38a556d1c73ff8fbbdd552da6045e5b64 (cherry picked from commit 1c5514b56619d0ae76948689bb51479f131d0e30) --- .../celllayout/MulticellReorderAlgorithm.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java b/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java index cb1216109a..a2e26b37f3 100644 --- a/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java +++ b/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java @@ -19,8 +19,10 @@ import android.view.View; import com.android.launcher3.CellLayout; import com.android.launcher3.MultipageCellLayout; +import com.android.launcher3.ShortcutAndWidgetContainer; import com.android.launcher3.util.GridOccupancy; +import java.util.Arrays; import java.util.function.Supplier; /** @@ -79,7 +81,7 @@ public class MulticellReorderAlgorithm extends ReorderAlgorithm { lp.canReorder = false; mcl.setCountX(mcl.getCountX() + 1); mcl.getShortcutsAndWidgets().addViewInLayout(mSeam, lp); - mcl.setOccupied(createGridOccupancyWithSeam(mcl.getOccupied())); + mcl.setOccupied(createGridOccupancyWithSeam()); mcl.mTmpOccupied = new GridOccupancy(mcl.getCountX(), mcl.getCountY()); } @@ -93,7 +95,8 @@ public class MulticellReorderAlgorithm extends ReorderAlgorithm { /** * The function supplied here will execute while the CellLayout has a simulated seam added. - * @param f function to run under simulation + * + * @param f function to run under simulation * @param return value of the supplied function * @return Value of supplied function */ @@ -110,18 +113,17 @@ public class MulticellReorderAlgorithm extends ReorderAlgorithm { return res; } - GridOccupancy createGridOccupancyWithSeam(GridOccupancy gridOccupancy) { + GridOccupancy createGridOccupancyWithSeam() { + ShortcutAndWidgetContainer shortcutAndWidgets = mCellLayout.getShortcutsAndWidgets(); GridOccupancy grid = new GridOccupancy(mCellLayout.getCountX(), mCellLayout.getCountY()); - for (int x = 0; x < mCellLayout.getCountX(); x++) { - for (int y = 0; y < mCellLayout.getCountY(); y++) { - int offset = x >= mCellLayout.getCountX() / 2 ? 1 : 0; - if (x == mCellLayout.getCountX() / 2) { - grid.cells[x][y] = true; - } else { - grid.cells[x][y] = gridOccupancy.cells[x - offset][y]; - } - } + for (int i = 0; i < shortcutAndWidgets.getChildCount(); i++) { + View view = shortcutAndWidgets.getChildAt(i); + CellLayoutLayoutParams lp = (CellLayoutLayoutParams) view.getLayoutParams(); + int seamOffset = lp.getCellX() >= mCellLayout.getCountX() / 2 && lp.canReorder ? 1 : 0; + grid.markCells(lp.getCellX() + seamOffset, lp.getCellY(), lp.cellHSpan, lp.cellVSpan, + true); } + Arrays.fill(grid.cells[mCellLayout.getCountX() / 2], true); return grid; } } From 1db329202976371924fd59169b7b880b80ad4552 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Fri, 14 Jul 2023 10:53:22 -0700 Subject: [PATCH 3/4] Clean up SplitData refactor flag Bug: 279494325 Test: Invoking split works from home, overview. Opening split to fullscreen also works Change-Id: Ie1f26f833d5c10bb114b9e8eb1bd9f3b6b913b3d --- .../quickstep/util/SplitSelectDataHolder.kt | 12 + .../util/SplitSelectStateController.java | 302 ++---------------- .../launcher3/config/FeatureFlags.java | 3 - 3 files changed, 35 insertions(+), 282 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt index e073264998..1a29c9ce17 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt +++ b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt @@ -370,6 +370,18 @@ class SplitSelectDataHolder( return secondTaskId } + fun getSplitEvent(): EventEnum? { + return splitEvent + } + + fun getInitialStagePosition(): Int { + return initialStagePosition + } + + fun getItemInfo(): ItemInfo? { + return itemInfo + } + private fun isSecondTaskIntentSet(): Boolean { return secondTaskId != INVALID_TASK_ID || secondIntent != null || secondPendingIntent != null diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index 970cf64906..51211dff07 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -16,14 +16,9 @@ package com.android.quickstep.util; -import static android.app.ActivityTaskManager.INVALID_TASK_ID; -import static android.app.PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT; -import static android.app.PendingIntent.FLAG_MUTABLE; - import static com.android.launcher3.Utilities.postAsyncCallback; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.SplitConfigurationOptions.DEFAULT_SPLIT_RATIO; -import static com.android.launcher3.util.SplitConfigurationOptions.getOppositeStagePosition; import static com.android.quickstep.util.SplitSelectDataHolder.SPLIT_PENDINGINTENT_PENDINGINTENT; import static com.android.quickstep.util.SplitSelectDataHolder.SPLIT_PENDINGINTENT_TASK; import static com.android.quickstep.util.SplitSelectDataHolder.SPLIT_SHORTCUT_TASK; @@ -41,7 +36,6 @@ import android.app.ActivityThread; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; -import android.content.pm.PackageManager; import android.content.pm.ShortcutInfo; import android.os.Bundle; import android.os.Handler; @@ -64,13 +58,11 @@ import com.android.internal.logging.InstanceId; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.model.data.ItemInfo; -import com.android.launcher3.shortcuts.ShortcutKey; import com.android.launcher3.statehandlers.DepthController; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.util.ComponentKey; -import com.android.launcher3.util.SplitConfigurationOptions; import com.android.launcher3.util.SplitConfigurationOptions.StagePosition; import com.android.quickstep.RecentsModel; import com.android.quickstep.SplitSelectionListener; @@ -100,30 +92,11 @@ public class SplitSelectStateController { private final SplitAnimationController mSplitAnimationController; private final AppPairsController mAppPairsController; private final SplitSelectDataHolder mSplitSelectDataHolder; - private StatsLogManager mStatsLogManager; + private final StatsLogManager mStatsLogManager; private final SystemUiProxy mSystemUiProxy; private final StateManager mStateManager; @Nullable private DepthController mDepthController; - private @StagePosition int mInitialStagePosition; - private ItemInfo mItemInfo; - /** {@link #mInitialTaskIntent} and {@link #mInitialUser} (the user of the Intent) are set - * together when split is initiated from an Intent. */ - private Intent mInitialTaskIntent; - private UserHandle mInitialUser; - private int mInitialTaskId = INVALID_TASK_ID; - /** {@link #mSecondTaskIntent} and {@link #mSecondUser} (the user of the Intent) are set - * together when split is confirmed with an Intent. Either this or {@link #mSecondPendingIntent} - * will be set, but not both - */ - private Intent mSecondTaskIntent; - /** - * Set when split is confirmed via a widget. Either this or {@link #mSecondTaskIntent} will be - * set, but not both - */ - private PendingIntent mSecondPendingIntent; - private UserHandle mSecondUser; - private int mSecondTaskId = INVALID_TASK_ID; private boolean mRecentsAnimationRunning; /** If {@code true}, animates the existing task view split placeholder view */ private boolean mAnimateCurrentTaskDismissal; @@ -135,8 +108,6 @@ public class SplitSelectStateController { /** If not null, this is the TaskView we want to launch from */ @Nullable private GroupedTaskView mLaunchingTaskView; - /** Represents where split is intended to be invoked from. */ - private StatsLogManager.EventEnum mSplitEvent; private FloatingTaskView mFirstFloatingTaskView; @@ -165,19 +136,8 @@ public class SplitSelectStateController { public void setInitialTaskSelect(@Nullable Intent intent, @StagePosition int stagePosition, @NonNull ItemInfo itemInfo, StatsLogManager.EventEnum splitEvent, int alreadyRunningTask) { - if (alreadyRunningTask != INVALID_TASK_ID) { - mInitialTaskId = alreadyRunningTask; - } else { - mInitialTaskIntent = intent; - mInitialUser = itemInfo.user; - } - - setInitialData(stagePosition, splitEvent, itemInfo); - - if (FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - mSplitSelectDataHolder.setInitialTaskSelect(intent, stagePosition, itemInfo, splitEvent, - alreadyRunningTask); - } + mSplitSelectDataHolder.setInitialTaskSelect(intent, stagePosition, itemInfo, splitEvent, + alreadyRunningTask); } /** @@ -187,19 +147,7 @@ public class SplitSelectStateController { public void setInitialTaskSelect(ActivityManager.RunningTaskInfo info, @StagePosition int stagePosition, @NonNull ItemInfo itemInfo, StatsLogManager.EventEnum splitEvent) { - mInitialTaskId = info.taskId; - setInitialData(stagePosition, splitEvent, itemInfo); - - if (FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - mSplitSelectDataHolder.setInitialTaskSelect(info, stagePosition, itemInfo, splitEvent); - } - } - - private void setInitialData(@StagePosition int stagePosition, - StatsLogManager.EventEnum splitEvent, ItemInfo itemInfo) { - mItemInfo = itemInfo; - mInitialStagePosition = stagePosition; - mSplitEvent = splitEvent; + mSplitSelectDataHolder.setInitialTaskSelect(info, stagePosition, itemInfo, splitEvent); } /** @@ -243,7 +191,7 @@ public class SplitSelectStateController { */ public boolean isInstanceOfComponent(@Nullable Task task, @NonNull ComponentKey componentKey) { // Exclude the task that is already staged - if (task == null || task.key.id == mInitialTaskId) { + if (task == null || task.key.id == mSplitSelectDataHolder.getInitialTaskId()) { return false; } @@ -273,20 +221,19 @@ public class SplitSelectStateController { } /** - * To be called when the actual tasks ({@link #mInitialTaskId}, {@link #mSecondTaskId}) are - * to be launched. Call after launcher side animations are complete. + * To be called when the both split tasks are ready to be launched. Call after launcher side + * animations are complete. */ public void launchSplitTasks(Consumer callback) { Pair instanceIds = LogUtils.getShellShareableInstanceId(); - launchTasks(mInitialTaskId, mInitialTaskIntent, mSecondTaskId, mSecondTaskIntent, - mInitialStagePosition, callback, false /* freezeTaskList */, DEFAULT_SPLIT_RATIO, + launchTasks(callback, false /* freezeTaskList */, DEFAULT_SPLIT_RATIO, instanceIds.first); mStatsLogManager.logger() - .withItemInfo(mItemInfo) + .withItemInfo(mSplitSelectDataHolder.getItemInfo()) .withInstanceId(instanceIds.second) - .log(mSplitEvent); + .log(mSplitSelectDataHolder.getSplitEvent()); } /** @@ -294,11 +241,7 @@ public class SplitSelectStateController { * @param task The second task that will be launched. */ public void setSecondTask(Task task) { - mSecondTaskId = task.key.id; - - if (FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - mSplitSelectDataHolder.setSecondTask(task.key.id); - } + mSplitSelectDataHolder.setSecondTask(task.key.id); } /** @@ -307,108 +250,29 @@ public class SplitSelectStateController { * @param user The user of that intent. */ public void setSecondTask(Intent intent, UserHandle user) { - mSecondTaskIntent = intent; - mSecondUser = user; - - if (FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - mSplitSelectDataHolder.setSecondTask(intent, user); - } + mSplitSelectDataHolder.setSecondTask(intent, user); } /** * To be called as soon as user selects the second app (even if animations aren't complete) - * Sets {@link #mSecondUser} from that of the pendingIntent * @param pendingIntent The second PendingIntent that will be launched. */ public void setSecondTask(PendingIntent pendingIntent) { - mSecondPendingIntent = pendingIntent; - mSecondUser = pendingIntent.getCreatorUserHandle(); - - if (FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - mSplitSelectDataHolder.setSecondTask(pendingIntent); - } + mSplitSelectDataHolder.setSecondTask(pendingIntent); } /** * To be called when we want to launch split pairs from Overview. Split can be initiated from * either Overview or home, or all apps. Either both taskIds are set, or a pending intent + a * fill in intent with a taskId2 are set. - * @param intent1 is null when split is initiated from Overview - * @param stagePosition representing location of task1 * @param shellInstanceId loggingId to be used by shell, will be non-null for actions that * create a split instance, null for cases that bring existing instaces to the * foreground (quickswitch, launching previous pairs from overview) */ - public void launchTasks(int taskId1, @Nullable Intent intent1, int taskId2, - @Nullable Intent intent2, @StagePosition int stagePosition, - Consumer callback, boolean freezeTaskList, float splitRatio, + public void launchTasks(Consumer callback, boolean freezeTaskList, float splitRatio, @Nullable InstanceId shellInstanceId) { TestLogging.recordEvent( TestProtocol.SEQUENCE_MAIN, "launchSplitTasks"); - if (FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - launchTasksRefactored(callback, freezeTaskList, splitRatio, shellInstanceId); - return; - } - - final ActivityOptions options1 = ActivityOptions.makeBasic(); - if (freezeTaskList) { - options1.setFreezeRecentTasksReordering(); - } - boolean hasSecondaryPendingIntent = mSecondPendingIntent != null; - if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) { - final RemoteTransition remoteTransition = getShellRemoteTransition(taskId1, taskId2, - callback); - if (intent1 == null && (intent2 == null && !hasSecondaryPendingIntent)) { - mSystemUiProxy.startTasks(taskId1, options1.toBundle(), taskId2, - null /* options2 */, stagePosition, splitRatio, remoteTransition, - shellInstanceId); - } else if (intent2 == null && !hasSecondaryPendingIntent) { - launchIntentOrShortcut(intent1, mInitialUser, options1, taskId2, stagePosition, - splitRatio, remoteTransition, shellInstanceId); - } else if (intent1 == null) { - launchIntentOrShortcut(intent2, mSecondUser, options1, taskId1, - getOppositeStagePosition(stagePosition), splitRatio, remoteTransition, - shellInstanceId); - } else { - mSystemUiProxy.startIntents(getPendingIntent(intent1, mInitialUser), - mInitialUser.getIdentifier(), getShortcutInfo(intent1, mInitialUser), - options1.toBundle(), hasSecondaryPendingIntent - ? mSecondPendingIntent - : getPendingIntent(intent2, mSecondUser), - mSecondUser.getIdentifier(), getShortcutInfo(intent2, mSecondUser), - null /* options2 */, stagePosition, splitRatio, remoteTransition, - shellInstanceId); - } - } else { - final RemoteAnimationAdapter adapter = getLegacyRemoteAdapter(taskId1, taskId2, - callback); - - if (intent1 == null && (intent2 == null && !hasSecondaryPendingIntent)) { - mSystemUiProxy.startTasksWithLegacyTransition(taskId1, options1.toBundle(), - taskId2, null /* options2 */, stagePosition, splitRatio, adapter, - shellInstanceId); - } else if (intent2 == null && !hasSecondaryPendingIntent) { - launchIntentOrShortcutLegacy(intent1, mInitialUser, options1, taskId2, - stagePosition, splitRatio, adapter, shellInstanceId); - } else if (intent1 == null) { - launchIntentOrShortcutLegacy(intent2, mSecondUser, options1, taskId1, - getOppositeStagePosition(stagePosition), splitRatio, adapter, - shellInstanceId); - } else { - mSystemUiProxy.startIntentsWithLegacyTransition( - getPendingIntent(intent1, mInitialUser), mInitialUser.getIdentifier(), - getShortcutInfo(intent1, mInitialUser), options1.toBundle(), - hasSecondaryPendingIntent - ? mSecondPendingIntent - : getPendingIntent(intent2, mSecondUser), - mSecondUser.getIdentifier(), getShortcutInfo(intent2, mSecondUser), - null /* options2 */, stagePosition, splitRatio, adapter, shellInstanceId); - } - } - } - - private void launchTasksRefactored(Consumer callback, boolean freezeTaskList, - float splitRatio, @Nullable InstanceId shellInstanceId) { final ActivityOptions options1 = ActivityOptions.makeBasic(); if (freezeTaskList) { options1.setFreezeRecentTasksReordering(); @@ -502,9 +366,8 @@ public class SplitSelectStateController { /** * Used to launch split screen from a split pair that already exists (usually accessible through - * Overview). This is different than - * {@link #launchTasks(int, Intent, int, Intent, int, Consumer, boolean, float, InstanceId)} in - * that this only launches split screen that are existing tasks. This doesn't determine which + * Overview). This is different than {@link #launchTasks(Consumer, boolean, float, InstanceId)} + * in that this only launches split screen that are existing tasks. This doesn't determine which * API should be used (i.e. launching split with existing tasks vs intents vs shortcuts, etc). * *

@@ -541,11 +404,6 @@ public class SplitSelectStateController { * split and fullscreen tasks) */ public void launchInitialAppFullscreen(Consumer callback) { - if (!FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - launchSplitTasks(callback); - return; - } - final ActivityOptions options1 = ActivityOptions.makeBasic(); SplitSelectDataHolder.SplitLaunchData launchData = mSplitSelectDataHolder.getFullscreenLaunchData(); @@ -612,95 +470,18 @@ public class SplitSelectStateController { ActivityThread.currentActivityThread().getApplicationThread()); } - private void launchIntentOrShortcut(Intent intent, UserHandle user, ActivityOptions options1, - int taskId, @StagePosition int stagePosition, float splitRatio, - RemoteTransition remoteTransition, @Nullable InstanceId shellInstanceId) { - final ShortcutInfo shortcutInfo = getShortcutInfo(intent, user); - if (shortcutInfo != null) { - mSystemUiProxy.startShortcutAndTask(shortcutInfo, - options1.toBundle(), taskId, null /* options2 */, stagePosition, - splitRatio, remoteTransition, shellInstanceId); - } else { - mSystemUiProxy.startIntentAndTask(getPendingIntent(intent, user), user.getIdentifier(), - options1.toBundle(), taskId, null /* options2 */, stagePosition, splitRatio, - remoteTransition, shellInstanceId); - } - } - - private void launchIntentOrShortcutLegacy(Intent intent, UserHandle user, - ActivityOptions options1, int taskId, @StagePosition int stagePosition, - float splitRatio, RemoteAnimationAdapter adapter, - @Nullable InstanceId shellInstanceId) { - final ShortcutInfo shortcutInfo = getShortcutInfo(intent, user); - if (shortcutInfo != null) { - mSystemUiProxy.startShortcutAndTaskWithLegacyTransition(shortcutInfo, - options1.toBundle(), taskId, null /* options2 */, stagePosition, - splitRatio, adapter, shellInstanceId); - } else { - mSystemUiProxy.startIntentAndTaskWithLegacyTransition( - getPendingIntent(intent, user), user.getIdentifier(), options1.toBundle(), - taskId, null /* options2 */, stagePosition, splitRatio, adapter, - shellInstanceId); - } - } - - /** - * We treat launching by intents as grouped in two ways, - * If {@param intent} represents the first app, we always convert the intent to pending intent - * It it represents second app, either the second intent OR mSecondPendingIntent will be used - * convert second intent to a pendingIntent OR return mSecondPendingIntent as is - */ - private PendingIntent getPendingIntent(Intent intent, UserHandle user) { - boolean isParamFirstIntent = intent != null && intent == mInitialTaskIntent; - if (!isParamFirstIntent && mSecondPendingIntent != null) { - // Because mSecondPendingIntent and mSecondTaskIntent can't both be set, we know we need - // to be using mSecondPendingIntent - return mSecondPendingIntent; - } - - // intent param must either be mInitialTaskIntent or mSecondTaskIntent, convert either to - // a new PendingIntent - return intent == null ? null : (user != null - ? PendingIntent.getActivityAsUser(mContext, 0, intent, - FLAG_MUTABLE | FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT, null /* options */, user) - : PendingIntent.getActivity(mContext, 0, intent, - FLAG_MUTABLE | FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT)); - } - public @StagePosition int getActiveSplitStagePosition() { - return mInitialStagePosition; + return mSplitSelectDataHolder.getInitialStagePosition(); } public StatsLogManager.EventEnum getSplitEvent() { - return mSplitEvent; + return mSplitSelectDataHolder.getSplitEvent(); } public void setRecentsAnimationRunning(boolean running) { mRecentsAnimationRunning = running; } - @Nullable - private ShortcutInfo getShortcutInfo(Intent intent, UserHandle user) { - if (intent == null || intent.getPackage() == null) { - return null; - } - - final String shortcutId = intent.getStringExtra(ShortcutKey.EXTRA_SHORTCUT_ID); - if (shortcutId == null) { - return null; - } - - try { - final Context context = mContext.createPackageContextAsUser( - intent.getPackage(), 0 /* flags */, user); - return new ShortcutInfo.Builder(context, shortcutId).build(); - } catch (PackageManager.NameNotFoundException e) { - Log.w(TAG, "Failed to create a ShortcutInfo for " + intent.getPackage()); - } - - return null; - } - public boolean isAnimateCurrentTaskDismissal() { return mAnimateCurrentTaskDismissal; } @@ -821,24 +602,12 @@ public class SplitSelectStateController { * other state. */ public void resetState() { - if (FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - mSplitSelectDataHolder.resetState(); - } + mSplitSelectDataHolder.resetState(); dispatchOnSplitSelectionExit(); - mInitialTaskId = INVALID_TASK_ID; - mInitialTaskIntent = null; - mSecondTaskId = INVALID_TASK_ID; - mSecondTaskIntent = null; - mInitialUser = null; - mSecondUser = null; - mInitialStagePosition = SplitConfigurationOptions.STAGE_POSITION_UNDEFINED; mRecentsAnimationRunning = false; mLaunchingTaskView = null; - mItemInfo = null; - mSplitEvent = null; mAnimateCurrentTaskDismissal = false; mDismissingFromSplitPair = false; - mSecondPendingIntent = null; mFirstFloatingTaskView = null; } @@ -847,11 +616,7 @@ public class SplitSelectStateController { * chosen */ public boolean isSplitSelectActive() { - if (FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - return mSplitSelectDataHolder.isSplitSelectActive(); - } else { - return isInitialTaskIntentSet() && !isSecondTaskIntentSet(); - } + return mSplitSelectDataHolder.isSplitSelectActive(); } /** @@ -859,36 +624,15 @@ public class SplitSelectStateController { * be launched */ public boolean isBothSplitAppsConfirmed() { - if (FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - return mSplitSelectDataHolder.isBothSplitAppsConfirmed(); - } else { - return isInitialTaskIntentSet() && isSecondTaskIntentSet(); - } - } - - private boolean isInitialTaskIntentSet() { - return (mInitialTaskId != INVALID_TASK_ID || mInitialTaskIntent != null); + return mSplitSelectDataHolder.isBothSplitAppsConfirmed(); } public int getInitialTaskId() { - if (FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - return mSplitSelectDataHolder.getInitialTaskId(); - } else { - return mInitialTaskId; - } + return mSplitSelectDataHolder.getInitialTaskId(); } public int getSecondTaskId() { - if (FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - return mSplitSelectDataHolder.getSecondTaskId(); - } else { - return mSecondTaskId; - } - } - - private boolean isSecondTaskIntentSet() { - return (mSecondTaskId != INVALID_TASK_ID || mSecondTaskIntent != null - || mSecondPendingIntent != null); + return mSplitSelectDataHolder.getSecondTaskId(); } public void setFirstFloatingTaskView(FloatingTaskView floatingTaskView) { diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 54265323cf..e3e14009ee 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -387,9 +387,6 @@ public final class FeatureFlags { "Use local overrides for search request timeout"); // TODO(Block 31): Clean up flags - public static final BooleanFlag ENABLE_SPLIT_LAUNCH_DATA_REFACTOR = getDebugFlag(279494325, - "ENABLE_SPLIT_LAUNCH_DATA_REFACTOR", ENABLED, - "Use refactored split launching code path"); // TODO(Block 32): Clean up flags public static final BooleanFlag ENABLE_RESPONSIVE_WORKSPACE = getDebugFlag(241386436, From 0d149e6f93656929a42221a40cc22d935472e805 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Fri, 14 Jul 2023 13:02:22 -0700 Subject: [PATCH 4/4] Exposing the layout URI builder method, so that it can be used in tests Bug: 286558846 Test: N/A Flag: N/A Change-Id: Ib39c0477bb977ac2eb3e484463bc3ea770dc4069 --- src/com/android/launcher3/model/ModelDbController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/launcher3/model/ModelDbController.java b/src/com/android/launcher3/model/ModelDbController.java index 1b1b38f4fd..e10e72d61b 100644 --- a/src/com/android/launcher3/model/ModelDbController.java +++ b/src/com/android/launcher3/model/ModelDbController.java @@ -466,7 +466,7 @@ public class ModelDbController { () -> parser, AutoInstallsLayout.TAG_WORKSPACE); } - private static Uri getLayoutUri(String authority, Context ctx) { + public static Uri getLayoutUri(String authority, Context ctx) { InvariantDeviceProfile grid = LauncherAppState.getIDP(ctx); return new Uri.Builder().scheme("content").authority(authority).path("launcher_layout") .appendQueryParameter("version", "1")