Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bfe4d6b4 authored by Brian Isganitis's avatar Brian Isganitis Committed by Android (Google) Code Review
Browse files

Merge changes Ie1b6609b,If115625c,I418675ba,I930e7458 into main

* changes:
  Add tests for TaskbarAllAppsViewController.
  Add tests for TaskbarAutohideSuspendController.
  Add tests for TaskbarScrimViewController.
  Add tests for TaskbarStashController.
parents bf09e036 d7dc6ba3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.view.View;
import android.view.accessibility.AccessibilityManager;

import androidx.annotation.ColorInt;
import androidx.annotation.VisibleForTesting;

import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -253,4 +254,9 @@ public class AppsDividerView extends View implements FloatingHeaderRow {
    public View getFocusedChild() {
        return null;
    }

    @VisibleForTesting
    public DividerType getDividerType() {
        return mDividerType;
    }
}
+16 −4
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import android.animation.ObjectAnimator;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;

import androidx.annotation.VisibleForTesting;

import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.taskbar.bubbles.BubbleControllers;
import com.android.launcher3.util.DisplayController;
@@ -77,7 +79,7 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa
    public void onTaskbarVisibilityChanged(int visibility) {
        mTaskbarVisible = visibility == VISIBLE;
        if (shouldShowScrim()) {
            showScrim(true, getScrimAlpha(), false /* skipAnim */);
            showScrim(true, computeScrimAlpha(), false /* skipAnim */);
        } else if (mScrimView.getScrimAlpha() > 0f) {
            showScrim(false, 0, false /* skipAnim */);
        }
@@ -96,7 +98,7 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa
            return;
        }
        mSysUiStateFlags = stateFlags;
        showScrim(shouldShowScrim(), getScrimAlpha(), skipAnim);
        showScrim(shouldShowScrim(), computeScrimAlpha(), skipAnim);
    }

    private boolean shouldShowScrim() {
@@ -119,7 +121,7 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa
                && !mControllers.taskbarStashController.isHiddenForBubbles();
    }

    private float getScrimAlpha() {
    private float computeScrimAlpha() {
        final boolean isPersistentTaskBarVisible =
                mTaskbarVisible && !DisplayController.isTransientTaskbar(mScrimView.getContext());
        final boolean manageMenuExpanded =
@@ -140,7 +142,7 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa
        mScrimView.setOnClickListener(showScrim ? (view) -> onClick() : null);
        mScrimView.setClickable(showScrim);
        if (skipAnim) {
            mScrimView.setScrimAlpha(alpha);
            mScrimAlpha.updateValue(alpha);
        } else {
            ObjectAnimator anim = mScrimAlpha.animateToValue(showScrim ? alpha : 0);
            anim.setInterpolator(showScrim ? SCRIM_ALPHA_IN : SCRIM_ALPHA_OUT);
@@ -167,4 +169,14 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa

        pw.println(prefix + "\tmScrimAlpha.value=" + mScrimAlpha.value);
    }

    @VisibleForTesting
    TaskbarScrimView getScrimView() {
        return mScrimView;
    }

    @VisibleForTesting
    float getScrimAlpha() {
        return mScrimAlpha.value;
    }
}
+38 −12
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
    private static final String TAG = "TaskbarStashController";
    private static final boolean DEBUG = false;

    private static boolean sEnableSoftwareImeForTests = false;

    /**
     * Def. value for @param shouldBubblesFollow in
     * {@link #updateAndAnimateTransientTaskbar(boolean)} */
@@ -130,19 +132,22 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
     *
     * Use {@link #getStashDuration()} to query duration
     */
    private static final long TASKBAR_STASH_DURATION = InsetsController.ANIMATION_DURATION_RESIZE;
    @VisibleForTesting
    static final long TASKBAR_STASH_DURATION = InsetsController.ANIMATION_DURATION_RESIZE;

    /**
     * How long to stash/unstash transient taskbar.
     *
     * Use {@link #getStashDuration()} to query duration.
     */
    private static final long TRANSIENT_TASKBAR_STASH_DURATION = 417;
    @VisibleForTesting
    static final long TRANSIENT_TASKBAR_STASH_DURATION = 417;

    /**
     * How long to stash/unstash when keyboard is appearing/disappearing.
     */
    private static final long TASKBAR_STASH_DURATION_FOR_IME = 80;
    @VisibleForTesting
    static final long TASKBAR_STASH_DURATION_FOR_IME = 80;

    /**
     * The scale TaskbarView animates to when being stashed.
@@ -163,7 +168,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
    /**
     * How long the icon/stash handle alpha animation plays.
     */
    public static final long TASKBAR_STASH_ALPHA_DURATION = 50;
    public static final long TRANSIENT_TASKBAR_STASH_ALPHA_DURATION = 50;

    /**
     * How long to delay the icon/stash handle alpha for the home to app taskbar animation.
@@ -252,7 +257,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
    private boolean mEnableBlockingTimeoutDuringTests = false;

    private Animator mTaskbarBackgroundAlphaAnimator;
    private long mTaskbarBackgroundDuration;
    private final long mTaskbarBackgroundDuration;
    private boolean mUserIsNotGoingHome = false;

    // Evaluate whether the handle should be stashed
@@ -799,14 +804,14 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
            if (animationType == TRANSITION_HANDLE_FADE) {
                // When fading, the handle fades in/out at the beginning of the transition with
                // TASKBAR_STASH_ALPHA_DURATION.
                backgroundAndHandleAlphaDuration = TASKBAR_STASH_ALPHA_DURATION;
                backgroundAndHandleAlphaDuration = TRANSIENT_TASKBAR_STASH_ALPHA_DURATION;
                // The iconAlphaDuration must be set to duration for the skippable interpolators
                // below to work.
                iconAlphaDuration = duration;
            } else {
                iconAlphaStartDelay = TASKBAR_STASH_ALPHA_START_DELAY;
                iconAlphaDuration = TASKBAR_STASH_ALPHA_DURATION;
                backgroundAndHandleAlphaDuration = TASKBAR_STASH_ALPHA_DURATION;
                iconAlphaDuration = TRANSIENT_TASKBAR_STASH_ALPHA_DURATION;
                backgroundAndHandleAlphaDuration = TRANSIENT_TASKBAR_STASH_ALPHA_DURATION;

                if (isStashed) {
                    if (animationType == TRANSITION_HOME_TO_APP) {
@@ -1070,7 +1075,8 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
    /**
     * When hiding the IME, delay the unstash animation to align with the end of the transition.
     */
    private long getTaskbarStashStartDelayForIme() {
    @VisibleForTesting
    long getTaskbarStashStartDelayForIme() {
        if (mIsImeShowing) {
            // Only delay when IME is exiting, not entering.
            return 0;
@@ -1126,13 +1132,13 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
        }

        // Do not stash if pinned taskbar, hardware keyboard is attached and no IME is docked
        if (mActivity.isHardwareKeyboard() && DisplayController.isPinnedTaskbar(mActivity)
        if (isHardwareKeyboard() && DisplayController.isPinnedTaskbar(mActivity)
                && !mActivity.isImeDocked()) {
            return false;
        }

        // Do not stash if hardware keyboard is attached, in 3 button nav and desktop windowing mode
        if (mActivity.isHardwareKeyboard()
        if (isHardwareKeyboard()
                && mActivity.isThreeButtonNav()
                && mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) {
            return false;
@@ -1146,6 +1152,21 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
        return mIsImeShowing || mIsImeSwitcherShowing;
    }

    private boolean isHardwareKeyboard() {
        return mActivity.isHardwareKeyboard() && !sEnableSoftwareImeForTests;
    }

    /**
     * Overrides {@link #isHardwareKeyboard()} to {@code false} for testing, if enabled.
     * <p>
     * Virtual devices are sometimes in hardware keyboard mode, leading to an inconsistent
     * testing environment.
     */
    @VisibleForTesting
    static void enableSoftwareImeForTests(boolean enable) {
        sEnableSoftwareImeForTests = enable;
    }

    /**
     * Updates the proper flag to indicate whether the task bar should be stashed.
     *
@@ -1271,7 +1292,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
    /**
     * Attempts to start timer to auto hide the taskbar based on time.
     */
    public void tryStartTaskbarTimeout() {
    private void tryStartTaskbarTimeout() {
        if (!DisplayController.isTransientTaskbar(mActivity)
                || mIsStashed
                || mEnableBlockingTimeoutDuringTests) {
@@ -1299,6 +1320,11 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
        updateAndAnimateTransientTaskbarForTimeout();
    }

    @VisibleForTesting
    Alarm getTimeoutAlarm() {
        return mTimeoutAlarm;
    }

    @Override
    public void dumpLogs(String prefix, PrintWriter pw) {
        pw.println(prefix + "TaskbarStashController:");
+4 −3
Original line number Diff line number Diff line
@@ -32,8 +32,8 @@ import com.android.launcher3.R
import com.android.launcher3.anim.AnimatedFloat
import com.android.launcher3.anim.SpringAnimationBuilder
import com.android.launcher3.taskbar.TaskbarInsetsController
import com.android.launcher3.taskbar.TaskbarStashController.TASKBAR_STASH_ALPHA_DURATION
import com.android.launcher3.taskbar.TaskbarStashController.TASKBAR_STASH_ALPHA_START_DELAY
import com.android.launcher3.taskbar.TaskbarStashController.TRANSIENT_TASKBAR_STASH_ALPHA_DURATION
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController
import com.android.launcher3.taskbar.bubbles.BubbleStashedHandleViewController
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.Companion.BAR_STASH_DURATION
@@ -305,7 +305,8 @@ class TransientBubbleStashController(

        animatorSet.play(
            createBackgroundAlphaAnimator(isStashed).apply {
                val alphaDuration = if (isStashed) duration else TASKBAR_STASH_ALPHA_DURATION
                val alphaDuration =
                    if (isStashed) duration else TRANSIENT_TASKBAR_STASH_ALPHA_DURATION
                val alphaDelay = if (isStashed) TASKBAR_STASH_ALPHA_START_DELAY else 0L
                this.duration = max(0L, alphaDuration - alphaDelay)
                this.startDelay = alphaDelay
@@ -317,7 +318,7 @@ class TransientBubbleStashController(
            bubbleBarBubbleAlpha
                .animateToValue(getBarAlphaStart(isStashed), getBarAlphaEnd(isStashed))
                .apply {
                    this.duration = TASKBAR_STASH_ALPHA_DURATION
                    this.duration = TRANSIENT_TASKBAR_STASH_ALPHA_DURATION
                    this.startDelay = TASKBAR_STASH_ALPHA_START_DELAY
                    this.interpolator = LINEAR
                }
+3 −1
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import android.window.flags.DesktopModeFlags;

import androidx.annotation.MainThread;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;

import com.android.internal.logging.InstanceId;
@@ -187,7 +188,8 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable {
    @Nullable
    private final ProxyUnfoldTransitionProvider mUnfoldTransitionProvider;

    private SystemUiProxy(Context context) {
    @VisibleForTesting
    protected SystemUiProxy(Context context) {
        mContext = context;
        mAsyncHandler = new Handler(UI_HELPER_EXECUTOR.getLooper(), this::handleMessageAsync);
        final Intent baseIntent = new Intent().setPackage(mContext.getPackageName());
Loading