Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java +12 −5 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import android.view.ViewConfiguration; import android.view.WindowInsets; import android.view.WindowManager; import android.view.WindowManagerGlobal; import android.window.DesktopExperienceFlags; import android.window.DesktopModeFlags; import android.window.WindowContainerTransaction; Loading Loading @@ -218,11 +219,17 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL relayoutParams.mRunningTaskInfo = taskInfo; relayoutParams.mLayoutResId = R.layout.caption_window_decor; relayoutParams.mCaptionHeightId = getCaptionHeightIdStatic(taskInfo.getWindowingMode()); if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { relayoutParams.mShadowRadiusId = hasGlobalFocus ? R.dimen.freeform_decor_shadow_focused_thickness : R.dimen.freeform_decor_shadow_unfocused_thickness; } else { relayoutParams.mShadowRadius = hasGlobalFocus ? context.getResources().getDimensionPixelSize( R.dimen.freeform_decor_shadow_focused_thickness) : context.getResources().getDimensionPixelSize( R.dimen.freeform_decor_shadow_unfocused_thickness); } relayoutParams.mApplyStartTransactionOnDraw = applyStartTransactionOnDraw; relayoutParams.mSetTaskVisibilityPositionAndCrop = shouldSetTaskVisibilityPositionAndCrop; relayoutParams.mIsCaptionVisible = taskInfo.isFreeform() Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +35 −9 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import android.view.WindowInsets; import android.view.WindowManager; import android.view.WindowManagerGlobal; import android.widget.ImageButton; import android.window.DesktopExperienceFlags; import android.window.DesktopModeFlags; import android.window.TaskSnapshot; import android.window.WindowContainerTransaction; Loading Loading @@ -719,7 +720,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin .getScaledTouchSlop(); final Resources res = mResult.mRootView.getResources(); final DragResizeWindowGeometry newGeometry = new DragResizeWindowGeometry( mRelayoutParams.mCornerRadius, DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue() ? mResult.mCornerRadius : mRelayoutParams.mCornerRadius, new Size(mResult.mWidth, mResult.mHeight), getResizeEdgeHandleSize(res), getResizeHandleEdgeInset(res), getFineResizeCornerSize(res), getLargeResizeCornerSize(res), Loading Loading @@ -1072,14 +1074,24 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin } if (isAppHeader && DesktopModeStatus.useWindowShadow(/* isFocusedWindow= */ hasGlobalFocus)) { if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { relayoutParams.mShadowRadiusId = hasGlobalFocus ? R.dimen.freeform_decor_shadow_focused_thickness : R.dimen.freeform_decor_shadow_unfocused_thickness; } else { relayoutParams.mShadowRadius = hasGlobalFocus ? context.getResources().getDimensionPixelSize( R.dimen.freeform_decor_shadow_focused_thickness) : context.getResources().getDimensionPixelSize( R.dimen.freeform_decor_shadow_unfocused_thickness); } } else { if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { relayoutParams.mShadowRadiusId = Resources.ID_NULL; } else { relayoutParams.mShadowRadius = INVALID_SHADOW_RADIUS; } } relayoutParams.mApplyStartTransactionOnDraw = applyStartTransactionOnDraw; relayoutParams.mSetTaskVisibilityPositionAndCrop = shouldSetTaskVisibilityPositionAndCrop; Loading @@ -1104,15 +1116,21 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin relayoutParams.mWindowDecorConfig = windowDecorConfig; if (DesktopModeStatus.useRoundedCorners()) { if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { relayoutParams.mCornerRadiusId = shouldIgnoreCornerRadius ? Resources.ID_NULL : getCornerRadiusId(relayoutParams.mLayoutResId); } else { relayoutParams.mCornerRadius = shouldIgnoreCornerRadius ? INVALID_CORNER_RADIUS : getCornerRadius(context, relayoutParams.mLayoutResId); } } // Set opaque background for all freeform tasks to prevent freeform tasks below // from being visible if freeform task window above is translucent. // Otherwise if fluid resize is enabled, add a background to freeform tasks. relayoutParams.mShouldSetBackground = DesktopModeStatus.shouldSetBackground(taskInfo); } @Deprecated private static int getCornerRadius(@NonNull Context context, int layoutResId) { if (layoutResId == R.layout.desktop_mode_app_header) { return loadDimensionPixelSize(context.getResources(), Loading @@ -1122,6 +1140,14 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin return INVALID_CORNER_RADIUS; } private static int getCornerRadiusId(int layoutResId) { if (layoutResId == R.layout.desktop_mode_app_header) { return com.android.wm.shell.shared.R.dimen .desktop_windowing_freeform_rounded_corner_radius; } return Resources.ID_NULL; } /** * If task has focused window decor, return the caption id of the fullscreen caption size * resource. Otherwise, return ID_NULL and caption width be set to task width. Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java +47 −9 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.view.SurfaceControlViewHost; import android.view.View; import android.view.WindowManager; import android.view.WindowlessWindowManager; import android.window.DesktopExperienceFlags; import android.window.SurfaceSyncGroup; import android.window.TaskConstants; import android.window.WindowContainerToken; Loading Loading @@ -286,6 +287,14 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> outResult.mCaptionX = (outResult.mWidth - outResult.mCaptionWidth) / 2; outResult.mCaptionY = 0; outResult.mCaptionTopPadding = params.mCaptionTopPadding; if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { outResult.mCornerRadius = params.mCornerRadiusId == Resources.ID_NULL ? INVALID_CORNER_RADIUS : loadDimensionPixelSize(resources, params.mCornerRadiusId); outResult.mShadowRadius = params.mShadowRadiusId == Resources.ID_NULL ? INVALID_SHADOW_RADIUS : loadDimensionPixelSize(resources, params.mShadowRadiusId); } Trace.beginSection("relayout-createViewHostIfNeeded"); createViewHostIfNeeded(mDecorWindowContext, mDisplay); Loading Loading @@ -497,10 +506,17 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> .setPosition(mTaskSurface, taskPosition.x, taskPosition.y); } if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { if (outResult.mShadowRadius != INVALID_SHADOW_RADIUS) { startT.setShadowRadius(mTaskSurface, outResult.mShadowRadius); finishT.setShadowRadius(mTaskSurface, outResult.mShadowRadius); } } else { if (params.mShadowRadius != INVALID_SHADOW_RADIUS) { startT.setShadowRadius(mTaskSurface, params.mShadowRadius); finishT.setShadowRadius(mTaskSurface, params.mShadowRadius); } } if (params.mSetTaskVisibilityPositionAndCrop) { startT.show(mTaskSurface); Loading @@ -517,11 +533,18 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> startT.unsetColor(mTaskSurface); } if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { if (outResult.mCornerRadius != INVALID_CORNER_RADIUS) { startT.setCornerRadius(mTaskSurface, outResult.mCornerRadius); finishT.setCornerRadius(mTaskSurface, outResult.mCornerRadius); } } else { if (params.mCornerRadius != INVALID_CORNER_RADIUS) { startT.setCornerRadius(mTaskSurface, params.mCornerRadius); finishT.setCornerRadius(mTaskSurface, params.mCornerRadius); } } } @NonNull private Region calculateLimitedTouchableRegion( Loading Loading @@ -824,9 +847,14 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> @InsetsSource.Flags int mInsetSourceFlags; final Region mDisplayExclusionRegion = Region.obtain(); @Deprecated int mShadowRadius = INVALID_SHADOW_RADIUS; @Deprecated int mCornerRadius = INVALID_CORNER_RADIUS; int mShadowRadiusId = Resources.ID_NULL; int mCornerRadiusId = Resources.ID_NULL; int mCaptionTopPadding; boolean mIsCaptionVisible; Loading @@ -849,9 +877,13 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> mIsInsetSource = true; mInsetSourceFlags = 0; mDisplayExclusionRegion.setEmpty(); if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { mShadowRadiusId = Resources.ID_NULL; mCornerRadiusId = Resources.ID_NULL; } else { mShadowRadius = INVALID_SHADOW_RADIUS; mCornerRadius = INVALID_SHADOW_RADIUS; } mCaptionTopPadding = 0; mIsCaptionVisible = false; Loading Loading @@ -893,6 +925,8 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> int mWidth; int mHeight; T mRootView; int mCornerRadius; int mShadowRadius; void reset() { mWidth = 0; Loading @@ -904,6 +938,10 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> mCaptionTopPadding = 0; mCustomizableCaptionRegion.setEmpty(); mRootView = null; if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { mCornerRadius = INVALID_CORNER_RADIUS; mShadowRadius = INVALID_SHADOW_RADIUS; } } } Loading libs/WindowManager/Shell/tests/unittest/res/values/dimen.xml +2 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ <!-- Resources used in WindowDecorationTests --> <dimen name="test_freeform_decor_caption_height">32dp</dimen> <dimen name="test_freeform_decor_caption_menu_width">216dp</dimen> <dimen name="test_freeform_shadow_radius">20dp</dimen> <dimen name="test_freeform_corner_radius">16dp</dimen> <dimen name="test_window_decor_left_outset">10dp</dimen> <dimen name="test_window_decor_top_outset">20dp</dimen> <dimen name="test_window_decor_right_outset">30dp</dimen> Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java +116 −7 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Point; import android.graphics.Rect; Loading Loading @@ -341,7 +342,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreSetForFreeform() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreSetForFreeform_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); RelayoutParams relayoutParams = new RelayoutParams(); Loading @@ -353,7 +355,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreNotSetForFullscreen() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreNotSetForFullscreen_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); RelayoutParams relayoutParams = new RelayoutParams(); Loading @@ -364,7 +367,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreNotSetForSplit() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreNotSetForSplit_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); RelayoutParams relayoutParams = new RelayoutParams(); Loading @@ -375,7 +379,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersSetForFreeform() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersSetForFreeform_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); fillRoundedCornersResources(/* fillValue= */ 30); Loading @@ -387,7 +392,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForFullscreen() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForFullscreen_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); fillRoundedCornersResources(/* fillValue= */ 30); Loading @@ -399,7 +405,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForSplit() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForSplit_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); fillRoundedCornersResources(/* fillValue= */ 30); Loading @@ -411,7 +418,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_shouldIgnoreCornerRadius_roundedCornersNotSet() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_shouldIgnoreCornerRadius_roundedCornersNotSet_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); fillRoundedCornersResources(/* fillValue= */ 30); Loading Loading @@ -439,6 +447,107 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { assertThat(relayoutParams.mCornerRadius).isEqualTo(INVALID_CORNER_RADIUS); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreSetForFreeform() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); RelayoutParams relayoutParams = new RelayoutParams(); updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mShadowRadiusId).isNotEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreNotSetForFullscreen() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); RelayoutParams relayoutParams = new RelayoutParams(); updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mShadowRadiusId).isEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreNotSetForSplit() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); RelayoutParams relayoutParams = new RelayoutParams(); updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mShadowRadiusId).isEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersSetForFreeform() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); RelayoutParams relayoutParams = new RelayoutParams(); updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mShadowRadiusId).isNotEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForFullscreen() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); RelayoutParams relayoutParams = new RelayoutParams(); updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mCornerRadiusId).isEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForSplit() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); RelayoutParams relayoutParams = new RelayoutParams(); updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mCornerRadiusId).isEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_shouldIgnoreCornerRadius_roundedCornersNotSet() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); RelayoutParams relayoutParams = new RelayoutParams(); DesktopModeWindowDecoration.updateRelayoutParams( relayoutParams, mTestableContext, taskInfo, mMockSplitScreenController, DEFAULT_APPLY_START_TRANSACTION_ON_DRAW, DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP, DEFAULT_IS_STATUSBAR_VISIBLE, DEFAULT_IS_KEYGUARD_VISIBLE_AND_OCCLUDED, DEFAULT_IS_IN_FULL_IMMERSIVE_MODE, DEFAULT_IS_DRAGGING, new InsetsState(), DEFAULT_HAS_GLOBAL_FOCUS, mExclusionRegion, /* shouldIgnoreCornerRadius= */ true, DEFAULT_SHOULD_EXCLUDE_CAPTION_FROM_APP_BOUNDS, DEFAULT_IS_RECENTS_TRANSITION_RUNNING, DEFAULT_IS_MOVING_TO_BACK); assertThat(relayoutParams.mCornerRadiusId).isEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_APP_HEADER_WITH_TASK_DENSITY) public void updateRelayoutParams_appHeader_usesTaskDensity() { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java +12 −5 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import android.view.ViewConfiguration; import android.view.WindowInsets; import android.view.WindowManager; import android.view.WindowManagerGlobal; import android.window.DesktopExperienceFlags; import android.window.DesktopModeFlags; import android.window.WindowContainerTransaction; Loading Loading @@ -218,11 +219,17 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL relayoutParams.mRunningTaskInfo = taskInfo; relayoutParams.mLayoutResId = R.layout.caption_window_decor; relayoutParams.mCaptionHeightId = getCaptionHeightIdStatic(taskInfo.getWindowingMode()); if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { relayoutParams.mShadowRadiusId = hasGlobalFocus ? R.dimen.freeform_decor_shadow_focused_thickness : R.dimen.freeform_decor_shadow_unfocused_thickness; } else { relayoutParams.mShadowRadius = hasGlobalFocus ? context.getResources().getDimensionPixelSize( R.dimen.freeform_decor_shadow_focused_thickness) : context.getResources().getDimensionPixelSize( R.dimen.freeform_decor_shadow_unfocused_thickness); } relayoutParams.mApplyStartTransactionOnDraw = applyStartTransactionOnDraw; relayoutParams.mSetTaskVisibilityPositionAndCrop = shouldSetTaskVisibilityPositionAndCrop; relayoutParams.mIsCaptionVisible = taskInfo.isFreeform() Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +35 −9 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import android.view.WindowInsets; import android.view.WindowManager; import android.view.WindowManagerGlobal; import android.widget.ImageButton; import android.window.DesktopExperienceFlags; import android.window.DesktopModeFlags; import android.window.TaskSnapshot; import android.window.WindowContainerTransaction; Loading Loading @@ -719,7 +720,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin .getScaledTouchSlop(); final Resources res = mResult.mRootView.getResources(); final DragResizeWindowGeometry newGeometry = new DragResizeWindowGeometry( mRelayoutParams.mCornerRadius, DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue() ? mResult.mCornerRadius : mRelayoutParams.mCornerRadius, new Size(mResult.mWidth, mResult.mHeight), getResizeEdgeHandleSize(res), getResizeHandleEdgeInset(res), getFineResizeCornerSize(res), getLargeResizeCornerSize(res), Loading Loading @@ -1072,14 +1074,24 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin } if (isAppHeader && DesktopModeStatus.useWindowShadow(/* isFocusedWindow= */ hasGlobalFocus)) { if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { relayoutParams.mShadowRadiusId = hasGlobalFocus ? R.dimen.freeform_decor_shadow_focused_thickness : R.dimen.freeform_decor_shadow_unfocused_thickness; } else { relayoutParams.mShadowRadius = hasGlobalFocus ? context.getResources().getDimensionPixelSize( R.dimen.freeform_decor_shadow_focused_thickness) : context.getResources().getDimensionPixelSize( R.dimen.freeform_decor_shadow_unfocused_thickness); } } else { if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { relayoutParams.mShadowRadiusId = Resources.ID_NULL; } else { relayoutParams.mShadowRadius = INVALID_SHADOW_RADIUS; } } relayoutParams.mApplyStartTransactionOnDraw = applyStartTransactionOnDraw; relayoutParams.mSetTaskVisibilityPositionAndCrop = shouldSetTaskVisibilityPositionAndCrop; Loading @@ -1104,15 +1116,21 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin relayoutParams.mWindowDecorConfig = windowDecorConfig; if (DesktopModeStatus.useRoundedCorners()) { if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { relayoutParams.mCornerRadiusId = shouldIgnoreCornerRadius ? Resources.ID_NULL : getCornerRadiusId(relayoutParams.mLayoutResId); } else { relayoutParams.mCornerRadius = shouldIgnoreCornerRadius ? INVALID_CORNER_RADIUS : getCornerRadius(context, relayoutParams.mLayoutResId); } } // Set opaque background for all freeform tasks to prevent freeform tasks below // from being visible if freeform task window above is translucent. // Otherwise if fluid resize is enabled, add a background to freeform tasks. relayoutParams.mShouldSetBackground = DesktopModeStatus.shouldSetBackground(taskInfo); } @Deprecated private static int getCornerRadius(@NonNull Context context, int layoutResId) { if (layoutResId == R.layout.desktop_mode_app_header) { return loadDimensionPixelSize(context.getResources(), Loading @@ -1122,6 +1140,14 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin return INVALID_CORNER_RADIUS; } private static int getCornerRadiusId(int layoutResId) { if (layoutResId == R.layout.desktop_mode_app_header) { return com.android.wm.shell.shared.R.dimen .desktop_windowing_freeform_rounded_corner_radius; } return Resources.ID_NULL; } /** * If task has focused window decor, return the caption id of the fullscreen caption size * resource. Otherwise, return ID_NULL and caption width be set to task width. Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java +47 −9 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.view.SurfaceControlViewHost; import android.view.View; import android.view.WindowManager; import android.view.WindowlessWindowManager; import android.window.DesktopExperienceFlags; import android.window.SurfaceSyncGroup; import android.window.TaskConstants; import android.window.WindowContainerToken; Loading Loading @@ -286,6 +287,14 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> outResult.mCaptionX = (outResult.mWidth - outResult.mCaptionWidth) / 2; outResult.mCaptionY = 0; outResult.mCaptionTopPadding = params.mCaptionTopPadding; if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { outResult.mCornerRadius = params.mCornerRadiusId == Resources.ID_NULL ? INVALID_CORNER_RADIUS : loadDimensionPixelSize(resources, params.mCornerRadiusId); outResult.mShadowRadius = params.mShadowRadiusId == Resources.ID_NULL ? INVALID_SHADOW_RADIUS : loadDimensionPixelSize(resources, params.mShadowRadiusId); } Trace.beginSection("relayout-createViewHostIfNeeded"); createViewHostIfNeeded(mDecorWindowContext, mDisplay); Loading Loading @@ -497,10 +506,17 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> .setPosition(mTaskSurface, taskPosition.x, taskPosition.y); } if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { if (outResult.mShadowRadius != INVALID_SHADOW_RADIUS) { startT.setShadowRadius(mTaskSurface, outResult.mShadowRadius); finishT.setShadowRadius(mTaskSurface, outResult.mShadowRadius); } } else { if (params.mShadowRadius != INVALID_SHADOW_RADIUS) { startT.setShadowRadius(mTaskSurface, params.mShadowRadius); finishT.setShadowRadius(mTaskSurface, params.mShadowRadius); } } if (params.mSetTaskVisibilityPositionAndCrop) { startT.show(mTaskSurface); Loading @@ -517,11 +533,18 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> startT.unsetColor(mTaskSurface); } if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { if (outResult.mCornerRadius != INVALID_CORNER_RADIUS) { startT.setCornerRadius(mTaskSurface, outResult.mCornerRadius); finishT.setCornerRadius(mTaskSurface, outResult.mCornerRadius); } } else { if (params.mCornerRadius != INVALID_CORNER_RADIUS) { startT.setCornerRadius(mTaskSurface, params.mCornerRadius); finishT.setCornerRadius(mTaskSurface, params.mCornerRadius); } } } @NonNull private Region calculateLimitedTouchableRegion( Loading Loading @@ -824,9 +847,14 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> @InsetsSource.Flags int mInsetSourceFlags; final Region mDisplayExclusionRegion = Region.obtain(); @Deprecated int mShadowRadius = INVALID_SHADOW_RADIUS; @Deprecated int mCornerRadius = INVALID_CORNER_RADIUS; int mShadowRadiusId = Resources.ID_NULL; int mCornerRadiusId = Resources.ID_NULL; int mCaptionTopPadding; boolean mIsCaptionVisible; Loading @@ -849,9 +877,13 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> mIsInsetSource = true; mInsetSourceFlags = 0; mDisplayExclusionRegion.setEmpty(); if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { mShadowRadiusId = Resources.ID_NULL; mCornerRadiusId = Resources.ID_NULL; } else { mShadowRadius = INVALID_SHADOW_RADIUS; mCornerRadius = INVALID_SHADOW_RADIUS; } mCaptionTopPadding = 0; mIsCaptionVisible = false; Loading Loading @@ -893,6 +925,8 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> int mWidth; int mHeight; T mRootView; int mCornerRadius; int mShadowRadius; void reset() { mWidth = 0; Loading @@ -904,6 +938,10 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> mCaptionTopPadding = 0; mCustomizableCaptionRegion.setEmpty(); mRootView = null; if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) { mCornerRadius = INVALID_CORNER_RADIUS; mShadowRadius = INVALID_SHADOW_RADIUS; } } } Loading
libs/WindowManager/Shell/tests/unittest/res/values/dimen.xml +2 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ <!-- Resources used in WindowDecorationTests --> <dimen name="test_freeform_decor_caption_height">32dp</dimen> <dimen name="test_freeform_decor_caption_menu_width">216dp</dimen> <dimen name="test_freeform_shadow_radius">20dp</dimen> <dimen name="test_freeform_corner_radius">16dp</dimen> <dimen name="test_window_decor_left_outset">10dp</dimen> <dimen name="test_window_decor_top_outset">20dp</dimen> <dimen name="test_window_decor_right_outset">30dp</dimen> Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java +116 −7 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Point; import android.graphics.Rect; Loading Loading @@ -341,7 +342,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreSetForFreeform() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreSetForFreeform_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); RelayoutParams relayoutParams = new RelayoutParams(); Loading @@ -353,7 +355,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreNotSetForFullscreen() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreNotSetForFullscreen_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); RelayoutParams relayoutParams = new RelayoutParams(); Loading @@ -364,7 +367,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreNotSetForSplit() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreNotSetForSplit_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); RelayoutParams relayoutParams = new RelayoutParams(); Loading @@ -375,7 +379,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersSetForFreeform() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersSetForFreeform_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); fillRoundedCornersResources(/* fillValue= */ 30); Loading @@ -387,7 +392,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForFullscreen() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForFullscreen_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); fillRoundedCornersResources(/* fillValue= */ 30); Loading @@ -399,7 +405,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForSplit() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForSplit_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); fillRoundedCornersResources(/* fillValue= */ 30); Loading @@ -411,7 +418,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { } @Test public void updateRelayoutParams_shouldIgnoreCornerRadius_roundedCornersNotSet() { @DisableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_shouldIgnoreCornerRadius_roundedCornersNotSet_dynamicDisabled() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); fillRoundedCornersResources(/* fillValue= */ 30); Loading Loading @@ -439,6 +447,107 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { assertThat(relayoutParams.mCornerRadius).isEqualTo(INVALID_CORNER_RADIUS); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreSetForFreeform() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); RelayoutParams relayoutParams = new RelayoutParams(); updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mShadowRadiusId).isNotEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreNotSetForFullscreen() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); RelayoutParams relayoutParams = new RelayoutParams(); updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mShadowRadiusId).isEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_windowShadowsAreNotSetForSplit() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); RelayoutParams relayoutParams = new RelayoutParams(); updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mShadowRadiusId).isEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersSetForFreeform() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); RelayoutParams relayoutParams = new RelayoutParams(); updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mShadowRadiusId).isNotEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForFullscreen() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); RelayoutParams relayoutParams = new RelayoutParams(); updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mCornerRadiusId).isEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForSplit() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); RelayoutParams relayoutParams = new RelayoutParams(); updateRelayoutParams(relayoutParams, taskInfo); assertThat(relayoutParams.mCornerRadiusId).isEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX) public void updateRelayoutParams_shouldIgnoreCornerRadius_roundedCornersNotSet() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); RelayoutParams relayoutParams = new RelayoutParams(); DesktopModeWindowDecoration.updateRelayoutParams( relayoutParams, mTestableContext, taskInfo, mMockSplitScreenController, DEFAULT_APPLY_START_TRANSACTION_ON_DRAW, DEFAULT_SHOULD_SET_TASK_POSITIONING_AND_CROP, DEFAULT_IS_STATUSBAR_VISIBLE, DEFAULT_IS_KEYGUARD_VISIBLE_AND_OCCLUDED, DEFAULT_IS_IN_FULL_IMMERSIVE_MODE, DEFAULT_IS_DRAGGING, new InsetsState(), DEFAULT_HAS_GLOBAL_FOCUS, mExclusionRegion, /* shouldIgnoreCornerRadius= */ true, DEFAULT_SHOULD_EXCLUDE_CAPTION_FROM_APP_BOUNDS, DEFAULT_IS_RECENTS_TRANSITION_RUNNING, DEFAULT_IS_MOVING_TO_BACK); assertThat(relayoutParams.mCornerRadiusId).isEqualTo(Resources.ID_NULL); } @Test @EnableFlags(Flags.FLAG_ENABLE_APP_HEADER_WITH_TASK_DENSITY) public void updateRelayoutParams_appHeader_usesTaskDensity() { Loading