summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Gustav Sennton <gsennton@google.com> 2025-02-07 09:35:08 +0000
committer Gustav Sennton <gsennton@google.com> 2025-02-07 11:02:26 +0000
commit89f81a4892383b51d9cebde6323b5f0697d0ae78 (patch)
tree3f7f707f184704df22e349d425a04deb88f1b635
parent2d6d7c3d6c138c4b361ab9891c57b42b4118df41 (diff)
Restore corner radius for freeform tasks after recents transition
Use the finish transaction from start() or merge() to restore the corner radius of freeform windows at the end of the recents transition. Bug: 378657004 Flag: com.android.window.flags.enable_desktop_recents_transitions_corners_bugfix Test: manual Change-Id: I9b32df365237ffc25593bfa78bfc3e61fd3c4d0c
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java28
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/recents/RecentsTransitionHandlerTest.java66
2 files changed, 94 insertions, 0 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
index ae8f8c4eff79..c74b348d9766 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
@@ -29,6 +29,7 @@ import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_PIP;
import static android.view.WindowManager.TRANSIT_SLEEP;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
+import static android.window.DesktopModeFlags.ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX;
import static android.window.TransitionInfo.FLAG_MOVED_TO_TOP;
import static android.window.TransitionInfo.FLAG_TRANSLUCENT;
@@ -46,6 +47,7 @@ import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.IApplicationThread;
import android.app.PendingIntent;
+import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Rect;
@@ -73,6 +75,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.IResultReceiver;
import com.android.internal.protolog.ProtoLog;
import com.android.wm.shell.Flags;
+import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.pip.PipUtils;
@@ -1353,6 +1356,8 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
wct.reorder(mPausingTasks.get(i).mToken, true /* onTop */);
t.show(mPausingTasks.get(i).mTaskSurface);
}
+ setCornerRadiusForFreeformTasks(
+ mRecentTasksController.getContext(), t, mPausingTasks);
if (!mKeyguardLocked && mRecentsTask != null) {
wct.restoreTransientOrder(mRecentsTask);
}
@@ -1390,6 +1395,8 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
for (int i = 0; i < mOpeningTasks.size(); ++i) {
t.show(mOpeningTasks.get(i).mTaskSurface);
}
+ setCornerRadiusForFreeformTasks(
+ mRecentTasksController.getContext(), t, mOpeningTasks);
for (int i = 0; i < mPausingTasks.size(); ++i) {
cleanUpPausingOrClosingTask(mPausingTasks.get(i), wct, t, sendUserLeaveHint);
}
@@ -1509,6 +1516,27 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
}
}
+ private static void setCornerRadiusForFreeformTasks(
+ Context context,
+ SurfaceControl.Transaction t,
+ ArrayList<TaskState> tasks) {
+ if (!ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX.isTrue()) {
+ return;
+ }
+ int cornerRadius = getCornerRadius(context);
+ for (int i = 0; i < tasks.size(); ++i) {
+ TaskState task = tasks.get(i);
+ if (task.mTaskInfo != null && task.mTaskInfo.isFreeform()) {
+ t.setCornerRadius(task.mTaskSurface, cornerRadius);
+ }
+ }
+ }
+
+ private static int getCornerRadius(Context context) {
+ return context.getResources().getDimensionPixelSize(
+ R.dimen.desktop_windowing_freeform_rounded_corner_radius);
+ }
+
private boolean allAppsAreTranslucent(ArrayList<TaskState> tasks) {
if (tasks == null) {
return false;
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/recents/RecentsTransitionHandlerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/recents/RecentsTransitionHandlerTest.java
index b50af741b2a6..439be9155b26 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/recents/RecentsTransitionHandlerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/recents/RecentsTransitionHandlerTest.java
@@ -17,9 +17,13 @@
package com.android.wm.shell.recents;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
+import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
+import static android.view.WindowManager.TRANSIT_CLOSE;
+import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
+import static com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX;
import static com.android.wm.shell.recents.RecentsTransitionStateListener.TRANSITION_STATE_ANIMATING;
import static com.android.wm.shell.recents.RecentsTransitionStateListener.TRANSITION_STATE_NOT_RUNNING;
import static com.android.wm.shell.recents.RecentsTransitionStateListener.TRANSITION_STATE_REQUESTED;
@@ -44,9 +48,11 @@ import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.res.Resources;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
+import android.platform.test.annotations.EnableFlags;
import android.view.SurfaceControl;
import android.window.TransitionInfo;
@@ -57,6 +63,7 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.dx.mockito.inline.extended.ExtendedMockito;
import com.android.dx.mockito.inline.extended.StaticMockitoSession;
import com.android.internal.os.IResultReceiver;
+import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestRunningTaskInfoBuilder;
@@ -92,9 +99,13 @@ import java.util.Optional;
@SmallTest
public class RecentsTransitionHandlerTest extends ShellTestCase {
+ private static final int FREEFORM_TASK_CORNER_RADIUS = 32;
+
@Mock
private Context mContext;
@Mock
+ private Resources mResources;
+ @Mock
private TaskStackListenerImpl mTaskStackListener;
@Mock
private ShellCommandHandler mShellCommandHandler;
@@ -134,6 +145,10 @@ public class RecentsTransitionHandlerTest extends ShellTestCase {
when(mContext.getPackageManager()).thenReturn(mock(PackageManager.class));
when(mContext.getSystemService(KeyguardManager.class))
.thenReturn(mock(KeyguardManager.class));
+ when(mContext.getResources()).thenReturn(mResources);
+ when(mResources.getDimensionPixelSize(
+ R.dimen.desktop_windowing_freeform_rounded_corner_radius)
+ ).thenReturn(FREEFORM_TASK_CORNER_RADIUS);
mShellInit = spy(new ShellInit(mMainExecutor));
mShellController = spy(new ShellController(mContext, mShellInit, mShellCommandHandler,
mDisplayInsetsController, mMainExecutor));
@@ -276,6 +291,57 @@ public class RecentsTransitionHandlerTest extends ShellTestCase {
assertThat(listener.getState()).isEqualTo(TRANSITION_STATE_NOT_RUNNING);
}
+ @Test
+ @EnableFlags(FLAG_ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX)
+ public void testMergeAndFinish_openingFreeformTasks_setsCornerRadius() {
+ ActivityManager.RunningTaskInfo freeformTask =
+ new TestRunningTaskInfoBuilder().setWindowingMode(WINDOWING_MODE_FREEFORM).build();
+ TransitionInfo mergeTransitionInfo = new TransitionInfoBuilder(TRANSIT_OPEN)
+ .addChange(TRANSIT_OPEN, freeformTask)
+ .build();
+ SurfaceControl leash = mergeTransitionInfo.getChanges().get(0).getLeash();
+ final IBinder transition = startRecentsTransition(/* synthetic= */ false);
+ SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class);
+ mRecentsTransitionHandler.startAnimation(
+ transition, createTransitionInfo(), new StubTransaction(), new StubTransaction(),
+ mock(Transitions.TransitionFinishCallback.class));
+
+ mRecentsTransitionHandler.findController(transition).merge(
+ mergeTransitionInfo,
+ new StubTransaction(),
+ finishT,
+ transition,
+ mock(Transitions.TransitionFinishCallback.class));
+ mRecentsTransitionHandler.findController(transition).finish(/* toHome= */ false,
+ false /* sendUserLeaveHint */, mock(IResultReceiver.class));
+ mMainExecutor.flushAll();
+
+ verify(finishT).setCornerRadius(leash, FREEFORM_TASK_CORNER_RADIUS);
+ }
+
+ @Test
+ @EnableFlags(FLAG_ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX)
+ public void testFinish_returningToFreeformTasks_setsCornerRadius() {
+ ActivityManager.RunningTaskInfo freeformTask =
+ new TestRunningTaskInfoBuilder().setWindowingMode(WINDOWING_MODE_FREEFORM).build();
+ TransitionInfo transitionInfo = new TransitionInfoBuilder(TRANSIT_CLOSE)
+ .addChange(TRANSIT_CLOSE, freeformTask)
+ .build();
+ SurfaceControl leash = transitionInfo.getChanges().get(0).getLeash();
+ final IBinder transition = startRecentsTransition(/* synthetic= */ false);
+ SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class);
+ mRecentsTransitionHandler.startAnimation(
+ transition, transitionInfo, new StubTransaction(), finishT,
+ mock(Transitions.TransitionFinishCallback.class));
+
+ mRecentsTransitionHandler.findController(transition).finish(/* toHome= */ false,
+ false /* sendUserLeaveHint */, mock(IResultReceiver.class));
+ mMainExecutor.flushAll();
+
+
+ verify(finishT).setCornerRadius(leash, FREEFORM_TASK_CORNER_RADIUS);
+ }
+
private IBinder startRecentsTransition(boolean synthetic) {
return startRecentsTransition(synthetic, mock(IRecentsAnimationRunner.class));
}