Snap for 13391261 from 055a15a214 to 25Q3-release
Change-Id: Id639dbf1c3f9cd3cfb48005e0574c0197b26a72d
This commit is contained in:
commit
5e030c0261
33 files changed
+907
-182
No files matched your search
@@ -21,9 +21,7 @@
|
||||
<item>com.android.launcher3/com.android.quickstep.interaction.GestureSandboxActivity</item>
|
||||
</string-array>
|
||||
|
||||
<string name="stats_log_manager_class" translatable="false">com.android.quickstep.logging.StatsLogCompatManager</string>
|
||||
<string name="test_information_handler_class" translatable="false">com.android.quickstep.QuickstepTestInformationHandler</string>
|
||||
<string name="app_launch_tracker_class" translatable="false">com.android.launcher3.appprediction.PredictionAppTracker</string>
|
||||
<string name="main_process_initializer_class" translatable="false">com.android.quickstep.QuickstepProcessInitializer</string>
|
||||
<string name="secondary_display_quickstep_delegate_class" translatable="false">com.android.launcher3.secondarydisplay.SecondaryDisplayQuickstepDelegateImpl</string>
|
||||
<string name="taskbar_model_callbacks_factory_class" translatable="false">com.android.launcher3.taskbar.TaskbarModelCallbacksFactory</string>
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.launcher3.dagger
|
||||
|
||||
import com.android.launcher3.icons.LauncherIconProvider
|
||||
import com.android.launcher3.icons.LauncherIconProviderImpl
|
||||
import com.android.launcher3.logging.StatsLogManager.StatsLogManagerFactory
|
||||
import com.android.launcher3.uioverrides.QuickstepWidgetHolder.QuickstepWidgetHolderFactory
|
||||
import com.android.launcher3.uioverrides.SystemApiWrapper
|
||||
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapperImpl
|
||||
@@ -28,6 +29,7 @@ import com.android.launcher3.util.window.RefreshRateTracker
|
||||
import com.android.launcher3.util.window.WindowManagerProxy
|
||||
import com.android.launcher3.widget.LauncherWidgetHolder.WidgetHolderFactory
|
||||
import com.android.quickstep.InstantAppResolverImpl
|
||||
import com.android.quickstep.logging.StatsLogCompatManager.StatsLogCompatManagerFactory
|
||||
import com.android.quickstep.util.ChoreographerFrameRateTracker
|
||||
import com.android.quickstep.util.GestureExclusionManager
|
||||
import com.android.quickstep.util.SystemWindowManagerProxy
|
||||
@@ -44,6 +46,11 @@ abstract class WindowManagerProxyModule {
|
||||
|
||||
@Module
|
||||
abstract class ApiWrapperModule {
|
||||
@Binds
|
||||
abstract fun bindStatsLogManagerFactory(
|
||||
impl: StatsLogCompatManagerFactory
|
||||
): StatsLogManagerFactory
|
||||
|
||||
@Binds abstract fun bindApiWrapper(systemApiWrapper: SystemApiWrapper): ApiWrapper
|
||||
|
||||
@Binds
|
||||
|
||||
@@ -313,11 +313,11 @@ public class KeyboardQuickSwitchViewController {
|
||||
// All DesktopTasks, irrespective of whether desktop mode is active, are launched here as
|
||||
// the class DesktopTask is used in a special way by KQS view for showing thumbnails of
|
||||
// freeform tasks.
|
||||
if (task instanceof DesktopTask) {
|
||||
if (task instanceof DesktopTask desktopTask) {
|
||||
boolean canUnminimizeDesktopTask = context.canUnminimizeDesktopTask(taskId);
|
||||
runOnUiWithJankMonitoring(() -> {
|
||||
UI_HELPER_EXECUTOR.execute(() -> {
|
||||
if (!mOnDesktop) {
|
||||
systemUiProxy.showDesktopApps(context.getDisplayId(), slideInTransition);
|
||||
systemUiProxy.activateDesk(desktopTask.getDeskId(), slideInTransition);
|
||||
}
|
||||
|
||||
systemUiProxy.showDesktopApp(taskId,
|
||||
@@ -327,7 +327,7 @@ public class KeyboardQuickSwitchViewController {
|
||||
return true;
|
||||
} else if (mOnDesktop && task instanceof SingleTask) {
|
||||
// Use the special API if user wants to switch to a fullscreen app while in desktop.
|
||||
runOnUiWithJankMonitoring(
|
||||
UI_HELPER_EXECUTOR.execute(
|
||||
() -> systemUiProxy.moveToFullscreen(taskId,
|
||||
DesktopModeTransitionSource.KEYBOARD_SHORTCUT, slideInTransition));
|
||||
return true;
|
||||
@@ -337,18 +337,6 @@ public class KeyboardQuickSwitchViewController {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void runOnUiWithJankMonitoring(Runnable runnable) {
|
||||
Runnable onStartCallback = () -> InteractionJankMonitorWrapper.begin(
|
||||
mKeyboardQuickSwitchView, Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_APP_LAUNCH);
|
||||
Runnable onFinishCallback = () -> InteractionJankMonitorWrapper.end(
|
||||
Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_APP_LAUNCH);
|
||||
UI_HELPER_EXECUTOR.execute(() -> {
|
||||
onStartCallback.run();
|
||||
runnable.run();
|
||||
onFinishCallback.run();
|
||||
});
|
||||
}
|
||||
|
||||
private RemoteTransition getUnminimizeTransition() {
|
||||
return new RemoteTransition(
|
||||
new DesktopAppLaunchTransition(
|
||||
|
||||
@@ -1296,25 +1296,20 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the TaskbarContainer size, using the maximum of the provided {@code size}
|
||||
* and the default size from {@link #getDefaultTaskbarWindowSize()}.
|
||||
* Updates the TaskbarContainer size (pass {@link #getDefaultTaskbarWindowSize()} to reset).
|
||||
*/
|
||||
public void setTaskbarWindowSize(int size) {
|
||||
// In landscape phone button nav mode, we should set the task bar width instead of height
|
||||
// because this is the only case in which the nav bar is not on the display bottom.
|
||||
int windowSize = size;
|
||||
if (windowSize != MATCH_PARENT) {
|
||||
windowSize = Math.max(size, getDefaultTaskbarWindowSize());
|
||||
}
|
||||
boolean landscapePhoneButtonNav = isPhoneButtonNavMode() && mDeviceProfile.isLandscape;
|
||||
if ((landscapePhoneButtonNav ? mWindowLayoutParams.width : mWindowLayoutParams.height)
|
||||
== windowSize || mIsDestroyed) {
|
||||
== size || mIsDestroyed) {
|
||||
return;
|
||||
}
|
||||
if (windowSize == MATCH_PARENT) {
|
||||
windowSize = mDeviceProfile.heightPx;
|
||||
if (size == MATCH_PARENT) {
|
||||
size = mDeviceProfile.heightPx;
|
||||
} else {
|
||||
mLastRequestedNonFullscreenSize = windowSize;
|
||||
mLastRequestedNonFullscreenSize = size;
|
||||
if (mIsFullscreen || mIsTaskbarSizeFrozenForAnimatingBubble) {
|
||||
// We either still need to be fullscreen or a bubble is still animating, so defer
|
||||
// any change to our height until setTaskbarWindowFullscreen(false) is called or
|
||||
@@ -1326,14 +1321,14 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
}
|
||||
}
|
||||
if (landscapePhoneButtonNav) {
|
||||
mWindowLayoutParams.width = windowSize;
|
||||
mWindowLayoutParams.width = size;
|
||||
for (int rot = Surface.ROTATION_0; rot <= Surface.ROTATION_270; rot++) {
|
||||
mWindowLayoutParams.paramsForRotation[rot].width = windowSize;
|
||||
mWindowLayoutParams.paramsForRotation[rot].width = size;
|
||||
}
|
||||
} else {
|
||||
mWindowLayoutParams.height = windowSize;
|
||||
mWindowLayoutParams.height = size;
|
||||
for (int rot = Surface.ROTATION_0; rot <= Surface.ROTATION_270; rot++) {
|
||||
mWindowLayoutParams.paramsForRotation[rot].height = windowSize;
|
||||
mWindowLayoutParams.paramsForRotation[rot].height = size;
|
||||
}
|
||||
}
|
||||
mControllers.runAfterInit(
|
||||
|
||||
@@ -15,17 +15,23 @@
|
||||
*/
|
||||
package com.android.launcher3.taskbar;
|
||||
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
|
||||
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.UiThread;
|
||||
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
import com.android.launcher3.celllayout.CellInfo;
|
||||
import com.android.launcher3.model.BgDataModel;
|
||||
import com.android.launcher3.model.BgDataModel.FixedContainerItems;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.taskbar.TaskbarView.TaskbarLayoutParams;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
@@ -104,7 +110,7 @@ public class TaskbarModelCallbacks implements
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleItemsAdded(List<ItemInfo> items) {
|
||||
private boolean handleItemsAdded(Iterable<ItemInfo> items) {
|
||||
boolean modified = false;
|
||||
for (ItemInfo item : items) {
|
||||
if (item.container == Favorites.CONTAINER_HOTSEAT) {
|
||||
@@ -117,7 +123,24 @@ public class TaskbarModelCallbacks implements
|
||||
|
||||
@Override
|
||||
public void bindItemsUpdated(Set<ItemInfo> updates) {
|
||||
updateContainerItems(updates, mContext);
|
||||
Set<ItemInfo> itemsToRebind = updateContainerItems(updates, mContext);
|
||||
|
||||
boolean removed = handleItemsRemoved(ItemInfoMatcher.ofItems(itemsToRebind));
|
||||
boolean added = handleItemsAdded(itemsToRebind);
|
||||
if (removed || added) {
|
||||
commitItemsToUI();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CellInfo getCellInfoForView(@NonNull View view) {
|
||||
return view.getLayoutParams() instanceof TaskbarLayoutParams tlp ? tlp.bindInfo : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isContainerSupported(int container) {
|
||||
return container == CONTAINER_HOTSEAT || container == CONTAINER_HOTSEAT_PREDICTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,15 +173,6 @@ public class TaskbarModelCallbacks implements
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindItemsModified(List<ItemInfo> items) {
|
||||
boolean removed = handleItemsRemoved(ItemInfoMatcher.ofItems(items));
|
||||
boolean added = handleItemsAdded(items);
|
||||
if (removed || added) {
|
||||
commitItemsToUI();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindExtraContainerItems(FixedContainerItems item) {
|
||||
if (item.containerId == Favorites.CONTAINER_HOTSEAT_PREDICTION) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.logging.InstanceId;
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
@@ -222,7 +223,8 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private SystemShortcut createPinShortcut(BaseTaskbarContext target, ItemInfo itemInfo,
|
||||
@VisibleForTesting
|
||||
SystemShortcut createPinShortcut(BaseTaskbarContext target, ItemInfo itemInfo,
|
||||
BubbleTextView originalView) {
|
||||
// Predicted items use {@code HotseatPredictionController.PinPrediction} shortcut to pin.
|
||||
if (itemInfo.isPredictedItem()) {
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.view.InputDevice;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
@@ -51,6 +52,7 @@ import com.android.launcher3.Insettable;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.apppairs.AppPairIcon;
|
||||
import com.android.launcher3.celllayout.CellInfo;
|
||||
import com.android.launcher3.folder.FolderIcon;
|
||||
import com.android.launcher3.folder.PreviewBackground;
|
||||
import com.android.launcher3.model.data.AppPairInfo;
|
||||
@@ -576,7 +578,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
} else {
|
||||
hotseatView = inflate(expectedLayoutResId);
|
||||
}
|
||||
LayoutParams lp = new LayoutParams(mIconTouchSize, mIconTouchSize);
|
||||
LayoutParams lp = new TaskbarLayoutParams(mIconTouchSize, mIconTouchSize);
|
||||
hotseatView.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding);
|
||||
addView(hotseatView, mNextViewIndex, lp);
|
||||
} else if (hotseatView instanceof FolderIcon fi) {
|
||||
@@ -584,6 +586,13 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
fi.getFolder().reapplyItemInfo();
|
||||
}
|
||||
|
||||
if (hotseatView.getLayoutParams() instanceof TaskbarLayoutParams tlp) {
|
||||
tlp.bindInfo = new CellInfo(hotseatView,
|
||||
hotseatItemInfo.screenId, hotseatItemInfo.container,
|
||||
hotseatItemInfo.cellX, hotseatItemInfo.cellY,
|
||||
hotseatItemInfo.spanX, hotseatItemInfo.spanY);
|
||||
}
|
||||
|
||||
// Apply the Hotseat ItemInfos, or hide the view if there is none for a given index.
|
||||
if (hotseatView instanceof BubbleTextView btv
|
||||
&& hotseatItemInfo instanceof WorkspaceItemInfo workspaceInfo) {
|
||||
@@ -702,7 +711,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
if (recentIcon == null) {
|
||||
// TODO(b/343289567 and b/316004172): support app pairs and desktop mode.
|
||||
recentIcon = inflate(expectedLayoutResId);
|
||||
LayoutParams lp = new LayoutParams(mIconTouchSize, mIconTouchSize);
|
||||
LayoutParams lp = new TaskbarLayoutParams(mIconTouchSize, mIconTouchSize);
|
||||
recentIcon.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding);
|
||||
addView(recentIcon, mNextViewIndex, lp);
|
||||
}
|
||||
@@ -1136,4 +1145,36 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
return navSpaceNeeded + getIconLayoutWidth();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
|
||||
return new TaskbarLayoutParams(lp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LayoutParams generateLayoutParams(AttributeSet attrs) {
|
||||
return new TaskbarLayoutParams(getContext(), attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
|
||||
return p instanceof TaskbarLayoutParams;
|
||||
}
|
||||
|
||||
public static class TaskbarLayoutParams extends FrameLayout.LayoutParams {
|
||||
|
||||
@Nullable public CellInfo bindInfo;
|
||||
|
||||
public TaskbarLayoutParams(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public TaskbarLayoutParams(ViewGroup.LayoutParams source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
public TaskbarLayoutParams(int width, int height) {
|
||||
super(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,10 +100,11 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|
||||
private ArrayMap<Integer, GroupedTaskInfo> mVisibleTasks = new ArrayMap<>();
|
||||
|
||||
private final Context mContext;
|
||||
private final DesktopVisibilityController mDesktopVisibilityController;
|
||||
|
||||
@Inject
|
||||
public TopTaskTracker(@ApplicationContext Context context, DaggerSingletonTracker tracker,
|
||||
SystemUiProxy systemUiProxy) {
|
||||
SystemUiProxy systemUiProxy, DesktopVisibilityController desktopVisibilityController) {
|
||||
if (!enableShellTopTaskTracking()) {
|
||||
mMainStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_MAIN;
|
||||
mSideStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_SIDE;
|
||||
@@ -122,6 +123,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|
||||
});
|
||||
|
||||
mContext = context;
|
||||
mDesktopVisibilityController = desktopVisibilityController;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -346,6 +348,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|
||||
// explicit)
|
||||
return new CachedTaskInfo(mVisibleTasks.get(displayId));
|
||||
} else {
|
||||
int activeDeskId = mDesktopVisibilityController.getActiveDeskId(displayId);
|
||||
if (filterOnlyVisibleRecents) {
|
||||
// Since we only know about the top most task, any filtering may not be applied on
|
||||
// the cache. The second to top task may change while the top task is still the
|
||||
@@ -355,10 +358,10 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|
||||
if (enableOverviewOnConnectedDisplays()) {
|
||||
return new CachedTaskInfo(Arrays.stream(tasks).filter(
|
||||
info -> ExternalDisplaysKt.getSafeDisplayId(info)
|
||||
== displayId).toList(), mContext, displayId);
|
||||
== displayId).toList(), mContext, displayId, activeDeskId);
|
||||
} else {
|
||||
return new CachedTaskInfo(Arrays.asList(tasks), mContext,
|
||||
displayId);
|
||||
displayId, activeDeskId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,7 +387,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|
||||
taskInfo -> !DesksUtils.isDesktopWallpaperTask(taskInfo));
|
||||
}
|
||||
|
||||
return new CachedTaskInfo(taskStream.toList(), mContext, displayId);
|
||||
return new CachedTaskInfo(taskStream.toList(), mContext, displayId, activeDeskId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,22 +419,25 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|
||||
private final GroupedTaskInfo mVisibleTasks;
|
||||
|
||||
private Context mContext;
|
||||
private final int mActiveDeskId;
|
||||
|
||||
// Only used when enableShellTopTaskTracking() is enabled
|
||||
CachedTaskInfo(@Nullable GroupedTaskInfo visibleTasks) {
|
||||
mAllCachedTasks = null;
|
||||
mTopTask = null;
|
||||
mVisibleTasks = visibleTasks;
|
||||
mActiveDeskId = INACTIVE_DESK_ID;
|
||||
}
|
||||
|
||||
// Only used when enableShellTopTaskTracking() is disabled
|
||||
CachedTaskInfo(@NonNull List<TaskInfo> allCachedTasks, Context context,
|
||||
int displayId) {
|
||||
int displayId, int activeDeskId) {
|
||||
mDisplayId = displayId;
|
||||
mVisibleTasks = null;
|
||||
mAllCachedTasks = allCachedTasks;
|
||||
mTopTask = allCachedTasks.isEmpty() ? null : allCachedTasks.get(0);
|
||||
mContext = context;
|
||||
mActiveDeskId = activeDeskId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -541,7 +547,8 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|
||||
&& t.getActivityType() != ACTIVITY_TYPE_RECENTS)
|
||||
.toList();
|
||||
return visibleNonExcludedTasks.isEmpty() ? null
|
||||
: new CachedTaskInfo(visibleNonExcludedTasks, mContext, mDisplayId);
|
||||
: new CachedTaskInfo(visibleNonExcludedTasks, mContext, mDisplayId,
|
||||
mActiveDeskId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -599,12 +606,9 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
|
||||
} else {
|
||||
final TaskInfo baseTaskInfo = getLegacyBaseTask();
|
||||
if (enableMultipleDesktops(mContext)) {
|
||||
DesktopVisibilityController desktopVisibilityController =
|
||||
DesktopVisibilityController.INSTANCE.get(mContext);
|
||||
if (desktopVisibilityController.isInDesktopMode(mDisplayId)) {
|
||||
if (mActiveDeskId != INACTIVE_DESK_ID) {
|
||||
return GroupedTaskInfo.forDeskTasks(
|
||||
desktopVisibilityController.getActiveDeskId(mDisplayId),
|
||||
mDisplayId, mAllCachedTasks,
|
||||
mActiveDeskId, mDisplayId, mAllCachedTasks,
|
||||
/* minimizedFreeformTaskIds = */ Collections.emptySet());
|
||||
}
|
||||
} else if (isDesktopTask(baseTaskInfo)) {
|
||||
|
||||
@@ -107,19 +107,10 @@ public class SettingsChangeLogger implements
|
||||
SettingsChangeLogger(@ApplicationContext Context context,
|
||||
DaggerSingletonTracker tracker,
|
||||
DisplayController displayController,
|
||||
SettingsCache settingsCache) {
|
||||
this(context, StatsLogManager.newInstance(context), tracker, displayController,
|
||||
settingsCache);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
SettingsChangeLogger(@ApplicationContext Context context,
|
||||
StatsLogManager statsLogManager,
|
||||
DaggerSingletonTracker tracker,
|
||||
DisplayController displayController,
|
||||
SettingsCache settingsCache) {
|
||||
SettingsCache settingsCache,
|
||||
StatsLogManager.StatsLogManagerFactory factory) {
|
||||
mContext = context;
|
||||
mStatsLogManager = statsLogManager;
|
||||
mStatsLogManager = factory.create(context);
|
||||
mLoggablePrefs = loadPrefKeys(context);
|
||||
|
||||
displayController.addChangeListener(this);
|
||||
|
||||
@@ -82,6 +82,8 @@ import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* This class calls StatsLog compile time generated methods.
|
||||
*
|
||||
@@ -121,10 +123,27 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
public static final CopyOnWriteArrayList<StatsLogConsumer> LOGS_CONSUMER =
|
||||
new CopyOnWriteArrayList<>();
|
||||
|
||||
public StatsLogCompatManager(Context context) {
|
||||
private StatsLogCompatManager(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is purely used to support dagger bindings to be overridden in launcher variants.
|
||||
* Very similar to {@link dagger.assisted.AssistedFactory}. But
|
||||
* {@link dagger.assisted.AssistedFactory} cannot be overridden and this makes dagger binding
|
||||
* difficult.
|
||||
*/
|
||||
public static class StatsLogCompatManagerFactory extends StatsLogManagerFactory {
|
||||
@Inject
|
||||
StatsLogCompatManagerFactory() {
|
||||
super();
|
||||
}
|
||||
|
||||
public StatsLogManager create(Context context) {
|
||||
return new StatsLogCompatManager(context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StatsLogger createLogger() {
|
||||
return new StatsCompatLogger(mContext, mActivityContext);
|
||||
|
||||
@@ -20,13 +20,12 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||
import static com.android.launcher3.states.RotationHelper.deltaRotation;
|
||||
import static com.android.launcher3.touch.PagedOrientationHandler.MATRIX_POST_TRANSLATE;
|
||||
import static com.android.launcher3.util.OverviewReleaseFlags.enableGridOnlyOverview;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
|
||||
import static com.android.quickstep.util.RecentsOrientedState.postDisplayRotation;
|
||||
import static com.android.quickstep.util.RecentsOrientedState.preDisplayRotation;
|
||||
import static com.android.wm.shell.Flags.enableFlexibleTwoAppSplit;
|
||||
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT;
|
||||
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT;
|
||||
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
|
||||
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.content.Context;
|
||||
@@ -56,6 +55,7 @@ import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties;
|
||||
import com.android.systemui.shared.recents.model.ThumbnailData;
|
||||
import com.android.systemui.shared.recents.utilities.PreviewPositionHelper;
|
||||
import com.android.wm.shell.shared.split.SplitBounds;
|
||||
import com.android.wm.shell.shared.split.SplitScreenConstants;
|
||||
|
||||
/**
|
||||
* A utility class which emulates the layout behavior of TaskView and RecentsView
|
||||
@@ -82,8 +82,8 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
|
||||
private PointF mPivotOverride = null;
|
||||
private final PointF mPivot = new PointF();
|
||||
private DeviceProfile mDp;
|
||||
@StagePosition
|
||||
private int mStagePosition = STAGE_POSITION_UNDEFINED;
|
||||
@SplitScreenConstants.SplitPosition
|
||||
private int mSplitPosition = SPLIT_POSITION_UNDEFINED;
|
||||
|
||||
private final Matrix mMatrix = new Matrix();
|
||||
private final Matrix mMatrixTmp = new Matrix();
|
||||
@@ -184,7 +184,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
|
||||
// sized task space bounds
|
||||
mTaskRect.set(mFullTaskSize);
|
||||
mOrientationState.getOrientationHandler()
|
||||
.setSplitTaskSwipeRect(mDp, mTaskRect, mSplitBounds, mStagePosition);
|
||||
.setSplitTaskSwipeRect(mDp, mTaskRect, mSplitBounds, mSplitPosition);
|
||||
} else if (mIsDesktopTask) {
|
||||
// For desktop, tasks can take up only part of the screen size.
|
||||
// Full task size represents the whole screen size, but scaled down to fit in recents.
|
||||
@@ -259,12 +259,12 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
|
||||
setPreview(runningTarget);
|
||||
mSplitBounds = splitInfo;
|
||||
if (mSplitBounds == null) {
|
||||
mStagePosition = STAGE_POSITION_UNDEFINED;
|
||||
mSplitPosition = SPLIT_POSITION_UNDEFINED;
|
||||
} else {
|
||||
mStagePosition = runningTarget.taskId == splitInfo.leftTopTaskId
|
||||
? STAGE_POSITION_TOP_OR_LEFT : STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
mSplitPosition = runningTarget.taskId == splitInfo.leftTopTaskId
|
||||
? SPLIT_POSITION_TOP_OR_LEFT : SPLIT_POSITION_BOTTOM_OR_RIGHT;
|
||||
if (enableFlexibleTwoAppSplit()) {
|
||||
mPositionHelper.setSplitBounds(mSplitBounds, mStagePosition);
|
||||
mPositionHelper.setSplitBounds(mSplitBounds, mSplitPosition);
|
||||
}
|
||||
}
|
||||
calculateTaskSize();
|
||||
|
||||
@@ -1708,7 +1708,7 @@ public abstract class RecentsView<
|
||||
protected void onPageEndTransition() {
|
||||
super.onPageEndTransition();
|
||||
ActiveGestureProtoLogProxy.logOnPageEndTransition(getNextPage());
|
||||
if (isClearAllHidden() && !mContainer.getDeviceProfile().isTablet) {
|
||||
if (!mContainer.getDeviceProfile().isTablet) {
|
||||
mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, false);
|
||||
}
|
||||
if (getNextPage() > 0) {
|
||||
@@ -2604,9 +2604,9 @@ public abstract class RecentsView<
|
||||
int pageOrientedSize = getPagedOrientationHandler().getMeasuredSize(this);
|
||||
// For GRID_ONLY_OVERVIEW, use +/- 1 task column as visible area for preloading
|
||||
// adjacent thumbnails, otherwise use +/-50% screen width
|
||||
int extraWidth =
|
||||
enableGridOnlyOverview() ? getLastComputedTaskSize().width() + getPageSpacing()
|
||||
: pageOrientedSize / 2;
|
||||
int extraWidth = enableGridOnlyOverview()
|
||||
? getLastComputedGridTaskSize().width() + getPageSpacing()
|
||||
: pageOrientedSize / 2;
|
||||
lowerIndex = upperIndex = 0;
|
||||
visibleStart = screenStart - extraWidth;
|
||||
visibleEnd = screenStart + pageOrientedSize + extraWidth;
|
||||
@@ -4241,7 +4241,7 @@ public abstract class RecentsView<
|
||||
// Update various scroll-dependent UI.
|
||||
dispatchScrollChanged();
|
||||
updateActionsViewFocusedScroll();
|
||||
if (isClearAllHidden() && !mContainer.getDeviceProfile().isTablet) {
|
||||
if (!mContainer.getDeviceProfile().isTablet) {
|
||||
mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING,
|
||||
false);
|
||||
}
|
||||
|
||||
+391
@@ -0,0 +1,391 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.taskbar
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.os.Process
|
||||
import android.platform.test.annotations.DisableFlags
|
||||
import android.platform.test.annotations.EnableFlags
|
||||
import android.platform.test.flag.junit.SetFlagsRule
|
||||
import android.view.Display.DEFAULT_DISPLAY
|
||||
import android.window.RemoteTransition
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import com.android.launcher3.Flags.FLAG_ENABLE_ALT_TAB_KQS_FLATENNING
|
||||
import com.android.launcher3.Flags.FLAG_ENABLE_ALT_TAB_KQS_ON_CONNECTED_DISPLAYS
|
||||
import com.android.launcher3.dagger.LauncherAppSingleton
|
||||
import com.android.launcher3.statehandlers.DesktopVisibilityController
|
||||
import com.android.launcher3.taskbar.TaskbarControllerTestUtil.runOnMainSync
|
||||
import com.android.launcher3.taskbar.rules.DisplayControllerModule
|
||||
import com.android.launcher3.taskbar.rules.MockedRecentsModelHelper
|
||||
import com.android.launcher3.taskbar.rules.MockedRecentsModelTestRule
|
||||
import com.android.launcher3.taskbar.rules.SandboxParams
|
||||
import com.android.launcher3.taskbar.rules.TaskbarSandboxComponent
|
||||
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule
|
||||
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.InjectController
|
||||
import com.android.launcher3.taskbar.rules.TaskbarWindowSandboxContext
|
||||
import com.android.launcher3.util.AllModulesForTest
|
||||
import com.android.launcher3.util.FakePrefsModule
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit.EmulatedDevices
|
||||
import com.android.launcher3.util.TestUtil.getOnUiThread
|
||||
import com.android.quickstep.RecentsModel
|
||||
import com.android.quickstep.SystemUiProxy
|
||||
import com.android.quickstep.util.DesktopTask
|
||||
import com.android.quickstep.util.GroupTask
|
||||
import com.android.quickstep.util.SingleTask
|
||||
import com.android.quickstep.util.SlideInRemoteTransition
|
||||
import com.android.quickstep.util.SplitTask
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import com.android.wm.shell.desktopmode.IDesktopTaskListener
|
||||
import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource
|
||||
import com.android.wm.shell.shared.desktopmode.DesktopTaskToFrontReason
|
||||
import com.android.wm.shell.shared.split.SplitBounds
|
||||
import com.android.wm.shell.shared.split.SplitScreenConstants
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentCaptor
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.kotlin.anyOrNull
|
||||
import org.mockito.kotlin.doAnswer
|
||||
import org.mockito.kotlin.eq
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.spy
|
||||
import org.mockito.kotlin.verify
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
@RunWith(LauncherMultivalentJUnit::class)
|
||||
@EmulatedDevices(["pixelTablet2023"])
|
||||
class KeyboardQuickSwitchControllerTest {
|
||||
private var systemUiProxySpy: SystemUiProxy? = null
|
||||
private var desktopTaskListener: IDesktopTaskListener? = null
|
||||
private val mockRecentsModelHelper: MockedRecentsModelHelper = MockedRecentsModelHelper()
|
||||
private val desktopVisibilityController: DesktopVisibilityController = mock()
|
||||
private val taskIdCaptor = ArgumentCaptor.forClass(Int::class.java)
|
||||
private val transitionCaptor = ArgumentCaptor.forClass(RemoteTransition::class.java)
|
||||
|
||||
@get:Rule(order = 0) val setFlagsRule = SetFlagsRule()
|
||||
@get:Rule(order = 1)
|
||||
val context =
|
||||
TaskbarWindowSandboxContext.create(
|
||||
SandboxParams(
|
||||
{
|
||||
spy(SystemUiProxy(ApplicationProvider.getApplicationContext())) { proxy ->
|
||||
systemUiProxySpy = proxy
|
||||
doAnswer { desktopTaskListener = it.getArgument(0) }
|
||||
.whenever(proxy)
|
||||
.setDesktopTaskListener(anyOrNull())
|
||||
}
|
||||
},
|
||||
builderBase =
|
||||
DaggerKeyboardQuickSwitchControllerComponent.builder()
|
||||
.bindRecentsModel(mockRecentsModelHelper.mockRecentsModel)
|
||||
.bindDesktopVisibilityController(desktopVisibilityController),
|
||||
)
|
||||
)
|
||||
|
||||
@get:Rule(order = 2) val recentsModel = MockedRecentsModelTestRule(mockRecentsModelHelper)
|
||||
@get:Rule(order = 3) val taskbarUnitTestRule = TaskbarUnitTestRule(this, context)
|
||||
|
||||
@InjectController lateinit var keyboardQuickSwitchController: KeyboardQuickSwitchController
|
||||
|
||||
private val isKqsShown: Boolean
|
||||
get() = getOnUiThread { keyboardQuickSwitchController.isShown }
|
||||
|
||||
private val shownTaskIds: List<Int>
|
||||
get() = getOnUiThread { keyboardQuickSwitchController.shownTaskIds() }
|
||||
|
||||
@Test
|
||||
fun noRecentTasks_noShownTaskIds() {
|
||||
triggerAltTab()
|
||||
|
||||
assertThat(isKqsShown).isTrue()
|
||||
assertThat(shownTaskIds).isEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onlySingleTasksPresent_shouldShowAllTaskIds() {
|
||||
updateRecentsModel(
|
||||
listOf(createSingleTask(PREVIOUS_TASK_ID), createSingleTask(RUNNING_TASK_ID))
|
||||
)
|
||||
|
||||
triggerAltTab()
|
||||
|
||||
assertThat(isKqsShown).isTrue()
|
||||
assertThat(shownTaskIds).containsExactly(RUNNING_TASK_ID, PREVIOUS_TASK_ID).inOrder()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onlyDesktopTasksPresent_shouldShowAllTaskIds() {
|
||||
updateRecentsModel(listOf(createDesktopTask(listOf(RUNNING_TASK_ID, PREVIOUS_TASK_ID))))
|
||||
enableDesktopMode()
|
||||
|
||||
triggerAltTab()
|
||||
|
||||
assertThat(isKqsShown).isTrue()
|
||||
assertThat(shownTaskIds).containsExactly(RUNNING_TASK_ID, PREVIOUS_TASK_ID).inOrder()
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING)
|
||||
fun singleAndDesktopTasksPresent_notOnDesktopWithFlatenningOff_onlyShowSingleTaskIds() {
|
||||
updateRecentsModel(
|
||||
listOf(
|
||||
createDesktopTask(listOf(PREVIOUS_TASK_ID, OLDEST_TASK_ID)),
|
||||
createSingleTask(RUNNING_TASK_ID),
|
||||
)
|
||||
)
|
||||
|
||||
triggerAltTab()
|
||||
|
||||
assertThat(isKqsShown).isTrue()
|
||||
assertThat(shownTaskIds).containsExactly(RUNNING_TASK_ID)
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING)
|
||||
fun singleAndDesktopTasksPresent_onDesktopWithFlatenningOff_onlyShowDesktopTaskIds() {
|
||||
updateRecentsModel(
|
||||
listOf(
|
||||
createDesktopTask(listOf(RUNNING_TASK_ID, OLDEST_TASK_ID)),
|
||||
createSingleTask(PREVIOUS_TASK_ID),
|
||||
)
|
||||
)
|
||||
enableDesktopMode()
|
||||
|
||||
triggerAltTab()
|
||||
|
||||
assertThat(isKqsShown).isTrue()
|
||||
assertThat(shownTaskIds).containsExactly(RUNNING_TASK_ID, OLDEST_TASK_ID).inOrder()
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING)
|
||||
fun singleAndDesktopTasksPresent_onDesktopWithFlatenningOn_showAllTaskIds() {
|
||||
updateRecentsModel(
|
||||
listOf(
|
||||
createDesktopTask(listOf(RUNNING_TASK_ID, OLDEST_TASK_ID)),
|
||||
createSingleTask(PREVIOUS_TASK_ID),
|
||||
)
|
||||
)
|
||||
enableDesktopMode()
|
||||
|
||||
triggerAltTab()
|
||||
|
||||
assertThat(isKqsShown).isTrue()
|
||||
assertThat(shownTaskIds)
|
||||
.containsExactly(RUNNING_TASK_ID, PREVIOUS_TASK_ID, OLDEST_TASK_ID)
|
||||
.inOrder()
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING)
|
||||
fun singleAndDesktopTasksPresent_notOnDesktopWithFlatenningOn_showAllTaskIds() {
|
||||
updateRecentsModel(
|
||||
listOf(
|
||||
createDesktopTask(listOf(PREVIOUS_TASK_ID, OLDEST_TASK_ID)),
|
||||
createSingleTask(RUNNING_TASK_ID),
|
||||
)
|
||||
)
|
||||
|
||||
triggerAltTab()
|
||||
|
||||
assertThat(isKqsShown).isTrue()
|
||||
assertThat(shownTaskIds)
|
||||
.containsExactly(RUNNING_TASK_ID, PREVIOUS_TASK_ID, OLDEST_TASK_ID)
|
||||
.inOrder()
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING, FLAG_ENABLE_ALT_TAB_KQS_ON_CONNECTED_DISPLAYS)
|
||||
fun multipleDesktopTasksPresent_onDesktopWithCdFlagOff_onlyShowCurrentDesktopTasks() {
|
||||
updateRecentsModel(
|
||||
listOf(
|
||||
createDesktopTask(listOf(RUNNING_TASK_ID)),
|
||||
createDesktopTask(listOf(PREVIOUS_TASK_ID)),
|
||||
)
|
||||
)
|
||||
enableDesktopMode()
|
||||
|
||||
triggerAltTab()
|
||||
|
||||
assertThat(isKqsShown).isTrue()
|
||||
assertThat(shownTaskIds).containsExactly(RUNNING_TASK_ID)
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING)
|
||||
@EnableFlags(FLAG_ENABLE_ALT_TAB_KQS_ON_CONNECTED_DISPLAYS)
|
||||
fun multipleDesktopTasksPresent_onDesktopWithCdFlagON_showAllDesktopTasks() {
|
||||
updateRecentsModel(
|
||||
listOf(
|
||||
createDesktopTask(listOf(RUNNING_TASK_ID)),
|
||||
createDesktopTask(listOf(PREVIOUS_TASK_ID)),
|
||||
)
|
||||
)
|
||||
enableDesktopMode()
|
||||
|
||||
triggerAltTab()
|
||||
|
||||
assertThat(isKqsShown).isTrue()
|
||||
assertThat(shownTaskIds).containsExactly(RUNNING_TASK_ID, PREVIOUS_TASK_ID).inOrder()
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING)
|
||||
fun splitAndSingleTaskPresent_withFlatenningOn_shouldSortTaskIds() {
|
||||
updateRecentsModel(
|
||||
listOf(
|
||||
createSplitTask(OLDEST_TASK_ID to RUNNING_TASK_ID),
|
||||
createSingleTask(PREVIOUS_TASK_ID),
|
||||
)
|
||||
)
|
||||
|
||||
triggerAltTab()
|
||||
|
||||
// Although single task is more recent than one of the split tasks, the split tasks should
|
||||
// be together. Furthermore, the shownTaskIds returns left split task first.
|
||||
assertThat(shownTaskIds)
|
||||
.containsExactly(OLDEST_TASK_ID, RUNNING_TASK_ID, PREVIOUS_TASK_ID)
|
||||
.inOrder()
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING)
|
||||
fun launchDesktopApp_notOnDesktop_shouldCallSysUIProxyToStartSpecificApp() {
|
||||
val deskId = 1
|
||||
updateRecentsModel(listOf(createDesktopTask(listOf(PREVIOUS_TASK_ID), deskId)))
|
||||
|
||||
triggerAltTabAndLaunchFocusedTask()
|
||||
|
||||
val deskIdCaptor = ArgumentCaptor.forClass(Int::class.java)
|
||||
verify(systemUiProxySpy)?.activateDesk(deskIdCaptor.capture(), transitionCaptor.capture())
|
||||
assertThat(deskIdCaptor.value).isEqualTo(deskId)
|
||||
assertThat(transitionCaptor.value.remoteTransition)
|
||||
.isInstanceOf(SlideInRemoteTransition::class.java)
|
||||
|
||||
verify(systemUiProxySpy)
|
||||
?.showDesktopApp(taskIdCaptor.capture(), eq(null), eq(DesktopTaskToFrontReason.ALT_TAB))
|
||||
assertThat(taskIdCaptor.value).isEqualTo(PREVIOUS_TASK_ID)
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING)
|
||||
fun launchSingleApp_onDesktop_shouldCallSysUIProxyToMoveToFullscreen() {
|
||||
updateRecentsModel(listOf(createSingleTask(PREVIOUS_TASK_ID)))
|
||||
enableDesktopMode()
|
||||
|
||||
triggerAltTabAndLaunchFocusedTask()
|
||||
|
||||
verify(systemUiProxySpy)
|
||||
?.moveToFullscreen(
|
||||
taskIdCaptor.capture(),
|
||||
eq(DesktopModeTransitionSource.KEYBOARD_SHORTCUT),
|
||||
transitionCaptor.capture(),
|
||||
)
|
||||
assertThat(taskIdCaptor.value).isEqualTo(PREVIOUS_TASK_ID)
|
||||
assertThat(transitionCaptor.value.remoteTransition)
|
||||
.isInstanceOf(SlideInRemoteTransition::class.java)
|
||||
}
|
||||
|
||||
private fun createSingleTask(taskId: Int) = SingleTask(createTask(taskId))
|
||||
|
||||
private fun createSplitTask(taskIds: Pair<Int, Int>) =
|
||||
SplitTask(
|
||||
createTask(taskIds.first),
|
||||
createTask(taskIds.second),
|
||||
SplitBounds(
|
||||
/* leftTopBounds = */ Rect(),
|
||||
/* rightBottomBounds = */ Rect(),
|
||||
/* leftTopTaskId = */ -1,
|
||||
/* rightBottomTaskId = */ -1,
|
||||
/* snapPosition = */ SplitScreenConstants.SNAP_TO_2_50_50,
|
||||
),
|
||||
)
|
||||
|
||||
private fun createDesktopTask(taskIds: List<Int>, deskId: Int = 0) =
|
||||
DesktopTask(deskId, DEFAULT_DISPLAY, taskIds.map { createTask(it) })
|
||||
|
||||
private fun enableDesktopMode() {
|
||||
whenever(desktopVisibilityController.isInDesktopMode(anyInt())).thenReturn(true)
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a task with the given ID and a fake package name.
|
||||
*
|
||||
* Note: the task ID is added to last active time, thus higher task ID indicates a more recent
|
||||
* active task.
|
||||
*/
|
||||
private fun createTask(taskId: Int): Task {
|
||||
return Task(
|
||||
Task.TaskKey(
|
||||
taskId,
|
||||
0,
|
||||
Intent().apply { `package` = "Fake${taskId}" },
|
||||
ComponentName("Fake${taskId}", ""),
|
||||
Process.myUserHandle().identifier,
|
||||
2000L + taskId,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun updateRecentsModel(tasks: List<GroupTask>) {
|
||||
recentsModel.updateRecentTasks(tasks)
|
||||
runOnMainSync { recentsModel.resolvePendingTaskRequests() }
|
||||
}
|
||||
|
||||
private fun triggerAltTab() = runOnMainSync {
|
||||
keyboardQuickSwitchController.openQuickSwitchView()
|
||||
recentsModel.resolvePendingTaskRequests()
|
||||
}
|
||||
|
||||
private fun triggerAltTabAndLaunchFocusedTask() {
|
||||
triggerAltTab()
|
||||
runOnMainSync { keyboardQuickSwitchController.launchFocusedTask() }
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val OLDEST_TASK_ID = 1
|
||||
const val PREVIOUS_TASK_ID = 2
|
||||
const val RUNNING_TASK_ID = 3
|
||||
}
|
||||
}
|
||||
|
||||
/** KeyboardQuickSwitchControllerComponent used to bind the RecentsModel. */
|
||||
@LauncherAppSingleton
|
||||
@Component(
|
||||
modules = [AllModulesForTest::class, FakePrefsModule::class, DisplayControllerModule::class]
|
||||
)
|
||||
interface KeyboardQuickSwitchControllerComponent : TaskbarSandboxComponent {
|
||||
|
||||
@Component.Builder
|
||||
interface Builder : TaskbarSandboxComponent.Builder {
|
||||
@BindsInstance fun bindRecentsModel(model: RecentsModel): Builder
|
||||
|
||||
@BindsInstance
|
||||
fun bindDesktopVisibilityController(
|
||||
desktopVisibilityController: DesktopVisibilityController
|
||||
): Builder
|
||||
|
||||
override fun build(): KeyboardQuickSwitchControllerComponent
|
||||
}
|
||||
}
|
||||
+167
@@ -25,11 +25,18 @@ import android.platform.test.annotations.EnableFlags
|
||||
import android.platform.test.flag.junit.SetFlagsRule
|
||||
import android.view.Display.DEFAULT_DISPLAY
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import com.android.launcher3.BubbleTextView
|
||||
import com.android.launcher3.Flags.FLAG_ENABLE_ALT_TAB_KQS_FLATENNING
|
||||
import com.android.launcher3.Flags.FLAG_ENABLE_MULTI_INSTANCE_MENU_TASKBAR
|
||||
import com.android.launcher3.Flags.FLAG_TASKBAR_OVERFLOW
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.dagger.LauncherAppSingleton
|
||||
import com.android.launcher3.dagger.LauncherComponentProvider.appComponent
|
||||
import com.android.launcher3.model.BgDataModel
|
||||
import com.android.launcher3.model.data.ItemInfo
|
||||
import com.android.launcher3.model.data.TaskItemInfo
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo
|
||||
import com.android.launcher3.popup.SystemShortcut
|
||||
import com.android.launcher3.taskbar.TaskbarControllerTestUtil.runOnMainSync
|
||||
import com.android.launcher3.taskbar.TaskbarViewTestUtil.createHotseatItems
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController
|
||||
@@ -50,18 +57,24 @@ import com.android.launcher3.util.AllModulesForTest
|
||||
import com.android.launcher3.util.FakePrefsModule
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit.EmulatedDevices
|
||||
import com.android.launcher3.util.Preconditions.assertNotNull
|
||||
import com.android.launcher3.util.TestUtil.getOnUiThread
|
||||
import com.android.quickstep.RecentsModel
|
||||
import com.android.quickstep.SystemUiProxy
|
||||
import com.android.quickstep.util.DesktopTask
|
||||
import com.android.quickstep.util.GroupTask
|
||||
import com.android.quickstep.util.SingleTask
|
||||
import com.android.quickstep.util.SingleTask.Companion.createTaskItemInfo
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE
|
||||
import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_TASKBAR_RUNNING_APPS
|
||||
import com.android.window.flags.Flags.FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU
|
||||
import com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_BAR
|
||||
import com.android.wm.shell.desktopmode.IDesktopTaskListener
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import java.util.function.Predicate
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -117,6 +130,10 @@ class TaskbarOverflowTest {
|
||||
@InjectController lateinit var keyboardQuickSwitchController: KeyboardQuickSwitchController
|
||||
|
||||
private var desktopTaskListener: IDesktopTaskListener? = null
|
||||
private val modelCallback = ModelCallbacks()
|
||||
|
||||
private val taskbarContext: TaskbarActivityContext
|
||||
get() = taskbarUnitTestRule.activityContext
|
||||
|
||||
private var currentControllerInitCallback: () -> Unit = {}
|
||||
set(value) {
|
||||
@@ -338,6 +355,7 @@ class TaskbarOverflowTest {
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
@DisableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING)
|
||||
fun testPressingOverflowButtonOpensKeyboardQuickSwitch() {
|
||||
val maxNumIconViews = maxNumberOfTaskbarIcons
|
||||
// Assume there are at least all apps and divider icon, as they would appear once running
|
||||
@@ -397,6 +415,7 @@ class TaskbarOverflowTest {
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
@DisableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING)
|
||||
fun testHotseatItemTasksNotShownInKQS() {
|
||||
val maxNumIconViews = maxNumberOfTaskbarIcons
|
||||
// Assume there are at least all apps and divider icon, as they would appear once running
|
||||
@@ -431,6 +450,126 @@ class TaskbarOverflowTest {
|
||||
.containsExactlyElementsIn(listOf(0) + (2..<createdTasks).toList())
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
@EnableFlags(FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU)
|
||||
fun pinToTaskbarShortcut_unpinPinnedItem() {
|
||||
// Create two tasks and two pinned items.
|
||||
createDesktopTask(2)
|
||||
val hotseatItems = createHotseatItems(2)
|
||||
var shortcut: SystemShortcut<*>? = null
|
||||
var hotseatIcon: BubbleTextView? = null
|
||||
runOnMainSync {
|
||||
val taskbarView = setUpTaskbarAndModelCallback(hotseatItems)
|
||||
hotseatIcon =
|
||||
taskbarView.iconViews.filterIsInstance<BubbleTextView>().first {
|
||||
it.tag is WorkspaceItemInfo
|
||||
}
|
||||
shortcut =
|
||||
taskbarContext.controllers.taskbarPopupController.createPinShortcut(
|
||||
taskbarContext,
|
||||
hotseatIcon!!.tag as ItemInfo,
|
||||
hotseatIcon,
|
||||
) as SystemShortcut<*>
|
||||
}
|
||||
assertNotNull(shortcut)
|
||||
runOnMainSync { shortcut?.onClick(hotseatIcon) }
|
||||
// After unpinning the first item, only the second app is left.
|
||||
assertThat(modelCallback.hotseatItems.map { info -> info.title })
|
||||
.isEqualTo(listOf("Test App 1"))
|
||||
// The unpinned app doesn't have a task so the shown tasks won't change.
|
||||
assertThat(recentAppsController.shownTasks.map { it.tasks[0].key.id })
|
||||
.isEqualTo(listOf(0, 1))
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
@EnableFlags(FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU)
|
||||
fun pinToTaskbarShortcut_unpinPinnedItemWithTask() {
|
||||
// Create two hotseat items with a task for both of them respectively.
|
||||
var hotseatItems =
|
||||
createHotseatItems(2).mapIndexed { idx, item -> TaskItemInfo(idx, item) }.toTypedArray()
|
||||
createDesktopTaskWithTasksFromPackages(hotseatItems.mapNotNull { it.targetPackage })
|
||||
var shortcut: SystemShortcut<*>? = null
|
||||
var hotseatIcon: BubbleTextView? = null
|
||||
runOnMainSync {
|
||||
val taskbarView = setUpTaskbarAndModelCallback(hotseatItems.map { it }.toTypedArray())
|
||||
hotseatIcon =
|
||||
taskbarView.iconViews.filterIsInstance<BubbleTextView>().first {
|
||||
it.tag is WorkspaceItemInfo
|
||||
}
|
||||
shortcut =
|
||||
taskbarContext.controllers.taskbarPopupController.createPinShortcut(
|
||||
taskbarContext,
|
||||
hotseatIcon!!.tag as ItemInfo,
|
||||
hotseatIcon,
|
||||
) as SystemShortcut<*>
|
||||
}
|
||||
// Before unpinning the app, both of the apps should be pinned and no shown task available.
|
||||
assertThat(modelCallback.hotseatItems.map { info -> info.title })
|
||||
.isEqualTo(listOf("Test App 0", "Test App 1"))
|
||||
assertThat(recentAppsController.shownTasks.map { it.tasks[0].key.id })
|
||||
.isEqualTo(emptyList<Int>())
|
||||
assertNotNull(shortcut)
|
||||
runOnMainSync { shortcut?.onClick(hotseatIcon) }
|
||||
// After unpinning the app, app 0 is removed and its task is shown as a recent task.
|
||||
assertThat(modelCallback.hotseatItems.map { info -> info.title })
|
||||
.isEqualTo(listOf("Test App 1"))
|
||||
assertThat(recentAppsController.shownTasks.map { it.tasks[0].key.id }).isEqualTo(listOf(0))
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
@EnableFlags(FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU)
|
||||
fun pinToTaskbarShortcut_pinRecentTask() {
|
||||
// Create two tasks and two pinned items.
|
||||
createDesktopTask(2)
|
||||
val hotseatItems = createHotseatItems(2)
|
||||
|
||||
var shortcut: SystemShortcut<*>? = null
|
||||
var recentTaskIcon: BubbleTextView? = null
|
||||
runOnMainSync {
|
||||
val taskbarView = setUpTaskbarAndModelCallback(hotseatItems)
|
||||
// Get the first recent task icon
|
||||
recentTaskIcon =
|
||||
taskbarView.iconViews.filterIsInstance<BubbleTextView>().first {
|
||||
it.tag is GroupTask
|
||||
}
|
||||
val recentTaskInfo =
|
||||
createTaskItemInfo(
|
||||
recentTaskIcon!!.tag as SingleTask,
|
||||
WorkspaceItemInfo().apply {
|
||||
title = "Test App 2"
|
||||
intent = Intent().apply { `package` = "fake" }
|
||||
},
|
||||
)
|
||||
shortcut =
|
||||
taskbarContext.controllers.taskbarPopupController.createPinShortcut(
|
||||
taskbarContext,
|
||||
recentTaskInfo,
|
||||
recentTaskIcon,
|
||||
) as SystemShortcut<*>
|
||||
}
|
||||
assertNotNull(shortcut)
|
||||
runOnMainSync { shortcut?.onClick(recentTaskIcon) }
|
||||
|
||||
// After pinning the recent task, it should be included in the hotseat items.
|
||||
assertThat(modelCallback.hotseatItems.map { info -> info.title })
|
||||
.isEqualTo(listOf("Test App 0", "Test App 1", "Test App 2"))
|
||||
// As the task is pinned, the shown tasks should remove it from the list
|
||||
assertThat(recentAppsController.shownTasks.map { it.tasks[0].key.id }).isEqualTo(listOf(1))
|
||||
}
|
||||
|
||||
private fun setUpTaskbarAndModelCallback(hotseatItems: Array<WorkspaceItemInfo>): TaskbarView {
|
||||
val taskbarView: TaskbarView =
|
||||
taskbarUnitTestRule.activityContext.dragLayer.findViewById(R.id.taskbar_view)
|
||||
taskbarView.updateItems(hotseatItems, recentAppsController.shownTasks)
|
||||
modelCallback.recentAppsController = recentAppsController
|
||||
context.baseContext.appComponent.launcherAppState.model.addCallbacksAndLoad(modelCallback)
|
||||
modelCallback.bindItems(hotseatItems.toList(), false)
|
||||
return taskbarView
|
||||
}
|
||||
|
||||
private fun createDesktopTask(tasksToAdd: Int) {
|
||||
createDesktopTaskWithTasksFromPackages((0..<tasksToAdd).map { "fake" })
|
||||
}
|
||||
@@ -547,6 +686,34 @@ class TaskbarOverflowTest {
|
||||
}
|
||||
return maxNumIconViews
|
||||
}
|
||||
|
||||
private class ModelCallbacks : BgDataModel.Callbacks {
|
||||
var hotseatItems = mutableListOf<WorkspaceItemInfo>()
|
||||
var recentAppsController: TaskbarRecentAppsController? = null
|
||||
|
||||
override fun bindItems(shortcuts: List<ItemInfo>, forceAnimateIcons: Boolean) {
|
||||
runOnMainSync {
|
||||
shortcuts
|
||||
.filter { item ->
|
||||
item is WorkspaceItemInfo &&
|
||||
!hotseatItems.any { it.targetPackage == item.targetPackage }
|
||||
}
|
||||
.forEach { item -> hotseatItems.add(item as WorkspaceItemInfo) }
|
||||
recentAppsController?.updateHotseatItemInfos(hotseatItems.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
override fun bindWorkspaceComponentsRemoved(matcher: Predicate<ItemInfo>) {
|
||||
runOnMainSync {
|
||||
for (i in hotseatItems.size - 1 downTo 0) {
|
||||
if (matcher.test(hotseatItems[i])) {
|
||||
hotseatItems.removeAt(i)
|
||||
}
|
||||
}
|
||||
recentAppsController?.updateHotseatItemInfos(hotseatItems.toTypedArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** TaskbarOverflowComponent used to bind the RecentsModel. */
|
||||
|
||||
+12
-8
@@ -21,6 +21,7 @@ import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Bitmap.createBitmap
|
||||
import android.os.Process
|
||||
import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT
|
||||
import com.android.launcher3.icons.BitmapInfo
|
||||
import com.android.launcher3.model.data.AppInfo
|
||||
import com.android.launcher3.model.data.AppPairInfo
|
||||
@@ -50,16 +51,17 @@ object TaskbarViewTestUtil {
|
||||
}
|
||||
|
||||
/** Creates an array of fake hotseat items. */
|
||||
fun createHotseatItems(size: Int): Array<ItemInfo> {
|
||||
fun createHotseatItems(size: Int): Array<WorkspaceItemInfo> {
|
||||
return Array(size) { createHotseatWorkspaceItem(it) }
|
||||
}
|
||||
|
||||
fun createHotseatWorkspaceItem(id: Int = 0): WorkspaceItemInfo {
|
||||
return WorkspaceItemInfo(
|
||||
AppInfo(TEST_COMPONENT, "Test App $id", Process.myUserHandle(), Intent())
|
||||
AppInfo(testComponent(id), "Test App $id", Process.myUserHandle(), testIntent(id))
|
||||
)
|
||||
.apply {
|
||||
this.id = id
|
||||
container = CONTAINER_HOTSEAT
|
||||
// Create a placeholder icon so that the test doesn't try to load a high-res icon.
|
||||
this.bitmap = BitmapInfo.fromBitmap(createBitmap(1, 1, Bitmap.Config.ALPHA_8))
|
||||
}
|
||||
@@ -93,8 +95,8 @@ object TaskbarViewTestUtil {
|
||||
TaskKey(
|
||||
id,
|
||||
5,
|
||||
TEST_INTENT,
|
||||
TEST_COMPONENT,
|
||||
testIntent(id),
|
||||
testComponent(id),
|
||||
Process.myUserHandle().identifier,
|
||||
System.currentTimeMillis(),
|
||||
)
|
||||
@@ -149,8 +151,10 @@ enum class TaskbarIconType {
|
||||
}
|
||||
|
||||
private const val TEST_PACKAGE = "com.android.launcher3.taskbar"
|
||||
private val TEST_COMPONENT = ComponentName(TEST_PACKAGE, "Activity")
|
||||
private val TEST_INTENT = Intent().apply {
|
||||
`package` = TEST_PACKAGE
|
||||
component = TEST_COMPONENT
|
||||
private val testComponent = { i: Int -> ComponentName(TEST_PACKAGE, "Activity $i") }
|
||||
private val testIntent = { i: Int ->
|
||||
Intent().apply {
|
||||
`package` = TEST_PACKAGE
|
||||
component = testComponent(i)
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -18,6 +18,7 @@ package com.android.quickstep;
|
||||
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import static com.android.launcher3.statehandlers.DesktopVisibilityController.INACTIVE_DESK_ID;
|
||||
import static com.android.quickstep.AbsSwipeUpHandler.STATE_HANDLER_INVALIDATED;
|
||||
import static com.android.wm.shell.shared.ShellSharedConstants.KEY_EXTRA_SHELL_CAN_HAND_OFF_ANIMATION;
|
||||
import static com.android.wm.shell.shared.split.SplitBounds.KEY_EXTRA_SPLIT_BOUNDS;
|
||||
@@ -111,7 +112,8 @@ public abstract class AbsSwipeUpHandlerTestCase<
|
||||
new ActivityManager.RunningTaskInfo();
|
||||
protected final TopTaskTracker.CachedTaskInfo mCachedTaskInfo =
|
||||
new TopTaskTracker.CachedTaskInfo(
|
||||
Collections.singletonList(mRunningTaskInfo), mContext, DEFAULT_DISPLAY);
|
||||
Collections.singletonList(mRunningTaskInfo), mContext, DEFAULT_DISPLAY,
|
||||
INACTIVE_DESK_ID);
|
||||
protected final RemoteAnimationTarget mRemoteAnimationTarget = new RemoteAnimationTarget(
|
||||
/* taskId= */ 0,
|
||||
/* mode= */ RemoteAnimationTarget.MODE_CLOSING,
|
||||
|
||||
+6
-4
@@ -60,6 +60,8 @@ class SettingsChangeLoggerTest {
|
||||
|
||||
private lateinit var mSystemUnderTest: SettingsChangeLogger
|
||||
|
||||
@Mock private lateinit var mStatsLogFactory: StatsLogManager.StatsLogManagerFactory
|
||||
|
||||
@Mock private lateinit var mStatsLogManager: StatsLogManager
|
||||
|
||||
@Mock private lateinit var mMockLogger: StatsLogManager.StatsLogger
|
||||
@@ -78,7 +80,7 @@ class SettingsChangeLoggerTest {
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
|
||||
whenever(mStatsLogFactory.create(mContext)).doReturn(mStatsLogManager)
|
||||
whenever(mStatsLogManager.logger()).doReturn(mMockLogger)
|
||||
whenever(mStatsLogManager.logger().withInstanceId(any())).doReturn(mMockLogger)
|
||||
mDefaultThemedIcons = themeManager.isMonoThemeEnabled
|
||||
@@ -91,10 +93,10 @@ class SettingsChangeLoggerTest {
|
||||
mSystemUnderTest =
|
||||
SettingsChangeLogger(
|
||||
mContext,
|
||||
mStatsLogManager,
|
||||
mTracker,
|
||||
displayController,
|
||||
settingsCache,
|
||||
mStatsLogFactory,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -109,10 +111,10 @@ class SettingsChangeLoggerTest {
|
||||
val systemUnderTest =
|
||||
SettingsChangeLogger(
|
||||
mContext,
|
||||
mStatsLogManager,
|
||||
mTracker,
|
||||
displayController,
|
||||
settingsCache,
|
||||
mStatsLogFactory,
|
||||
)
|
||||
|
||||
assertThat(systemUnderTest.loggingPrefs[ALLOW_ROTATION_PREFERENCE_KEY]!!.defaultValue)
|
||||
@@ -139,7 +141,7 @@ class SettingsChangeLoggerTest {
|
||||
LauncherPrefs.get(mContext).put(item = ALLOW_ROTATION, value = true)
|
||||
|
||||
// This a new object so the values of mLoggablePrefs will be different
|
||||
SettingsChangeLogger(mContext, mStatsLogManager, mTracker, displayController, settingsCache)
|
||||
SettingsChangeLogger(mContext, mTracker, displayController, settingsCache, mStatsLogFactory)
|
||||
.logSnapshot(mInstanceId)
|
||||
|
||||
verify(mMockLogger, atLeastOnce()).log(mEventCaptor.capture())
|
||||
|
||||
@@ -32,12 +32,14 @@ import com.android.launcher3.ui.AbstractLauncherUiTest;
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
||||
import com.android.launcher3.util.TestUtil;
|
||||
import com.android.launcher3.util.Wait;
|
||||
import com.android.quickstep.fallback.window.RecentsWindowFlags;
|
||||
import com.android.quickstep.fallback.window.RecentsWindowManager;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
|
||||
import org.junit.rules.RuleChain;
|
||||
import org.junit.rules.TestRule;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -57,6 +59,10 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<Quick
|
||||
|
||||
@Override
|
||||
protected void onLauncherActivityClose(QuickstepLauncher launcher) {
|
||||
if (RecentsWindowFlags.enableLauncherOverviewInWindow.isTrue()) {
|
||||
executeOnRecentsWindow(RecentsWindowManager::cleanupRecentsWindow);
|
||||
return;
|
||||
}
|
||||
RecentsView recentsView = launcher.getOverviewPanel();
|
||||
if (recentsView != null) {
|
||||
recentsView.finishRecentsAnimation(false /* toRecents */, null);
|
||||
@@ -87,6 +93,14 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<Quick
|
||||
});
|
||||
}
|
||||
|
||||
protected void executeOnRecentsWindow(Consumer<RecentsWindowManager> f) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return;
|
||||
getFromRecentsWindow(recentsWindowManager -> {
|
||||
f.accept(recentsWindowManager);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
|
||||
// flakiness.
|
||||
protected void waitForRecentsWindowCondition(
|
||||
|
||||
@@ -62,9 +62,7 @@
|
||||
|
||||
<!-- Various classes overriden by projects/build flavors. -->
|
||||
<string name="folder_name_provider_class" translatable="false"></string>
|
||||
<string name="stats_log_manager_class" translatable="false"></string>
|
||||
<string name="main_process_initializer_class" translatable="false"></string>
|
||||
<string name="app_launch_tracker_class" translatable="false"></string>
|
||||
<string name="test_information_handler_class" translatable="false"></string>
|
||||
<string name="secondary_display_quickstep_delegate_class" translatable="false"></string>
|
||||
<string name="taskbar_search_session_controller_class" translatable="false"></string>
|
||||
|
||||
@@ -1076,10 +1076,8 @@ public class CellLayout extends ViewGroup {
|
||||
int delay, boolean permanent, boolean adjustOccupied) {
|
||||
ShortcutAndWidgetContainer clc = getShortcutsAndWidgets();
|
||||
|
||||
if (clc.indexOfChild(child) != -1 && (child instanceof Reorderable)) {
|
||||
if (clc.indexOfChild(child) != -1 && (child instanceof Reorderable item)) {
|
||||
final CellLayoutLayoutParams lp = (CellLayoutLayoutParams) child.getLayoutParams();
|
||||
final ItemInfo info = (ItemInfo) child.getTag();
|
||||
final Reorderable item = (Reorderable) child;
|
||||
|
||||
// We cancel any existing animations
|
||||
if (mReorderAnimators.containsKey(lp)) {
|
||||
@@ -1485,7 +1483,7 @@ public class CellLayout extends ViewGroup {
|
||||
lp.setCellX(lp.getTmpCellX());
|
||||
lp.setCellY(lp.getTmpCellY());
|
||||
if (requiresDbUpdate) {
|
||||
Launcher.cast(mActivity).getModelWriter().modifyItemInDatabase(info, container,
|
||||
mActivity.getModelWriter().modifyItemInDatabase(info, container,
|
||||
screenId, lp.getCellX(), lp.getCellY(), lp.cellHSpan, lp.cellVSpan);
|
||||
}
|
||||
}
|
||||
@@ -1855,8 +1853,7 @@ public class CellLayout extends ViewGroup {
|
||||
|
||||
public void markCellsAsOccupiedForView(View view) {
|
||||
if (view instanceof LauncherAppWidgetHostView
|
||||
&& view.getTag() instanceof LauncherAppWidgetInfo) {
|
||||
LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) view.getTag();
|
||||
&& view.getTag() instanceof LauncherAppWidgetInfo info) {
|
||||
CellPos pos = mActivity.getCellPosMapper().mapModelToPresenter(info);
|
||||
mOccupied.markCells(pos.cellX, pos.cellY, info.spanX, info.spanY, true);
|
||||
return;
|
||||
@@ -1869,8 +1866,7 @@ public class CellLayout extends ViewGroup {
|
||||
|
||||
public void markCellsAsUnoccupiedForView(View view) {
|
||||
if (view instanceof LauncherAppWidgetHostView
|
||||
&& view.getTag() instanceof LauncherAppWidgetInfo) {
|
||||
LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) view.getTag();
|
||||
&& view.getTag() instanceof LauncherAppWidgetInfo info) {
|
||||
CellPos pos = mActivity.getCellPosMapper().mapModelToPresenter(info);
|
||||
mOccupied.markCells(pos.cellX, pos.cellY, info.spanX, info.spanY, false);
|
||||
return;
|
||||
|
||||
@@ -2526,11 +2526,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
mModelCallbacks.bindWorkspaceComponentsRemoved(matcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindItemsModified(List<ItemInfo> items) {
|
||||
mModelCallbacks.bindItemsModified(items);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@code LauncherBindingDelegate}
|
||||
*/
|
||||
|
||||
@@ -197,17 +197,6 @@ public class LauncherSettings {
|
||||
|
||||
public static final int CONTAINER_UNKNOWN = -1;
|
||||
|
||||
|
||||
/**
|
||||
* Function to know if a container belongs to the Workspace.
|
||||
*/
|
||||
public static boolean containerBelongsToWorkspace(int container) {
|
||||
return container == CONTAINER_DESKTOP
|
||||
|| container == CONTAINER_HOTSEAT
|
||||
|| container == CONTAINER_PREDICTION
|
||||
|| container == CONTAINER_HOTSEAT_PREDICTION;
|
||||
}
|
||||
|
||||
public static final String containerToString(int container) {
|
||||
switch (container) {
|
||||
case CONTAINER_DESKTOP: return "desktop";
|
||||
|
||||
@@ -6,7 +6,6 @@ import android.os.Trace
|
||||
import android.util.Log
|
||||
import androidx.annotation.UiThread
|
||||
import com.android.launcher3.LauncherConstants.TraceEvents
|
||||
import com.android.launcher3.LauncherSettings.Favorites.containerBelongsToWorkspace
|
||||
import com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET
|
||||
import com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID
|
||||
import com.android.launcher3.allapps.AllAppsStore
|
||||
@@ -204,8 +203,20 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
|
||||
* method from LauncherModel.Callbacks.
|
||||
*/
|
||||
override fun bindItemsUpdated(updates: Set<ItemInfo>) {
|
||||
launcher.workspace.updateContainerItems(updates, launcher)
|
||||
val workspace = launcher.workspace
|
||||
val itemsToRebind = workspace.updateContainerItems(updates, launcher)
|
||||
PopupContainerWithArrow.dismissInvalidPopup(launcher)
|
||||
|
||||
if (itemsToRebind.isEmpty()) return
|
||||
workspace.removeItemsByMatcher(ItemInfoMatcher.ofItems(itemsToRebind), false)
|
||||
itemsToRebind
|
||||
.filter { workspace.isContainerSupported(it.container) }
|
||||
.let {
|
||||
if (it.isNotEmpty()) {
|
||||
launcher.bindItems(it, false)
|
||||
}
|
||||
}
|
||||
workspace.stripEmptyScreens()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,13 +231,6 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
|
||||
PopupContainerWithArrow.dismissInvalidPopup(launcher)
|
||||
}
|
||||
|
||||
override fun bindItemsModified(itemsParam: MutableList<ItemInfo>) {
|
||||
val items = itemsParam.filter { containerBelongsToWorkspace(it.container) }
|
||||
launcher.workspace.removeItemsByMatcher(ItemInfoMatcher.ofItems(items), false)
|
||||
launcher.bindItems(items, false)
|
||||
launcher.workspace.stripEmptyScreens()
|
||||
}
|
||||
|
||||
override fun bindAllWidgets(allWidgets: List<WidgetsListBaseEntry>) {
|
||||
launcher.widgetPickerDataProvider.setWidgets(allWidgets)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ package com.android.launcher3;
|
||||
import static com.android.launcher3.AbstractFloatingView.TYPE_WIDGET_RESIZE_FRAME;
|
||||
import static com.android.launcher3.BubbleTextView.DISPLAY_FOLDER;
|
||||
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_PREDICTION;
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.EDIT_MODE;
|
||||
import static com.android.launcher3.LauncherState.FLAG_MULTI_PAGE;
|
||||
@@ -62,6 +65,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.Toast;
|
||||
@@ -2043,9 +2047,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
// Move internally
|
||||
boolean hasMovedLayouts = (getParentCellLayoutForView(cell) != dropTargetLayout);
|
||||
boolean hasMovedIntoHotseat = mLauncher.isHotseatLayout(dropTargetLayout);
|
||||
int container = hasMovedIntoHotseat ?
|
||||
LauncherSettings.Favorites.CONTAINER_HOTSEAT :
|
||||
LauncherSettings.Favorites.CONTAINER_DESKTOP;
|
||||
int container = hasMovedIntoHotseat ? CONTAINER_HOTSEAT : CONTAINER_DESKTOP;
|
||||
int screenId = (mTargetCell[0] < 0) ?
|
||||
mDragInfo.screenId : getCellLayoutId(dropTargetLayout);
|
||||
int spanX = mDragInfo != null ? mDragInfo.spanX : 1;
|
||||
@@ -2148,8 +2150,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
lp.cellVSpan = item.spanY;
|
||||
lp.isLockedToGrid = true;
|
||||
|
||||
if (container != LauncherSettings.Favorites.CONTAINER_HOTSEAT &&
|
||||
cell instanceof LauncherAppWidgetHostView) {
|
||||
if (container != CONTAINER_HOTSEAT
|
||||
&& cell instanceof LauncherAppWidgetHostView) {
|
||||
|
||||
// We post this call so that the widget has a chance to be placed
|
||||
// in its final location
|
||||
@@ -2805,8 +2807,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
*/
|
||||
private void onDropExternal(final int[] touchXY, final CellLayout cellLayout, DragObject d) {
|
||||
final int container = mLauncher.isHotseatLayout(cellLayout)
|
||||
? LauncherSettings.Favorites.CONTAINER_HOTSEAT
|
||||
: LauncherSettings.Favorites.CONTAINER_DESKTOP;
|
||||
? CONTAINER_HOTSEAT
|
||||
: CONTAINER_DESKTOP;
|
||||
if (d.dragInfo instanceof PendingAddShortcutInfo) {
|
||||
WorkspaceItemInfo si = ((PendingAddShortcutInfo) d.dragInfo)
|
||||
.getActivityInfo(mLauncher).createWorkspaceItemInfo();
|
||||
@@ -3347,6 +3349,30 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CellInfo getCellInfoForView(@NonNull View view) {
|
||||
ViewParent parent = view.getParent();
|
||||
if (parent != null
|
||||
&& parent.getParent() instanceof CellLayout cl
|
||||
&& view.getLayoutParams() instanceof CellLayoutLayoutParams lp) {
|
||||
int container = mLauncher.isHotseatLayout(cl) ? CONTAINER_HOTSEAT : CONTAINER_DESKTOP;
|
||||
CellPos pos = getCellPosMapper().mapPresenterToModel(
|
||||
lp.getCellX(), lp.getCellY(), getCellLayoutId(cl), container);
|
||||
return new CellInfo(view,
|
||||
pos.screenId, container, pos.cellX, pos.cellY, lp.cellHSpan, lp.cellVSpan);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isContainerSupported(int container) {
|
||||
return container == CONTAINER_DESKTOP
|
||||
|| container == CONTAINER_HOTSEAT
|
||||
|| container == CONTAINER_PREDICTION
|
||||
|| container == CONTAINER_HOTSEAT_PREDICTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View mapOverItems(@NonNull ItemOperator op) {
|
||||
return mapOverCellLayouts(getWorkspaceAndHotseatCellLayouts(), op);
|
||||
|
||||
@@ -26,17 +26,38 @@ import com.android.launcher3.util.CellAndSpan
|
||||
// 2. When long clicking on an empty cell in a CellLayout, we save information about the
|
||||
// cellX and cellY coordinates and which page was clicked. We then set this as a tag on
|
||||
// the CellLayout that was long clicked
|
||||
class CellInfo(v: View?, info: ItemInfo, cellPos: CellPos) :
|
||||
CellAndSpan(cellPos.cellX, cellPos.cellY, info.spanX, info.spanY) {
|
||||
@JvmField val cell: View?
|
||||
@JvmField val screenId: Int
|
||||
@JvmField val container: Int
|
||||
class CellInfo(
|
||||
@JvmField val cell: View?,
|
||||
@JvmField val screenId: Int,
|
||||
@JvmField val container: Int,
|
||||
cellX: Int,
|
||||
cellY: Int,
|
||||
spanX: Int,
|
||||
spanY: Int,
|
||||
) : CellAndSpan(cellX, cellY, spanX, spanY) {
|
||||
|
||||
init {
|
||||
cell = v
|
||||
screenId = cellPos.screenId
|
||||
container = info.container
|
||||
}
|
||||
constructor(
|
||||
cell: View?,
|
||||
info: ItemInfo,
|
||||
cellPos: CellPos,
|
||||
) : this(
|
||||
cell,
|
||||
cellPos.screenId,
|
||||
info.container,
|
||||
cellPos.cellX,
|
||||
cellPos.cellY,
|
||||
info.spanX,
|
||||
info.spanY,
|
||||
)
|
||||
|
||||
/** Returns if the provided [item] represents the same position info as itself */
|
||||
fun isSameAs(item: ItemInfo) =
|
||||
item.container == container &&
|
||||
item.screenId == screenId &&
|
||||
item.cellX == cellX &&
|
||||
item.cellY == cellY &&
|
||||
item.spanX == spanX &&
|
||||
item.spanY == spanY
|
||||
|
||||
override fun toString(): String {
|
||||
return "CellInfo(cell=$cell, screenId=$screenId, container=$container)"
|
||||
|
||||
@@ -27,6 +27,8 @@ import com.android.launcher3.RemoveAnimationSettingsTracker;
|
||||
import com.android.launcher3.graphics.GridCustomizationsProxy;
|
||||
import com.android.launcher3.graphics.ThemeManager;
|
||||
import com.android.launcher3.icons.LauncherIcons.IconPool;
|
||||
import com.android.launcher3.logging.DumpManager;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.model.ItemInstallQueue;
|
||||
import com.android.launcher3.model.LoaderCursor.LoaderCursorFactory;
|
||||
import com.android.launcher3.pm.InstallSessionHelper;
|
||||
@@ -34,7 +36,6 @@ import com.android.launcher3.pm.UserCache;
|
||||
import com.android.launcher3.util.ApiWrapper;
|
||||
import com.android.launcher3.util.DaggerSingletonTracker;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.logging.DumpManager;
|
||||
import com.android.launcher3.util.DynamicResource;
|
||||
import com.android.launcher3.util.InstantAppResolver;
|
||||
import com.android.launcher3.util.LockedUserState;
|
||||
@@ -93,8 +94,8 @@ public interface LauncherBaseAppComponent {
|
||||
WidgetHolderFactory getWidgetHolderFactory();
|
||||
RefreshRateTracker getFrameRateProvider();
|
||||
InstantAppResolver getInstantAppResolver();
|
||||
|
||||
DumpManager getDumpManager();
|
||||
StatsLogManager.StatsLogManagerFactory getStatsLogManagerFactory();
|
||||
|
||||
/** Builder for LauncherBaseAppComponent. */
|
||||
interface Builder {
|
||||
|
||||
@@ -1598,6 +1598,11 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
return mContent.iterateOverItems((info, view) -> info == item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isContainerSupported(int container) {
|
||||
return container == mInfo.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility methods to iterate over items of the view
|
||||
*/
|
||||
|
||||
@@ -141,11 +141,8 @@ public class FolderGridOrganizer {
|
||||
* @return true if there was any change
|
||||
*/
|
||||
public boolean updateRankAndPos(ItemInfo item, int rank) {
|
||||
Point pos = getPosForRank(rank);
|
||||
if (!pos.equals(item.cellX, item.cellY) || rank != item.rank) {
|
||||
if (rank != item.rank) {
|
||||
item.rank = rank;
|
||||
item.cellX = pos.x;
|
||||
item.cellY = pos.y;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -156,8 +153,13 @@ public class FolderGridOrganizer {
|
||||
*/
|
||||
public Point getPosForRank(int rank) {
|
||||
int pagePos = rank % mMaxItemsPerPage;
|
||||
mPoint.x = pagePos % mCountX;
|
||||
mPoint.y = pagePos / mCountX;
|
||||
if (mCountX == 0) {
|
||||
mPoint.x = 0;
|
||||
mPoint.y = 0;
|
||||
} else {
|
||||
mPoint.x = pagePos % mCountX;
|
||||
mPoint.y = pagePos / mCountX;
|
||||
}
|
||||
return mPoint;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Point;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
@@ -262,12 +263,11 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> implements Cli
|
||||
icon.setOnFocusChangeListener(mFocusIndicatorHelper);
|
||||
|
||||
CellLayoutLayoutParams lp = (CellLayoutLayoutParams) icon.getLayoutParams();
|
||||
Point pos = mOrganizer.getPosForRank(item.rank);
|
||||
if (lp == null) {
|
||||
icon.setLayoutParams(new CellLayoutLayoutParams(
|
||||
item.cellX, item.cellY, item.spanX, item.spanY));
|
||||
icon.setLayoutParams(new CellLayoutLayoutParams(pos.x, pos.y, 1, 1));
|
||||
} else {
|
||||
lp.setCellX(item.cellX);
|
||||
lp.setCellY(item.cellY);
|
||||
lp.setCellXY(pos);
|
||||
lp.cellHSpan = lp.cellVSpan = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,14 +28,16 @@ import androidx.annotation.Nullable;
|
||||
import androidx.slice.SliceItem;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.dagger.LauncherComponentProvider;
|
||||
import com.android.launcher3.logger.LauncherAtom;
|
||||
import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
|
||||
import com.android.launcher3.logger.LauncherAtom.FromState;
|
||||
import com.android.launcher3.logger.LauncherAtom.ToState;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.util.ResourceBasedOverride;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Handles the user event logging in R+.
|
||||
*
|
||||
@@ -45,7 +47,7 @@ import com.android.launcher3.views.ActivityContext;
|
||||
* Actual call happens only for Launcher variant that implements QuickStep.
|
||||
* </pre>
|
||||
*/
|
||||
public class StatsLogManager implements ResourceBasedOverride {
|
||||
public class StatsLogManager {
|
||||
|
||||
public static final int LAUNCHER_STATE_UNSPECIFIED = 0;
|
||||
public static final int LAUNCHER_STATE_BACKGROUND = 1;
|
||||
@@ -62,11 +64,28 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
private KeyboardStateManager mKeyboardStateManager;
|
||||
private InstanceId mInstanceId;
|
||||
|
||||
public StatsLogManager(@NonNull Context context) {
|
||||
|
||||
protected StatsLogManager(@NonNull Context context) {
|
||||
mContext = context;
|
||||
mActivityContext = ActivityContext.lookupContextNoThrow(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is purely used to support dagger bindings to be overridden in launcher variants.
|
||||
* Very similar to {@link dagger.assisted.AssistedFactory}. But
|
||||
* {@link dagger.assisted.AssistedFactory} cannot be overridden and this makes dagger binding
|
||||
* difficult.
|
||||
*/
|
||||
public static class StatsLogManagerFactory {
|
||||
@Inject
|
||||
public StatsLogManagerFactory() {
|
||||
}
|
||||
|
||||
public StatsLogManager create(Context context) {
|
||||
return new StatsLogManager(context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns event enum based on the two state transition information when swipe
|
||||
* gesture happens(to be removed during UserEventDispatcher cleanup).
|
||||
@@ -1356,7 +1375,6 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
* Creates a new instance of {@link StatsLogManager} based on provided context.
|
||||
*/
|
||||
public static StatsLogManager newInstance(Context context) {
|
||||
return Overrides.getObject(
|
||||
StatsLogManager.class, context, R.string.stats_log_manager_class);
|
||||
return LauncherComponentProvider.get(context).getStatsLogManagerFactory().create(context);
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,8 @@ import com.android.launcher3.Flags;
|
||||
import com.android.launcher3.Workspace;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dagger.LauncherAppSingleton;
|
||||
import com.android.launcher3.logging.DumpManager;
|
||||
import com.android.launcher3.logging.DumpManager.LauncherDumpable;
|
||||
import com.android.launcher3.logging.FileLog;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.CollectionInfo;
|
||||
@@ -61,8 +63,6 @@ import com.android.launcher3.shortcuts.ShortcutRequest;
|
||||
import com.android.launcher3.shortcuts.ShortcutRequest.QueryResult;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.DaggerSingletonTracker;
|
||||
import com.android.launcher3.logging.DumpManager;
|
||||
import com.android.launcher3.logging.DumpManager.LauncherDumpable;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
import com.android.launcher3.util.IntSparseArrayMap;
|
||||
@@ -465,11 +465,6 @@ public class BgDataModel implements LauncherDumpable {
|
||||
default void bindAppsAdded(IntArray newScreens,
|
||||
ArrayList<ItemInfo> addNotAnimated, ArrayList<ItemInfo> addAnimated) { }
|
||||
|
||||
/**
|
||||
* Called when some persistent property of an item is modified
|
||||
*/
|
||||
default void bindItemsModified(List<ItemInfo> items) { }
|
||||
|
||||
/**
|
||||
* Binds updated incremental download progress
|
||||
*/
|
||||
|
||||
@@ -51,6 +51,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
@@ -177,7 +178,7 @@ public class ModelWriter {
|
||||
public void moveItemsInDatabase(final ArrayList<ItemInfo> items, int container, int screen) {
|
||||
ArrayList<ContentValues> contentValues = new ArrayList<>();
|
||||
int count = items.size();
|
||||
notifyOtherCallbacks(c -> c.bindItemsModified(items));
|
||||
notifyOtherCallbacks(c -> c.bindItemsUpdated(new HashSet<>(items)));
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
ItemInfo item = items.get(i);
|
||||
@@ -229,7 +230,7 @@ public class ModelWriter {
|
||||
}
|
||||
|
||||
public void notifyItemModified(ItemInfo item) {
|
||||
notifyOtherCallbacks(c -> c.bindItemsModified(Collections.singletonList(item)));
|
||||
notifyOtherCallbacks(c -> c.bindItemsUpdated(Collections.singleton(item)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.launcher3.util
|
||||
import android.view.View
|
||||
import com.android.launcher3.BubbleTextView
|
||||
import com.android.launcher3.apppairs.AppPairIcon
|
||||
import com.android.launcher3.celllayout.CellInfo
|
||||
import com.android.launcher3.folder.Folder
|
||||
import com.android.launcher3.folder.FolderIcon
|
||||
import com.android.launcher3.model.data.AppPairInfo
|
||||
@@ -31,18 +32,28 @@ import com.android.launcher3.widget.PendingAppWidgetHostView
|
||||
import java.util.function.Predicate
|
||||
|
||||
/** Interface representing a container which can bind Launcher items with some utility methods */
|
||||
interface LauncherBindableItemsContainer {
|
||||
fun interface LauncherBindableItemsContainer {
|
||||
|
||||
/**
|
||||
* Called to update workspace items as a result of {@link
|
||||
* com.android.launcher3.model.BgDataModel.Callbacks#bindItemsUpdated(Set)}
|
||||
* Called to update items in a specific container as a result of
|
||||
* [com.android.launcher3.model.BgDataModel.Callbacks.bindItemsUpdated]. Returns a set of items
|
||||
* which were potentially moved and need to be rebound to the container.
|
||||
*/
|
||||
fun updateContainerItems(updates: Set<ItemInfo>, context: ActivityContext) {
|
||||
fun updateContainerItems(updates: Set<ItemInfo>, context: ActivityContext): Set<ItemInfo> {
|
||||
val op = ItemOperator { info, v ->
|
||||
when {
|
||||
v is BubbleTextView && info is WorkspaceItemInfo && updates.contains(info) ->
|
||||
v.applyFromWorkspaceItem(info)
|
||||
v is FolderIcon && info is FolderInfo -> v.updatePreviewItems(updates::contains)
|
||||
v is FolderIcon && info is FolderInfo -> {
|
||||
v.updatePreviewItems(updates::contains)
|
||||
if (updates.contains(info)) {
|
||||
v.onItemsChanged(false)
|
||||
v.folder.apply {
|
||||
reapplyItemInfo()
|
||||
if (isOpen()) close(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
v is AppPairIcon && info is AppPairInfo ->
|
||||
v.maybeRedrawForWorkspaceUpdate(updates::contains)
|
||||
v is PendingAppWidgetHostView && updates.contains(info) -> {
|
||||
@@ -57,6 +68,20 @@ interface LauncherBindableItemsContainer {
|
||||
|
||||
mapOverItems(op)
|
||||
Folder.getOpen(context)?.mapOverItems(op)
|
||||
|
||||
// Check for moved items
|
||||
val itemsToRebind = updates.filterTo(mutableSetOf()) { isContainerSupported(it.container) }
|
||||
mapOverItems { info, v ->
|
||||
info?.apply {
|
||||
if (!updates.contains(this)) return@apply
|
||||
val uiInfo = getCellInfoForView(v) ?: return@apply
|
||||
if (uiInfo.isSameAs(this)) itemsToRebind.remove(this) else itemsToRebind.add(this)
|
||||
}
|
||||
|
||||
// Iterate all items
|
||||
false
|
||||
}
|
||||
return itemsToRebind
|
||||
}
|
||||
|
||||
/** Returns the first view, matching the [op] */
|
||||
@@ -69,6 +94,16 @@ interface LauncherBindableItemsContainer {
|
||||
|
||||
fun getViewByItemId(id: Int): View? = mapOverItems { info, _ -> info != null && info.id == id }
|
||||
|
||||
/**
|
||||
* Returns the currently bound info for the [view] or null if the view is not bound. It can be
|
||||
* used to determine if the UI needs to be updated if it is different that the info represented
|
||||
* underlying item
|
||||
*/
|
||||
fun getCellInfoForView(view: View): CellInfo? = null
|
||||
|
||||
/** Returns if the provided [container] is supported by to this container */
|
||||
fun isContainerSupported(container: Int) = false
|
||||
|
||||
/**
|
||||
* Map the [op] over the shortcuts and widgets. Once we found the first view which matches, we
|
||||
* will stop the iteration and return that view.
|
||||
|
||||
Reference in new issue
Block a user