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

Commit 250f92bb authored by Xin Li's avatar Xin Li Committed by Gerrit Code Review
Browse files

Merge "Merge Android 12 QPR 3"

parents 70689199 5e36e260
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.hardware.SensorManager;
import android.hardware.devicestate.DeviceStateManager;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.IBinder;
import android.view.View;
import android.view.WindowInsets;
import android.window.SplashScreen;
@@ -513,11 +514,26 @@ public abstract class BaseQuickstepLauncher extends Launcher
    }

    /**
     * Adds a new launch cookie for the activity launch of the given {@param info} if supported.
     * Adds a new launch cookie for the activity launch if supported.
     *
     * @param info the item info for the launch
     * @param opts the options to set the launchCookie on.
     */
    public void addLaunchCookie(ItemInfo info, ActivityOptions opts) {
        IBinder launchCookie = getLaunchCookie(info);
        if (launchCookie != null) {
            opts.setLaunchCookie(launchCookie);
        }
    }

    /**
     * Return a new launch cookie for the activity launch if supported.
     *
     * @param info the item info for the launch
     */
    public IBinder getLaunchCookie(ItemInfo info) {
        if (info == null) {
            return;
            return null;
        }
        switch (info.container) {
            case LauncherSettings.Favorites.CONTAINER_DESKTOP:
@@ -531,8 +547,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
                    break;
                }
                // Reset any existing launch cookies associated with the cookie
                opts.setLaunchCookie(ObjectWrapper.wrap(NO_MATCHING_ID));
                return;
                return ObjectWrapper.wrap(NO_MATCHING_ID);
        }
        switch (info.itemType) {
            case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
@@ -543,10 +558,9 @@ public abstract class BaseQuickstepLauncher extends Launcher
                break;
            default:
                // Reset any existing launch cookies associated with the cookie
                opts.setLaunchCookie(ObjectWrapper.wrap(NO_MATCHING_ID));
                return;
                return ObjectWrapper.wrap(NO_MATCHING_ID);
        }
        opts.setLaunchCookie(ObjectWrapper.wrap(new Integer(info.id)));
        return ObjectWrapper.wrap(new Integer(info.id));
    }

    public void setHintUserWillBeActive() {
+26 −2
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_TRANSITIONS;
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.statehandlers.DepthController.DEPTH;
import static com.android.launcher3.util.DisplayController.getSingleFrameMs;
import static com.android.launcher3.testing.TestProtocol.BAD_STATE;
import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION;
import static com.android.launcher3.views.FloatingIconView.getFloatingIconView;
import static com.android.quickstep.TaskViewUtils.findTaskViewToLaunch;
@@ -75,6 +76,8 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;
import android.util.Pair;
import android.util.Size;
import android.view.SurfaceControl;
@@ -133,6 +136,7 @@ import com.android.systemui.shared.system.WindowManagerWrapper;
import com.android.wm.shell.startingsurface.IStartingWindowListener;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;

@@ -609,9 +613,28 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
        RecentsView overview = mLauncher.getOverviewPanel();
        ObjectAnimator alpha = ObjectAnimator.ofFloat(overview,
                RecentsView.CONTENT_ALPHA, alphas);
        Log.d(BAD_STATE, "QTM composeViewContentAnimator alphas=" + Arrays.toString(alphas));
        alpha.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                Log.d(BAD_STATE, "QTM composeViewContentAnimator onStart");
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                float alpha = overview == null ? -1 : RecentsView.CONTENT_ALPHA.get(overview);
                Log.d(BAD_STATE, "QTM composeViewContentAnimator onCancel, alpha=" + alpha);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                Log.d(BAD_STATE, "QTM composeViewContentAnimator onEnd");
            }
        });
        alpha.setDuration(CONTENT_ALPHA_DURATION);
        alpha.setInterpolator(LINEAR);
        anim.play(alpha);
        Log.d(BAD_STATE, "QTM composeViewContentAnimator setFreezeVisibility=true");
        overview.setFreezeViewVisibility(true);

        ObjectAnimator scaleAnim = ObjectAnimator.ofFloat(overview, SCALE_PROPERTY, scales);
