listener);
-
/**
* Sets a flag indicating whether to pause scroll.
* Should be set to {@code true} while the screen is binding or new data is being applied,
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
index 09f3bd43f6..c2ab115c0c 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
@@ -27,39 +27,30 @@ import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.graphics.Canvas;
-import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Paint.Style;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.RectF;
-import android.graphics.drawable.VectorDrawable;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.IntProperty;
-import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewOutlineProvider;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
-import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
-import androidx.core.content.ContextCompat;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.Themes;
-import java.util.function.Consumer;
-
/**
* {@link PageIndicator} which shows dots per page. The active page is shown with the current
* accent color.
@@ -75,15 +66,12 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
private static final int PAGINATION_FADE_IN_DURATION = 83;
private static final int PAGINATION_FADE_OUT_DURATION = 167;
- private static final int DISABLED_ARROW_OPACITY = 97; // 38%
-
private static final int ENTER_ANIMATION_START_DELAY = 300;
private static final int ENTER_ANIMATION_STAGGERED_DELAY = 150;
private static final int ENTER_ANIMATION_DURATION = 400;
private static final int HEIGHT_MULTIPLIER = 4;
private static final int WIDTH_MULTIPLIER = 3;
- private static final float ARROW_TOUCH_BOX_FACTOR = 2f;
private static final int PAGE_INDICATOR_ALPHA = 255;
private static final int DOT_ALPHA = 128;
@@ -92,7 +80,6 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
private static final int VISIBLE_ALPHA = 255;
private static final int INVISIBLE_ALPHA = 0;
private Paint mPaginationPaint;
- private @Nullable Consumer mOnArrowClickListener;
// This value approximately overshoots to 1.5 times the original size.
private static final float ENTER_ANIMATION_OVERSHOOT_TENSION = 4.9f;
@@ -135,14 +122,6 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
private final float mGapWidth;
private final float mCircleGap;
private final boolean mIsRtl;
- private final VectorDrawable mArrowRight;
- private final VectorDrawable mArrowLeft;
- private final Rect mArrowRightBounds = new Rect();
- private final Rect mArrowLeftBounds = new Rect();
- private final int mArrowTouchBoxExtraWidth;
- private final int mArrowTouchBoxHeight;
- private final int mArrowGapWidth;
- private final int mArrowLength;
private int mNumPages;
private int mActivePage;
@@ -194,23 +173,6 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
: DOT_GAP_FACTOR * mDotRadius;
setOutlineProvider(new MyOutlineProver());
mIsRtl = Utilities.isRtl(getResources());
- mArrowRight = setupArrow(R.drawable.ic_chevron_right_rounded_700);
- mArrowLeft = setupArrow(R.drawable.ic_chevron_left_rounded_700);
- /* the width of the arrows themselves plus extra folder / touch padding. x2 for 2 arrows. */
- mArrowTouchBoxExtraWidth = 2 * ((int) ((5.5f) * mGapWidth)
- + getResources().getDimensionPixelSize(R.dimen.folder_footer_horiz_padding));
- mArrowTouchBoxHeight =
- getResources().getDimensionPixelSize(R.dimen.folder_footer_height_default);
- mArrowLength = getResources().getDimensionPixelSize(R.dimen.folder_arrow_icon_length);
- mArrowGapWidth = getResources().getDimensionPixelSize(R.dimen.folder_arrow_gap_width);
- }
-
- private VectorDrawable setupArrow(@DrawableRes int resId) {
- VectorDrawable icon = (VectorDrawable) ContextCompat.getDrawable(getContext(), resId);
- ColorFilter arrowColorFilter = new PorterDuffColorFilter(mPaginationPaint.getColor(),
- PorterDuff.Mode.SRC_ATOP);
- icon.setColorFilter(arrowColorFilter);
- return icon;
}
@Override
@@ -448,11 +410,6 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
requestLayout();
}
- @Override
- public void setArrowClickListener(@Nullable Consumer listener) {
- mOnArrowClickListener = listener;
- }
-
@Override
public void setPauseScroll(boolean pause, boolean isTwoPanels) {
mIsTwoPanels = isTwoPanels;
@@ -467,20 +424,13 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- // TODO(b/394355070): Verify Folder Entry Animation works correctly with visual updates
// Add extra spacing of mDotRadius on all sides so than entry animation could be run
- // and so the hitboxes of arrows can be clicked easier.
int width = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY ?
MeasureSpec.getSize(widthMeasureSpec)
: (int) ((mNumPages * WIDTH_MULTIPLIER + 2) * mDotRadius);
int height = MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY
? MeasureSpec.getSize(heightMeasureSpec)
: (int) (HEIGHT_MULTIPLIER * mDotRadius);
- if (enableLauncherVisualRefresh() && mOnArrowClickListener != null) {
- // Extra height and width and gaps for accessibility arrows.
- width += mArrowTouchBoxExtraWidth;
- height = mArrowTouchBoxHeight;
- }
setMeasuredDimension(width, height);
}
@@ -573,17 +523,6 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
float bounceProgress = (posDif > 1) ? posDif - 1 : 0;
float bounceAdjustment = Math.abs(currentPosition - boundedPosition) * diameter;
- if (mOnArrowClickListener != null) {
- // Here we draw the Left Arrow
- mArrowLeft.setAlpha(boundedPosition == 0 ? DISABLED_ARROW_OPACITY : alpha);
- mArrowLeftBounds.left = (int) (sTempRect.left - mArrowGapWidth - mArrowLength);
- mArrowLeftBounds.top = (int) (y - (float) mArrowLength / 2);
- mArrowLeftBounds.right = mArrowLeftBounds.left + mArrowLength;
- mArrowLeftBounds.bottom = mArrowLeftBounds.top + mArrowLength;
- mArrowLeft.setBounds(mArrowLeftBounds);
- mArrowLeft.draw(canvas);
- }
-
// Here we draw the dots, one at a time from the left-most dot to the right-most dot
// 1.0 => 000000 000000111111 000000
// 1.3 => 000000 0000001111 11000000
@@ -640,17 +579,6 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
sTempRect.left = sTempRect.right + mGapWidth;
}
- if (mOnArrowClickListener != null) {
- // Here we draw the Right Arrow
- mArrowRight.setAlpha(boundedPosition == (mNumPages - 1)
- ? DISABLED_ARROW_OPACITY : alpha);
- mArrowRightBounds.left = (int) (sTempRect.left - mGapWidth + mArrowGapWidth);
- mArrowRightBounds.top = (int) (y - (float) mArrowLength / 2);
- mArrowRightBounds.right = mArrowRightBounds.left + mArrowLength;
- mArrowRightBounds.bottom = mArrowRightBounds.top + mArrowLength;
- mArrowRight.setBounds(mArrowRightBounds);
- mArrowRight.draw(canvas);
- }
} else {
// Here we draw the dots
mPaginationPaint.setAlpha((int) (alpha * DOT_ALPHA_FRACTION));
@@ -668,27 +596,6 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator
mPaginationPaint.setAlpha(alpha);
}
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- if (mOnArrowClickListener == null) {
- // No - Op. Don't care about touch events
- } else if ((mIsRtl && withinExpandedBounds(mArrowRightBounds, ev))
- || (!mIsRtl && withinExpandedBounds(mArrowLeftBounds, ev))) {
- mOnArrowClickListener.accept(Direction.START);
- } else if ((mIsRtl && withinExpandedBounds(mArrowLeftBounds, ev))
- || (!mIsRtl && withinExpandedBounds(mArrowRightBounds, ev))) {
- mOnArrowClickListener.accept(Direction.END);
- }
- return super.onTouchEvent(ev);
- }
-
- // For larger Touch box
- private boolean withinExpandedBounds(Rect rect, MotionEvent ev) {
- RectF scaledRect = new RectF(rect);
- scale(scaledRect, ARROW_TOUCH_BOX_FACTOR);
- return scaledRect.contains(ev.getX(), ev.getY());
- }
-
private static void scale(RectF rect, float factor) {
float horizontalAdjustment = rect.width() * (factor - 1) / 2;
float verticalAdjustment = rect.height() * (factor - 1) / 2;
diff --git a/src/com/android/launcher3/pageindicators/PaginationArrow.kt b/src/com/android/launcher3/pageindicators/PaginationArrow.kt
new file mode 100644
index 0000000000..77a9e3c232
--- /dev/null
+++ b/src/com/android/launcher3/pageindicators/PaginationArrow.kt
@@ -0,0 +1,69 @@
+/*
+ * 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.pageindicators
+
+import android.annotation.SuppressLint
+import android.content.Context
+import android.util.AttributeSet
+import android.view.MotionEvent
+import android.widget.ImageView
+import androidx.core.content.ContextCompat
+import com.android.launcher3.R
+
+/**
+ * Handles logic for the pagination arrow. The foreground and background images and the pressed /
+ * hovered state UX.
+ */
+@SuppressLint("AppCompatCustomView")
+class PaginationArrow(context: Context, attrs: AttributeSet) : ImageView(context, attrs) {
+ private val bgCircle = ContextCompat.getDrawable(context, R.drawable.ic_circle)
+
+ init {
+ foreground = ContextCompat.getDrawable(context, R.drawable.ic_chevron_left_rounded_700)
+ }
+
+ override fun onTouchEvent(event: MotionEvent?): Boolean {
+ when (event?.action) {
+ MotionEvent.ACTION_DOWN -> {
+ background = bgCircle
+ background.alpha = BACKGROUND_PRESSED_OPACITY
+ }
+ MotionEvent.ACTION_UP -> background = null
+ }
+ return super.onTouchEvent(event)
+ }
+
+ override fun onHoverEvent(event: MotionEvent?): Boolean {
+ when (event?.action) {
+ MotionEvent.ACTION_HOVER_ENTER -> {
+ background = bgCircle
+ background.alpha = BACKGROUND_HOVERED_OPACITY
+ }
+ MotionEvent.ACTION_HOVER_EXIT -> background = null
+ }
+ return super.onHoverEvent(event)
+ }
+
+ companion object {
+ const val FULLY_OPAQUE = 1f
+ const val DISABLED_ARROW_OPACITY = .38f
+
+ // alpha ints are 0 - 255; the former being transparent and the latter being fully opaque
+ private const val BACKGROUND_HOVERED_OPACITY = 28 // 11%
+ private const val BACKGROUND_PRESSED_OPACITY = 38 // 15%
+ }
+}
diff --git a/src/com/android/launcher3/util/Executors.java b/src/com/android/launcher3/util/Executors.java
index 296fc8ad27..23db7a1b28 100644
--- a/src/com/android/launcher3/util/Executors.java
+++ b/src/com/android/launcher3/util/Executors.java
@@ -66,6 +66,12 @@ public class Executors {
public static final LooperExecutor UI_HELPER_EXECUTOR =
new LooperExecutor("UiThreadHelper", Process.THREAD_PRIORITY_FOREGROUND);
+ /**
+ * A background executor for running tasks that are not time sensitive, typically for data
+ * transformations.
+ */
+ public static final LooperExecutor DATA_HELPER_EXECUTOR =
+ new LooperExecutor("DataThreadHelper", Process.THREAD_PRIORITY_DEFAULT);
/** A background executor to preinflate views. */
public static final ExecutorService VIEW_PREINFLATION_EXECUTOR =
diff --git a/src/com/android/launcher3/util/LooperExecutor.kt b/src/com/android/launcher3/util/LooperExecutor.kt
index 6ff528d264..aff46ec8d7 100644
--- a/src/com/android/launcher3/util/LooperExecutor.kt
+++ b/src/com/android/launcher3/util/LooperExecutor.kt
@@ -21,12 +21,14 @@ import android.os.Looper
import android.os.Process
import android.os.Process.THREAD_PRIORITY_FOREGROUND
import androidx.annotation.IntDef
-import java.util.concurrent.AbstractExecutorService
+
+import com.google.common.util.concurrent.AbstractListeningExecutorService
+
import java.util.concurrent.TimeUnit
import kotlin.annotation.AnnotationRetention.SOURCE
-/** Extension of [AbstractExecutorService] which executed on a provided looper. */
-class LooperExecutor(looper: Looper, private val defaultPriority: Int) : AbstractExecutorService() {
+/** Extension of [AbstractListeningExecutorService] which executed on a provided looper. */
+class LooperExecutor(looper: Looper, private val defaultPriority: Int) : AbstractListeningExecutorService() {
val handler: Handler = Handler(looper)
@JvmOverloads
diff --git a/src/com/android/launcher3/util/dagger/LauncherExecutorsModule.kt b/src/com/android/launcher3/util/dagger/LauncherExecutorsModule.kt
new file mode 100644
index 0000000000..b80fa575cf
--- /dev/null
+++ b/src/com/android/launcher3/util/dagger/LauncherExecutorsModule.kt
@@ -0,0 +1,92 @@
+/*
+ * 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.util.dagger
+
+import com.android.launcher3.concurrent.annotations.Background
+import com.android.launcher3.concurrent.annotations.LightweightBackground
+import com.android.launcher3.concurrent.annotations.LightweightBackgroundPriority
+import com.android.launcher3.concurrent.annotations.Ui
+import com.android.launcher3.concurrent.annotations.ThreadPool
+
+import com.android.launcher3.concurrent.ExecutorsModule
+
+import com.android.launcher3.dagger.LauncherAppSingleton
+import com.android.launcher3.util.Executors
+import com.android.launcher3.util.LooperExecutor
+
+import com.google.common.util.concurrent.ListeningExecutorService
+import com.google.common.util.concurrent.MoreExecutors
+
+import dagger.Module
+import dagger.Binds
+import dagger.Provides
+
+import java.util.concurrent.Executor
+import java.util.concurrent.ExecutorService
+
+/**
+ * Module that provides the executors for Launcher3 as per the [ExecutorsModule]
+ * interface.
+ */
+@Module
+abstract class LauncherExecutorsModule {
+
+ // Include UI LooperExecutor bindings here since they're not provided
+ // by the ExecutorsModule interface.
+ @Binds
+ @LauncherAppSingleton
+ @Ui
+ abstract fun provideUiExecutor(
+ @Ui executor: LooperExecutor
+ ): ListeningExecutorService
+
+ companion object {
+ @Provides
+ @LauncherAppSingleton
+ @Ui
+ fun provideUiLooperExecutor(): LooperExecutor {
+ return Executors.MAIN_EXECUTOR
+ }
+
+ @Provides
+ @LauncherAppSingleton
+ @LightweightBackground(LightweightBackgroundPriority.UI)
+ fun provideUiExecutorService(): ListeningExecutorService {
+ return Executors.UI_HELPER_EXECUTOR
+ }
+
+ @Provides
+ @LauncherAppSingleton
+ @LightweightBackground(LightweightBackgroundPriority.DATA)
+ fun provideDataExecutorService(): ListeningExecutorService {
+ return Executors.DATA_HELPER_EXECUTOR
+ }
+
+ @Provides
+ @LauncherAppSingleton
+ @Background
+ fun provideBackgroundExecutorService(): ListeningExecutorService {
+ return Executors.ORDERED_BG_EXECUTOR
+ }
+
+ @Provides
+ @LauncherAppSingleton
+ @ThreadPool
+ fun provideThreadPoolExecutorService(): ListeningExecutorService {
+ return MoreExecutors.listeningDecorator(Executors.THREAD_POOL_EXECUTOR)
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/launcher3/views/ClipIconView.java b/src/com/android/launcher3/views/ClipIconView.java
index 30a3c4540b..eb25003925 100644
--- a/src/com/android/launcher3/views/ClipIconView.java
+++ b/src/com/android/launcher3/views/ClipIconView.java
@@ -16,7 +16,6 @@
package com.android.launcher3.views;
import static com.android.app.animation.Interpolators.LINEAR;
-import static com.android.launcher3.Flags.enableAdditionalHomeAnimations;
import static com.android.launcher3.Utilities.boundToRange;
import static com.android.launcher3.Utilities.mapToRange;
import static com.android.launcher3.anim.AnimatorListeners.forEndCallback;
@@ -102,9 +101,6 @@ public class ClipIconView extends View implements ClipPathView {
* within the clip bounds of this view.
*/
public void setTaskViewArtist(TaskViewArtist taskViewArtist) {
- if (!enableAdditionalHomeAnimations()) {
- return;
- }
mTaskViewArtist = taskViewArtist;
invalidate();
}
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index 5b3abc383a..e2b56bef10 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -18,7 +18,6 @@ package com.android.launcher3.views;
import static android.view.Gravity.LEFT;
import static com.android.app.animation.Interpolators.LINEAR;
-import static com.android.launcher3.Flags.enableAdditionalHomeAnimations;
import static com.android.launcher3.Utilities.getFullDrawable;
import static com.android.launcher3.Utilities.mapToRange;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
@@ -169,8 +168,7 @@ public class FloatingIconView extends FrameLayout implements
// FIV hasn't fully laid out. During those frames, hide this FIV and continue drawing the
// TaskView directly while transforming it in the place of this FIV. However, if we fade
// the TaskView at all, we need to display this FIV regardless.
- setAlpha(!enableAdditionalHomeAnimations() || isLaidOut() || taskViewDrawAlpha < 255
- ? alpha : 0f);
+ setAlpha(isLaidOut() || taskViewDrawAlpha < 255 ? alpha : 0f);
mClipIconView.update(rect, progress, shapeProgressStart, cornerRadius, isOpening, this,
mLauncher.getDeviceProfile(), taskViewDrawAlpha);
diff --git a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
index 185c3ee9ed..e94f3a065d 100644
--- a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
+++ b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
@@ -26,12 +26,9 @@ import androidx.annotation.Nullable;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
-import com.android.launcher3.pageindicators.Direction;
import com.android.launcher3.pageindicators.PageIndicator;
import com.android.launcher3.views.ActivityContext;
-import java.util.function.Consumer;
-
/**
* Supports two indicator colors, dedicated for personal and work tabs.
*/
@@ -80,11 +77,6 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
public void setMarkersCount(int numMarkers) {
}
- @Override
- public void setArrowClickListener(Consumer listener) {
- // No-Op. All Apps doesn't need accessibility arrows for single click navigation.
- }
-
@Override
public boolean hasOverlappingRendering() {
return false;
diff --git a/tests/src/com/android/launcher3/LauncherIntentTest.java b/tests/src/com/android/launcher3/LauncherIntentTest.java
index 6b686e51fb..2151fc3fe1 100644
--- a/tests/src/com/android/launcher3/LauncherIntentTest.java
+++ b/tests/src/com/android/launcher3/LauncherIntentTest.java
@@ -62,8 +62,10 @@ public class LauncherIntentTest extends BaseLauncherActivityTest {
// Highlights the search bar, then fills text to display the SearchView.
private void moveToSearchView() {
// All Apps view should be loaded
- assertTrue("Launcher internal state is not All Apps",
- isInState(() -> LauncherState.ALL_APPS));
+ assertTrue(
+ "Launcher internal state is not All Apps",
+ getLauncherInteractor().isInState(LauncherState.ALL_APPS)
+ );
getLauncherActivity().executeOnLauncher(
launcher -> launcher.getAppsView().getSearchView().requestFocus()
);
@@ -83,8 +85,10 @@ public class LauncherIntentTest extends BaseLauncherActivityTest {
// Checks if main adapter view is selected, search bar is out of focus and scroller is at start.
private void assertOnMainAdapterAToZView() {
// All Apps State should be loaded
- assertTrue("Launcher internal state is not All Apps",
- isInState(() -> LauncherState.ALL_APPS));
+ assertTrue(
+ "Launcher internal state is not All Apps",
+ getLauncherInteractor().isInState(LauncherState.ALL_APPS)
+ );
// A-Z recycler view should be active.
waitForLauncherCondition("A-Z view not active.",
diff --git a/tests/src/com/android/launcher3/compat/PromiseIconUiTest.java b/tests/src/com/android/launcher3/compat/PromiseIconUiTest.java
index 67b13794ee..9e90f92dcc 100644
--- a/tests/src/com/android/launcher3/compat/PromiseIconUiTest.java
+++ b/tests/src/com/android/launcher3/compat/PromiseIconUiTest.java
@@ -18,6 +18,8 @@ package com.android.launcher3.compat;
import static android.os.Process.myUserHandle;
+import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
+
import static com.android.launcher3.Flags.FLAG_ENABLE_SUPPORT_FOR_ARCHIVING;
import static com.google.common.truth.Truth.assertThat;
@@ -32,6 +34,7 @@ import android.text.TextUtils;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
+import androidx.test.uiautomator.UiDevice;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
@@ -64,6 +67,8 @@ public class PromiseIconUiTest extends BaseLauncherActivityTest {
public static final String DUMMY_PACKAGE = "com.example.android.aardwolf";
public static final String DUMMY_LABEL = "Aardwolf";
+ public UiDevice uiDevice = UiDevice.getInstance(getInstrumentation());
+
private int mSessionId = -1;
@Before
@@ -136,7 +141,7 @@ public class PromiseIconUiTest extends BaseLauncherActivityTest {
@RequiresFlagsEnabled(FLAG_ENABLE_SUPPORT_FOR_ARCHIVING)
public void testPromiseIcon_addedArchivedApp() throws Throwable {
installDummyAppAndWaitForUIUpdate();
- assertThat(executeShellCommand(
+ assertThat(uiDevice.executeShellCommand(
String.format("pm archive --user %d %s",
myUserHandle().getIdentifier(), DUMMY_PACKAGE)))
.isEqualTo("Success\n");
diff --git a/tests/src/com/android/launcher3/ui/WorkProfileTest.java b/tests/src/com/android/launcher3/ui/WorkProfileTest.java
index c191760f5d..6b2065f077 100644
--- a/tests/src/com/android/launcher3/ui/WorkProfileTest.java
+++ b/tests/src/com/android/launcher3/ui/WorkProfileTest.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.ui;
+import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
+
import static com.android.launcher3.LauncherPrefs.WORK_EDU_STEP;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST;
@@ -33,6 +35,7 @@ import android.view.View;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
+import androidx.test.uiautomator.UiDevice;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherPrefs;
@@ -68,13 +71,15 @@ public class WorkProfileTest extends BaseLauncherActivityTest {
@Rule
public TestStabilityRule mTestStabilityRule = new TestStabilityRule();
+ public UiDevice uiDevice = UiDevice.getInstance(getInstrumentation());
+
private int mProfileUserId;
private boolean mWorkProfileSetupSuccessful;
private static final String TAG = "WorkProfileTest";
@Before
public void setUp() throws Exception {
- String output = executeShellCommand(String.format(
+ String output = uiDevice.executeShellCommand(String.format(
"pm create-user --profileOf %d --managed TestProfile",
Process.myUserHandle().getIdentifier()));
updateWorkProfileSetupSuccessful("pm create-user", output);
@@ -99,7 +104,7 @@ public class WorkProfileTest extends BaseLauncherActivityTest {
@After
public void removeWorkProfile() throws Exception {
TestUtil.uninstallDummyApp();
- executeShellCommand("pm remove-user --wait " + mProfileUserId);
+ uiDevice.executeShellCommand("pm remove-user --wait " + mProfileUserId);
}
private void waitForWorkTabSetup() {
diff --git a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
index f777049f0a..152ea2c4ed 100644
--- a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
@@ -123,7 +123,7 @@ public class AddConfigWidgetTest extends BaseLauncherActivityTest {
v instanceof WidgetCell
&& v.getTag() instanceof PendingAddWidgetInfo pawi
&& mWidgetInfo.provider.equals(pawi.componentName)));
- addWidgetToWorkspace(widgetView);
+ getLauncherInteractor().addWidgetToWorkspace(widgetView);
// Widget id for which the config activity was opened
mWidgetId = monitor.getWidgetId();
diff --git a/tests/src/com/android/launcher3/ui/widget/RequestPinItemTest.java b/tests/src/com/android/launcher3/ui/widget/RequestPinItemTest.java
index 91ad341440..a52a5af9da 100644
--- a/tests/src/com/android/launcher3/ui/widget/RequestPinItemTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/RequestPinItemTest.java
@@ -151,7 +151,7 @@ public class RequestPinItemTest extends BaseLauncherActivityTest {
BlockingBroadcastReceiver openMonitor = new BlockingBroadcastReceiver(
RequestPinItemActivity.class.getName());
Context testContext = getInstrumentation().getContext();
- startAppFast(
+ getLauncherInteractor().startAppFast(
testContext.getPackageName(),
new Intent(testContext, RequestPinItemActivity.class));
assertNotNull(openMonitor.blockingGetExtraIntent());
diff --git a/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java b/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java
index 5e4b9c8c34..a1181f3732 100644
--- a/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java
+++ b/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java
@@ -66,7 +66,7 @@ public class ThemeIconsTest extends BaseLauncherActivityTest {
scrollToAppIcon(APP_NAME);
BubbleTextView btv = getLauncherActivity().getFromLauncher(
l -> verifyIconTheme(APP_NAME, l.getAppsView(), false));
- addToWorkspace(btv);
+ getLauncherInteractor().addToWorkspace(btv);
getLauncherActivity().executeOnLauncher(
l -> verifyIconTheme(APP_NAME, l.getWorkspace(), false)
);
@@ -87,7 +87,7 @@ public class ThemeIconsTest extends BaseLauncherActivityTest {
BubbleTextView menuItem = getOnceNotNull("Popup menu not open", l ->
(AbstractFloatingView.getOpenView(l, TYPE_ACTION_POPUP) instanceof ArrowPopup ap)
? findBtv(SHORTCUT_NAME, ap) : null);
- addToWorkspace(menuItem);
+ getLauncherInteractor().addToWorkspace(menuItem);
getLauncherActivity().executeOnLauncher(
l -> verifyIconTheme(SHORTCUT_NAME, l.getWorkspace(), false));
}
@@ -104,7 +104,7 @@ public class ThemeIconsTest extends BaseLauncherActivityTest {
l -> verifyIconTheme(APP_NAME, l.getAppsView(), false)
);
- addToWorkspace(btv);
+ getLauncherInteractor().addToWorkspace(btv);
getLauncherActivity().executeOnLauncher(
l -> verifyIconTheme(APP_NAME, l.getWorkspace(), true));
}
@@ -123,7 +123,7 @@ public class ThemeIconsTest extends BaseLauncherActivityTest {
BubbleTextView menuItem = getOnceNotNull("Popup menu not open", l ->
(AbstractFloatingView.getOpenView(l, TYPE_ACTION_POPUP) instanceof ArrowPopup ap)
? findBtv(SHORTCUT_NAME, ap) : null);
- addToWorkspace(menuItem);
+ getLauncherInteractor().addToWorkspace(menuItem);
getLauncherActivity().executeOnLauncher(
l -> verifyIconTheme(SHORTCUT_NAME, l.getWorkspace(), true));
}
diff --git a/tests/src/com/android/launcher3/util/BaseLauncherActivityTest.kt b/tests/src/com/android/launcher3/util/BaseLauncherActivityTest.kt
index ecf4606956..dd28f5acb6 100644
--- a/tests/src/com/android/launcher3/util/BaseLauncherActivityTest.kt
+++ b/tests/src/com/android/launcher3/util/BaseLauncherActivityTest.kt
@@ -16,7 +16,6 @@
package com.android.launcher3.util
import android.content.Context
-import android.content.Intent
import android.os.SystemClock
import android.view.InputDevice
import android.view.KeyCharacterMap
@@ -29,15 +28,12 @@ import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import androidx.test.uiautomator.UiDevice
import com.android.launcher3.Launcher
import com.android.launcher3.LauncherAppState
-import com.android.launcher3.LauncherState
-import com.android.launcher3.R
import com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST
import com.android.launcher3.integration.util.LauncherActivityScenarioRule
import com.android.launcher3.util.ModelTestExtensions.loadModelSync
import com.android.launcher3.util.Wait.atMost
import java.util.function.Function
import java.util.function.Predicate
-import java.util.function.Supplier
import org.junit.Rule
/**
@@ -51,6 +47,8 @@ open class BaseLauncherActivityTest {
var launcherActivity =
LauncherActivityScenarioRule(getInstrumentation().targetContext)
+ val launcherInteractor = LauncherActivityInteractor(launcherActivity)
+
@JvmField val uiDevice = UiDevice.getInstance(getInstrumentation())
protected fun loadLauncherSync() {
@@ -60,9 +58,6 @@ open class BaseLauncherActivityTest {
protected fun targetContext(): Context = getInstrumentation().targetContext
- protected fun isInState(state: Supplier): Boolean =
- launcherActivity.getFromLauncher { it.stateManager.state == state.get() }!!
-
protected fun waitForLauncherCondition(message: String, condition: (LAUNCHER_TYPE) -> Boolean) =
atMost(message, { launcherActivity.getFromLauncher(condition)!! })
@@ -105,47 +100,11 @@ open class BaseLauncherActivityTest {
launcherActivity.executeOnLauncher { it.dispatchKeyEvent(event) }
}
- @JvmOverloads
- fun startAppFast(
- packageName: String,
- intent: Intent = targetContext().packageManager.getLaunchIntentForPackage(packageName)!!,
- ) {
- intent.addCategory(Intent.CATEGORY_LAUNCHER)
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
- targetContext().startActivity(intent)
- uiDevice.waitForIdle()
- }
-
fun freezeAllApps() =
launcherActivity.executeOnLauncher {
it.appsView.appsStore.enableDeferUpdates(DEFER_UPDATES_TEST)
}
- fun executeShellCommand(cmd: String) = uiDevice.executeShellCommand(cmd)
-
- fun addToWorkspace(view: View) {
- TestUtil.runOnExecutorSync(Executors.MAIN_EXECUTOR) {
- view.accessibilityDelegate.performAccessibilityAction(
- view,
- R.id.action_add_to_workspace,
- null,
- )
- }
- UiDevice.getInstance(getInstrumentation()).waitForIdle()
- }
-
- /**
- * Match the behavior with how widget is added in reality with "tap to add" (even with screen
- * readers).
- */
- fun addWidgetToWorkspace(view: View) {
- launcherActivity.executeOnLauncher {
- view.performClick()
- UiDevice.getInstance(getInstrumentation()).waitForIdle()
- view.findViewById(R.id.widget_add_button).performClick()
- }
- }
-
fun ViewGroup.searchView(filter: Predicate): View? {
if (filter.test(this)) return this
for (child in children) {
diff --git a/tests/src/com/android/launcher3/util/LauncherActivityInteractor.kt b/tests/src/com/android/launcher3/util/LauncherActivityInteractor.kt
new file mode 100644
index 0000000000..d2c7df298a
--- /dev/null
+++ b/tests/src/com/android/launcher3/util/LauncherActivityInteractor.kt
@@ -0,0 +1,71 @@
+/*
+ * 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.util
+
+import android.content.Intent
+import android.view.View
+import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
+import androidx.test.uiautomator.UiDevice
+import com.android.launcher3.Launcher
+import com.android.launcher3.LauncherState
+import com.android.launcher3.R
+import com.android.launcher3.integration.util.LauncherActivityScenarioRule
+
+class LauncherActivityInteractor(
+ val launcherActivity: LauncherActivityScenarioRule
+) {
+
+ val uiDevice = UiDevice.getInstance(getInstrumentation())
+
+ @JvmOverloads
+ fun startAppFast(
+ packageName: String,
+ intent: Intent =
+ launcherActivity.context.packageManager.getLaunchIntentForPackage(packageName)!!,
+ ) =
+ launcherActivity.context
+ .startActivity(
+ intent
+ .addCategory(Intent.CATEGORY_LAUNCHER)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
+ )
+ .run { uiDevice.waitForIdle() }
+
+ fun addToWorkspace(view: View) =
+ TestUtil.runOnExecutorSync(Executors.MAIN_EXECUTOR) {
+ view.accessibilityDelegate.performAccessibilityAction(
+ view,
+ R.id.action_add_to_workspace,
+ null,
+ )
+ }
+ .run { uiDevice.waitForIdle() }
+
+ /**
+ * Match the behavior with how widget is added in reality with "tap to add" (even with screen
+ * readers).
+ */
+ fun addWidgetToWorkspace(view: View) =
+ launcherActivity.executeOnLauncher {
+ view.performClick()
+ UiDevice.getInstance(getInstrumentation()).waitForIdle()
+ view.findViewById(R.id.widget_add_button).performClick()
+ }
+
+ fun isInState(state: LauncherState): Boolean =
+ launcherActivity.getFromLauncher { it.stateManager.state == state }!!
+}