From 62d70cb705a77e426b75d8ee49e74459c02d2838 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Fri, 6 May 2022 20:17:57 +0100 Subject: [PATCH 1/4] Add DisplayController in PreviewContext's allowed objects Fix: 231526132 Test: switch grids Change-Id: Ie43c54c5fbbea51ee3b795be6baa9c2eaf5e15e4 (cherry picked from commit 114572268581eead50b6f536959c50ef9da9d276) Merged-In: Ie43c54c5fbbea51ee3b795be6baa9c2eaf5e15e4 --- .../android/launcher3/graphics/LauncherPreviewRenderer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java index a11bd4fdad..d5bcb0cbcb 100644 --- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java @@ -83,6 +83,7 @@ import com.android.launcher3.pm.UserCache; import com.android.launcher3.uioverrides.PredictedAppIconInflater; import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; import com.android.launcher3.util.ComponentKey; +import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.MainThreadInitializedObject.SandboxContext; @@ -129,7 +130,7 @@ public class LauncherPreviewRenderer extends ContextWrapper super(base, UserCache.INSTANCE, InstallSessionHelper.INSTANCE, LauncherAppState.INSTANCE, InvariantDeviceProfile.INSTANCE, CustomWidgetManager.INSTANCE, PluginManagerWrapper.INSTANCE, - WindowManagerProxy.INSTANCE); + WindowManagerProxy.INSTANCE, DisplayController.INSTANCE); mIdp = idp; mObjectMap.put(InvariantDeviceProfile.INSTANCE, idp); mObjectMap.put(LauncherAppState.INSTANCE, From 5aff4cf01580cf9cc27a7b493cded9559ca5331d Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 23 Jun 2022 12:00:57 -0700 Subject: [PATCH 2/4] Moving widget padding to drawable instead of using itemDecorator ItemDecorator uses item position which is not stable during animations. Moving it to the background allows the padding to be stable Bug: 236961658 Test: Verified that the app doesn't crash. Change-Id: Ied12077de4097e827c5c4157f5196346a301f185 (cherry picked from commit ed681548fcc3519ed4c28d758a2a2cbbc22fd2db) Merged-In: Ied12077de4097e827c5c4157f5196346a301f185 --- res/layout/widgets_list_row_header.xml | 1 - .../picker/WidgetsListDrawableFactory.java | 11 ++++- .../widget/picker/WidgetsRecyclerView.java | 41 +------------------ 3 files changed, 12 insertions(+), 41 deletions(-) diff --git a/res/layout/widgets_list_row_header.xml b/res/layout/widgets_list_row_header.xml index 3cdc2e844b..35bea279c0 100644 --- a/res/layout/widgets_list_row_header.xml +++ b/res/layout/widgets_list_row_header.xml @@ -19,7 +19,6 @@ android:id="@+id/widgets_list_header" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingVertical="@dimen/widget_list_header_view_vertical_padding" android:orientation="horizontal" android:importantForAccessibility="yes" android:focusable="true" diff --git a/src/com/android/launcher3/widget/picker/WidgetsListDrawableFactory.java b/src/com/android/launcher3/widget/picker/WidgetsListDrawableFactory.java index c61e3a4349..984a2741e7 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsListDrawableFactory.java +++ b/src/com/android/launcher3/widget/picker/WidgetsListDrawableFactory.java @@ -27,6 +27,7 @@ import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; +import android.graphics.drawable.InsetDrawable; import android.graphics.drawable.RippleDrawable; import android.graphics.drawable.StateListDrawable; @@ -40,6 +41,8 @@ final class WidgetsListDrawableFactory { private final float mMiddleCornerRadius; private final ColorStateList mSurfaceColor; private final ColorStateList mRippleColor; + private final int mVerticalPadding; + private final int mHeaderMargin; WidgetsListDrawableFactory(Context context) { Resources res = context.getResources(); @@ -48,6 +51,9 @@ final class WidgetsListDrawableFactory { mSurfaceColor = context.getColorStateList(R.color.surface); mRippleColor = ColorStateList.valueOf( Themes.getAttrColor(context, android.R.attr.colorControlHighlight)); + mVerticalPadding = + res.getDimensionPixelSize(R.dimen.widget_list_header_view_vertical_padding); + mHeaderMargin = res.getDimensionPixelSize(R.dimen.widget_list_entry_spacing); } /** @@ -74,7 +80,10 @@ final class WidgetsListDrawableFactory { stateList.addState( LAST.mStateSet, createRoundedRectDrawable(mMiddleCornerRadius, mTopBottomCornerRadius)); - return new RippleDrawable(mRippleColor, /* content= */ stateList, /* mask= */ stateList); + RippleDrawable ripple = + new RippleDrawable(mRippleColor, /* content= */ stateList, /* mask= */ stateList); + ripple.setPadding(0, mVerticalPadding, 0, mVerticalPadding); + return new InsetDrawable(ripple, 0, mHeaderMargin, 0, 0); } /** diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java index daa67a973c..4c0e0d595f 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java +++ b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java @@ -16,18 +16,12 @@ package com.android.launcher3.widget.picker; -import static com.android.launcher3.widget.picker.WidgetsListAdapter.VIEW_TYPE_WIDGETS_HEADER; -import static com.android.launcher3.widget.picker.WidgetsListAdapter.VIEW_TYPE_WIDGETS_SEARCH_HEADER; - import android.content.Context; import android.graphics.Point; -import android.graphics.Rect; import android.util.AttributeSet; import android.util.SparseIntArray; import android.view.MotionEvent; -import android.view.View; -import androidx.annotation.NonNull; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView.OnItemTouchListener; @@ -55,7 +49,6 @@ public class WidgetsRecyclerView extends FastScrollRecyclerView implements OnIte * VIEW_TYPE_WIDGETS_LIST is not visible on the screen. */ private final SparseIntArray mCachedSizes = new SparseIntArray(); - private final SpacingDecoration mSpacingDecoration; public WidgetsRecyclerView(Context context) { this(context, null); @@ -70,9 +63,6 @@ public class WidgetsRecyclerView extends FastScrollRecyclerView implements OnIte super(context, attrs, defStyleAttr); mScrollbarTop = getResources().getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin); addOnItemTouchListener(this); - - mSpacingDecoration = new SpacingDecoration(context); - addItemDecoration(mSpacingDecoration); } @Override @@ -183,7 +173,7 @@ public class WidgetsRecyclerView extends FastScrollRecyclerView implements OnIte @Override protected int getItemsHeight(int untilIndex) { // Initialize cache - int childCount = getChildCount(); + int childCount = Math.min(getChildCount(), getAdapter().getItemCount()); int startPosition; if (childCount > 0 && ((startPosition = getChildAdapterPosition(getChildAt(0))) != NO_POSITION)) { @@ -200,7 +190,7 @@ public class WidgetsRecyclerView extends FastScrollRecyclerView implements OnIte int totalItemsHeight = 0; for (int i = 0; i < untilIndex; i++) { int type = mAdapter.getItemViewType(i); - totalItemsHeight += mCachedSizes.get(type) + mSpacingDecoration.getSpacing(i, type); + totalItemsHeight += mCachedSizes.get(type); } return totalItemsHeight; } @@ -216,31 +206,4 @@ public class WidgetsRecyclerView extends FastScrollRecyclerView implements OnIte */ int getHeaderViewHeight(); } - - private static class SpacingDecoration extends RecyclerView.ItemDecoration { - - private final int mSpacingBetweenEntries; - - SpacingDecoration(@NonNull Context context) { - mSpacingBetweenEntries = - context.getResources().getDimensionPixelSize(R.dimen.widget_list_entry_spacing); - } - - @Override - public void getItemOffsets( - @NonNull Rect outRect, - @NonNull View view, - @NonNull RecyclerView parent, - @NonNull RecyclerView.State state) { - super.getItemOffsets(outRect, view, parent, state); - int position = parent.getChildAdapterPosition(view); - outRect.top += getSpacing(position, parent.getAdapter().getItemViewType(position)); - } - - public int getSpacing(int position, int type) { - boolean isHeader = type == VIEW_TYPE_WIDGETS_SEARCH_HEADER - || type == VIEW_TYPE_WIDGETS_HEADER; - return position > 0 && isHeader ? mSpacingBetweenEntries : 0; - } - } } From d5afb43342974168ebd7cb73b70c9dac7ea04421 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 15 Sep 2022 20:48:09 +0000 Subject: [PATCH 3/4] Revert "Using Transaction directly instead of building surface p..." Revert "Removing unused surface transaction wrappers" Revert submission 19933596-tcompat Reason for revert: b/246899728 Reverted Changes: I31123dff7:Using Transaction directly instead of building sur... I2e2526d21:Removing unused surface transaction wrappers Change-Id: I63d1d8bb723b7bd05d345fb21a67f88e5fb36bc1 (cherry picked from commit 9925bbd147b8a4760708cb3f642ea0e9ee807e8e) Merged-In: I63d1d8bb723b7bd05d345fb21a67f88e5fb36bc1 --- .../launcher3/QuickstepTransitionManager.java | 124 ++++++++++-------- .../quickstep/FallbackSwipeHandler.java | 14 +- .../LauncherBackAnimationController.java | 14 +- .../quickstep/SwipeUpAnimationLogic.java | 12 +- .../com/android/quickstep/TaskViewUtils.java | 22 ++-- .../DeviceLockedInputConsumer.java | 6 +- .../SwipeUpGestureTutorialController.java | 31 ++--- .../util/RecordingSurfaceTransaction.java | 81 ------------ .../util/RemoteFadeOutAnimationListener.java | 4 +- .../quickstep/util/SurfaceTransaction.java | 110 ---------------- .../util/SurfaceTransactionApplier.java | 13 +- .../quickstep/util/TaskViewSimulator.java | 12 +- .../quickstep/util/TransformParams.java | 43 +++--- .../android/quickstep/views/RecentsView.java | 11 +- .../WidgetsPredicationUpdateTaskTest.java | 2 + .../quickstep/util/TaskViewSimulatorTest.java | 19 ++- 16 files changed, 173 insertions(+), 345 deletions(-) delete mode 100644 quickstep/src/com/android/quickstep/util/RecordingSurfaceTransaction.java delete mode 100644 quickstep/src/com/android/quickstep/util/SurfaceTransaction.java diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 03caf907f6..9a1ed4d56d 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -122,8 +122,6 @@ import com.android.quickstep.util.MultiValueUpdateListener; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.RemoteAnimationProvider; import com.android.quickstep.util.StaggeredWorkspaceAnim; -import com.android.quickstep.util.SurfaceTransaction; -import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties; import com.android.quickstep.util.SurfaceTransactionApplier; import com.android.quickstep.util.WorkspaceRevealAnim; import com.android.quickstep.views.FloatingWidgetView; @@ -136,6 +134,7 @@ import com.android.systemui.shared.system.RemoteAnimationDefinitionCompat; import com.android.systemui.shared.system.RemoteAnimationRunnerCompat; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; import com.android.systemui.shared.system.RemoteTransitionCompat; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams; import com.android.wm.shell.startingsurface.IStartingWindowListener; import java.util.ArrayList; @@ -814,11 +813,10 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener return; } - SurfaceTransaction transaction = new SurfaceTransaction(); - + ArrayList params = new ArrayList<>(); for (int i = appTargets.length - 1; i >= 0; i--) { RemoteAnimationTargetCompat target = appTargets[i]; - SurfaceProperties builder = transaction.forSurface(target.leash); + SurfaceParams.Builder builder = new SurfaceParams.Builder(target.leash); if (target.mode == MODE_OPENING) { matrix.setScale(scale, scale); @@ -839,11 +837,11 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener floatingView.update(mIconAlpha.value, 255, floatingIconBounds, percent, 0f, mWindowRadius.value * scale, true /* isOpening */); - builder.setMatrix(matrix) - .setWindowCrop(crop) - .setAlpha(1f - mIconAlpha.value) - .setCornerRadius(mWindowRadius.value) - .setShadowRadius(mShadowRadius.value); + builder.withMatrix(matrix) + .withWindowCrop(crop) + .withAlpha(1f - mIconAlpha.value) + .withCornerRadius(mWindowRadius.value) + .withShadowRadius(mShadowRadius.value); } else if (target.mode == MODE_CLOSING) { if (target.localBounds != null) { final Rect localBounds = target.localBounds; @@ -863,26 +861,29 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener tmpPos.y = tmp; } matrix.setTranslate(tmpPos.x, tmpPos.y); - builder.setMatrix(matrix) - .setWindowCrop(crop) - .setAlpha(1f); + builder.withMatrix(matrix) + .withWindowCrop(crop) + .withAlpha(1f); } + params.add(builder.build()); } if (navBarTarget != null) { - SurfaceProperties navBuilder = - transaction.forSurface(navBarTarget.leash); + final SurfaceParams.Builder navBuilder = + new SurfaceParams.Builder(navBarTarget.leash); if (mNavFadeIn.value > mNavFadeIn.getStartValue()) { matrix.setScale(scale, scale); matrix.postTranslate(windowTransX0, windowTransY0); - navBuilder.setMatrix(matrix) - .setWindowCrop(crop) - .setAlpha(mNavFadeIn.value); + navBuilder.withMatrix(matrix) + .withWindowCrop(crop) + .withAlpha(mNavFadeIn.value); } else { - navBuilder.setAlpha(mNavFadeOut.value); + navBuilder.withAlpha(mNavFadeOut.value); } + params.add(navBuilder.build()); } - surfaceApplier.scheduleApply(transaction); + + surfaceApplier.scheduleApply(params.toArray(new SurfaceParams[params.size()])); } }; appAnimator.addUpdateListener(listener); @@ -998,33 +999,37 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener matrix.postScale(mAppWindowScale, mAppWindowScale, widgetBackgroundBounds.left, widgetBackgroundBounds.top); - SurfaceTransaction transaction = new SurfaceTransaction(); + ArrayList params = new ArrayList<>(); float floatingViewAlpha = appTargetsAreTranslucent ? 1 - mPreviewAlpha.value : 1; for (int i = appTargets.length - 1; i >= 0; i--) { RemoteAnimationTargetCompat target = appTargets[i]; - SurfaceProperties builder = transaction.forSurface(target.leash); + SurfaceParams.Builder builder = new SurfaceParams.Builder(target.leash); if (target.mode == MODE_OPENING) { floatingView.update(widgetBackgroundBounds, floatingViewAlpha, mWidgetForegroundAlpha.value, mWidgetFallbackBackgroundAlpha.value, mCornerRadiusProgress.value); - builder.setMatrix(matrix) - .setWindowCrop(appWindowCrop) - .setAlpha(mPreviewAlpha.value) - .setCornerRadius(mWindowRadius.value / mAppWindowScale); + builder.withMatrix(matrix) + .withWindowCrop(appWindowCrop) + .withAlpha(mPreviewAlpha.value) + .withCornerRadius(mWindowRadius.value / mAppWindowScale); } + params.add(builder.build()); } if (navBarTarget != null) { - SurfaceProperties navBuilder = transaction.forSurface(navBarTarget.leash); + final SurfaceParams.Builder navBuilder = + new SurfaceParams.Builder(navBarTarget.leash); if (mNavFadeIn.value > mNavFadeIn.getStartValue()) { - navBuilder.setMatrix(matrix) - .setWindowCrop(appWindowCrop) - .setAlpha(mNavFadeIn.value); + navBuilder.withMatrix(matrix) + .withWindowCrop(appWindowCrop) + .withAlpha(mNavFadeIn.value); } else { - navBuilder.setAlpha(mNavFadeOut.value); + navBuilder.withAlpha(mNavFadeOut.value); } + params.add(navBuilder.build()); } - surfaceApplier.scheduleApply(transaction); + + surfaceApplier.scheduleApply(params.toArray(new SurfaceParams[params.size()])); } }); @@ -1219,15 +1224,16 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener unlockAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { - SurfaceTransaction transaction = new SurfaceTransaction(); + SurfaceParams[] params = new SurfaceParams[appTargets.length]; for (int i = appTargets.length - 1; i >= 0; i--) { RemoteAnimationTargetCompat target = appTargets[i]; - transaction.forSurface(target.leash) - .setAlpha(1f) - .setWindowCrop(target.screenSpaceBounds) - .setCornerRadius(cornerRadius); + params[i] = new SurfaceParams.Builder(target.leash) + .withAlpha(1f) + .withWindowCrop(target.screenSpaceBounds) + .withCornerRadius(cornerRadius) + .build(); } - surfaceApplier.scheduleApply(transaction); + surfaceApplier.scheduleApply(params); } }); return unlockAnimator; @@ -1445,10 +1451,10 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener @Override public void onUpdate(float percent, boolean initOnly) { - SurfaceTransaction transaction = new SurfaceTransaction(); + SurfaceParams[] params = new SurfaceParams[appTargets.length]; for (int i = appTargets.length - 1; i >= 0; i--) { RemoteAnimationTargetCompat target = appTargets[i]; - SurfaceProperties builder = transaction.forSurface(target.leash); + SurfaceParams.Builder builder = new SurfaceParams.Builder(target.leash); if (target.localBounds != null) { tmpPos.set(target.localBounds.left, target.localBounds.top); @@ -1470,19 +1476,20 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener tmpRect.centerY()); matrix.postTranslate(0, mDy.value); matrix.postTranslate(tmpPos.x, tmpPos.y); - builder.setMatrix(matrix) - .setWindowCrop(crop) - .setAlpha(mAlpha.value) - .setCornerRadius(windowCornerRadius) - .setShadowRadius(mShadowRadius.value); + builder.withMatrix(matrix) + .withWindowCrop(crop) + .withAlpha(mAlpha.value) + .withCornerRadius(windowCornerRadius) + .withShadowRadius(mShadowRadius.value); } else if (target.mode == MODE_OPENING) { matrix.setTranslate(tmpPos.x, tmpPos.y); - builder.setMatrix(matrix) - .setWindowCrop(crop) - .setAlpha(1f); + builder.withMatrix(matrix) + .withWindowCrop(crop) + .withAlpha(1f); } + params[i] = builder.build(); } - surfaceApplier.scheduleApply(transaction); + surfaceApplier.scheduleApply(params); } }); @@ -1852,10 +1859,10 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener @Override public void onUpdate(RectF currentRectF, float progress) { - SurfaceTransaction transaction = new SurfaceTransaction(); + SurfaceParams[] params = new SurfaceParams[mAppTargets.length]; for (int i = mAppTargets.length - 1; i >= 0; i--) { RemoteAnimationTargetCompat target = mAppTargets[i]; - SurfaceProperties builder = transaction.forSurface(target.leash); + SurfaceParams.Builder builder = new SurfaceParams.Builder(target.leash); if (target.localBounds != null) { mTmpPos.set(target.localBounds.left, target.localBounds.top); @@ -1890,17 +1897,18 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener mMatrix.setScale(scale, scale); mMatrix.postTranslate(mCurrentRect.left, mCurrentRect.top); - builder.setMatrix(mMatrix) - .setWindowCrop(mTmpRect) - .setAlpha(getWindowAlpha(progress)) - .setCornerRadius(getCornerRadius(progress) / scale); + builder.withMatrix(mMatrix) + .withWindowCrop(mTmpRect) + .withAlpha(getWindowAlpha(progress)) + .withCornerRadius(getCornerRadius(progress) / scale); } else if (target.mode == MODE_OPENING) { mMatrix.setTranslate(mTmpPos.x, mTmpPos.y); - builder.setMatrix(mMatrix) - .setAlpha(1f); + builder.withMatrix(mMatrix) + .withAlpha(1f); } + params[i] = builder.build(); } - mSurfaceApplier.scheduleApply(transaction); + mSurfaceApplier.scheduleApply(params); } protected float getWindowAlpha(float progress) { diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java index e55e966c13..99f7bdd2e7 100644 --- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java @@ -65,12 +65,12 @@ import com.android.launcher3.util.DisplayController; import com.android.quickstep.fallback.FallbackRecentsView; import com.android.quickstep.fallback.RecentsState; import com.android.quickstep.util.RectFSpringAnim; -import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties; import com.android.quickstep.util.TransformParams; import com.android.quickstep.util.TransformParams.BuilderProxy; import com.android.systemui.shared.recents.model.Task.TaskKey; import com.android.systemui.shared.system.InputConsumerController; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -125,18 +125,18 @@ public class FallbackSwipeHandler extends } } - private void updateHomeActivityTransformDuringSwipeUp(SurfaceProperties builder, + private void updateHomeActivityTransformDuringSwipeUp(SurfaceParams.Builder builder, RemoteAnimationTargetCompat app, TransformParams params) { setHomeScaleAndAlpha(builder, app, mCurrentShift.value, Utilities.boundToRange(1 - mCurrentShift.value, 0, 1)); } - private void setHomeScaleAndAlpha(SurfaceProperties builder, + private void setHomeScaleAndAlpha(SurfaceParams.Builder builder, RemoteAnimationTargetCompat app, float verticalShift, float alpha) { float scale = Utilities.mapRange(verticalShift, 1, mMaxLauncherScale); mTmpMatrix.setScale(scale, scale, app.localBounds.exactCenterX(), app.localBounds.exactCenterY()); - builder.setMatrix(mTmpMatrix).setAlpha(alpha); + builder.withMatrix(mTmpMatrix).withAlpha(alpha); } @Override @@ -279,12 +279,12 @@ public class FallbackSwipeHandler extends return mTargetRect; } - private void updateRecentsActivityTransformDuringHomeAnim(SurfaceProperties builder, + private void updateRecentsActivityTransformDuringHomeAnim(SurfaceParams.Builder builder, RemoteAnimationTargetCompat app, TransformParams params) { - builder.setAlpha(mRecentsAlpha.value); + builder.withAlpha(mRecentsAlpha.value); } - private void updateHomeActivityTransformDuringHomeAnim(SurfaceProperties builder, + private void updateHomeActivityTransformDuringHomeAnim(SurfaceParams.Builder builder, RemoteAnimationTargetCompat app, TransformParams params) { setHomeScaleAndAlpha(builder, app, mVerticalShiftForScale.value, mHomeAlpha.value); } diff --git a/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java b/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java index ee3b0752b9..7a281dd2a7 100644 --- a/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java +++ b/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java @@ -46,6 +46,7 @@ import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.quickstep.util.RectFSpringAnim; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat; /** * Controls the animation of swiping back and returning to launcher. @@ -241,17 +242,20 @@ public class LauncherBackAnimationController { /** Transform the target window to match the target rect. */ private void applyTransform(RectF targetRect, float cornerRadius) { + SyncRtSurfaceTransactionApplierCompat.SurfaceParams.Builder builder = + new SyncRtSurfaceTransactionApplierCompat.SurfaceParams.Builder(mBackTarget.leash); final float scale = targetRect.width() / mStartRect.width(); mTransformMatrix.reset(); mTransformMatrix.setScale(scale, scale); mTransformMatrix.postTranslate(targetRect.left, targetRect.top); + builder.withMatrix(mTransformMatrix) + .withWindowCrop(mStartRect) + .withCornerRadius(cornerRadius); + SyncRtSurfaceTransactionApplierCompat.SurfaceParams surfaceParams = builder.build(); - if (mBackTarget.leash.isValid()) { - mTransaction.setMatrix(mBackTarget.leash, mTransformMatrix, new float[9]); - mTransaction.setWindowCrop(mBackTarget.leash, mStartRect); - mTransaction.setCornerRadius(mBackTarget.leash, cornerRadius); + if (surfaceParams.surface.isValid()) { + surfaceParams.applyTo(mTransaction); } - mTransaction.apply(); } diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java index 71e8a774f7..baeb514e18 100644 --- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java +++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java @@ -37,11 +37,11 @@ import com.android.launcher3.touch.PagedOrientationHandler; import com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle; import com.android.quickstep.util.AnimatorControllerWithResistance; import com.android.quickstep.util.RectFSpringAnim; -import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties; import com.android.quickstep.util.TaskViewSimulator; import com.android.quickstep.util.TransformParams; import com.android.quickstep.util.TransformParams.BuilderProxy; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams.Builder; import java.util.Arrays; import java.util.function.Consumer; @@ -335,11 +335,11 @@ public abstract class SwipeUpAnimationLogic implements } @Override - public void onBuildTargetParams(SurfaceProperties builder, RemoteAnimationTargetCompat app, - TransformParams params) { - builder.setMatrix(mMatrix) - .setWindowCrop(mCropRect) - .setCornerRadius(params.getCornerRadius()); + public void onBuildTargetParams( + Builder builder, RemoteAnimationTargetCompat app, TransformParams params) { + builder.withMatrix(mMatrix) + .withWindowCrop(mCropRect) + .withCornerRadius(params.getCornerRadius()); } @Override diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 41972c6b5b..a96524e186 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -72,8 +72,6 @@ import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.util.DisplayController; import com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle; import com.android.quickstep.util.MultiValueUpdateListener; -import com.android.quickstep.util.SurfaceTransaction; -import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties; import com.android.quickstep.util.SurfaceTransactionApplier; import com.android.quickstep.util.TaskViewSimulator; import com.android.quickstep.util.TransformParams; @@ -84,6 +82,7 @@ import com.android.quickstep.views.TaskView; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams; import java.util.ArrayList; import java.util.List; @@ -253,24 +252,21 @@ public final class TaskViewUtils { @Override public void onUpdate(float percent, boolean initOnly) { - + final SurfaceParams.Builder navBuilder = + new SurfaceParams.Builder(navBarTarget.leash); // TODO Do we need to operate over multiple TVSs for the navbar leash? for (RemoteTargetHandle handle : remoteTargetHandles) { - SurfaceTransaction transaction = new SurfaceTransaction(); - SurfaceProperties navBuilder = - transaction.forSurface(navBarTarget.leash); - if (mNavFadeIn.value > mNavFadeIn.getStartValue()) { TaskViewSimulator taskViewSimulator = handle.getTaskViewSimulator(); taskViewSimulator.getCurrentCropRect().round(cropRect); - navBuilder.setMatrix(taskViewSimulator.getCurrentMatrix()) - .setWindowCrop(cropRect) - .setAlpha(mNavFadeIn.value); + navBuilder.withMatrix(taskViewSimulator.getCurrentMatrix()) + .withWindowCrop(cropRect) + .withAlpha(mNavFadeIn.value); } else { - navBuilder.setAlpha(mNavFadeOut.value); + navBuilder.withAlpha(mNavFadeOut.value); } - handle.getTransformParams().applySurfaceParams(transaction); + handle.getTransformParams().applySurfaceParams(navBuilder.build()); } } }); @@ -478,7 +474,7 @@ public final class TaskViewUtils { * If {@param launchingTaskView} is not null, then this will play the tasks launch animation * from the position of the GroupedTaskView (when user taps on the TaskView to start it). * Technically this case should be taken care of by - * {@link #composeRecentsSplitLaunchAnimatorLegacy} below, but the way we launch tasks whether + * {@link #composeRecentsSplitLaunchAnimatorLegacy()} below, but the way we launch tasks whether * it's a single task or multiple tasks results in different entry-points. * * If it is null, then it will simply fade in the starting apps and fade out launcher (for the diff --git a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java index c131c055f6..6bc24f2b9b 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java @@ -53,13 +53,13 @@ import com.android.quickstep.RecentsAnimationController; import com.android.quickstep.RecentsAnimationDeviceState; import com.android.quickstep.RecentsAnimationTargets; import com.android.quickstep.TaskAnimationManager; -import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties; import com.android.quickstep.util.TransformParams; import com.android.quickstep.util.TransformParams.BuilderProxy; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.InputMonitorCompat; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams.Builder; import java.util.HashMap; @@ -290,9 +290,9 @@ public class DeviceLockedInputConsumer implements InputConsumer, @Override public void onBuildTargetParams( - SurfaceProperties builder, RemoteAnimationTargetCompat app, TransformParams params) { + Builder builder, RemoteAnimationTargetCompat app, TransformParams params) { mMatrix.setTranslate(0, mProgress.value * mMaxTranslationY); - builder.setMatrix(mMatrix); + builder.withMatrix(mMatrix); } @Override diff --git a/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java index 401df24d9f..fa7bc04b30 100644 --- a/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java +++ b/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java @@ -33,6 +33,7 @@ import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; import android.os.Build; +import android.view.SurfaceControl; import android.view.View; import android.view.ViewOutlineProvider; @@ -52,11 +53,9 @@ import com.android.quickstep.RecentsAnimationDeviceState; import com.android.quickstep.RemoteTargetGluer; import com.android.quickstep.SwipeUpAnimationLogic; import com.android.quickstep.SwipeUpAnimationLogic.RunningWindowAnim; -import com.android.quickstep.util.RecordingSurfaceTransaction; -import com.android.quickstep.util.RecordingSurfaceTransaction.MockProperties; import com.android.quickstep.util.RectFSpringAnim; -import com.android.quickstep.util.SurfaceTransaction; import com.android.quickstep.util.TransformParams; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams; @TargetApi(Build.VERSION_CODES.R) abstract class SwipeUpGestureTutorialController extends TutorialController { @@ -416,23 +415,21 @@ abstract class SwipeUpGestureTutorialController extends TutorialController { private class FakeTransformParams extends TransformParams { @Override - public SurfaceTransaction createSurfaceParams(BuilderProxy proxy) { - RecordingSurfaceTransaction transaction = new RecordingSurfaceTransaction(); - proxy.onBuildTargetParams(transaction.mockProperties, null, this); - return transaction; + public SurfaceParams[] createSurfaceParams(BuilderProxy proxy) { + SurfaceParams.Builder builder = new SurfaceParams.Builder((SurfaceControl) null); + proxy.onBuildTargetParams(builder, null, this); + return new SurfaceParams[] {builder.build()}; } @Override - public void applySurfaceParams(SurfaceTransaction params) { - if (params instanceof RecordingSurfaceTransaction) { - MockProperties p = ((RecordingSurfaceTransaction) params).mockProperties; - mFakeTaskView.setAnimationMatrix(p.matrix); - mFakePreviousTaskView.setAnimationMatrix(p.matrix); - mFakeTaskViewRect.set(p.windowCrop); - mFakeTaskViewRadius = p.cornerRadius; - mFakeTaskView.invalidateOutline(); - mFakePreviousTaskView.invalidateOutline(); - } + public void applySurfaceParams(SurfaceParams[] params) { + SurfaceParams p = params[0]; + mFakeTaskView.setAnimationMatrix(p.matrix); + mFakePreviousTaskView.setAnimationMatrix(p.matrix); + mFakeTaskViewRect.set(p.windowCrop); + mFakeTaskViewRadius = p.cornerRadius; + mFakeTaskView.invalidateOutline(); + mFakePreviousTaskView.invalidateOutline(); } } } diff --git a/quickstep/src/com/android/quickstep/util/RecordingSurfaceTransaction.java b/quickstep/src/com/android/quickstep/util/RecordingSurfaceTransaction.java deleted file mode 100644 index a56c851137..0000000000 --- a/quickstep/src/com/android/quickstep/util/RecordingSurfaceTransaction.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2022 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.quickstep.util; - -import android.graphics.Matrix; -import android.graphics.Rect; - -/** - * Extension for {@link SurfaceTransaction} which records the commands for mocking - */ -public class RecordingSurfaceTransaction extends SurfaceTransaction { - - /** - * A mock builder which can be used for recording values - */ - public final MockProperties mockProperties = new MockProperties(); - - /** - * Extension of {@link SurfaceProperties} which just stores all the values locally - */ - public class MockProperties extends SurfaceProperties { - - public float alpha = -1; - public Matrix matrix = null; - public Rect windowCrop = null; - public float cornerRadius = 0; - public float shadowRadius = 0; - - MockProperties() { - super(null); - } - - @Override - public SurfaceProperties setAlpha(float alpha) { - this.alpha = alpha; - return this; - } - - @Override - public SurfaceProperties setMatrix(Matrix matrix) { - this.matrix = matrix; - return this; - } - - @Override - public SurfaceProperties setWindowCrop(Rect windowCrop) { - this.windowCrop = windowCrop; - return this; - } - - @Override - public SurfaceProperties setLayer(int relativeLayer) { - return this; - } - - @Override - public SurfaceProperties setCornerRadius(float radius) { - this.cornerRadius = radius; - return this; - } - - @Override - public SurfaceProperties setShadowRadius(float radius) { - this.shadowRadius = radius; - return this; - } - } -} diff --git a/quickstep/src/com/android/quickstep/util/RemoteFadeOutAnimationListener.java b/quickstep/src/com/android/quickstep/util/RemoteFadeOutAnimationListener.java index b2e159ee10..81c124f7e2 100644 --- a/quickstep/src/com/android/quickstep/util/RemoteFadeOutAnimationListener.java +++ b/quickstep/src/com/android/quickstep/util/RemoteFadeOutAnimationListener.java @@ -19,10 +19,10 @@ import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MOD import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; -import android.view.SurfaceControl.Transaction; import com.android.quickstep.RemoteAnimationTargets; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; +import com.android.systemui.shared.system.TransactionCompat; /** * Animation listener which fades out the closing targets @@ -40,7 +40,7 @@ public class RemoteFadeOutAnimationListener implements AnimatorUpdateListener { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { - Transaction t = new Transaction(); + TransactionCompat t = new TransactionCompat(); if (mFirstFrame) { for (RemoteAnimationTargetCompat target : mTarget.unfilteredApps) { t.show(target.leash); diff --git a/quickstep/src/com/android/quickstep/util/SurfaceTransaction.java b/quickstep/src/com/android/quickstep/util/SurfaceTransaction.java deleted file mode 100644 index 6bdcf4db2e..0000000000 --- a/quickstep/src/com/android/quickstep/util/SurfaceTransaction.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2022 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.quickstep.util; - -import android.graphics.Matrix; -import android.graphics.Rect; -import android.view.SurfaceControl; -import android.view.SurfaceControl.Transaction; - -/** - * Helper class for building a {@link Transaction}. - */ -public class SurfaceTransaction { - - private final Transaction mTransaction = new Transaction(); - private final float[] mTmpValues = new float[9]; - - /** - * Creates a new builder for the provided surface - */ - public SurfaceProperties forSurface(SurfaceControl surface) { - return new SurfaceProperties(surface); - } - - /** - * Returns the final transaction - */ - public Transaction getTransaction() { - return mTransaction; - } - - /** - * Utility class to update surface params in a transaction - */ - public class SurfaceProperties { - - private final SurfaceControl mSurface; - - SurfaceProperties(SurfaceControl surface) { - mSurface = surface; - } - - /** - * @param alpha The alpha value to apply to the surface. - * @return this Builder - */ - public SurfaceProperties setAlpha(float alpha) { - mTransaction.setAlpha(mSurface, alpha); - return this; - } - - /** - * @param matrix The matrix to apply to the surface. - * @return this Builder - */ - public SurfaceProperties setMatrix(Matrix matrix) { - mTransaction.setMatrix(mSurface, matrix, mTmpValues); - return this; - } - - /** - * @param windowCrop The window crop to apply to the surface. - * @return this Builder - */ - public SurfaceProperties setWindowCrop(Rect windowCrop) { - mTransaction.setWindowCrop(mSurface, windowCrop); - return this; - } - - /** - * @param relativeLayer The relative layer. - * @return this Builder - */ - public SurfaceProperties setLayer(int relativeLayer) { - mTransaction.setLayer(mSurface, relativeLayer); - return this; - } - - /** - * @param radius the Radius for rounded corners to apply to the surface. - * @return this Builder - */ - public SurfaceProperties setCornerRadius(float radius) { - mTransaction.setCornerRadius(mSurface, radius); - return this; - } - - /** - * @param radius the Radius for the shadows to apply to the surface. - * @return this Builder - */ - public SurfaceProperties setShadowRadius(float radius) { - mTransaction.setShadowRadius(mSurface, radius); - return this; - } - } -} diff --git a/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java b/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java index 95473dc39a..1200208e30 100644 --- a/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java +++ b/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java @@ -25,6 +25,7 @@ import android.view.View; import android.view.ViewRootImpl; import com.android.quickstep.RemoteAnimationTargets.ReleaseCheck; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams; import java.util.function.Consumer; @@ -69,12 +70,18 @@ public class SurfaceTransactionApplier extends ReleaseCheck { * @param params The surface parameters to apply. DO NOT MODIFY the list after passing into * this method to avoid synchronization issues. */ - public void scheduleApply(SurfaceTransaction params) { + public void scheduleApply(final SurfaceParams... params) { View view = mTargetViewRootImpl.getView(); if (view == null) { return; } - Transaction t = params.getTransaction(); + Transaction t = new Transaction(); + for (int i = params.length - 1; i >= 0; i--) { + SurfaceParams surfaceParams = params[i]; + if (surfaceParams.surface.isValid()) { + surfaceParams.applyTo(t); + } + } mLastSequenceNumber++; final int toApplySeqNo = mLastSequenceNumber; @@ -95,7 +102,7 @@ public class SurfaceTransactionApplier extends ReleaseCheck { } /** - * Creates an instance of SurfaceTransactionApplier, deferring until the target view is + * Creates an instance of SyncRtSurfaceTransactionApplier, deferring until the target view is * attached if necessary. */ public static void create( diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index faa5b640e4..1a026fc31d 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -47,11 +47,11 @@ import com.android.launcher3.util.TraceHelper; import com.android.quickstep.AnimatedFloat; import com.android.quickstep.BaseActivityInterface; import com.android.quickstep.TaskAnimationManager; -import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties; import com.android.quickstep.views.TaskThumbnailView.PreviewPositionHelper; import com.android.quickstep.views.TaskView.FullscreenDrawParams; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams.Builder; /** * A utility class which emulates the layout behavior of TaskView and RecentsView @@ -387,10 +387,10 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { @Override public void onBuildTargetParams( - SurfaceProperties builder, RemoteAnimationTargetCompat app, TransformParams params) { - builder.setMatrix(mMatrix) - .setWindowCrop(mTmpCropRect) - .setCornerRadius(getCurrentCornerRadius()); + Builder builder, RemoteAnimationTargetCompat app, TransformParams params) { + builder.withMatrix(mMatrix) + .withWindowCrop(mTmpCropRect) + .withCornerRadius(getCurrentCornerRadius()); // If mDrawsBelowRecents is unset, no reordering will be enforced. if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mDrawsBelowRecents != null) { @@ -399,7 +399,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { // conflict with layers that WM core positions (ie. the input consumers). For shell // transitions, the animation leashes are reparented to an animation container so we // can bump layers as needed. - builder.setLayer(mDrawsBelowRecents + builder.withLayer(mDrawsBelowRecents ? Integer.MIN_VALUE + 1 : ENABLE_SHELL_TRANSITIONS ? Integer.MAX_VALUE : 0); } diff --git a/quickstep/src/com/android/quickstep/util/TransformParams.java b/quickstep/src/com/android/quickstep/util/TransformParams.java index 3d505c6234..a7f25d40ef 100644 --- a/quickstep/src/com/android/quickstep/util/TransformParams.java +++ b/quickstep/src/com/android/quickstep/util/TransformParams.java @@ -21,8 +21,10 @@ import android.view.SurfaceControl; import com.android.launcher3.Utilities; import com.android.launcher3.anim.Interpolators; import com.android.quickstep.RemoteAnimationTargets; -import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams; +import com.android.systemui.shared.system.TransactionCompat; public class TransformParams { @@ -111,7 +113,8 @@ public class TransformParams { * Sets the SyncRtSurfaceTransactionApplierCompat that will apply the SurfaceParams that * are computed based on these TransformParams. */ - public TransformParams setSyncTransactionApplier(SurfaceTransactionApplier applier) { + public TransformParams setSyncTransactionApplier( + SurfaceTransactionApplier applier) { mSyncTransactionApplier = applier; return this; } @@ -134,14 +137,16 @@ public class TransformParams { return this; } - public SurfaceTransaction createSurfaceParams(BuilderProxy proxy) { + public SurfaceParams[] createSurfaceParams(BuilderProxy proxy) { RemoteAnimationTargets targets = mTargetSet; - SurfaceTransaction transaction = new SurfaceTransaction(); + final int appLength = targets.unfilteredApps.length; + final int wallpaperLength = targets.wallpapers != null ? targets.wallpapers.length : 0; + SurfaceParams[] surfaceParams = new SurfaceParams[appLength + wallpaperLength]; mRecentsSurface = getRecentsSurface(targets); - for (int i = 0; i < targets.unfilteredApps.length; i++) { + for (int i = 0; i < appLength; i++) { RemoteAnimationTargetCompat app = targets.unfilteredApps[i]; - SurfaceProperties builder = transaction.forSurface(app.leash); + SurfaceParams.Builder builder = new SurfaceParams.Builder(app.leash); if (app.mode == targets.targetMode) { if (app.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) { @@ -151,9 +156,9 @@ public class TransformParams { if (app.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_ASSISTANT && app.isNotInRecents) { float progress = Utilities.boundToRange(getProgress(), 0, 1); - builder.setAlpha(1 - Interpolators.DEACCEL_2_5.getInterpolation(progress)); + builder.withAlpha(1 - Interpolators.DEACCEL_2_5.getInterpolation(progress)); } else { - builder.setAlpha(getTargetAlpha()); + builder.withAlpha(getTargetAlpha()); } proxy.onBuildTargetParams(builder, app, this); @@ -161,15 +166,15 @@ public class TransformParams { } else { mBaseBuilderProxy.onBuildTargetParams(builder, app, this); } + surfaceParams[i] = builder.build(); } - // always put wallpaper layer to bottom. - final int wallpaperLength = targets.wallpapers != null ? targets.wallpapers.length : 0; for (int i = 0; i < wallpaperLength; i++) { RemoteAnimationTargetCompat wallpaper = targets.wallpapers[i]; - transaction.forSurface(wallpaper.leash).setLayer(Integer.MIN_VALUE); + surfaceParams[appLength + i] = new SurfaceParams.Builder(wallpaper.leash) + .withLayer(Integer.MIN_VALUE).build(); } - return transaction; + return surfaceParams; } private static SurfaceControl getRecentsSurface(RemoteAnimationTargets targets) { @@ -208,11 +213,15 @@ public class TransformParams { return mTargetSet; } - public void applySurfaceParams(SurfaceTransaction builder) { + public void applySurfaceParams(SurfaceParams... params) { if (mSyncTransactionApplier != null) { - mSyncTransactionApplier.scheduleApply(builder); + mSyncTransactionApplier.scheduleApply(params); } else { - builder.getTransaction().apply(); + TransactionCompat t = new TransactionCompat(); + for (SurfaceParams param : params) { + SyncRtSurfaceTransactionApplierCompat.applyParams(t, param); + } + t.apply(); } } @@ -220,9 +229,9 @@ public class TransformParams { public interface BuilderProxy { BuilderProxy NO_OP = (builder, app, params) -> { }; - BuilderProxy ALWAYS_VISIBLE = (builder, app, params) -> builder.setAlpha(1); + BuilderProxy ALWAYS_VISIBLE = (builder, app, params) ->builder.withAlpha(1); - void onBuildTargetParams(SurfaceProperties builder, + void onBuildTargetParams(SurfaceParams.Builder builder, RemoteAnimationTargetCompat app, TransformParams params); } } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index ab1b43357d..28a358e1c6 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -177,7 +177,6 @@ import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.util.RecentsOrientedState; import com.android.quickstep.util.SplitScreenBounds; import com.android.quickstep.util.SplitSelectStateController; -import com.android.quickstep.util.SurfaceTransaction; import com.android.quickstep.util.SurfaceTransactionApplier; import com.android.quickstep.util.TaskViewSimulator; import com.android.quickstep.util.TaskVisualsChangeListener; @@ -190,6 +189,7 @@ import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; import com.android.systemui.shared.system.PackageManagerWrapper; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams; import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.shared.system.TaskStackChangeListeners; import com.android.wm.shell.pip.IPipAnimationListener; @@ -1117,15 +1117,14 @@ public abstract class RecentsView { float percent = valueAnimator.getAnimatedFraction(); - SurfaceTransaction transaction = new SurfaceTransaction(); + SurfaceParams.Builder builder = new SurfaceParams.Builder( + apps[apps.length - 1].leash); Matrix matrix = new Matrix(); matrix.postScale(percent, percent); matrix.postTranslate(mActivity.getDeviceProfile().widthPx * (1 - percent) / 2, mActivity.getDeviceProfile().heightPx * (1 - percent) / 2); - transaction.forSurface(apps[apps.length - 1].leash) - .setAlpha(percent) - .setMatrix(matrix); - surfaceApplier.scheduleApply(transaction); + builder.withAlpha(percent).withMatrix(matrix); + surfaceApplier.scheduleApply(builder.build()); }); anim.play(appAnimator); anim.addListener(new AnimatorListenerAdapter() { diff --git a/quickstep/tests/src/com/android/launcher3/model/WidgetsPredicationUpdateTaskTest.java b/quickstep/tests/src/com/android/launcher3/model/WidgetsPredicationUpdateTaskTest.java index b90369132b..c1b3beb475 100644 --- a/quickstep/tests/src/com/android/launcher3/model/WidgetsPredicationUpdateTaskTest.java +++ b/quickstep/tests/src/com/android/launcher3/model/WidgetsPredicationUpdateTaskTest.java @@ -36,6 +36,7 @@ import android.appwidget.AppWidgetProviderInfo; import android.content.ComponentName; import android.os.UserHandle; import android.text.TextUtils; +import android.util.Log; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; @@ -110,6 +111,7 @@ public final class WidgetsPredicationUpdateTaskTest { doReturn(allWidgets).when(manager).getInstalledProvidersForProfile(eq(myUserHandle())); doAnswer(i -> { String pkg = i.getArgument(0); + Log.e("Hello", "Getting v " + pkg); return TextUtils.isEmpty(pkg) ? allWidgets : allWidgets.stream() .filter(a -> pkg.equals(a.provider.getPackageName())) .collect(Collectors.toList()); diff --git a/quickstep/tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java b/quickstep/tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java index c2667b8633..190b002d09 100644 --- a/quickstep/tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java +++ b/quickstep/tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java @@ -24,6 +24,7 @@ import android.graphics.Rect; import android.graphics.RectF; import android.util.ArrayMap; import android.view.Surface; +import android.view.SurfaceControl; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; @@ -41,8 +42,8 @@ import com.android.launcher3.util.window.CachedDisplayInfo; import com.android.launcher3.util.window.WindowManagerProxy; import com.android.quickstep.FallbackActivityInterface; import com.android.quickstep.SystemUiProxy; -import com.android.quickstep.util.RecordingSurfaceTransaction.MockProperties; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; +import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams; import org.hamcrest.Description; import org.hamcrest.TypeSafeMatcher; @@ -206,21 +207,17 @@ public class TaskViewSimulatorTest { } @Override - public SurfaceTransaction createSurfaceParams(BuilderProxy proxy) { - RecordingSurfaceTransaction transaction = new RecordingSurfaceTransaction(); - proxy.onBuildTargetParams( - transaction.mockProperties, mock(RemoteAnimationTargetCompat.class), this); - return transaction; + public SurfaceParams[] createSurfaceParams(BuilderProxy proxy) { + SurfaceParams.Builder builder = new SurfaceParams.Builder((SurfaceControl) null); + proxy.onBuildTargetParams(builder, mock(RemoteAnimationTargetCompat.class), this); + return new SurfaceParams[] {builder.build()}; } @Override - public void applySurfaceParams(SurfaceTransaction params) { - Assert.assertTrue(params instanceof RecordingSurfaceTransaction); - MockProperties p = ((RecordingSurfaceTransaction) params).mockProperties; - + public void applySurfaceParams(SurfaceParams[] params) { // Verify that the task position remains the same RectF newAppBounds = new RectF(mAppBounds); - p.matrix.mapRect(newAppBounds); + params[0].matrix.mapRect(newAppBounds); Assert.assertThat(newAppBounds, new AlmostSame(mAppBounds)); System.err.println("Bounds mapped: " + mAppBounds + " => " + newAppBounds); From 441cdeb0824da44cb507595098dd563f89c21ef8 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Wed, 5 Oct 2022 00:57:09 -0700 Subject: [PATCH 4/4] Differentiate between app row and shortcut icons. This is a simplified version of ag/20118087. It fixes the bug with rows of shortcuts being in the search results (e.g. Gmail and WhatsApp conversations), but it will not handle cases where there are multiple rows of app icons. Currently I do not know of any cases where that would happen. Test: Manual with and without inject_web_top (which moves app row) for WhatsApp and Gmail with AiAi fishfood. Bug: 239927522 Change-Id: Ie9c62c0ee81086801942328c8770f37d5bf622c3 (cherry picked from commit 0d3c3d8fc551cab0fad8a47375898bcbf5acd3cf) Merged-In: Ie9c62c0ee81086801942328c8770f37d5bf622c3 --- .../launcher3/allapps/SearchTransitionController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/allapps/SearchTransitionController.java b/src/com/android/launcher3/allapps/SearchTransitionController.java index a1f5bc696f..11ceb0a55c 100644 --- a/src/com/android/launcher3/allapps/SearchTransitionController.java +++ b/src/com/android/launcher3/allapps/SearchTransitionController.java @@ -20,6 +20,7 @@ import static android.view.View.VISIBLE; import static androidx.recyclerview.widget.RecyclerView.NO_POSITION; +import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; import static com.android.launcher3.anim.AnimatorListeners.forEndCallback; import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback; import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7; @@ -38,6 +39,7 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.R; import com.android.launcher3.Utilities; +import com.android.launcher3.model.data.ItemInfo; /** Coordinates the transition between Search and A-Z in All Apps. */ public class SearchTransitionController { @@ -186,7 +188,9 @@ public class SearchTransitionController { top = searchResultView.getTop(); } - if (searchResultView instanceof BubbleTextView) { + if (searchResultView instanceof BubbleTextView + && searchResultView.getTag() instanceof ItemInfo + && ((ItemInfo) searchResultView.getTag()).itemType == ITEM_TYPE_APPLICATION) { // The first app icon will set appRowHeight, which will also contribute to // totalHeight. Additional app icons should remove the appRowHeight to remain in // the same row as the first app. @@ -196,6 +200,8 @@ public class SearchTransitionController { totalHeight += appRowHeight; } // Don't scale/fade app row. + searchResultView.setScaleY(1); + searchResultView.setAlpha(1); continue; }