@@ -620,6 +643,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
        anim.play(scaleAnim);

        return () -> {
            Log.d(BAD_STATE, "QTM composeViewContentAnimator onEnd setFreezeVisibility=false");
            overview.setFreezeViewVisibility(false);
            SCALE_PROPERTY.set(overview, 1f);
            mLauncher.getStateManager().reapplyState();
@@ -1274,8 +1298,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
            }
        }

        return mLauncher.getFirstMatchForAppClose(launchCookieItemId,
                packageName, UserHandle.of(runningTaskTarget.taskInfo.userId));
        return mLauncher.getFirstMatchForAppClose(launchCookieItemId, packageName,
                UserHandle.of(runningTaskTarget.taskInfo.userId), true /* supportsAllAppsState */);
    }

    private @NonNull RectF getDefaultWindowTargetRect() {
+19 −6
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.launcher3.taskbar;

import static android.view.InsetsState.ITYPE_BOTTOM_MANDATORY_GESTURES;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
@@ -90,11 +91,12 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ

    private static final String WINDOW_TITLE = "Taskbar";

    private final DeviceProfile mDeviceProfile;
    private final LayoutInflater mLayoutInflater;
    private final TaskbarDragLayer mDragLayer;
    private final TaskbarControllers mControllers;

    private DeviceProfile mDeviceProfile;

    private final WindowManager mWindowManager;
    private final @Nullable RoundedCorner mLeftCorner, mRightCorner;
    private final int mTaskbarHeightForIme;
@@ -125,10 +127,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
                Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0);

        final Resources resources = getResources();
        float taskbarIconSize = resources.getDimension(R.dimen.taskbar_icon_size);
        mDeviceProfile.updateIconSize(1, resources);
        float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
        mDeviceProfile.updateIconSize(iconScale, resources);
        updateIconSize(resources);

        mTaskbarHeightForIme = resources.getDimensionPixelSize(R.dimen.taskbar_ime_size);

@@ -197,7 +196,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        WindowManagerWrapper wmWrapper = WindowManagerWrapper.getInstance();
        wmWrapper.setProvidesInsetsTypes(
                mWindowLayoutParams,
                new int[] { ITYPE_EXTRA_NAVIGATION_BAR, ITYPE_BOTTOM_TAPPABLE_ELEMENT }
                new int[] { ITYPE_EXTRA_NAVIGATION_BAR, ITYPE_BOTTOM_TAPPABLE_ELEMENT,
                        ITYPE_BOTTOM_MANDATORY_GESTURES }
        );
        // Adjust the frame by the rounded corners (ie. leaving just the bar as the inset) when
        // the IME is showing
@@ -211,6 +211,19 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        mWindowManager.addView(mDragLayer, mWindowLayoutParams);
    }

    /** Updates the Device profile instance to the latest representation of the screen. */
    public void updateDeviceProfile(DeviceProfile dp) {
        mDeviceProfile = dp;
        updateIconSize(getResources());
    }

    private void updateIconSize(Resources resources) {
        float taskbarIconSize = resources.getDimension(R.dimen.taskbar_icon_size);
        mDeviceProfile.updateIconSize(1, resources);
        float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
        mDeviceProfile.updateIconSize(iconScale, resources);
    }

    public void onConfigurationChanged(@Config int configChanges) {
        mControllers.onConfigurationChanged(configChanges);
    }
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ public class TaskbarDragController extends DragController<TaskbarActivityContext
            PopupContainerWithArrow<TaskbarActivityContext> popupContainer =
                    mControllers.taskbarPopupController.showForIcon(btv);
            if (popupContainer != null) {
                dragOptions.preDragCondition = popupContainer.createPreDragCondition();
                dragOptions.preDragCondition = popupContainer.createPreDragCondition(false);
            }
        }

