Merge "Polish activity transition for letterbox" into tm-qpr-dev am: c3a33cde83
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18320843 Change-Id: I92dc418580d4503ee80ae9d94520d4b5d2c92009 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -660,6 +660,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
|
|
||||||
boolean mUseTransferredAnimation;
|
boolean mUseTransferredAnimation;
|
||||||
|
|
||||||
|
/** Whether we need to setup the animation to animate only within the letterbox. */
|
||||||
|
private boolean mNeedsLetterboxedAnimation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #currentLaunchCanTurnScreenOn()
|
* @see #currentLaunchCanTurnScreenOn()
|
||||||
*/
|
*/
|
||||||
@@ -1762,8 +1765,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
mLetterboxUiController.layoutLetterbox(winHint);
|
mLetterboxUiController.layoutLetterbox(winHint);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasWallpaperBackgroudForLetterbox() {
|
boolean hasWallpaperBackgroundForLetterbox() {
|
||||||
return mLetterboxUiController.hasWallpaperBackgroudForLetterbox();
|
return mLetterboxUiController.hasWallpaperBackgroundForLetterbox();
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateLetterboxSurface(WindowState winHint, Transaction t) {
|
||||||
|
mLetterboxUiController.updateLetterboxSurface(winHint, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateLetterboxSurface(WindowState winHint) {
|
void updateLetterboxSurface(WindowState winHint) {
|
||||||
@@ -5334,6 +5341,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
commitVisibility(visible, performLayout, false /* fromTransition */);
|
commitVisibility(visible, performLayout, false /* fromTransition */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setNeedsLetterboxedAnimation(boolean needsLetterboxedAnimation) {
|
||||||
|
mNeedsLetterboxedAnimation = needsLetterboxedAnimation;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isNeedsLetterboxedAnimation() {
|
||||||
|
return mNeedsLetterboxedAnimation;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isInLetterboxAnimation() {
|
||||||
|
return mNeedsLetterboxedAnimation && isAnimating();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post process after applying an app transition animation.
|
* Post process after applying an app transition animation.
|
||||||
*
|
*
|
||||||
@@ -7261,6 +7280,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
.setParent(getAnimationLeashParent())
|
.setParent(getAnimationLeashParent())
|
||||||
.setName(getSurfaceControl() + " - animation-bounds")
|
.setName(getSurfaceControl() + " - animation-bounds")
|
||||||
.setCallsite("ActivityRecord.createAnimationBoundsLayer");
|
.setCallsite("ActivityRecord.createAnimationBoundsLayer");
|
||||||
|
if (mNeedsLetterboxedAnimation) {
|
||||||
|
// Needs to be an effect layer to support rounded corners
|
||||||
|
builder.setEffectLayer();
|
||||||
|
}
|
||||||
final SurfaceControl boundsLayer = builder.build();
|
final SurfaceControl boundsLayer = builder.build();
|
||||||
t.show(boundsLayer);
|
t.show(boundsLayer);
|
||||||
return boundsLayer;
|
return boundsLayer;
|
||||||
@@ -7298,6 +7321,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
mAnimatingActivityRegistry.notifyStarting(this);
|
mAnimatingActivityRegistry.notifyStarting(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mNeedsLetterboxedAnimation) {
|
||||||
|
updateLetterboxSurface(findMainWindow(), t);
|
||||||
|
mNeedsAnimationBoundsLayer = true;
|
||||||
|
}
|
||||||
|
|
||||||
// If the animation needs to be cropped then an animation bounds layer is created as a
|
// If the animation needs to be cropped then an animation bounds layer is created as a
|
||||||
// child of the root pinned task or animation layer. The leash is then reparented to this
|
// child of the root pinned task or animation layer. The leash is then reparented to this
|
||||||
// new layer.
|
// new layer.
|
||||||
@@ -7320,6 +7348,17 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
t.setLayer(leash, 0);
|
t.setLayer(leash, 0);
|
||||||
t.setLayer(mAnimationBoundsLayer, getLastLayer());
|
t.setLayer(mAnimationBoundsLayer, getLastLayer());
|
||||||
|
|
||||||
|
if (mNeedsLetterboxedAnimation) {
|
||||||
|
final int cornerRadius = mLetterboxUiController
|
||||||
|
.getRoundedCornersRadius(findMainWindow());
|
||||||
|
|
||||||
|
final Rect letterboxInnerBounds = new Rect();
|
||||||
|
getLetterboxInnerBounds(letterboxInnerBounds);
|
||||||
|
|
||||||
|
t.setCornerRadius(mAnimationBoundsLayer, cornerRadius)
|
||||||
|
.setCrop(mAnimationBoundsLayer, letterboxInnerBounds);
|
||||||
|
}
|
||||||
|
|
||||||
// Reparent leash to animation bounds layer.
|
// Reparent leash to animation bounds layer.
|
||||||
t.reparent(leash, mAnimationBoundsLayer);
|
t.reparent(leash, mAnimationBoundsLayer);
|
||||||
}
|
}
|
||||||
@@ -7433,6 +7472,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
mAnimationBoundsLayer = null;
|
mAnimationBoundsLayer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mNeedsAnimationBoundsLayer = false;
|
||||||
|
if (mNeedsLetterboxedAnimation) {
|
||||||
|
mNeedsLetterboxedAnimation = false;
|
||||||
|
updateLetterboxSurface(findMainWindow(), t);
|
||||||
|
}
|
||||||
|
|
||||||
if (mAnimatingActivityRegistry != null) {
|
if (mAnimatingActivityRegistry != null) {
|
||||||
mAnimatingActivityRegistry.notifyFinished(this);
|
mAnimatingActivityRegistry.notifyFinished(this);
|
||||||
}
|
}
|
||||||
@@ -7445,7 +7490,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "AR#onAnimationFinished");
|
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "AR#onAnimationFinished");
|
||||||
mTransit = TRANSIT_OLD_UNSET;
|
mTransit = TRANSIT_OLD_UNSET;
|
||||||
mTransitFlags = 0;
|
mTransitFlags = 0;
|
||||||
mNeedsAnimationBoundsLayer = false;
|
|
||||||
|
|
||||||
setAppLayoutChanges(FINISH_LAYOUT_REDO_ANIM | FINISH_LAYOUT_REDO_WALLPAPER,
|
setAppLayoutChanges(FINISH_LAYOUT_REDO_ANIM | FINISH_LAYOUT_REDO_WALLPAPER,
|
||||||
"ActivityRecord");
|
"ActivityRecord");
|
||||||
|
|||||||
@@ -81,9 +81,11 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
|
|||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
|
import android.util.Pair;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.RemoteAnimationAdapter;
|
import android.view.RemoteAnimationAdapter;
|
||||||
@@ -1028,6 +1030,32 @@ public class AppTransitionController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AppTransition.isActivityTransitOld(transit)) {
|
||||||
|
final ArrayList<Pair<ActivityRecord, Rect>> closingLetterboxes = new ArrayList();
|
||||||
|
for (int i = 0; i < closingApps.size(); ++i) {
|
||||||
|
ActivityRecord closingApp = closingApps.valueAt(i);
|
||||||
|
if (closingApp.areBoundsLetterboxed()) {
|
||||||
|
final Rect insets = closingApp.getLetterboxInsets();
|
||||||
|
closingLetterboxes.add(new Pair(closingApp, insets));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < openingApps.size(); ++i) {
|
||||||
|
ActivityRecord openingApp = openingApps.valueAt(i);
|
||||||
|
if (openingApp.areBoundsLetterboxed()) {
|
||||||
|
final Rect openingInsets = openingApp.getLetterboxInsets();
|
||||||
|
for (Pair<ActivityRecord, Rect> closingLetterbox : closingLetterboxes) {
|
||||||
|
final Rect closingInsets = closingLetterbox.second;
|
||||||
|
if (openingInsets.equals(closingInsets)) {
|
||||||
|
ActivityRecord closingApp = closingLetterbox.first;
|
||||||
|
openingApp.setNeedsLetterboxedAnimation(true);
|
||||||
|
closingApp.setNeedsLetterboxedAnimation(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final ArraySet<WindowContainer> openingWcs = getAnimationTargets(
|
final ArraySet<WindowContainer> openingWcs = getAnimationTargets(
|
||||||
openingApps, closingApps, true /* visible */);
|
openingApps, closingApps, true /* visible */);
|
||||||
final ArraySet<WindowContainer> closingWcs = getAnimationTargets(
|
final ArraySet<WindowContainer> closingWcs = getAnimationTargets(
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class Letterbox {
|
|||||||
private final Supplier<Boolean> mHasWallpaperBackgroundSupplier;
|
private final Supplier<Boolean> mHasWallpaperBackgroundSupplier;
|
||||||
private final Supplier<Integer> mBlurRadiusSupplier;
|
private final Supplier<Integer> mBlurRadiusSupplier;
|
||||||
private final Supplier<Float> mDarkScrimAlphaSupplier;
|
private final Supplier<Float> mDarkScrimAlphaSupplier;
|
||||||
|
private final Supplier<SurfaceControl> mParentSurfaceSupplier;
|
||||||
|
|
||||||
private final Rect mOuter = new Rect();
|
private final Rect mOuter = new Rect();
|
||||||
private final Rect mInner = new Rect();
|
private final Rect mInner = new Rect();
|
||||||
@@ -87,7 +88,8 @@ public class Letterbox {
|
|||||||
Supplier<Integer> blurRadiusSupplier,
|
Supplier<Integer> blurRadiusSupplier,
|
||||||
Supplier<Float> darkScrimAlphaSupplier,
|
Supplier<Float> darkScrimAlphaSupplier,
|
||||||
IntConsumer doubleTapCallbackX,
|
IntConsumer doubleTapCallbackX,
|
||||||
IntConsumer doubleTapCallbackY) {
|
IntConsumer doubleTapCallbackY,
|
||||||
|
Supplier<SurfaceControl> parentSurface) {
|
||||||
mSurfaceControlFactory = surfaceControlFactory;
|
mSurfaceControlFactory = surfaceControlFactory;
|
||||||
mTransactionFactory = transactionFactory;
|
mTransactionFactory = transactionFactory;
|
||||||
mAreCornersRounded = areCornersRounded;
|
mAreCornersRounded = areCornersRounded;
|
||||||
@@ -97,6 +99,7 @@ public class Letterbox {
|
|||||||
mDarkScrimAlphaSupplier = darkScrimAlphaSupplier;
|
mDarkScrimAlphaSupplier = darkScrimAlphaSupplier;
|
||||||
mDoubleTapCallbackX = doubleTapCallbackX;
|
mDoubleTapCallbackX = doubleTapCallbackX;
|
||||||
mDoubleTapCallbackY = doubleTapCallbackY;
|
mDoubleTapCallbackY = doubleTapCallbackY;
|
||||||
|
mParentSurfaceSupplier = parentSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,7 +124,6 @@ public class Letterbox {
|
|||||||
mFullWindowSurface.layout(outer.left, outer.top, outer.right, outer.bottom, surfaceOrigin);
|
mFullWindowSurface.layout(outer.left, outer.top, outer.right, outer.bottom, surfaceOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the insets between the outer and inner rects.
|
* Gets the insets between the outer and inner rects.
|
||||||
*/
|
*/
|
||||||
@@ -333,6 +335,7 @@ public class Letterbox {
|
|||||||
private SurfaceControl mSurface;
|
private SurfaceControl mSurface;
|
||||||
private Color mColor;
|
private Color mColor;
|
||||||
private boolean mHasWallpaperBackground;
|
private boolean mHasWallpaperBackground;
|
||||||
|
private SurfaceControl mParentSurface;
|
||||||
|
|
||||||
private final Rect mSurfaceFrameRelative = new Rect();
|
private final Rect mSurfaceFrameRelative = new Rect();
|
||||||
private final Rect mLayoutFrameGlobal = new Rect();
|
private final Rect mLayoutFrameGlobal = new Rect();
|
||||||
@@ -403,10 +406,12 @@ public class Letterbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mColor = mColorSupplier.get();
|
mColor = mColorSupplier.get();
|
||||||
|
mParentSurface = mParentSurfaceSupplier.get();
|
||||||
t.setColor(mSurface, getRgbColorArray());
|
t.setColor(mSurface, getRgbColorArray());
|
||||||
t.setPosition(mSurface, mSurfaceFrameRelative.left, mSurfaceFrameRelative.top);
|
t.setPosition(mSurface, mSurfaceFrameRelative.left, mSurfaceFrameRelative.top);
|
||||||
t.setWindowCrop(mSurface, mSurfaceFrameRelative.width(),
|
t.setWindowCrop(mSurface, mSurfaceFrameRelative.width(),
|
||||||
mSurfaceFrameRelative.height());
|
mSurfaceFrameRelative.height());
|
||||||
|
t.reparent(mSurface, mParentSurface);
|
||||||
|
|
||||||
mHasWallpaperBackground = mHasWallpaperBackgroundSupplier.get();
|
mHasWallpaperBackground = mHasWallpaperBackgroundSupplier.get();
|
||||||
updateAlphaAndBlur(t);
|
updateAlphaAndBlur(t);
|
||||||
@@ -452,12 +457,13 @@ public class Letterbox {
|
|||||||
|
|
||||||
public boolean needsApplySurfaceChanges() {
|
public boolean needsApplySurfaceChanges() {
|
||||||
return !mSurfaceFrameRelative.equals(mLayoutFrameRelative)
|
return !mSurfaceFrameRelative.equals(mLayoutFrameRelative)
|
||||||
// If mSurfaceFrameRelative is empty then mHasWallpaperBackground and mColor
|
// If mSurfaceFrameRelative is empty then mHasWallpaperBackground, mColor,
|
||||||
// may never be updated in applySurfaceChanges but this doesn't mean that
|
// and mParentSurface may never be updated in applySurfaceChanges but this
|
||||||
// update is needed.
|
// doesn't mean that update is needed.
|
||||||
|| !mSurfaceFrameRelative.isEmpty()
|
|| !mSurfaceFrameRelative.isEmpty()
|
||||||
&& (mHasWallpaperBackgroundSupplier.get() != mHasWallpaperBackground
|
&& (mHasWallpaperBackgroundSupplier.get() != mHasWallpaperBackground
|
||||||
|| !mColorSupplier.get().equals(mColor));
|
|| !mColorSupplier.get().equals(mColor)
|
||||||
|
|| mParentSurfaceSupplier.get() != mParentSurface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ final class LetterboxConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides corners raidus for activities presented in the letterbox mode. If given value < 0,
|
* Overrides corners radius for activities presented in the letterbox mode. If given value < 0,
|
||||||
* both it and a value of {@link
|
* both it and a value of {@link
|
||||||
* com.android.internal.R.integer.config_letterboxActivityCornersRadius} will be ignored and
|
* com.android.internal.R.integer.config_letterboxActivityCornersRadius} will be ignored and
|
||||||
* corners of the activity won't be rounded.
|
* corners of the activity won't be rounded.
|
||||||
@@ -275,7 +275,7 @@ final class LetterboxConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets corners raidus for activities presented in the letterbox mode to {@link
|
* Resets corners radius for activities presented in the letterbox mode to {@link
|
||||||
* com.android.internal.R.integer.config_letterboxActivityCornersRadius}.
|
* com.android.internal.R.integer.config_letterboxActivityCornersRadius}.
|
||||||
*/
|
*/
|
||||||
void resetLetterboxActivityCornersRadius() {
|
void resetLetterboxActivityCornersRadius() {
|
||||||
@@ -291,7 +291,7 @@ final class LetterboxConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets corners raidus for activities presented in the letterbox mode.
|
* Gets corners radius for activities presented in the letterbox mode.
|
||||||
*/
|
*/
|
||||||
int getLetterboxActivityCornersRadius() {
|
int getLetterboxActivityCornersRadius() {
|
||||||
return mLetterboxActivityCornersRadius;
|
return mLetterboxActivityCornersRadius;
|
||||||
@@ -318,7 +318,7 @@ final class LetterboxConfiguration {
|
|||||||
/**
|
/**
|
||||||
* Sets color of letterbox background which is used when {@link
|
* Sets color of letterbox background which is used when {@link
|
||||||
* #getLetterboxBackgroundType()} is {@link #LETTERBOX_BACKGROUND_SOLID_COLOR} or as
|
* #getLetterboxBackgroundType()} is {@link #LETTERBOX_BACKGROUND_SOLID_COLOR} or as
|
||||||
* fallback for other backfround types.
|
* fallback for other background types.
|
||||||
*/
|
*/
|
||||||
void setLetterboxBackgroundColor(Color color) {
|
void setLetterboxBackgroundColor(Color color) {
|
||||||
mLetterboxBackgroundColorOverride = color;
|
mLetterboxBackgroundColorOverride = color;
|
||||||
@@ -327,7 +327,7 @@ final class LetterboxConfiguration {
|
|||||||
/**
|
/**
|
||||||
* Sets color ID of letterbox background which is used when {@link
|
* Sets color ID of letterbox background which is used when {@link
|
||||||
* #getLetterboxBackgroundType()} is {@link #LETTERBOX_BACKGROUND_SOLID_COLOR} or as
|
* #getLetterboxBackgroundType()} is {@link #LETTERBOX_BACKGROUND_SOLID_COLOR} or as
|
||||||
* fallback for other backfround types.
|
* fallback for other background types.
|
||||||
*/
|
*/
|
||||||
void setLetterboxBackgroundColorResourceId(int colorId) {
|
void setLetterboxBackgroundColorResourceId(int colorId) {
|
||||||
mLetterboxBackgroundColorResourceIdOverride = colorId;
|
mLetterboxBackgroundColorResourceIdOverride = colorId;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ final class LetterboxUiController {
|
|||||||
|
|
||||||
// Taskbar expanded height. Used to determine whether to crop an app window to display rounded
|
// Taskbar expanded height. Used to determine whether to crop an app window to display rounded
|
||||||
// corners above the taskbar.
|
// corners above the taskbar.
|
||||||
private float mExpandedTaskBarHeight;
|
private final float mExpandedTaskBarHeight;
|
||||||
|
|
||||||
private boolean mShowWallpaperForLetterboxBackground;
|
private boolean mShowWallpaperForLetterboxBackground;
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ final class LetterboxUiController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasWallpaperBackgroudForLetterbox() {
|
boolean hasWallpaperBackgroundForLetterbox() {
|
||||||
return mShowWallpaperForLetterboxBackground;
|
return mShowWallpaperForLetterboxBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +137,11 @@ final class LetterboxUiController {
|
|||||||
void getLetterboxInnerBounds(Rect outBounds) {
|
void getLetterboxInnerBounds(Rect outBounds) {
|
||||||
if (mLetterbox != null) {
|
if (mLetterbox != null) {
|
||||||
outBounds.set(mLetterbox.getInnerFrame());
|
outBounds.set(mLetterbox.getInnerFrame());
|
||||||
|
final WindowState w = mActivityRecord.findMainWindow();
|
||||||
|
if (w == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
adjustBoundsForTaskbar(w, outBounds);
|
||||||
} else {
|
} else {
|
||||||
outBounds.setEmpty();
|
outBounds.setEmpty();
|
||||||
}
|
}
|
||||||
@@ -160,13 +165,17 @@ final class LetterboxUiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateLetterboxSurface(WindowState winHint) {
|
void updateLetterboxSurface(WindowState winHint) {
|
||||||
|
updateLetterboxSurface(winHint, mActivityRecord.getSyncTransaction());
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateLetterboxSurface(WindowState winHint, Transaction t) {
|
||||||
final WindowState w = mActivityRecord.findMainWindow();
|
final WindowState w = mActivityRecord.findMainWindow();
|
||||||
if (w != winHint && winHint != null && w != null) {
|
if (w != winHint && winHint != null && w != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
layoutLetterbox(winHint);
|
layoutLetterbox(winHint);
|
||||||
if (mLetterbox != null && mLetterbox.needsApplySurfaceChanges()) {
|
if (mLetterbox != null && mLetterbox.needsApplySurfaceChanges()) {
|
||||||
mLetterbox.applySurfaceChanges(mActivityRecord.getSyncTransaction());
|
mLetterbox.applySurfaceChanges(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,14 +200,22 @@ final class LetterboxUiController {
|
|||||||
mActivityRecord.mWmService.mTransactionFactory,
|
mActivityRecord.mWmService.mTransactionFactory,
|
||||||
this::shouldLetterboxHaveRoundedCorners,
|
this::shouldLetterboxHaveRoundedCorners,
|
||||||
this::getLetterboxBackgroundColor,
|
this::getLetterboxBackgroundColor,
|
||||||
this::hasWallpaperBackgroudForLetterbox,
|
this::hasWallpaperBackgroundForLetterbox,
|
||||||
this::getLetterboxWallpaperBlurRadius,
|
this::getLetterboxWallpaperBlurRadius,
|
||||||
this::getLetterboxWallpaperDarkScrimAlpha,
|
this::getLetterboxWallpaperDarkScrimAlpha,
|
||||||
this::handleHorizontalDoubleTap,
|
this::handleHorizontalDoubleTap,
|
||||||
this::handleVerticalDoubleTap);
|
this::handleVerticalDoubleTap,
|
||||||
|
this::getLetterboxParentSurface);
|
||||||
mLetterbox.attachInput(w);
|
mLetterbox.attachInput(w);
|
||||||
}
|
}
|
||||||
mActivityRecord.getPosition(mTmpPoint);
|
|
||||||
|
if (mActivityRecord.isInLetterboxAnimation()) {
|
||||||
|
// In this case we attach the letterbox to the task instead of the activity.
|
||||||
|
mActivityRecord.getTask().getPosition(mTmpPoint);
|
||||||
|
} else {
|
||||||
|
mActivityRecord.getPosition(mTmpPoint);
|
||||||
|
}
|
||||||
|
|
||||||
// Get the bounds of the "space-to-fill". The transformed bounds have the highest
|
// Get the bounds of the "space-to-fill". The transformed bounds have the highest
|
||||||
// priority because the activity is launched in a rotated environment. In multi-window
|
// priority because the activity is launched in a rotated environment. In multi-window
|
||||||
// mode, the task-level represents this. In fullscreen-mode, the task container does
|
// mode, the task-level represents this. In fullscreen-mode, the task container does
|
||||||
@@ -215,6 +232,13 @@ final class LetterboxUiController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SurfaceControl getLetterboxParentSurface() {
|
||||||
|
if (mActivityRecord.isInLetterboxAnimation()) {
|
||||||
|
return mActivityRecord.getTask().getSurfaceControl();
|
||||||
|
}
|
||||||
|
return mActivityRecord.getSurfaceControl();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean shouldLetterboxHaveRoundedCorners() {
|
private boolean shouldLetterboxHaveRoundedCorners() {
|
||||||
// TODO(b/214030873): remove once background is drawn for transparent activities
|
// TODO(b/214030873): remove once background is drawn for transparent activities
|
||||||
// Letterbox shouldn't have rounded corners if the activity is transparent
|
// Letterbox shouldn't have rounded corners if the activity is transparent
|
||||||
@@ -436,7 +460,7 @@ final class LetterboxUiController {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LETTERBOX_BACKGROUND_WALLPAPER:
|
case LETTERBOX_BACKGROUND_WALLPAPER:
|
||||||
if (hasWallpaperBackgroudForLetterbox()) {
|
if (hasWallpaperBackgroundForLetterbox()) {
|
||||||
// Color is used for translucent scrim that dims wallpaper.
|
// Color is used for translucent scrim that dims wallpaper.
|
||||||
return Color.valueOf(Color.BLACK);
|
return Color.valueOf(Color.BLACK);
|
||||||
}
|
}
|
||||||
@@ -459,15 +483,14 @@ final class LetterboxUiController {
|
|||||||
private void updateRoundedCorners(WindowState mainWindow) {
|
private void updateRoundedCorners(WindowState mainWindow) {
|
||||||
final SurfaceControl windowSurface = mainWindow.getClientViewRootSurface();
|
final SurfaceControl windowSurface = mainWindow.getClientViewRootSurface();
|
||||||
if (windowSurface != null && windowSurface.isValid()) {
|
if (windowSurface != null && windowSurface.isValid()) {
|
||||||
Transaction transaction = mActivityRecord.getSyncTransaction();
|
final Transaction transaction = mActivityRecord.getSyncTransaction();
|
||||||
|
|
||||||
final InsetsState insetsState = mainWindow.getInsetsState();
|
if (!requiresRoundedCorners(mainWindow) || mActivityRecord.isInLetterboxAnimation()) {
|
||||||
final InsetsSource taskbarInsetsSource =
|
// We don't want corner radius on the window.
|
||||||
insetsState.peekSource(InsetsState.ITYPE_EXTRA_NAVIGATION_BAR);
|
// In the case the ActivityRecord requires a letterboxed animation we never want
|
||||||
|
// rounded corners on the window because rounded corners are applied at the
|
||||||
if (!isLetterboxedNotForDisplayCutout(mainWindow)
|
// animation-bounds surface level and rounded corners on the window would interfere
|
||||||
|| !mLetterboxConfiguration.isLetterboxActivityCornersRounded()
|
// with that leading to unexpected rounded corner positioning during the animation.
|
||||||
|| taskbarInsetsSource == null) {
|
|
||||||
transaction
|
transaction
|
||||||
.setWindowCrop(windowSurface, null)
|
.setWindowCrop(windowSurface, null)
|
||||||
.setCornerRadius(windowSurface, 0);
|
.setCornerRadius(windowSurface, 0);
|
||||||
@@ -476,48 +499,89 @@ final class LetterboxUiController {
|
|||||||
|
|
||||||
Rect cropBounds = null;
|
Rect cropBounds = null;
|
||||||
|
|
||||||
// Rounded corners should be displayed above the taskbar. When taskbar is hidden,
|
if (hasVisibleTaskbar(mainWindow)) {
|
||||||
// an insets frame is equal to a navigation bar which shouldn't affect position of
|
|
||||||
// rounded corners since apps are expected to handle navigation bar inset.
|
|
||||||
// This condition checks whether the taskbar is visible.
|
|
||||||
// Do not crop the taskbar inset if the window is in immersive mode - the user can
|
|
||||||
// swipe to show/hide the taskbar as an overlay.
|
|
||||||
if (taskbarInsetsSource.getFrame().height() >= mExpandedTaskBarHeight
|
|
||||||
&& taskbarInsetsSource.isVisible()) {
|
|
||||||
cropBounds = new Rect(mActivityRecord.getBounds());
|
cropBounds = new Rect(mActivityRecord.getBounds());
|
||||||
// Activity bounds are in screen coordinates while (0,0) for activity's surface
|
// Activity bounds are in screen coordinates while (0,0) for activity's surface
|
||||||
// control is at the top left corner of an app window so offsetting bounds
|
// control is at the top left corner of an app window so offsetting bounds
|
||||||
// accordingly.
|
// accordingly.
|
||||||
cropBounds.offsetTo(0, 0);
|
cropBounds.offsetTo(0, 0);
|
||||||
// Rounded cornerners should be displayed above the taskbar.
|
// Rounded corners should be displayed above the taskbar.
|
||||||
cropBounds.bottom =
|
adjustBoundsForTaskbarUnchecked(mainWindow, cropBounds);
|
||||||
Math.min(cropBounds.bottom, taskbarInsetsSource.getFrame().top);
|
|
||||||
if (mActivityRecord.inSizeCompatMode()
|
|
||||||
&& mActivityRecord.getSizeCompatScale() < 1.0f) {
|
|
||||||
cropBounds.scale(1.0f / mActivityRecord.getSizeCompatScale());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction
|
transaction
|
||||||
.setWindowCrop(windowSurface, cropBounds)
|
.setWindowCrop(windowSurface, cropBounds)
|
||||||
.setCornerRadius(windowSurface, getRoundedCorners(insetsState));
|
.setCornerRadius(windowSurface, getRoundedCornersRadius(mainWindow));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns rounded corners radius based on override in
|
private boolean requiresRoundedCorners(WindowState mainWindow) {
|
||||||
|
final InsetsSource taskbarInsetsSource = getTaskbarInsetsSource(mainWindow);
|
||||||
|
|
||||||
|
return isLetterboxedNotForDisplayCutout(mainWindow)
|
||||||
|
&& mLetterboxConfiguration.isLetterboxActivityCornersRounded()
|
||||||
|
&& taskbarInsetsSource != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns rounded corners radius the letterboxed activity should have based on override in
|
||||||
// R.integer.config_letterboxActivityCornersRadius or min device bottom corner radii.
|
// R.integer.config_letterboxActivityCornersRadius or min device bottom corner radii.
|
||||||
// Device corners can be different on the right and left sides but we use the same radius
|
// Device corners can be different on the right and left sides but we use the same radius
|
||||||
// for all corners for consistency and pick a minimal bottom one for consistency with a
|
// for all corners for consistency and pick a minimal bottom one for consistency with a
|
||||||
// taskbar rounded corners.
|
// taskbar rounded corners.
|
||||||
private int getRoundedCorners(InsetsState insetsState) {
|
int getRoundedCornersRadius(WindowState mainWindow) {
|
||||||
|
if (!requiresRoundedCorners(mainWindow)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (mLetterboxConfiguration.getLetterboxActivityCornersRadius() >= 0) {
|
if (mLetterboxConfiguration.getLetterboxActivityCornersRadius() >= 0) {
|
||||||
return mLetterboxConfiguration.getLetterboxActivityCornersRadius();
|
return mLetterboxConfiguration.getLetterboxActivityCornersRadius();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final InsetsState insetsState = mainWindow.getInsetsState();
|
||||||
return Math.min(
|
return Math.min(
|
||||||
getInsetsStateCornerRadius(insetsState, RoundedCorner.POSITION_BOTTOM_LEFT),
|
getInsetsStateCornerRadius(insetsState, RoundedCorner.POSITION_BOTTOM_LEFT),
|
||||||
getInsetsStateCornerRadius(insetsState, RoundedCorner.POSITION_BOTTOM_RIGHT));
|
getInsetsStateCornerRadius(insetsState, RoundedCorner.POSITION_BOTTOM_RIGHT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the taskbar is visible. Returns false if the window is in immersive mode,
|
||||||
|
* since the user can swipe to show/hide the taskbar as an overlay.
|
||||||
|
*/
|
||||||
|
private boolean hasVisibleTaskbar(WindowState mainWindow) {
|
||||||
|
final InsetsSource taskbarInsetsSource = getTaskbarInsetsSource(mainWindow);
|
||||||
|
|
||||||
|
return taskbarInsetsSource != null
|
||||||
|
&& taskbarInsetsSource.getFrame().height() >= mExpandedTaskBarHeight
|
||||||
|
&& taskbarInsetsSource.isVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
private InsetsSource getTaskbarInsetsSource(WindowState mainWindow) {
|
||||||
|
final InsetsState insetsState = mainWindow.getInsetsState();
|
||||||
|
return insetsState.peekSource(InsetsState.ITYPE_EXTRA_NAVIGATION_BAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void adjustBoundsForTaskbar(WindowState mainWindow, Rect bounds) {
|
||||||
|
// Rounded corners should be displayed above the taskbar. When taskbar is hidden,
|
||||||
|
// an insets frame is equal to a navigation bar which shouldn't affect position of
|
||||||
|
// rounded corners since apps are expected to handle navigation bar inset.
|
||||||
|
// This condition checks whether the taskbar is visible.
|
||||||
|
// Do not crop the taskbar inset if the window is in immersive mode - the user can
|
||||||
|
// swipe to show/hide the taskbar as an overlay.
|
||||||
|
if (hasVisibleTaskbar(mainWindow)) {
|
||||||
|
adjustBoundsForTaskbarUnchecked(mainWindow, bounds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void adjustBoundsForTaskbarUnchecked(WindowState mainWindow, Rect bounds) {
|
||||||
|
// Rounded corners should be displayed above the taskbar.
|
||||||
|
bounds.bottom =
|
||||||
|
Math.min(bounds.bottom, getTaskbarInsetsSource(mainWindow).getFrame().top);
|
||||||
|
if (mActivityRecord.inSizeCompatMode()
|
||||||
|
&& mActivityRecord.getSizeCompatScale() < 1.0f) {
|
||||||
|
bounds.scale(1.0f / mActivityRecord.getSizeCompatScale());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int getInsetsStateCornerRadius(
|
private int getInsetsStateCornerRadius(
|
||||||
InsetsState insetsState, @RoundedCorner.Position int position) {
|
InsetsState insetsState, @RoundedCorner.Position int position) {
|
||||||
RoundedCorner corner = insetsState.getRoundedCorners().getRoundedCorner(position);
|
RoundedCorner corner = insetsState.getRoundedCorners().getRoundedCorner(position);
|
||||||
@@ -592,7 +656,7 @@ final class LetterboxUiController {
|
|||||||
+ letterboxBackgroundTypeToString(
|
+ letterboxBackgroundTypeToString(
|
||||||
mLetterboxConfiguration.getLetterboxBackgroundType()));
|
mLetterboxConfiguration.getLetterboxBackgroundType()));
|
||||||
pw.println(prefix + " letterboxCornerRadius="
|
pw.println(prefix + " letterboxCornerRadius="
|
||||||
+ getRoundedCorners(mainWin.getInsetsState()));
|
+ getRoundedCornersRadius(mainWin));
|
||||||
if (mLetterboxConfiguration.getLetterboxBackgroundType()
|
if (mLetterboxConfiguration.getLetterboxBackgroundType()
|
||||||
== LETTERBOX_BACKGROUND_WALLPAPER) {
|
== LETTERBOX_BACKGROUND_WALLPAPER) {
|
||||||
pw.println(prefix + " isLetterboxWallpaperBlurSupported="
|
pw.println(prefix + " isLetterboxWallpaperBlurSupported="
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ import android.animation.Animator;
|
|||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
import android.graphics.BitmapShader;
|
||||||
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Insets;
|
import android.graphics.Insets;
|
||||||
|
import android.graphics.Paint;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.hardware.power.Boost;
|
import android.hardware.power.Boost;
|
||||||
@@ -374,43 +377,45 @@ class SurfaceAnimationRunner {
|
|||||||
final int targetSurfaceWidth = bounds.width();
|
final int targetSurfaceWidth = bounds.width();
|
||||||
|
|
||||||
if (maxExtensionInsets.left < 0) {
|
if (maxExtensionInsets.left < 0) {
|
||||||
final Rect edgeBounds = new Rect(0, 0, 1, targetSurfaceHeight);
|
final Rect edgeBounds = new Rect(bounds.left, bounds.top, bounds.left + 1,
|
||||||
|
bounds.bottom);
|
||||||
final Rect extensionRect = new Rect(0, 0,
|
final Rect extensionRect = new Rect(0, 0,
|
||||||
-maxExtensionInsets.left, targetSurfaceHeight);
|
-maxExtensionInsets.left, targetSurfaceHeight);
|
||||||
final int xPos = maxExtensionInsets.left;
|
final int xPos = bounds.left + maxExtensionInsets.left;
|
||||||
final int yPos = 0;
|
final int yPos = bounds.top;
|
||||||
createExtensionSurface(leash, edgeBounds,
|
createExtensionSurface(leash, edgeBounds,
|
||||||
extensionRect, xPos, yPos, "Left Edge Extension", transaction);
|
extensionRect, xPos, yPos, "Left Edge Extension", transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxExtensionInsets.top < 0) {
|
if (maxExtensionInsets.top < 0) {
|
||||||
final Rect edgeBounds = new Rect(0, 0, targetSurfaceWidth, 1);
|
final Rect edgeBounds = new Rect(bounds.left, bounds.top, targetSurfaceWidth,
|
||||||
|
bounds.top + 1);
|
||||||
final Rect extensionRect = new Rect(0, 0,
|
final Rect extensionRect = new Rect(0, 0,
|
||||||
targetSurfaceWidth, -maxExtensionInsets.top);
|
targetSurfaceWidth, -maxExtensionInsets.top);
|
||||||
final int xPos = 0;
|
final int xPos = bounds.left;
|
||||||
final int yPos = maxExtensionInsets.top;
|
final int yPos = bounds.top + maxExtensionInsets.top;
|
||||||
createExtensionSurface(leash, edgeBounds,
|
createExtensionSurface(leash, edgeBounds,
|
||||||
extensionRect, xPos, yPos, "Top Edge Extension", transaction);
|
extensionRect, xPos, yPos, "Top Edge Extension", transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxExtensionInsets.right < 0) {
|
if (maxExtensionInsets.right < 0) {
|
||||||
final Rect edgeBounds = new Rect(targetSurfaceWidth - 1, 0,
|
final Rect edgeBounds = new Rect(bounds.right - 1, bounds.top, bounds.right,
|
||||||
targetSurfaceWidth, targetSurfaceHeight);
|
bounds.bottom);
|
||||||
final Rect extensionRect = new Rect(0, 0,
|
final Rect extensionRect = new Rect(0, 0,
|
||||||
-maxExtensionInsets.right, targetSurfaceHeight);
|
-maxExtensionInsets.right, targetSurfaceHeight);
|
||||||
final int xPos = targetSurfaceWidth;
|
final int xPos = bounds.right;
|
||||||
final int yPos = 0;
|
final int yPos = bounds.top;
|
||||||
createExtensionSurface(leash, edgeBounds,
|
createExtensionSurface(leash, edgeBounds,
|
||||||
extensionRect, xPos, yPos, "Right Edge Extension", transaction);
|
extensionRect, xPos, yPos, "Right Edge Extension", transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxExtensionInsets.bottom < 0) {
|
if (maxExtensionInsets.bottom < 0) {
|
||||||
final Rect edgeBounds = new Rect(0, targetSurfaceHeight - 1,
|
final Rect edgeBounds = new Rect(bounds.left, bounds.bottom - 1,
|
||||||
targetSurfaceWidth, targetSurfaceHeight);
|
bounds.right, bounds.bottom);
|
||||||
final Rect extensionRect = new Rect(0, 0,
|
final Rect extensionRect = new Rect(0, 0,
|
||||||
targetSurfaceWidth, -maxExtensionInsets.bottom);
|
targetSurfaceWidth, -maxExtensionInsets.bottom);
|
||||||
final int xPos = maxExtensionInsets.left;
|
final int xPos = bounds.left;
|
||||||
final int yPos = targetSurfaceHeight;
|
final int yPos = bounds.bottom;
|
||||||
createExtensionSurface(leash, edgeBounds,
|
createExtensionSurface(leash, edgeBounds,
|
||||||
extensionRect, xPos, yPos, "Bottom Edge Extension", transaction);
|
extensionRect, xPos, yPos, "Bottom Edge Extension", transaction);
|
||||||
}
|
}
|
||||||
@@ -453,16 +458,20 @@ class SurfaceAnimationRunner {
|
|||||||
.setHidden(true)
|
.setHidden(true)
|
||||||
.setCallsite("DefaultTransitionHandler#startAnimation")
|
.setCallsite("DefaultTransitionHandler#startAnimation")
|
||||||
.setOpaque(true)
|
.setOpaque(true)
|
||||||
.setBufferSize(edgeBounds.width(), edgeBounds.height())
|
.setBufferSize(extensionRect.width(), extensionRect.height())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final Surface surface = new Surface(edgeExtensionLayer);
|
BitmapShader shader = new BitmapShader(edgeBuffer.asBitmap(),
|
||||||
surface.attachAndQueueBufferWithColorSpace(edgeBuffer.getHardwareBuffer(),
|
android.graphics.Shader.TileMode.CLAMP,
|
||||||
edgeBuffer.getColorSpace());
|
android.graphics.Shader.TileMode.CLAMP);
|
||||||
surface.release();
|
final Paint paint = new Paint();
|
||||||
|
paint.setShader(shader);
|
||||||
|
|
||||||
final float scaleX = getScaleXForExtensionSurface(edgeBounds, extensionRect);
|
final Surface surface = new Surface(edgeExtensionLayer);
|
||||||
final float scaleY = getScaleYForExtensionSurface(edgeBounds, extensionRect);
|
Canvas c = surface.lockHardwareCanvas();
|
||||||
|
c.drawRect(extensionRect, paint);
|
||||||
|
surface.unlockCanvasAndPost(c);
|
||||||
|
surface.release();
|
||||||
|
|
||||||
synchronized (mEdgeExtensionLock) {
|
synchronized (mEdgeExtensionLock) {
|
||||||
if (!mEdgeExtensions.containsKey(leash)) {
|
if (!mEdgeExtensions.containsKey(leash)) {
|
||||||
@@ -472,7 +481,6 @@ class SurfaceAnimationRunner {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
startTransaction.setScale(edgeExtensionLayer, scaleX, scaleY);
|
|
||||||
startTransaction.reparent(edgeExtensionLayer, leash);
|
startTransaction.reparent(edgeExtensionLayer, leash);
|
||||||
startTransaction.setLayer(edgeExtensionLayer, Integer.MIN_VALUE);
|
startTransaction.setLayer(edgeExtensionLayer, Integer.MIN_VALUE);
|
||||||
startTransaction.setPosition(edgeExtensionLayer, xPos, yPos);
|
startTransaction.setPosition(edgeExtensionLayer, xPos, yPos);
|
||||||
@@ -508,8 +516,6 @@ class SurfaceAnimationRunner {
|
|||||||
throw new RuntimeException("Unexpected edgeBounds and extensionRect heights");
|
throw new RuntimeException("Unexpected edgeBounds and extensionRect heights");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static final class RunningAnimation {
|
private static final class RunningAnimation {
|
||||||
final AnimationSpec mAnimSpec;
|
final AnimationSpec mAnimSpec;
|
||||||
final SurfaceControl mLeash;
|
final SurfaceControl mLeash;
|
||||||
|
|||||||
@@ -3015,6 +3015,10 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
|
|||||||
final float windowCornerRadius = !inMultiWindowMode()
|
final float windowCornerRadius = !inMultiWindowMode()
|
||||||
? getDisplayContent().getWindowCornerRadius()
|
? getDisplayContent().getWindowCornerRadius()
|
||||||
: 0;
|
: 0;
|
||||||
|
if (asActivityRecord() != null
|
||||||
|
&& asActivityRecord().isNeedsLetterboxedAnimation()) {
|
||||||
|
asActivityRecord().getLetterboxInnerBounds(mTmpRect);
|
||||||
|
}
|
||||||
AnimationAdapter adapter = new LocalAnimationAdapter(
|
AnimationAdapter adapter = new LocalAnimationAdapter(
|
||||||
new WindowAnimationSpec(a, mTmpPoint, mTmpRect,
|
new WindowAnimationSpec(a, mTmpPoint, mTmpRect,
|
||||||
getDisplayContent().mAppTransition.canSkipFirstFrame(),
|
getDisplayContent().mAppTransition.canSkipFirstFrame(),
|
||||||
|
|||||||
@@ -6053,7 +6053,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean hasWallpaperForLetterboxBackground() {
|
boolean hasWallpaperForLetterboxBackground() {
|
||||||
return mActivityRecord != null && mActivityRecord.hasWallpaperBackgroudForLetterbox();
|
return mActivityRecord != null && mActivityRecord.hasWallpaperBackgroundForLetterbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class LetterboxTest {
|
|||||||
private boolean mHasWallpaperBackground = false;
|
private boolean mHasWallpaperBackground = false;
|
||||||
private int mBlurRadius = 0;
|
private int mBlurRadius = 0;
|
||||||
private float mDarkScrimAlpha = 0.5f;
|
private float mDarkScrimAlpha = 0.5f;
|
||||||
|
private SurfaceControl mParentSurface = mock(SurfaceControl.class);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@@ -63,7 +64,8 @@ public class LetterboxTest {
|
|||||||
mLetterbox = new Letterbox(mSurfaces, StubTransaction::new,
|
mLetterbox = new Letterbox(mSurfaces, StubTransaction::new,
|
||||||
() -> mAreCornersRounded, () -> Color.valueOf(mColor),
|
() -> mAreCornersRounded, () -> Color.valueOf(mColor),
|
||||||
() -> mHasWallpaperBackground, () -> mBlurRadius, () -> mDarkScrimAlpha,
|
() -> mHasWallpaperBackground, () -> mBlurRadius, () -> mDarkScrimAlpha,
|
||||||
/* doubleTapCallbackX= */ x -> {}, /* doubleTapCallbackY= */ y -> {});
|
/* doubleTapCallbackX= */ x -> {}, /* doubleTapCallbackY= */ y -> {},
|
||||||
|
() -> mParentSurface);
|
||||||
mTransaction = spy(StubTransaction.class);
|
mTransaction = spy(StubTransaction.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,6 +206,22 @@ public class LetterboxTest {
|
|||||||
verify(mTransaction).setAlpha(mSurfaces.fullWindowSurface, mDarkScrimAlpha);
|
verify(mTransaction).setAlpha(mSurfaces.fullWindowSurface, mDarkScrimAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNeedsApplySurfaceChanges_setParentSurface() {
|
||||||
|
mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000));
|
||||||
|
mLetterbox.applySurfaceChanges(mTransaction);
|
||||||
|
|
||||||
|
verify(mTransaction).reparent(mSurfaces.top, mParentSurface);
|
||||||
|
assertFalse(mLetterbox.needsApplySurfaceChanges());
|
||||||
|
|
||||||
|
mParentSurface = mock(SurfaceControl.class);
|
||||||
|
|
||||||
|
assertTrue(mLetterbox.needsApplySurfaceChanges());
|
||||||
|
|
||||||
|
mLetterbox.applySurfaceChanges(mTransaction);
|
||||||
|
verify(mTransaction).reparent(mSurfaces.top, mParentSurface);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplySurfaceChanges_cornersNotRounded_surfaceFullWindowSurfaceNotCreated() {
|
public void testApplySurfaceChanges_cornersNotRounded_surfaceFullWindowSurfaceNotCreated() {
|
||||||
mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000));
|
mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000));
|
||||||
|
|||||||
Reference in New Issue
Block a user