Merge "Removing ext_test directory" into main
diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java
index 847088d..5f53cc3 100644
--- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java
@@ -138,7 +138,7 @@
// views have been added in the KeyboardQuickSwitchView.
GroupTask task = mControllerCallbacks.getTaskAt(index);
if (task == null) {
- return Math.max(0, index);
+ return mOnDesktop ? 1 : Math.max(0, index);
}
if (mControllerCallbacks.isTaskRunning(task)) {
// Ignore attempts to run the selected task if it is already running.
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index aedbe6c..26212c1 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -37,14 +37,12 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING;
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_FULLSCREEN;
-import static com.android.launcher3.taskbar.TaskbarDragLayerController.TASKBAR_REAPPEAR_DELAY_MS;
import static com.android.launcher3.testing.shared.ResourceUtils.getBoolByName;
import static com.android.quickstep.util.AnimUtils.completeRunnableListCallback;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING;
import android.animation.AnimatorSet;
-import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
@@ -82,7 +80,6 @@
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.R;
-import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.apppairs.AppPairIcon;
import com.android.launcher3.config.FeatureFlags;
@@ -1432,23 +1429,6 @@
});
}
- public void hideTaskbarWhenFolding() {
- AnimatedFloat alphaAnim = mControllers.taskbarDragLayerController.getTaskbarAlpha();
- alphaAnim.cancelAnimation();
- alphaAnim.updateValue(0);
- ObjectAnimator animator = alphaAnim.animateToValue(1).setDuration(0);
- animator.setStartDelay(TASKBAR_REAPPEAR_DELAY_MS);
- animator.start();
- }
-
- public void cancelHideTaskbarWhenFolding() {
- mControllers.taskbarDragLayerController.getTaskbarAlpha().cancelAnimation();
- }
-
- public void resetHideTaskbarWhenUnfolding() {
- mControllers.taskbarDragLayerController.getTaskbarAlpha().updateValue(1);
- }
-
protected boolean isUserSetupComplete() {
return mIsUserSetupComplete;
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java
index e48c20d..ff890fb 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java
@@ -44,12 +44,6 @@
private static final boolean DEBUG = SystemProperties.getBoolean(
"persist.debug.draw_taskbar_debug_ui", false);
- // Delay to reset the task bar alpha back to 1 after fading it for transition from unfold to
- // fold. Normally this is not needed since the new task bar is recreated after fading, but in
- // case something goes wrong this provides a fallback mechanism to make sure the task bar is
- // visible after the transition finishes.
- public static final long TASKBAR_REAPPEAR_DELAY_MS = 2000;
-
private final TaskbarActivityContext mActivity;
private final TaskbarDragLayer mTaskbarDragLayer;
private final int mFolderMargin;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 8d48154..a14e3fd 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -205,7 +205,13 @@
mLauncherState = finalState;
updateStateForFlag(FLAG_LAUNCHER_IN_STATE_TRANSITION, false);
applyState();
- updateOverviewDragState(finalState);
+ boolean disallowLongClick =
+ FeatureFlags.enableSplitContextually()
+ ? mLauncher.isSplitSelectionActive()
+ : finalState == LauncherState.OVERVIEW_SPLIT_SELECT;
+ com.android.launcher3.taskbar.Utilities.setOverviewDragState(
+ mControllers, finalState.disallowTaskbarGlobalDrag(),
+ disallowLongClick, finalState.allowTaskbarInitialSplitSelection());
}
};
@@ -250,7 +256,6 @@
mCanSyncViews = true;
mLauncher.addOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
- updateOverviewDragState(mLauncherState);
}
public void onDestroy() {
@@ -323,7 +328,7 @@
updateStateForSysuiFlags(systemUiStateFlags, /* applyState */ true);
}
- private void updateStateForSysuiFlags(int systemUiStateFlags, boolean applyState) {
+ private void updateStateForSysuiFlags(int systemUiStateFlags, boolean applyState) {
final boolean prevIsAwake = hasAnyFlag(FLAG_AWAKE);
final boolean currIsAwake = hasAnyFlag(systemUiStateFlags, SYSUI_STATE_AWAKE);
@@ -353,21 +358,6 @@
}
/**
- * Updates overview drag state on various controllers based on {@link #mLauncherState}.
- *
- * @param launcherState The current state launcher is in
- */
- private void updateOverviewDragState(LauncherState launcherState) {
- boolean disallowLongClick =
- FeatureFlags.enableSplitContextually()
- ? mLauncher.isSplitSelectionActive()
- : launcherState == LauncherState.OVERVIEW_SPLIT_SELECT;
- com.android.launcher3.taskbar.Utilities.setOverviewDragState(
- mControllers, launcherState.disallowTaskbarGlobalDrag(),
- disallowLongClick, launcherState.allowTaskbarInitialSplitSelection());
- }
-
- /**
* Updates the proper flag to change the state of the task bar.
*
* Note that this only updates the flag. {@link #applyState()} needs to be called separately.
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index ecbc7e7..e4f9ba5 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -29,7 +29,6 @@
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
import static com.android.launcher3.util.DisplayController.CHANGE_TASKBAR_PINNING;
import static com.android.launcher3.util.DisplayController.TASKBAR_NOT_DESTROYED_TAG;
-import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
import static com.android.quickstep.util.SystemActionConstants.ACTION_SHOW_TASKBAR;
@@ -43,7 +42,6 @@
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
-import android.hardware.devicestate.DeviceStateManager;
import android.hardware.display.DisplayManager;
import android.net.Uri;
import android.os.Handler;
@@ -111,7 +109,6 @@
private final Context mContext;
private final @Nullable Context mNavigationBarPanelContext;
- private final DeviceStateManager mDeviceStateManager;
private WindowManager mWindowManager;
private FrameLayout mTaskbarRootLayout;
private boolean mAddedWindow;
@@ -180,8 +177,7 @@
}
};
- private final UnfoldTransitionProgressProvider.TransitionProgressListener
- mUnfoldTransitionProgressListener =
+ UnfoldTransitionProgressProvider.TransitionProgressListener mUnfoldTransitionProgressListener =
new UnfoldTransitionProgressProvider.TransitionProgressListener() {
@Override
public void onTransitionStarted() {
@@ -210,9 +206,6 @@
}
};
- private final DeviceStateManager.FoldStateListener mFoldStateListener;
- private Boolean mFolded;
-
@SuppressLint("WrongConstant")
public TaskbarManager(
TouchInteractionService service, AllAppsActionManager allAppsActionManager) {
@@ -240,29 +233,6 @@
}
};
}
- // Temporary solution to mitigate the visual jump from folding the device. Currently, the
- // screen turns on much earlier than we receive the onConfigurationChanged callback or
- // receiving the correct device profile. While the ideal the solution is to align turning
- // the screen on after onConfigurationChanged (by either delaying turning on the screen or
- // figuring out what is causing the delay in getting onConfigurationChanged callback), one
- // easy temporary mitigation is to dimming the bar so that the visual jump isn't as glaring.
- mFoldStateListener = new DeviceStateManager.FoldStateListener(mContext, folded -> {
- boolean firstTime = mFolded == null;
- if (mTaskbarActivityContext == null) {
- return;
- }
- if (!firstTime && mFolded.booleanValue() != folded) {
- mTaskbarActivityContext.cancelHideTaskbarWhenFolding();
- }
- mFolded = folded;
- if (folded && !firstTime) {
- mTaskbarActivityContext.hideTaskbarWhenFolding();
- } else {
- mTaskbarActivityContext.resetHideTaskbarWhenUnfolding();
- }
- });
- mDeviceStateManager = mContext.getSystemService(DeviceStateManager.class);
- mDeviceStateManager.registerCallback(MAIN_EXECUTOR, mFoldStateListener);
mNavButtonController = new TaskbarNavButtonController(service,
SystemUiProxy.INSTANCE.get(mContext), new Handler(),
AssistUtils.newInstance(mContext));
@@ -619,7 +589,6 @@
Log.d(TASKBAR_NOT_DESTROYED_TAG, "unregistering component callbacks from destroy().");
mContext.unregisterComponentCallbacks(mComponentCallbacks);
mContext.unregisterReceiver(mShutdownReceiver);
- mDeviceStateManager.unregisterCallback(mFoldStateListener);
}
public @Nullable TaskbarActivityContext getCurrentActivityContext() {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 020b34e..e7d2843 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -259,6 +259,7 @@
import com.android.launcher3.widget.custom.CustomWidgetManager;
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
import com.android.launcher3.widget.picker.WidgetsFullSheet;
+import com.android.launcher3.widget.util.WidgetSizes;
import com.android.systemui.plugins.LauncherOverlayPlugin;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.plugins.shared.LauncherOverlayManager;
@@ -829,7 +830,7 @@
announceForAccessibility(R.string.item_added_to_workspace);
break;
case REQUEST_CREATE_APPWIDGET:
- completeAddAppWidget(appWidgetId, info, null, null, false, null);
+ completeAddAppWidget(appWidgetId, info, null, null, false, true, null);
break;
case REQUEST_RECONFIGURE_APPWIDGET:
getStatsLogManager().logger().withItemInfo(info).log(LAUNCHER_WIDGET_RECONFIGURED);
@@ -1027,7 +1028,7 @@
requestArgs.getWidgetHandler().getProviderInfo(this));
boundWidget = layout;
onCompleteRunnable = () -> {
- completeAddAppWidget(appWidgetId, requestArgs, layout, null, false, null);
+ completeAddAppWidget(appWidgetId, requestArgs, layout, null, false, true, null);
if (!isInState(EDIT_MODE)) {
mStateManager.goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
}
@@ -1458,7 +1459,8 @@
@Thunk
void completeAddAppWidget(int appWidgetId, ItemInfo itemInfo,
@Nullable AppWidgetHostView hostView, LauncherAppWidgetProviderInfo appWidgetInfo,
- boolean showPendingWidget, @Nullable Bitmap widgetPreviewBitmap) {
+ boolean showPendingWidget, boolean updateWidgetSize,
+ @Nullable Bitmap widgetPreviewBitmap) {
if (appWidgetInfo == null) {
appWidgetInfo = mAppWidgetManager.getLauncherAppWidgetInfo(appWidgetId,
@@ -1499,8 +1501,14 @@
reInflatedHostView,
(LauncherAppWidgetInfo) reInflatedHostView.getTag(),
presenterPos);
+ // We always update widget size after re-inflating PendingAppWidgetHostView
+ WidgetSizes.updateWidgetSizeRanges(
+ reInflatedHostView, this, itemInfo.spanX, itemInfo.spanY);
return;
}
+ if (updateWidgetSize) {
+ WidgetSizes.updateWidgetSizeRanges(hostView, this, itemInfo.spanX, itemInfo.spanY);
+ }
if (itemInfo instanceof PendingAddWidgetInfo) {
launcherInfo.sourceContainer = ((PendingAddWidgetInfo) itemInfo).sourceContainer;
} else if (itemInfo instanceof PendingRequestArgs) {
@@ -1839,7 +1847,7 @@
: () -> mStateManager.goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
completeAddAppWidget(appWidgetId, info, boundWidget,
addFlowHandler.getProviderInfo(this), addFlowHandler.needsConfigure(),
- widgetPreviewBitmap);
+ false, widgetPreviewBitmap);
mWorkspace.removeExtraEmptyScreenDelayed(delay, false, onComplete);
}
diff --git a/src/com/android/launcher3/allapps/PrivateAppsSectionDecorator.java b/src/com/android/launcher3/allapps/PrivateAppsSectionDecorator.java
index 8712b84..18175b6 100644
--- a/src/com/android/launcher3/allapps/PrivateAppsSectionDecorator.java
+++ b/src/com/android/launcher3/allapps/PrivateAppsSectionDecorator.java
@@ -56,7 +56,7 @@
new SectionDecorationHandler.UnionDecorationHandler(
decorationHandler, parent.getPaddingLeft(),
parent.getPaddingRight()));
- unionHandler.addChild(decorationHandler, view, true /* applyBackground */);
+ unionHandler.addChild(decorationHandler, view);
deferredDecorations.put(PRIVATE_APP_SECTION, unionHandler);
} else {
decorationHandler.onFocusDraw(c, view);
diff --git a/src/com/android/launcher3/allapps/SectionDecorationHandler.java b/src/com/android/launcher3/allapps/SectionDecorationHandler.java
index f79b82c..ac9b146 100644
--- a/src/com/android/launcher3/allapps/SectionDecorationHandler.java
+++ b/src/com/android/launcher3/allapps/SectionDecorationHandler.java
@@ -176,13 +176,10 @@
/**
* Expands decoration bounds to include child {@link PrivateAppsSectionDecorator}
*/
- public void addChild(SectionDecorationHandler child, View view, boolean applyBackground) {
+ public void addChild(SectionDecorationHandler child, View view) {
int scaledHeight = (int) (view.getHeight() * view.getScaleY());
mBounds.union(view.getLeft(), view.getY(),
view.getRight(), view.getY() + scaledHeight);
- if (applyBackground) {
- applyBackground(view, mContext, null, false);
- }
mIsBottomRound |= child.mIsBottomRound;
mIsBottomLeftRound |= child.mIsBottomLeftRound;
mIsBottomRightRound |= child.mIsBottomRightRound;
diff --git a/tests/Android.bp b/tests/Android.bp
index 3a9f4ad..eeafdba 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -206,6 +206,7 @@
"androidx.test.uiautomator_uiautomator",
"androidx.core_core-animation-testing",
"androidx.test.ext.junit",
+ "androidx.test.rules",
"mockito-robolectric-prebuilt",
"mockito-kotlin2",
"platform-parametric-runner-lib",
diff --git a/tests/src/com/android/launcher3/icons/FastBitmapDrawableTest.java b/tests/multivalentTests/src/com/android/launcher3/icons/FastBitmapDrawableTest.java
similarity index 100%
rename from tests/src/com/android/launcher3/icons/FastBitmapDrawableTest.java
rename to tests/multivalentTests/src/com/android/launcher3/icons/FastBitmapDrawableTest.java
diff --git a/tests/src/com/android/launcher3/model/WorkspaceItemProcessorTest.kt b/tests/src/com/android/launcher3/model/WorkspaceItemProcessorTest.kt
index f333494..30957fc 100644
--- a/tests/src/com/android/launcher3/model/WorkspaceItemProcessorTest.kt
+++ b/tests/src/com/android/launcher3/model/WorkspaceItemProcessorTest.kt
@@ -25,30 +25,22 @@
import android.content.pm.ShortcutInfo
import android.os.UserHandle
import android.util.LongSparseArray
-import com.android.dx.mockito.inline.extended.ExtendedMockito
import com.android.launcher3.LauncherAppState
import com.android.launcher3.LauncherSettings.Favorites
-import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP
import com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
-import com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET
import com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT
import com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_FOLDER
-import com.android.launcher3.Utilities
import com.android.launcher3.Utilities.EMPTY_PERSON_ARRAY
-import com.android.launcher3.backuprestore.LauncherRestoreEventLogger
import com.android.launcher3.backuprestore.LauncherRestoreEventLogger.RestoreError.Companion.MISSING_INFO
import com.android.launcher3.backuprestore.LauncherRestoreEventLogger.RestoreError.Companion.PROFILE_DELETED
import com.android.launcher3.model.data.FolderInfo
import com.android.launcher3.model.data.IconRequestInfo
import com.android.launcher3.model.data.ItemInfo
-import com.android.launcher3.model.data.LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG
-import com.android.launcher3.model.data.LauncherAppWidgetInfo.FLAG_UI_NOT_READY
import com.android.launcher3.model.data.WorkspaceItemInfo
import com.android.launcher3.shortcuts.ShortcutKey
import com.android.launcher3.util.ComponentKey
import com.android.launcher3.util.PackageManagerHelper
import com.android.launcher3.util.PackageUserKey
-import com.android.launcher3.widget.LauncherAppWidgetProviderInfo
import com.android.launcher3.widget.WidgetInflater
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
@@ -79,30 +71,28 @@
@Mock private lateinit var mockUserManagerState: UserManagerState
@Mock private lateinit var mockWidgetInflater: WidgetInflater
- private var mUserHandle: UserHandle = UserHandle(0)
- private var mIconRequestInfos: MutableList<IconRequestInfo<WorkspaceItemInfo>> = mutableListOf()
- private var mComponentName: ComponentName = ComponentName("package", "class")
- private var mUnlockedUsersArray: LongSparseArray<Boolean> = LongSparseArray()
- private var mKeyToPinnedShortcutsMap: MutableMap<ShortcutKey, ShortcutInfo> = mutableMapOf()
- private var mInstallingPkgs: HashMap<PackageUserKey, PackageInstaller.SessionInfo> = hashMapOf()
- private var mAllDeepShortcuts: MutableList<ShortcutInfo> = mutableListOf()
- private var mWidgetProvidersMap: MutableMap<ComponentKey, AppWidgetProviderInfo?> =
- mutableMapOf()
- private var mPendingPackages: MutableSet<PackageUserKey> = mutableSetOf()
+ private lateinit var userHandle: UserHandle
+ private lateinit var iconRequestInfos: MutableList<IconRequestInfo<WorkspaceItemInfo>>
+ private lateinit var componentName: ComponentName
+ private lateinit var unlockedUsersArray: LongSparseArray<Boolean>
+ private lateinit var keyToPinnedShortcutsMap: MutableMap<ShortcutKey, ShortcutInfo>
+ private lateinit var installingPkgs: HashMap<PackageUserKey, PackageInstaller.SessionInfo>
+ private lateinit var allDeepShortcuts: MutableList<ShortcutInfo>
private lateinit var itemProcessorUnderTest: WorkspaceItemProcessor
@Before
fun setup() {
- mUserHandle = UserHandle(0)
+ userHandle = UserHandle(0)
mockIconRequestInfo = mock<IconRequestInfo<WorkspaceItemInfo>>()
+ iconRequestInfos = mutableListOf(mockIconRequestInfo)
mockWorkspaceInfo = mock<WorkspaceItemInfo>()
mockBgDataModel = mock<BgDataModel>()
- mComponentName = ComponentName("package", "class")
- mUnlockedUsersArray = LongSparseArray<Boolean>(1).apply { put(101, true) }
+ componentName = ComponentName("package", "class")
+ unlockedUsersArray = LongSparseArray<Boolean>(1).apply { put(101, true) }
mockIntent =
mock<Intent>().apply {
- whenever(component).thenReturn(mComponentName)
+ whenever(component).thenReturn(componentName)
whenever(`package`).thenReturn("pkg")
whenever(getStringExtra(ShortcutKey.EXTRA_SHORTCUT_ID)).thenReturn("")
}
@@ -119,17 +109,17 @@
}
mockPmHelper =
mock<PackageManagerHelper>().apply {
- whenever(getAppLaunchIntent(mComponentName.packageName, mUserHandle))
+ whenever(getAppLaunchIntent(componentName.packageName, userHandle))
.thenReturn(mockIntent)
}
mockLauncherApps =
mock<LauncherApps>().apply {
- whenever(isPackageEnabled("package", mUserHandle)).thenReturn(true)
- whenever(isActivityEnabled(mComponentName, mUserHandle)).thenReturn(true)
+ whenever(isPackageEnabled("package", userHandle)).thenReturn(true)
+ whenever(isActivityEnabled(componentName, userHandle)).thenReturn(true)
}
mockCursor =
mock(LoaderCursor::class.java, RETURNS_DEEP_STUBS).apply {
- user = mUserHandle
+ user = userHandle
itemType = ITEM_TYPE_APPLICATION
id = 1
restoreFlag = 1
@@ -144,12 +134,9 @@
}
mockUserManagerState = mock<UserManagerState>()
mockWidgetInflater = mock<WidgetInflater>()
- mKeyToPinnedShortcutsMap = mutableMapOf()
- mInstallingPkgs = hashMapOf()
- mAllDeepShortcuts = mutableListOf()
- mWidgetProvidersMap = mutableMapOf()
- mIconRequestInfos = mutableListOf()
- mPendingPackages = mutableSetOf()
+ keyToPinnedShortcutsMap = mutableMapOf()
+ installingPkgs = hashMapOf()
+ allDeepShortcuts = mutableListOf()
}
/**
@@ -162,18 +149,18 @@
memoryLogger: LoaderMemoryLogger? = null,
userManagerState: UserManagerState = mockUserManagerState,
launcherApps: LauncherApps = mockLauncherApps,
- shortcutKeyToPinnedShortcuts: Map<ShortcutKey, ShortcutInfo> = mKeyToPinnedShortcutsMap,
+ shortcutKeyToPinnedShortcuts: Map<ShortcutKey, ShortcutInfo> = keyToPinnedShortcutsMap,
app: LauncherAppState = mockAppState,
bgDataModel: BgDataModel = mockBgDataModel,
- widgetProvidersMap: MutableMap<ComponentKey, AppWidgetProviderInfo?> = mWidgetProvidersMap,
+ widgetProvidersMap: MutableMap<ComponentKey, AppWidgetProviderInfo?> = mutableMapOf(),
widgetInflater: WidgetInflater = mockWidgetInflater,
pmHelper: PackageManagerHelper = mockPmHelper,
- iconRequestInfos: MutableList<IconRequestInfo<WorkspaceItemInfo>> = mIconRequestInfos,
+ iconRequestInfos: MutableList<IconRequestInfo<WorkspaceItemInfo>> = mutableListOf(),
isSdCardReady: Boolean = false,
- pendingPackages: MutableSet<PackageUserKey> = mPendingPackages,
- unlockedUsers: LongSparseArray<Boolean> = mUnlockedUsersArray,
- installingPkgs: HashMap<PackageUserKey, PackageInstaller.SessionInfo> = mInstallingPkgs,
- allDeepShortcuts: MutableList<ShortcutInfo> = mAllDeepShortcuts
+ pendingPackages: MutableSet<PackageUserKey> = mutableSetOf(),
+ unlockedUsers: LongSparseArray<Boolean> = unlockedUsersArray,
+ installingPkgs: HashMap<PackageUserKey, PackageInstaller.SessionInfo> = hashMapOf(),
+ allDeepShortcuts: MutableList<ShortcutInfo> = mutableListOf()
) =
WorkspaceItemProcessor(
c = cursor,
@@ -240,8 +227,8 @@
fun `When app has empty String target package then mark deleted`() {
// Given
- mComponentName = ComponentName("", "")
- whenever(mockIntent.component).thenReturn(mComponentName)
+ componentName = ComponentName("", "")
+ whenever(mockIntent.component).thenReturn(componentName)
whenever(mockCursor.parseIntent()).thenReturn(mockIntent)
itemProcessorUnderTest = createWorkspaceItemProcessorUnderTest()
@@ -268,7 +255,7 @@
.isEqualTo(0)
// currently gets marked restored twice, although markRestore() has check for restoreFlag
verify(mockCursor, times(2)).markRestored()
- assertThat(mIconRequestInfos).containsExactly(mockIconRequestInfo)
+ assertThat(iconRequestInfos).containsExactly(mockIconRequestInfo)
verify(mockCursor).checkAndAddItem(mockWorkspaceInfo, mockBgDataModel, null)
}
@@ -278,12 +265,12 @@
// Given
mockLauncherApps =
mock<LauncherApps>().apply {
- whenever(isPackageEnabled("package", mUserHandle)).thenReturn(true)
- whenever(isActivityEnabled(mComponentName, mUserHandle)).thenReturn(false)
+ whenever(isPackageEnabled("package", userHandle)).thenReturn(true)
+ whenever(isActivityEnabled(componentName, userHandle)).thenReturn(false)
}
mockPmHelper =
mock<PackageManagerHelper>().apply {
- whenever(getAppLaunchIntent(mComponentName.packageName, mUserHandle))
+ whenever(getAppLaunchIntent(componentName.packageName, userHandle))
.thenReturn(mockIntent)
}
itemProcessorUnderTest = createWorkspaceItemProcessorUnderTest()
@@ -296,7 +283,7 @@
.that(mockCursor.restoreFlag)
.isEqualTo(0)
verify(mockCursor.updater().put(Favorites.INTENT, mockIntent.toUri(0))).commit()
- assertThat(mIconRequestInfos).containsExactly(mockIconRequestInfo)
+ assertThat(iconRequestInfos).containsExactly(mockIconRequestInfo)
verify(mockCursor).checkAndAddItem(mockWorkspaceInfo, mockBgDataModel, null)
}
@@ -306,13 +293,12 @@
// Given
mockLauncherApps =
mock<LauncherApps>().apply {
- whenever(isPackageEnabled("package", mUserHandle)).thenReturn(true)
- whenever(isActivityEnabled(mComponentName, mUserHandle)).thenReturn(false)
+ whenever(isPackageEnabled("package", userHandle)).thenReturn(true)
+ whenever(isActivityEnabled(componentName, userHandle)).thenReturn(false)
}
mockPmHelper =
mock<PackageManagerHelper>().apply {
- whenever(getAppLaunchIntent(mComponentName.packageName, mUserHandle))
- .thenReturn(null)
+ whenever(getAppLaunchIntent(componentName.packageName, userHandle)).thenReturn(null)
}
itemProcessorUnderTest = createWorkspaceItemProcessorUnderTest()
@@ -351,9 +337,10 @@
whenever(persons).thenReturn(EMPTY_PERSON_ARRAY)
}
val shortcutKey = ShortcutKey.fromIntent(mockIntent, mockCursor.user)
- mKeyToPinnedShortcutsMap[shortcutKey] = expectedShortcutInfo
+ keyToPinnedShortcutsMap[shortcutKey] = expectedShortcutInfo
+ iconRequestInfos = mutableListOf()
itemProcessorUnderTest =
- createWorkspaceItemProcessorUnderTest(allDeepShortcuts = mAllDeepShortcuts)
+ createWorkspaceItemProcessorUnderTest(allDeepShortcuts = allDeepShortcuts)
// When
itemProcessorUnderTest.processItem()
@@ -362,8 +349,8 @@
assertWithMessage("item restoreFlag should be set to 0")
.that(mockCursor.restoreFlag)
.isEqualTo(0)
- assertThat(mIconRequestInfos).isEmpty()
- assertThat(mAllDeepShortcuts).containsExactly(expectedShortcutInfo)
+ assertThat(iconRequestInfos).isEmpty()
+ assertThat(allDeepShortcuts).containsExactly(expectedShortcutInfo)
verify(mockCursor).markRestored()
verify(mockCursor).checkAndAddItem(any(), any(), anyOrNull())
}
@@ -373,6 +360,8 @@
// Given
mockCursor.itemType = ITEM_TYPE_DEEP_SHORTCUT
+ iconRequestInfos = mutableListOf()
+ keyToPinnedShortcutsMap = hashMapOf()
itemProcessorUnderTest = createWorkspaceItemProcessorUnderTest()
// When
@@ -382,7 +371,7 @@
assertWithMessage("item restoreFlag should be set to 0")
.that(mockCursor.restoreFlag)
.isEqualTo(0)
- assertThat(mIconRequestInfos).isEmpty()
+ assertThat(iconRequestInfos).isEmpty()
verify(mockCursor, times(0)).checkAndAddItem(any(), any(), anyOrNull())
verify(mockCursor)
.markDeleted(
@@ -438,189 +427,4 @@
assertThat(actualFolderInfo.options).isEqualTo(expectedFolderInfo.options)
verify(mockCursor).checkAndAddItem(actualFolderInfo, mockBgDataModel, null)
}
-
- @Test
- fun `When valid Widget then checkAndAddItem`() {
-
- // Given
- mockCursor =
- mock<LoaderCursor>().apply {
- itemType = ITEM_TYPE_APPWIDGET
- id = 1
- user = UserHandle(1)
- restoreFlag = FLAG_DIRECT_CONFIG
- container = CONTAINER_DESKTOP
- whenever(isOnWorkspaceOrHotseat).thenCallRealMethod()
- whenever(appWidgetProvider)
- .thenReturn("com.google.android.testApp/com.android.testApp.testAppProvider")
- whenever(appWidgetId).thenReturn(0)
- whenever(spanX).thenReturn(2)
- whenever(spanY).thenReturn(1)
- whenever(options).thenReturn(0)
- whenever(appWidgetSource).thenReturn(20)
- whenever(applyCommonProperties(any())).thenCallRealMethod()
- }
- val mockProviderInfo =
- mock<LauncherAppWidgetProviderInfo>().apply {
- provider = mock()
- whenever(user).thenReturn(UserHandle(1))
- }
- val inflationResult =
- WidgetInflater.InflationResult(
- type = WidgetInflater.TYPE_REAL,
- widgetInfo = mockProviderInfo
- )
- mockWidgetInflater =
- mock<WidgetInflater>().apply {
- whenever(inflateAppWidget(any())).thenReturn(inflationResult)
- }
- itemProcessorUnderTest =
- createWorkspaceItemProcessorUnderTest(widgetProvidersMap = mWidgetProvidersMap)
-
- // When
- itemProcessorUnderTest.processItem()
-
- // Then
- assertThat(
- mWidgetProvidersMap[ComponentKey(mockProviderInfo.provider, mockProviderInfo.user)]
- )
- .isEqualTo(inflationResult.widgetInfo)
- verify(mockCursor).checkAndAddItem(any(), any())
- }
-
- @Test
- fun `When valid Pending Widget then checkAndAddItem`() {
-
- // Given
- mockCursor =
- mock<LoaderCursor>().apply {
- itemType = ITEM_TYPE_APPWIDGET
- id = 1
- user = UserHandle(1)
- restoreFlag = FLAG_UI_NOT_READY
- container = CONTAINER_DESKTOP
- whenever(isOnWorkspaceOrHotseat).thenCallRealMethod()
- whenever(appWidgetProvider)
- .thenReturn("com.google.android.testApp/com.android.testApp.testAppProvider")
- whenever(appWidgetId).thenReturn(0)
- whenever(spanX).thenReturn(2)
- whenever(spanY).thenReturn(1)
- whenever(options).thenReturn(0)
- whenever(appWidgetSource).thenReturn(20)
- whenever(applyCommonProperties(any())).thenCallRealMethod()
- }
- val mockProviderInfo =
- mock<LauncherAppWidgetProviderInfo>().apply {
- provider = mock()
- whenever(user).thenReturn(UserHandle(1))
- }
- val inflationResult =
- WidgetInflater.InflationResult(
- type = WidgetInflater.TYPE_PENDING,
- widgetInfo = mockProviderInfo
- )
- mockWidgetInflater =
- mock<WidgetInflater>().apply {
- whenever(inflateAppWidget(any())).thenReturn(inflationResult)
- }
- itemProcessorUnderTest =
- createWorkspaceItemProcessorUnderTest(widgetProvidersMap = mWidgetProvidersMap)
-
- // When
- itemProcessorUnderTest.processItem()
-
- // Then
- verify(mockCursor).checkAndAddItem(any(), any())
- }
-
- @Test
- fun `When Unrestored Pending App Widget then mark deleted`() {
-
- // Given
- val expectedProvider = "com.google.android.testApp/com.android.testApp.testAppProvider"
- mockCursor =
- mock<LoaderCursor>().apply {
- itemType = ITEM_TYPE_APPWIDGET
- id = 1
- user = UserHandle(1)
- restoreFlag = FLAG_UI_NOT_READY
- container = CONTAINER_DESKTOP
- whenever(isOnWorkspaceOrHotseat).thenCallRealMethod()
- whenever(appWidgetProvider).thenReturn(expectedProvider)
- whenever(appWidgetId).thenReturn(0)
- whenever(spanX).thenReturn(2)
- whenever(spanY).thenReturn(1)
- whenever(options).thenReturn(0)
- whenever(appWidgetSource).thenReturn(20)
- whenever(applyCommonProperties(any())).thenCallRealMethod()
- }
- mInstallingPkgs = hashMapOf()
- val inflationResult =
- WidgetInflater.InflationResult(type = WidgetInflater.TYPE_PENDING, widgetInfo = null)
- mockWidgetInflater =
- mock<WidgetInflater>().apply {
- whenever(inflateAppWidget(any())).thenReturn(inflationResult)
- }
- itemProcessorUnderTest =
- createWorkspaceItemProcessorUnderTest(widgetProvidersMap = mWidgetProvidersMap)
- val expectedComponentName = ComponentName.unflattenFromString(expectedProvider)
-
- // When
- itemProcessorUnderTest.processItem()
-
- // Then
- verify(mockCursor)
- .markDeleted(
- "Unrestored widget removed: $expectedComponentName",
- LauncherRestoreEventLogger.RestoreError.APP_NOT_INSTALLED
- )
- }
-
- @Test
- fun `When Archived Pending App Widget then checkAndAddItem`() {
-
- // Given
- val expectedProvider = "com.google.android.testApp/com.android.testApp.testAppProvider"
- val expectedComponentName = ComponentName.unflattenFromString(expectedProvider)
- val expectedPackage = expectedComponentName!!.packageName
- val mockitoSession =
- ExtendedMockito.mockitoSession().mockStatic(Utilities::class.java).startMocking()
- whenever(Utilities.enableSupportForArchiving()).thenReturn(true)
- mockPmHelper =
- mock<PackageManagerHelper>().apply {
- whenever(isAppArchived(expectedPackage)).thenReturn(true)
- }
- mockCursor =
- mock<LoaderCursor>().apply {
- itemType = ITEM_TYPE_APPWIDGET
- id = 1
- user = UserHandle(1)
- restoreFlag = FLAG_UI_NOT_READY
- container = CONTAINER_DESKTOP
- whenever(isOnWorkspaceOrHotseat).thenCallRealMethod()
- whenever(appWidgetProvider).thenReturn(expectedProvider)
- whenever(appWidgetId).thenReturn(0)
- whenever(spanX).thenReturn(2)
- whenever(spanY).thenReturn(1)
- whenever(options).thenReturn(0)
- whenever(appWidgetSource).thenReturn(20)
- whenever(applyCommonProperties(any())).thenCallRealMethod()
- }
- mInstallingPkgs = hashMapOf()
- val inflationResult =
- WidgetInflater.InflationResult(type = WidgetInflater.TYPE_PENDING, widgetInfo = null)
- mockWidgetInflater =
- mock<WidgetInflater>().apply {
- whenever(inflateAppWidget(any())).thenReturn(inflationResult)
- }
- itemProcessorUnderTest =
- createWorkspaceItemProcessorUnderTest(widgetProvidersMap = mWidgetProvidersMap)
-
- // When
- itemProcessorUnderTest.processItem()
-
- // Then
- mockitoSession.finishMocking()
- verify(mockCursor).checkAndAddItem(any(), any())
- }
}