+74 −50
Original line number Diff line number Diff line
@@ -207,14 +207,36 @@ import java.util.function.Supplier;

    private Animator onStateChangeApplied(int changedFlags, long duration, boolean start) {
        AnimatorSet animatorSet = new AnimatorSet();
        if (hasAnyFlag(changedFlags, FLAG_RESUMED)) {

        // Add the state animation first to ensure FLAG_IN_STASHED_LAUNCHER_STATE is set and we can
        // determine whether goingToUnstashedLauncherStateChanged.
        boolean wasGoingToUnstashedLauncherState = goingToUnstashedLauncherState();
        if (hasAnyFlag(changedFlags, FLAG_TRANSITION_STATE_RUNNING)) {
            boolean committed = !hasAnyFlag(FLAG_TRANSITION_STATE_RUNNING);
            playStateTransitionAnim(animatorSet, duration, committed);

            if (committed && mLauncherState == LauncherState.QUICK_SWITCH) {
                // We're about to be paused, set immediately to ensure seamless handoff.
                updateStateForFlag(FLAG_RESUMED, false);
                applyState(0 /* duration */);
            }
        }
        boolean goingToUnstashedLauncherStateChanged = wasGoingToUnstashedLauncherState
                != goingToUnstashedLauncherState();

        boolean launcherStateChangedDuringAnimToResumeAlignment =
                mIconAlignmentForResumedState.isAnimating() && goingToUnstashedLauncherStateChanged;
        if (hasAnyFlag(changedFlags, FLAG_RESUMED)
                || launcherStateChangedDuringAnimToResumeAlignment) {
            boolean isResumed = isResumed();
            ObjectAnimator anim = mIconAlignmentForResumedState
                    .animateToValue(isResumed && goingToUnstashedLauncherState()
                            ? 1 : 0)
            float toAlignmentForResumedState = isResumed && goingToUnstashedLauncherState() ? 1 : 0;
            // If we're already animating to the value, just leave it be instead of restarting it.
            if (!mIconAlignmentForResumedState.isAnimatingToValue(toAlignmentForResumedState)) {
                ObjectAnimator resumeAlignAnim = mIconAlignmentForResumedState
                        .animateToValue(toAlignmentForResumedState)
                        .setDuration(duration);

            anim.addListener(new AnimatorListenerAdapter() {
                resumeAlignAnim.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        mIsAnimatingToLauncherViaResume = false;
@@ -224,23 +246,32 @@ import java.util.function.Supplier;
                    public void onAnimationStart(Animator animation) {
                        mIsAnimatingToLauncherViaResume = isResumed;

                    TaskbarStashController stashController = mControllers.taskbarStashController;
                        TaskbarStashController stashController =
                                mControllers.taskbarStashController;
                        stashController.updateStateForFlag(FLAG_IN_APP, !isResumed);
                        stashController.applyState(duration);
                    }
                });
            animatorSet.play(anim);
                animatorSet.play(resumeAlignAnim);
            }
        }

        if (hasAnyFlag(changedFlags, FLAG_RECENTS_ANIMATION_RUNNING)) {

        boolean launcherStateChangedDuringAnimToGestureAlignment =
                mIconAlignmentForGestureState.isAnimating() && goingToUnstashedLauncherStateChanged;
        if (hasAnyFlag(changedFlags, FLAG_RECENTS_ANIMATION_RUNNING)
                || launcherStateChangedDuringAnimToGestureAlignment) {
            boolean isRecentsAnimationRunning = isRecentsAnimationRunning();
            Animator animator = mIconAlignmentForGestureState
                    .animateToValue(isRecentsAnimationRunning && goingToUnstashedLauncherState()
                            ? 1 : 0);
            float toAlignmentForGestureState = isRecentsAnimationRunning
                    && goingToUnstashedLauncherState() ? 1 : 0;
            // If we're already animating to the value, just leave it be instead of restarting it.
            if (!mIconAlignmentForGestureState.isAnimatingToValue(toAlignmentForGestureState)) {
                Animator gestureAlignAnim = mIconAlignmentForGestureState
                        .animateToValue(toAlignmentForGestureState);
                if (isRecentsAnimationRunning) {
                animator.setDuration(duration);
                    gestureAlignAnim.setDuration(duration);
                }
            animator.addListener(new AnimatorListenerAdapter() {
                gestureAlignAnim.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        mIsAnimatingToLauncherViaGesture = false;
@@ -251,7 +282,8 @@ import java.util.function.Supplier;
                        mIsAnimatingToLauncherViaGesture = isRecentsAnimationRunning();
                    }
                });
            animatorSet.play(animator);
                animatorSet.play(gestureAlignAnim);
            }
        }

        if (hasAnyFlag(changedFlags, FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING)) {
@@ -260,17 +292,6 @@ import java.util.function.Supplier;
                    .setDuration(duration));
        }

        if (hasAnyFlag(changedFlags, FLAG_TRANSITION_STATE_RUNNING)) {
            boolean committed = !hasAnyFlag(FLAG_TRANSITION_STATE_RUNNING);
            playStateTransitionAnim(animatorSet, duration, committed);

            if (committed && mLauncherState == LauncherState.QUICK_SWITCH) {
                // We're about to be paused, set immediately to ensure seamless handoff.
                updateStateForFlag(FLAG_RESUMED, false);
                applyState(0 /* duration */);
            }
        }

        if (start) {
            animatorSet.start();
        }
@@ -310,9 +331,12 @@ import java.util.function.Supplier;
            animatorSet.play(stashAnimator);
        }

        // If we're already animating to the value, just leave it be instead of restarting it.
        if (!mIconAlignmentForLauncherState.isAnimatingToValue(toAlignment)) {
            animatorSet.play(mIconAlignmentForLauncherState.animateToValue(toAlignment)
                    .setDuration(duration));
        }
    }

    private boolean isResumed() {
        return (mState & FLAG_RESUMED) != 0;
Loading