Merge "Create separate source of truth for display info" into udc-dev am: b3b1502e23

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21916011

Change-Id: I786a2da8b87a290824c19007eed59329fb5115e0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Ikram Gabiyev
2023-03-09 19:19:08 +00:00
committed by Automerger Merge Worker
19 changed files with 287 additions and 188 deletions

View File

@@ -31,6 +31,7 @@ import com.android.wm.shell.common.annotations.ShellMainThread;
import com.android.wm.shell.pip.Pip; import com.android.wm.shell.pip.Pip;
import com.android.wm.shell.pip.PipAnimationController; import com.android.wm.shell.pip.PipAnimationController;
import com.android.wm.shell.pip.PipAppOpsListener; import com.android.wm.shell.pip.PipAppOpsListener;
import com.android.wm.shell.pip.PipDisplayLayoutState;
import com.android.wm.shell.pip.PipMediaController; import com.android.wm.shell.pip.PipMediaController;
import com.android.wm.shell.pip.PipParamsChangedForwarder; import com.android.wm.shell.pip.PipParamsChangedForwarder;
import com.android.wm.shell.pip.PipSnapAlgorithm; import com.android.wm.shell.pip.PipSnapAlgorithm;
@@ -70,7 +71,7 @@ public abstract class TvPipModule {
ShellInit shellInit, ShellInit shellInit,
ShellController shellController, ShellController shellController,
TvPipBoundsState tvPipBoundsState, TvPipBoundsState tvPipBoundsState,
PipSizeSpecHandler pipSizeSpecHandler, PipDisplayLayoutState pipDisplayLayoutState,
TvPipBoundsAlgorithm tvPipBoundsAlgorithm, TvPipBoundsAlgorithm tvPipBoundsAlgorithm,
TvPipBoundsController tvPipBoundsController, TvPipBoundsController tvPipBoundsController,
PipAppOpsListener pipAppOpsListener, PipAppOpsListener pipAppOpsListener,
@@ -91,7 +92,7 @@ public abstract class TvPipModule {
shellInit, shellInit,
shellController, shellController,
tvPipBoundsState, tvPipBoundsState,
pipSizeSpecHandler, pipDisplayLayoutState,
tvPipBoundsAlgorithm, tvPipBoundsAlgorithm,
tvPipBoundsController, tvPipBoundsController,
pipAppOpsListener, pipAppOpsListener,
@@ -141,14 +142,15 @@ public abstract class TvPipModule {
@WMSingleton @WMSingleton
@Provides @Provides
static TvPipBoundsState provideTvPipBoundsState(Context context, static TvPipBoundsState provideTvPipBoundsState(Context context,
PipSizeSpecHandler pipSizeSpecHandler) { PipSizeSpecHandler pipSizeSpecHandler, PipDisplayLayoutState pipDisplayLayoutState) {
return new TvPipBoundsState(context, pipSizeSpecHandler); return new TvPipBoundsState(context, pipSizeSpecHandler, pipDisplayLayoutState);
} }
@WMSingleton @WMSingleton
@Provides @Provides
static PipSizeSpecHandler providePipSizeSpecHelper(Context context) { static PipSizeSpecHandler providePipSizeSpecHelper(Context context,
return new PipSizeSpecHandler(context); PipDisplayLayoutState pipDisplayLayoutState) {
return new PipSizeSpecHandler(context, pipDisplayLayoutState);
} }
// Handler needed for loadDrawableAsync() in PipControlsViewController // Handler needed for loadDrawableAsync() in PipControlsViewController
@@ -203,7 +205,7 @@ public abstract class TvPipModule {
TvPipMenuController tvPipMenuController, TvPipMenuController tvPipMenuController,
SyncTransactionQueue syncTransactionQueue, SyncTransactionQueue syncTransactionQueue,
TvPipBoundsState tvPipBoundsState, TvPipBoundsState tvPipBoundsState,
PipSizeSpecHandler pipSizeSpecHandler, PipDisplayLayoutState pipDisplayLayoutState,
PipTransitionState pipTransitionState, PipTransitionState pipTransitionState,
TvPipBoundsAlgorithm tvPipBoundsAlgorithm, TvPipBoundsAlgorithm tvPipBoundsAlgorithm,
PipAnimationController pipAnimationController, PipAnimationController pipAnimationController,
@@ -215,7 +217,7 @@ public abstract class TvPipModule {
PipUiEventLogger pipUiEventLogger, ShellTaskOrganizer shellTaskOrganizer, PipUiEventLogger pipUiEventLogger, ShellTaskOrganizer shellTaskOrganizer,
@ShellMainThread ShellExecutor mainExecutor) { @ShellMainThread ShellExecutor mainExecutor) {
return new TvPipTaskOrganizer(context, return new TvPipTaskOrganizer(context,
syncTransactionQueue, pipTransitionState, tvPipBoundsState, pipSizeSpecHandler, syncTransactionQueue, pipTransitionState, tvPipBoundsState, pipDisplayLayoutState,
tvPipBoundsAlgorithm, tvPipMenuController, pipAnimationController, tvPipBoundsAlgorithm, tvPipMenuController, pipAnimationController,
pipSurfaceTransactionHelper, pipTransitionController, pipParamsChangedForwarder, pipSurfaceTransactionHelper, pipTransitionController, pipParamsChangedForwarder,
splitScreenControllerOptional, displayController, pipUiEventLogger, splitScreenControllerOptional, displayController, pipUiEventLogger,

View File

@@ -65,6 +65,7 @@ import com.android.wm.shell.pip.PipAnimationController;
import com.android.wm.shell.pip.PipAppOpsListener; import com.android.wm.shell.pip.PipAppOpsListener;
import com.android.wm.shell.pip.PipBoundsAlgorithm; import com.android.wm.shell.pip.PipBoundsAlgorithm;
import com.android.wm.shell.pip.PipBoundsState; import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipDisplayLayoutState;
import com.android.wm.shell.pip.PipMediaController; import com.android.wm.shell.pip.PipMediaController;
import com.android.wm.shell.pip.PipParamsChangedForwarder; import com.android.wm.shell.pip.PipParamsChangedForwarder;
import com.android.wm.shell.pip.PipSnapAlgorithm; import com.android.wm.shell.pip.PipSnapAlgorithm;
@@ -344,6 +345,7 @@ public abstract class WMShellModule {
PhonePipKeepClearAlgorithm pipKeepClearAlgorithm, PhonePipKeepClearAlgorithm pipKeepClearAlgorithm,
PipBoundsState pipBoundsState, PipBoundsState pipBoundsState,
PipSizeSpecHandler pipSizeSpecHandler, PipSizeSpecHandler pipSizeSpecHandler,
PipDisplayLayoutState pipDisplayLayoutState,
PipMotionHelper pipMotionHelper, PipMotionHelper pipMotionHelper,
PipMediaController pipMediaController, PipMediaController pipMediaController,
PhonePipMenuController phonePipMenuController, PhonePipMenuController phonePipMenuController,
@@ -360,18 +362,18 @@ public abstract class WMShellModule {
return Optional.ofNullable(PipController.create( return Optional.ofNullable(PipController.create(
context, shellInit, shellCommandHandler, shellController, context, shellInit, shellCommandHandler, shellController,
displayController, pipAnimationController, pipAppOpsListener, pipBoundsAlgorithm, displayController, pipAnimationController, pipAppOpsListener, pipBoundsAlgorithm,
pipKeepClearAlgorithm, pipBoundsState, pipSizeSpecHandler, pipMotionHelper, pipKeepClearAlgorithm, pipBoundsState, pipSizeSpecHandler, pipDisplayLayoutState,
pipMediaController, phonePipMenuController, pipTaskOrganizer, pipTransitionState, pipMotionHelper, pipMediaController, phonePipMenuController, pipTaskOrganizer,
pipTouchHandler, pipTransitionController, windowManagerShellWrapper, pipTransitionState, pipTouchHandler, pipTransitionController,
taskStackListener, pipParamsChangedForwarder, displayInsetsController, windowManagerShellWrapper, taskStackListener, pipParamsChangedForwarder,
oneHandedController, mainExecutor)); displayInsetsController, oneHandedController, mainExecutor));
} }
@WMSingleton @WMSingleton
@Provides @Provides
static PipBoundsState providePipBoundsState(Context context, static PipBoundsState providePipBoundsState(Context context,
PipSizeSpecHandler pipSizeSpecHandler) { PipSizeSpecHandler pipSizeSpecHandler, PipDisplayLayoutState pipDisplayLayoutState) {
return new PipBoundsState(context, pipSizeSpecHandler); return new PipBoundsState(context, pipSizeSpecHandler, pipDisplayLayoutState);
} }
@WMSingleton @WMSingleton
@@ -388,8 +390,9 @@ public abstract class WMShellModule {
@WMSingleton @WMSingleton
@Provides @Provides
static PipSizeSpecHandler providePipSizeSpecHelper(Context context) { static PipSizeSpecHandler providePipSizeSpecHelper(Context context,
return new PipSizeSpecHandler(context); PipDisplayLayoutState pipDisplayLayoutState) {
return new PipSizeSpecHandler(context, pipDisplayLayoutState);
} }
@WMSingleton @WMSingleton
@@ -446,7 +449,7 @@ public abstract class WMShellModule {
SyncTransactionQueue syncTransactionQueue, SyncTransactionQueue syncTransactionQueue,
PipTransitionState pipTransitionState, PipTransitionState pipTransitionState,
PipBoundsState pipBoundsState, PipBoundsState pipBoundsState,
PipSizeSpecHandler pipSizeSpecHandler, PipDisplayLayoutState pipDisplayLayoutState,
PipBoundsAlgorithm pipBoundsAlgorithm, PipBoundsAlgorithm pipBoundsAlgorithm,
PhonePipMenuController menuPhoneController, PhonePipMenuController menuPhoneController,
PipAnimationController pipAnimationController, PipAnimationController pipAnimationController,
@@ -458,7 +461,7 @@ public abstract class WMShellModule {
PipUiEventLogger pipUiEventLogger, ShellTaskOrganizer shellTaskOrganizer, PipUiEventLogger pipUiEventLogger, ShellTaskOrganizer shellTaskOrganizer,
@ShellMainThread ShellExecutor mainExecutor) { @ShellMainThread ShellExecutor mainExecutor) {
return new PipTaskOrganizer(context, return new PipTaskOrganizer(context,
syncTransactionQueue, pipTransitionState, pipBoundsState, pipSizeSpecHandler, syncTransactionQueue, pipTransitionState, pipBoundsState, pipDisplayLayoutState,
pipBoundsAlgorithm, menuPhoneController, pipAnimationController, pipBoundsAlgorithm, menuPhoneController, pipAnimationController,
pipSurfaceTransactionHelper, pipTransitionController, pipParamsChangedForwarder, pipSurfaceTransactionHelper, pipTransitionController, pipParamsChangedForwarder,
splitScreenControllerOptional, displayController, pipUiEventLogger, splitScreenControllerOptional, displayController, pipUiEventLogger,
@@ -477,12 +480,12 @@ public abstract class WMShellModule {
static PipTransitionController providePipTransitionController(Context context, static PipTransitionController providePipTransitionController(Context context,
ShellInit shellInit, ShellTaskOrganizer shellTaskOrganizer, Transitions transitions, ShellInit shellInit, ShellTaskOrganizer shellTaskOrganizer, Transitions transitions,
PipAnimationController pipAnimationController, PipBoundsAlgorithm pipBoundsAlgorithm, PipAnimationController pipAnimationController, PipBoundsAlgorithm pipBoundsAlgorithm,
PipBoundsState pipBoundsState, PipSizeSpecHandler pipSizeSpecHandler, PipBoundsState pipBoundsState, PipDisplayLayoutState pipDisplayLayoutState,
PipTransitionState pipTransitionState, PhonePipMenuController pipMenuController, PipTransitionState pipTransitionState, PhonePipMenuController pipMenuController,
PipSurfaceTransactionHelper pipSurfaceTransactionHelper, PipSurfaceTransactionHelper pipSurfaceTransactionHelper,
Optional<SplitScreenController> splitScreenOptional) { Optional<SplitScreenController> splitScreenOptional) {
return new PipTransition(context, shellInit, shellTaskOrganizer, transitions, return new PipTransition(context, shellInit, shellTaskOrganizer, transitions,
pipBoundsState, pipSizeSpecHandler, pipTransitionState, pipMenuController, pipBoundsState, pipDisplayLayoutState, pipTransitionState, pipMenuController,
pipBoundsAlgorithm, pipAnimationController, pipSurfaceTransactionHelper, pipBoundsAlgorithm, pipAnimationController, pipSurfaceTransactionHelper,
splitScreenOptional); splitScreenOptional);
} }

View File

@@ -30,7 +30,6 @@ import android.graphics.Rect;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.ArraySet; import android.util.ArraySet;
import android.util.Size; import android.util.Size;
import android.view.Display;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog; import com.android.internal.protolog.common.ProtoLog;
@@ -77,6 +76,7 @@ public class PipBoundsState {
private final @NonNull Rect mExpandedBounds = new Rect(); private final @NonNull Rect mExpandedBounds = new Rect();
private final @NonNull Rect mNormalMovementBounds = new Rect(); private final @NonNull Rect mNormalMovementBounds = new Rect();
private final @NonNull Rect mExpandedMovementBounds = new Rect(); private final @NonNull Rect mExpandedMovementBounds = new Rect();
private final @NonNull PipDisplayLayoutState mPipDisplayLayoutState;
private final Point mMaxSize = new Point(); private final Point mMaxSize = new Point();
private final Point mMinSize = new Point(); private final Point mMinSize = new Point();
private final @NonNull Context mContext; private final @NonNull Context mContext;
@@ -86,8 +86,6 @@ public class PipBoundsState {
private @Nullable PipReentryState mPipReentryState; private @Nullable PipReentryState mPipReentryState;
private final @Nullable PipSizeSpecHandler mPipSizeSpecHandler; private final @Nullable PipSizeSpecHandler mPipSizeSpecHandler;
private @Nullable ComponentName mLastPipComponentName; private @Nullable ComponentName mLastPipComponentName;
private int mDisplayId = Display.DEFAULT_DISPLAY;
private final @NonNull DisplayLayout mDisplayLayout = new DisplayLayout();
private final @NonNull MotionBoundsState mMotionBoundsState = new MotionBoundsState(); private final @NonNull MotionBoundsState mMotionBoundsState = new MotionBoundsState();
private boolean mIsImeShowing; private boolean mIsImeShowing;
private int mImeHeight; private int mImeHeight;
@@ -120,10 +118,12 @@ public class PipBoundsState {
private @Nullable TriConsumer<Boolean, Integer, Boolean> mOnShelfVisibilityChangeCallback; private @Nullable TriConsumer<Boolean, Integer, Boolean> mOnShelfVisibilityChangeCallback;
private List<Consumer<Rect>> mOnPipExclusionBoundsChangeCallbacks = new ArrayList<>(); private List<Consumer<Rect>> mOnPipExclusionBoundsChangeCallbacks = new ArrayList<>();
public PipBoundsState(@NonNull Context context, PipSizeSpecHandler pipSizeSpecHandler) { public PipBoundsState(@NonNull Context context, PipSizeSpecHandler pipSizeSpecHandler,
PipDisplayLayoutState pipDisplayLayoutState) {
mContext = context; mContext = context;
reloadResources(); reloadResources();
mPipSizeSpecHandler = pipSizeSpecHandler; mPipSizeSpecHandler = pipSizeSpecHandler;
mPipDisplayLayoutState = pipDisplayLayoutState;
} }
/** Reloads the resources. */ /** Reloads the resources. */
@@ -290,31 +290,16 @@ public class PipBoundsState {
return mLastPipComponentName; return mLastPipComponentName;
} }
/** Get the current display id. */
public int getDisplayId() {
return mDisplayId;
}
/** Set the current display id for the associated display layout. */
public void setDisplayId(int displayId) {
mDisplayId = displayId;
}
/** Returns the display's bounds. */ /** Returns the display's bounds. */
@NonNull @NonNull
public Rect getDisplayBounds() { public Rect getDisplayBounds() {
return new Rect(0, 0, mDisplayLayout.width(), mDisplayLayout.height()); return mPipDisplayLayoutState.getDisplayBounds();
}
/** Update the display layout. */
public void setDisplayLayout(@NonNull DisplayLayout displayLayout) {
mDisplayLayout.set(displayLayout);
} }
/** Get a copy of the display layout. */ /** Get a copy of the display layout. */
@NonNull @NonNull
public DisplayLayout getDisplayLayout() { public DisplayLayout getDisplayLayout() {
return new DisplayLayout(mDisplayLayout); return mPipDisplayLayoutState.getDisplayLayout();
} }
@VisibleForTesting @VisibleForTesting
@@ -568,7 +553,6 @@ public class PipBoundsState {
pw.println(innerPrefix + "mExpandedMovementBounds=" + mExpandedMovementBounds); pw.println(innerPrefix + "mExpandedMovementBounds=" + mExpandedMovementBounds);
pw.println(innerPrefix + "mLastPipComponentName=" + mLastPipComponentName); pw.println(innerPrefix + "mLastPipComponentName=" + mLastPipComponentName);
pw.println(innerPrefix + "mAspectRatio=" + mAspectRatio); pw.println(innerPrefix + "mAspectRatio=" + mAspectRatio);
pw.println(innerPrefix + "mDisplayId=" + mDisplayId);
pw.println(innerPrefix + "mStashedState=" + mStashedState); pw.println(innerPrefix + "mStashedState=" + mStashedState);
pw.println(innerPrefix + "mStashOffset=" + mStashOffset); pw.println(innerPrefix + "mStashOffset=" + mStashOffset);
pw.println(innerPrefix + "mIsImeShowing=" + mIsImeShowing); pw.println(innerPrefix + "mIsImeShowing=" + mIsImeShowing);

View File

@@ -0,0 +1,91 @@
/*
* Copyright (C) 2023 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.wm.shell.pip;
import android.content.Context;
import android.graphics.Rect;
import android.view.Surface;
import androidx.annotation.NonNull;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.dagger.WMSingleton;
import java.io.PrintWriter;
import javax.inject.Inject;
/**
* Acts as a source of truth for display related information for PIP.
*/
@WMSingleton
public class PipDisplayLayoutState {
private static final String TAG = PipDisplayLayoutState.class.getSimpleName();
private Context mContext;
private int mDisplayId;
@NonNull private DisplayLayout mDisplayLayout;
@Inject
public PipDisplayLayoutState(Context context) {
mContext = context;
mDisplayLayout = new DisplayLayout();
}
/** Update the display layout. */
public void setDisplayLayout(@NonNull DisplayLayout displayLayout) {
mDisplayLayout.set(displayLayout);
}
/** Get a copy of the display layout. */
@NonNull
public DisplayLayout getDisplayLayout() {
return new DisplayLayout(mDisplayLayout);
}
/** Get the display bounds */
@NonNull
public Rect getDisplayBounds() {
return new Rect(0, 0, mDisplayLayout.width(), mDisplayLayout.height());
}
/**
* Apply a rotation to this layout and its parameters.
* @param targetRotation
*/
public void rotateTo(@Surface.Rotation int targetRotation) {
mDisplayLayout.rotateTo(mContext.getResources(), targetRotation);
}
/** Get the current display id */
public int getDisplayId() {
return mDisplayId;
}
/** Set the current display id for the associated display layout. */
public void setDisplayId(int displayId) {
mDisplayId = displayId;
}
/** Dumps internal state. */
public void dump(PrintWriter pw, String prefix) {
final String innerPrefix = prefix + " ";
pw.println(prefix + TAG);
pw.println(innerPrefix + "mDisplayId=" + mDisplayId);
pw.println(innerPrefix + "getDisplayBounds=" + getDisplayBounds());
}
}

View File

@@ -79,13 +79,11 @@ import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.animation.Interpolators; import com.android.wm.shell.animation.Interpolators;
import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.ScreenshotUtils; import com.android.wm.shell.common.ScreenshotUtils;
import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.common.annotations.ShellMainThread; import com.android.wm.shell.common.annotations.ShellMainThread;
import com.android.wm.shell.pip.phone.PipMotionHelper; import com.android.wm.shell.pip.phone.PipMotionHelper;
import com.android.wm.shell.pip.phone.PipSizeSpecHandler;
import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.transition.Transitions; import com.android.wm.shell.transition.Transitions;
@@ -128,7 +126,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
private final Context mContext; private final Context mContext;
private final SyncTransactionQueue mSyncTransactionQueue; private final SyncTransactionQueue mSyncTransactionQueue;
private final PipBoundsState mPipBoundsState; private final PipBoundsState mPipBoundsState;
private final PipSizeSpecHandler mPipSizeSpecHandler; private final PipDisplayLayoutState mPipDisplayLayoutState;
private final PipBoundsAlgorithm mPipBoundsAlgorithm; private final PipBoundsAlgorithm mPipBoundsAlgorithm;
private final @NonNull PipMenuController mPipMenuController; private final @NonNull PipMenuController mPipMenuController;
private final PipAnimationController mPipAnimationController; private final PipAnimationController mPipAnimationController;
@@ -316,7 +314,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
@NonNull SyncTransactionQueue syncTransactionQueue, @NonNull SyncTransactionQueue syncTransactionQueue,
@NonNull PipTransitionState pipTransitionState, @NonNull PipTransitionState pipTransitionState,
@NonNull PipBoundsState pipBoundsState, @NonNull PipBoundsState pipBoundsState,
@NonNull PipSizeSpecHandler pipSizeSpecHandler, @NonNull PipDisplayLayoutState pipDisplayLayoutState,
@NonNull PipBoundsAlgorithm boundsHandler, @NonNull PipBoundsAlgorithm boundsHandler,
@NonNull PipMenuController pipMenuController, @NonNull PipMenuController pipMenuController,
@NonNull PipAnimationController pipAnimationController, @NonNull PipAnimationController pipAnimationController,
@@ -332,7 +330,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
mSyncTransactionQueue = syncTransactionQueue; mSyncTransactionQueue = syncTransactionQueue;
mPipTransitionState = pipTransitionState; mPipTransitionState = pipTransitionState;
mPipBoundsState = pipBoundsState; mPipBoundsState = pipBoundsState;
mPipSizeSpecHandler = pipSizeSpecHandler; mPipDisplayLayoutState = pipDisplayLayoutState;
mPipBoundsAlgorithm = boundsHandler; mPipBoundsAlgorithm = boundsHandler;
mPipMenuController = pipMenuController; mPipMenuController = pipMenuController;
mPipTransitionController = pipTransitionController; mPipTransitionController = pipTransitionController;
@@ -653,7 +651,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
// If the displayId of the task is different than what PipBoundsHandler has, then update // If the displayId of the task is different than what PipBoundsHandler has, then update
// it. This is possible if we entered PiP on an external display. // it. This is possible if we entered PiP on an external display.
if (info.displayId != mPipBoundsState.getDisplayId() if (info.displayId != mPipDisplayLayoutState.getDisplayId()
&& mOnDisplayIdChangeCallback != null) { && mOnDisplayIdChangeCallback != null) {
mOnDisplayIdChangeCallback.accept(info.displayId); mOnDisplayIdChangeCallback.accept(info.displayId);
} }
@@ -1635,15 +1633,15 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
return animator; return animator;
} }
/** Computes destination bounds in old rotation and returns source hint rect if available. */ /** Computes destination bounds in old rotation and returns source hint rect if available.
*
* Note: updates the internal state of {@link PipDisplayLayoutState} by applying a rotation
* transformation onto the display layout.
*/
private @Nullable Rect computeRotatedBounds(int rotationDelta, int direction, private @Nullable Rect computeRotatedBounds(int rotationDelta, int direction,
Rect outDestinationBounds, Rect sourceHintRect) { Rect outDestinationBounds, Rect sourceHintRect) {
if (direction == TRANSITION_DIRECTION_TO_PIP) { if (direction == TRANSITION_DIRECTION_TO_PIP) {
DisplayLayout layoutCopy = mPipBoundsState.getDisplayLayout(); mPipDisplayLayoutState.rotateTo(mNextRotation);
layoutCopy.rotateTo(mContext.getResources(), mNextRotation);
mPipBoundsState.setDisplayLayout(layoutCopy);
mPipSizeSpecHandler.setDisplayLayout(layoutCopy);
final Rect displayBounds = mPipBoundsState.getDisplayBounds(); final Rect displayBounds = mPipBoundsState.getDisplayBounds();
outDestinationBounds.set(mPipBoundsAlgorithm.getEntryDestinationBounds()); outDestinationBounds.set(mPipBoundsAlgorithm.getEntryDestinationBounds());

View File

@@ -64,8 +64,6 @@ import androidx.annotation.Nullable;
import com.android.internal.protolog.common.ProtoLog; import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.R; import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.pip.phone.PipSizeSpecHandler;
import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.sysui.ShellInit; import com.android.wm.shell.sysui.ShellInit;
@@ -85,7 +83,7 @@ public class PipTransition extends PipTransitionController {
private final Context mContext; private final Context mContext;
private final PipTransitionState mPipTransitionState; private final PipTransitionState mPipTransitionState;
private final PipSizeSpecHandler mPipSizeSpecHandler; private final PipDisplayLayoutState mPipDisplayLayoutState;
private final int mEnterExitAnimationDuration; private final int mEnterExitAnimationDuration;
private final PipSurfaceTransactionHelper mSurfaceTransactionHelper; private final PipSurfaceTransactionHelper mSurfaceTransactionHelper;
private final Optional<SplitScreenController> mSplitScreenOptional; private final Optional<SplitScreenController> mSplitScreenOptional;
@@ -116,7 +114,7 @@ public class PipTransition extends PipTransitionController {
@NonNull ShellTaskOrganizer shellTaskOrganizer, @NonNull ShellTaskOrganizer shellTaskOrganizer,
@NonNull Transitions transitions, @NonNull Transitions transitions,
PipBoundsState pipBoundsState, PipBoundsState pipBoundsState,
PipSizeSpecHandler pipSizeSpecHandler, PipDisplayLayoutState pipDisplayLayoutState,
PipTransitionState pipTransitionState, PipTransitionState pipTransitionState,
PipMenuController pipMenuController, PipMenuController pipMenuController,
PipBoundsAlgorithm pipBoundsAlgorithm, PipBoundsAlgorithm pipBoundsAlgorithm,
@@ -127,7 +125,7 @@ public class PipTransition extends PipTransitionController {
pipBoundsAlgorithm, pipAnimationController); pipBoundsAlgorithm, pipAnimationController);
mContext = context; mContext = context;
mPipTransitionState = pipTransitionState; mPipTransitionState = pipTransitionState;
mPipSizeSpecHandler = pipSizeSpecHandler; mPipDisplayLayoutState = pipDisplayLayoutState;
mEnterExitAnimationDuration = context.getResources() mEnterExitAnimationDuration = context.getResources()
.getInteger(R.integer.config_pipResizeAnimationDuration); .getInteger(R.integer.config_pipResizeAnimationDuration);
mSurfaceTransactionHelper = pipSurfaceTransactionHelper; mSurfaceTransactionHelper = pipSurfaceTransactionHelper;
@@ -313,11 +311,7 @@ public class PipTransition extends PipTransitionController {
// initial state under the new rotation. // initial state under the new rotation.
int rotationDelta = deltaRotation(startRotation, endRotation); int rotationDelta = deltaRotation(startRotation, endRotation);
if (rotationDelta != Surface.ROTATION_0) { if (rotationDelta != Surface.ROTATION_0) {
DisplayLayout layoutCopy = mPipBoundsState.getDisplayLayout(); mPipDisplayLayoutState.rotateTo(endRotation);
layoutCopy.rotateTo(mContext.getResources(), endRotation);
mPipBoundsState.setDisplayLayout(layoutCopy);
mPipSizeSpecHandler.setDisplayLayout(layoutCopy);
final Rect destinationBounds = mPipBoundsAlgorithm.getEntryDestinationBounds(); final Rect destinationBounds = mPipBoundsAlgorithm.getEntryDestinationBounds();
wct.setBounds(mRequestedEnterTask, destinationBounds); wct.setBounds(mRequestedEnterTask, destinationBounds);
@@ -398,7 +392,7 @@ public class PipTransition extends PipTransitionController {
// Launcher may update the Shelf height during the animation, which will update the // Launcher may update the Shelf height during the animation, which will update the
// destination bounds. Because this is in fixed rotation, We need to make sure the // destination bounds. Because this is in fixed rotation, We need to make sure the
// finishTransaction is using the updated bounds in the display rotation. // finishTransaction is using the updated bounds in the display rotation.
final Rect displayBounds = mPipBoundsState.getDisplayBounds(); final Rect displayBounds = mPipDisplayLayoutState.getDisplayBounds();
final Rect finishBounds = new Rect(destinationBounds); final Rect finishBounds = new Rect(destinationBounds);
rotateBounds(finishBounds, displayBounds, mEndFixedRotation, displayRotation); rotateBounds(finishBounds, displayBounds, mEndFixedRotation, displayRotation);
mSurfaceTransactionHelper.crop(mFinishTransaction, leash, finishBounds); mSurfaceTransactionHelper.crop(mFinishTransaction, leash, finishBounds);
@@ -640,7 +634,7 @@ public class PipTransition extends PipTransitionController {
@NonNull TaskInfo taskInfo) { @NonNull TaskInfo taskInfo) {
startTransaction.apply(); startTransaction.apply();
finishTransaction.setWindowCrop(info.getChanges().get(0).getLeash(), finishTransaction.setWindowCrop(info.getChanges().get(0).getLeash(),
mPipBoundsState.getDisplayBounds()); mPipDisplayLayoutState.getDisplayBounds());
mPipOrganizer.onExitPipFinished(taskInfo); mPipOrganizer.onExitPipFinished(taskInfo);
finishCallback.onTransitionFinished(null, null); finishCallback.onTransitionFinished(null, null);
} }
@@ -834,13 +828,9 @@ public class PipTransition extends PipTransitionController {
/** Computes destination bounds in old rotation and updates source hint rect if available. */ /** Computes destination bounds in old rotation and updates source hint rect if available. */
private void computeEnterPipRotatedBounds(int rotationDelta, int startRotation, int endRotation, private void computeEnterPipRotatedBounds(int rotationDelta, int startRotation, int endRotation,
TaskInfo taskInfo, Rect outDestinationBounds, @Nullable Rect outSourceHintRect) { TaskInfo taskInfo, Rect outDestinationBounds, @Nullable Rect outSourceHintRect) {
DisplayLayout layoutCopy = mPipBoundsState.getDisplayLayout(); mPipDisplayLayoutState.rotateTo(endRotation);
layoutCopy.rotateTo(mContext.getResources(), endRotation); final Rect displayBounds = mPipDisplayLayoutState.getDisplayBounds();
mPipBoundsState.setDisplayLayout(layoutCopy);
mPipSizeSpecHandler.setDisplayLayout(layoutCopy);
final Rect displayBounds = mPipBoundsState.getDisplayBounds();
outDestinationBounds.set(mPipBoundsAlgorithm.getEntryDestinationBounds()); outDestinationBounds.set(mPipBoundsAlgorithm.getEntryDestinationBounds());
// Transform the destination bounds to current display coordinates. // Transform the destination bounds to current display coordinates.
rotateBounds(outDestinationBounds, displayBounds, endRotation, startRotation); rotateBounds(outDestinationBounds, displayBounds, endRotation, startRotation);

View File

@@ -83,6 +83,7 @@ import com.android.wm.shell.pip.PipAnimationController;
import com.android.wm.shell.pip.PipAppOpsListener; import com.android.wm.shell.pip.PipAppOpsListener;
import com.android.wm.shell.pip.PipBoundsAlgorithm; import com.android.wm.shell.pip.PipBoundsAlgorithm;
import com.android.wm.shell.pip.PipBoundsState; import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipDisplayLayoutState;
import com.android.wm.shell.pip.PipKeepClearAlgorithmInterface; import com.android.wm.shell.pip.PipKeepClearAlgorithmInterface;
import com.android.wm.shell.pip.PipMediaController; import com.android.wm.shell.pip.PipMediaController;
import com.android.wm.shell.pip.PipParamsChangedForwarder; import com.android.wm.shell.pip.PipParamsChangedForwarder;
@@ -139,6 +140,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
private PipKeepClearAlgorithmInterface mPipKeepClearAlgorithm; private PipKeepClearAlgorithmInterface mPipKeepClearAlgorithm;
private PipBoundsState mPipBoundsState; private PipBoundsState mPipBoundsState;
private PipSizeSpecHandler mPipSizeSpecHandler; private PipSizeSpecHandler mPipSizeSpecHandler;
private PipDisplayLayoutState mPipDisplayLayoutState;
private PipMotionHelper mPipMotionHelper; private PipMotionHelper mPipMotionHelper;
private PipTouchHandler mTouchHandler; private PipTouchHandler mTouchHandler;
private PipTransitionController mPipTransitionController; private PipTransitionController mPipTransitionController;
@@ -310,7 +312,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
@Override @Override
public void onDisplayAdded(int displayId) { public void onDisplayAdded(int displayId) {
if (displayId != mPipBoundsState.getDisplayId()) { if (displayId != mPipDisplayLayoutState.getDisplayId()) {
return; return;
} }
onDisplayChanged(mDisplayController.getDisplayLayout(displayId), onDisplayChanged(mDisplayController.getDisplayLayout(displayId),
@@ -319,7 +321,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
@Override @Override
public void onDisplayConfigurationChanged(int displayId, Configuration newConfig) { public void onDisplayConfigurationChanged(int displayId, Configuration newConfig) {
if (displayId != mPipBoundsState.getDisplayId()) { if (displayId != mPipDisplayLayoutState.getDisplayId()) {
return; return;
} }
onDisplayChanged(mDisplayController.getDisplayLayout(displayId), onDisplayChanged(mDisplayController.getDisplayLayout(displayId),
@@ -329,7 +331,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
@Override @Override
public void onKeepClearAreasChanged(int displayId, Set<Rect> restricted, public void onKeepClearAreasChanged(int displayId, Set<Rect> restricted,
Set<Rect> unrestricted) { Set<Rect> unrestricted) {
if (mPipBoundsState.getDisplayId() == displayId) { if (mPipDisplayLayoutState.getDisplayId() == displayId) {
if (mEnablePipKeepClearAlgorithm) { if (mEnablePipKeepClearAlgorithm) {
mPipBoundsState.setKeepClearAreas(restricted, unrestricted); mPipBoundsState.setKeepClearAreas(restricted, unrestricted);
@@ -389,6 +391,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
PipKeepClearAlgorithmInterface pipKeepClearAlgorithm, PipKeepClearAlgorithmInterface pipKeepClearAlgorithm,
PipBoundsState pipBoundsState, PipBoundsState pipBoundsState,
PipSizeSpecHandler pipSizeSpecHandler, PipSizeSpecHandler pipSizeSpecHandler,
PipDisplayLayoutState pipDisplayLayoutState,
PipMotionHelper pipMotionHelper, PipMotionHelper pipMotionHelper,
PipMediaController pipMediaController, PipMediaController pipMediaController,
PhonePipMenuController phonePipMenuController, PhonePipMenuController phonePipMenuController,
@@ -411,8 +414,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb
return new PipController(context, shellInit, shellCommandHandler, shellController, return new PipController(context, shellInit, shellCommandHandler, shellController,
displayController, pipAnimationController, pipAppOpsListener, displayController, pipAnimationController, pipAppOpsListener,
pipBoundsAlgorithm, pipKeepClearAlgorithm, pipBoundsState, pipSizeSpecHandler, pipBoundsAlgorithm, pipKeepClearAlgorithm, pipBoundsState, pipSizeSpecHandler,
pipMotionHelper, pipMediaController, phonePipMenuController, pipTaskOrganizer, pipDisplayLayoutState, pipMotionHelper, pipMediaController, phonePipMenuController,
pipTransitionState, pipTouchHandler, pipTransitionController, pipTaskOrganizer, pipTransitionState, pipTouchHandler, pipTransitionController,
windowManagerShellWrapper, taskStackListener, pipParamsChangedForwarder, windowManagerShellWrapper, taskStackListener, pipParamsChangedForwarder,
displayInsetsController, oneHandedController, mainExecutor) displayInsetsController, oneHandedController, mainExecutor)
.mImpl; .mImpl;
@@ -429,6 +432,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
PipKeepClearAlgorithmInterface pipKeepClearAlgorithm, PipKeepClearAlgorithmInterface pipKeepClearAlgorithm,
@NonNull PipBoundsState pipBoundsState, @NonNull PipBoundsState pipBoundsState,
PipSizeSpecHandler pipSizeSpecHandler, PipSizeSpecHandler pipSizeSpecHandler,
@NonNull PipDisplayLayoutState pipDisplayLayoutState,
PipMotionHelper pipMotionHelper, PipMotionHelper pipMotionHelper,
PipMediaController pipMediaController, PipMediaController pipMediaController,
PhonePipMenuController phonePipMenuController, PhonePipMenuController phonePipMenuController,
@@ -455,6 +459,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
mPipKeepClearAlgorithm = pipKeepClearAlgorithm; mPipKeepClearAlgorithm = pipKeepClearAlgorithm;
mPipBoundsState = pipBoundsState; mPipBoundsState = pipBoundsState;
mPipSizeSpecHandler = pipSizeSpecHandler; mPipSizeSpecHandler = pipSizeSpecHandler;
mPipDisplayLayoutState = pipDisplayLayoutState;
mPipMotionHelper = pipMotionHelper; mPipMotionHelper = pipMotionHelper;
mPipTaskOrganizer = pipTaskOrganizer; mPipTaskOrganizer = pipTaskOrganizer;
mPipTransitionState = pipTransitionState; mPipTransitionState = pipTransitionState;
@@ -482,7 +487,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
INPUT_CONSUMER_PIP, mMainExecutor); INPUT_CONSUMER_PIP, mMainExecutor);
mPipTransitionController.registerPipTransitionCallback(this); mPipTransitionController.registerPipTransitionCallback(this);
mPipTaskOrganizer.registerOnDisplayIdChangeCallback((int displayId) -> { mPipTaskOrganizer.registerOnDisplayIdChangeCallback((int displayId) -> {
mPipBoundsState.setDisplayId(displayId); mPipDisplayLayoutState.setDisplayId(displayId);
onDisplayChanged(mDisplayController.getDisplayLayout(displayId), onDisplayChanged(mDisplayController.getDisplayLayout(displayId),
false /* saveRestoreSnapFraction */); false /* saveRestoreSnapFraction */);
}); });
@@ -522,11 +527,10 @@ public class PipController implements PipTransitionController.PipTransitionCallb
// Ensure that we have the display info in case we get calls to update the bounds before the // Ensure that we have the display info in case we get calls to update the bounds before the
// listener calls back // listener calls back
mPipBoundsState.setDisplayId(mContext.getDisplayId()); mPipDisplayLayoutState.setDisplayId(mContext.getDisplayId());
DisplayLayout layout = new DisplayLayout(mContext, mContext.getDisplay()); DisplayLayout layout = new DisplayLayout(mContext, mContext.getDisplay());
mPipSizeSpecHandler.setDisplayLayout(layout); mPipDisplayLayoutState.setDisplayLayout(layout);
mPipBoundsState.setDisplayLayout(layout);
try { try {
mWindowManagerShellWrapper.addPinnedStackListener(mPinnedTaskListener); mWindowManagerShellWrapper.addPinnedStackListener(mPinnedTaskListener);
@@ -621,12 +625,12 @@ public class PipController implements PipTransitionController.PipTransitionCallb
} }
}); });
mDisplayInsetsController.addInsetsChangedListener(mPipBoundsState.getDisplayId(), mDisplayInsetsController.addInsetsChangedListener(mPipDisplayLayoutState.getDisplayId(),
new DisplayInsetsController.OnInsetsChangedListener() { new DisplayInsetsController.OnInsetsChangedListener() {
@Override @Override
public void insetsChanged(InsetsState insetsState) { public void insetsChanged(InsetsState insetsState) {
DisplayLayout pendingLayout = DisplayLayout pendingLayout = mDisplayController
mDisplayController.getDisplayLayout(mPipBoundsState.getDisplayId()); .getDisplayLayout(mPipDisplayLayoutState.getDisplayId());
if (mIsInFixedRotation if (mIsInFixedRotation
|| pendingLayout.rotation() || pendingLayout.rotation()
!= mPipBoundsState.getDisplayLayout().rotation()) { != mPipBoundsState.getDisplayLayout().rotation()) {
@@ -634,8 +638,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb
return; return;
} }
int oldMaxMovementBound = mPipBoundsState.getMovementBounds().bottom; int oldMaxMovementBound = mPipBoundsState.getMovementBounds().bottom;
onDisplayChangedUncheck( onDisplayChangedUncheck(mDisplayController
mDisplayController.getDisplayLayout(mPipBoundsState.getDisplayId()), .getDisplayLayout(mPipDisplayLayoutState.getDisplayId()),
false /* saveRestoreSnapFraction */); false /* saveRestoreSnapFraction */);
int newMaxMovementBound = mPipBoundsState.getMovementBounds().bottom; int newMaxMovementBound = mPipBoundsState.getMovementBounds().bottom;
if (!mEnablePipKeepClearAlgorithm) { if (!mEnablePipKeepClearAlgorithm) {
@@ -721,7 +725,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
} }
private void onDisplayChanged(DisplayLayout layout, boolean saveRestoreSnapFraction) { private void onDisplayChanged(DisplayLayout layout, boolean saveRestoreSnapFraction) {
if (!mPipBoundsState.getDisplayLayout().isSameGeometry(layout)) { if (!mPipDisplayLayoutState.getDisplayLayout().isSameGeometry(layout)) {
PipAnimationController.PipTransitionAnimator animator = PipAnimationController.PipTransitionAnimator animator =
mPipAnimationController.getCurrentAnimator(); mPipAnimationController.getCurrentAnimator();
if (animator != null && animator.isRunning()) { if (animator != null && animator.isRunning()) {
@@ -735,11 +739,10 @@ public class PipController implements PipTransitionController.PipTransitionCallb
private void onDisplayChangedUncheck(DisplayLayout layout, boolean saveRestoreSnapFraction) { private void onDisplayChangedUncheck(DisplayLayout layout, boolean saveRestoreSnapFraction) {
Runnable updateDisplayLayout = () -> { Runnable updateDisplayLayout = () -> {
final boolean fromRotation = Transitions.ENABLE_SHELL_TRANSITIONS final boolean fromRotation = Transitions.ENABLE_SHELL_TRANSITIONS
&& mPipBoundsState.getDisplayLayout().rotation() != layout.rotation(); && mPipDisplayLayoutState.getDisplayLayout().rotation() != layout.rotation();
// update the internal state of objects subscribed to display changes // update the internal state of objects subscribed to display changes
mPipSizeSpecHandler.setDisplayLayout(layout); mPipDisplayLayoutState.setDisplayLayout(layout);
mPipBoundsState.setDisplayLayout(layout);
final WindowContainerTransaction wct = final WindowContainerTransaction wct =
fromRotation ? new WindowContainerTransaction() : null; fromRotation ? new WindowContainerTransaction() : null;
@@ -763,11 +766,13 @@ public class PipController implements PipTransitionController.PipTransitionCallb
mPipBoundsState.getStashedState()); mPipBoundsState.getStashedState());
// Scale PiP on density dpi change, so it appears to be the same size physically. // Scale PiP on density dpi change, so it appears to be the same size physically.
final boolean densityDpiChanged = mPipBoundsState.getDisplayLayout().densityDpi() != 0 final boolean densityDpiChanged =
&& (mPipBoundsState.getDisplayLayout().densityDpi() != layout.densityDpi()); mPipDisplayLayoutState.getDisplayLayout().densityDpi() != 0
&& (mPipDisplayLayoutState.getDisplayLayout().densityDpi()
!= layout.densityDpi());
if (densityDpiChanged) { if (densityDpiChanged) {
final float scale = (float) layout.densityDpi() final float scale = (float) layout.densityDpi()
/ mPipBoundsState.getDisplayLayout().densityDpi(); / mPipDisplayLayoutState.getDisplayLayout().densityDpi();
postChangeBounds.set(0, 0, postChangeBounds.set(0, 0,
(int) (postChangeBounds.width() * scale), (int) (postChangeBounds.width() * scale),
(int) (postChangeBounds.height() * scale)); (int) (postChangeBounds.height() * scale));
@@ -782,8 +787,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb
pipSnapAlgorithm.applySnapFraction(postChangeBounds, postChangeMovementBounds, pipSnapAlgorithm.applySnapFraction(postChangeBounds, postChangeMovementBounds,
snapFraction, mPipBoundsState.getStashedState(), snapFraction, mPipBoundsState.getStashedState(),
mPipBoundsState.getStashOffset(), mPipBoundsState.getStashOffset(),
mPipBoundsState.getDisplayBounds(), mPipDisplayLayoutState.getDisplayBounds(),
mPipBoundsState.getDisplayLayout().stableInsets()); mPipDisplayLayoutState.getDisplayLayout().stableInsets());
if (densityDpiChanged) { if (densityDpiChanged) {
// Using PipMotionHelper#movePip directly here may cause race condition since // Using PipMotionHelper#movePip directly here may cause race condition since
@@ -1040,7 +1045,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
// Populate inset / normal bounds and DisplayInfo from mPipBoundsHandler before // Populate inset / normal bounds and DisplayInfo from mPipBoundsHandler before
// passing to mTouchHandler/mPipTaskOrganizer // passing to mTouchHandler/mPipTaskOrganizer
final Rect outBounds = new Rect(toBounds); final Rect outBounds = new Rect(toBounds);
final int rotation = mPipBoundsState.getDisplayLayout().rotation(); final int rotation = mPipDisplayLayoutState.getDisplayLayout().rotation();
mPipBoundsAlgorithm.getInsetBounds(mTmpInsetBounds); mPipBoundsAlgorithm.getInsetBounds(mTmpInsetBounds);
mPipBoundsState.setNormalBounds(mPipBoundsAlgorithm.getNormalBounds()); mPipBoundsState.setNormalBounds(mPipBoundsAlgorithm.getNormalBounds());
@@ -1064,11 +1069,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
private void onDisplayRotationChangedNotInPip(Context context, int toRotation) { private void onDisplayRotationChangedNotInPip(Context context, int toRotation) {
// Update the display layout, note that we have to do this on every rotation even if we // Update the display layout, note that we have to do this on every rotation even if we
// aren't in PIP since we need to update the display layout to get the right resources // aren't in PIP since we need to update the display layout to get the right resources
DisplayLayout layoutCopy = mPipBoundsState.getDisplayLayout(); mPipDisplayLayoutState.rotateTo(toRotation);
layoutCopy.rotateTo(context.getResources(), toRotation);
mPipBoundsState.setDisplayLayout(layoutCopy);
mPipSizeSpecHandler.setDisplayLayout(layoutCopy);
} }
/** /**
@@ -1081,7 +1082,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
Rect outInsetBounds, Rect outInsetBounds,
int displayId, int fromRotation, int toRotation, WindowContainerTransaction t) { int displayId, int fromRotation, int toRotation, WindowContainerTransaction t) {
// Bail early if the event is not sent to current display // Bail early if the event is not sent to current display
if ((displayId != mPipBoundsState.getDisplayId()) || (fromRotation == toRotation)) { if ((displayId != mPipDisplayLayoutState.getDisplayId()) || (fromRotation == toRotation)) {
return false; return false;
} }
@@ -1105,11 +1106,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
mPipBoundsState.getStashedState()); mPipBoundsState.getStashedState());
// Update the display layout // Update the display layout
DisplayLayout layoutCopy = mPipBoundsState.getDisplayLayout(); mPipDisplayLayoutState.rotateTo(toRotation);
layoutCopy.rotateTo(context.getResources(), toRotation);
mPipBoundsState.setDisplayLayout(layoutCopy);
mPipSizeSpecHandler.setDisplayLayout(layoutCopy);
// Calculate the stack bounds in the new orientation based on same fraction along the // Calculate the stack bounds in the new orientation based on same fraction along the
// rotated movement bounds. // rotated movement bounds.
@@ -1117,8 +1114,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb
postChangeStackBounds, false /* adjustForIme */); postChangeStackBounds, false /* adjustForIme */);
pipSnapAlgorithm.applySnapFraction(postChangeStackBounds, postChangeMovementBounds, pipSnapAlgorithm.applySnapFraction(postChangeStackBounds, postChangeMovementBounds,
snapFraction, mPipBoundsState.getStashedState(), mPipBoundsState.getStashOffset(), snapFraction, mPipBoundsState.getStashedState(), mPipBoundsState.getStashOffset(),
mPipBoundsState.getDisplayBounds(), mPipDisplayLayoutState.getDisplayBounds(),
mPipBoundsState.getDisplayLayout().stableInsets()); mPipDisplayLayoutState.getDisplayLayout().stableInsets());
mPipBoundsAlgorithm.getInsetBounds(outInsetBounds); mPipBoundsAlgorithm.getInsetBounds(outInsetBounds);
outBounds.set(postChangeStackBounds); outBounds.set(postChangeStackBounds);
@@ -1136,6 +1133,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
mPipBoundsState.dump(pw, innerPrefix); mPipBoundsState.dump(pw, innerPrefix);
mPipInputConsumer.dump(pw, innerPrefix); mPipInputConsumer.dump(pw, innerPrefix);
mPipSizeSpecHandler.dump(pw, innerPrefix); mPipSizeSpecHandler.dump(pw, innerPrefix);
mPipDisplayLayoutState.dump(pw, innerPrefix);
} }
/** /**

View File

@@ -31,6 +31,7 @@ import android.util.Size;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.wm.shell.R; import com.android.wm.shell.R;
import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.pip.PipDisplayLayoutState;
import java.io.PrintWriter; import java.io.PrintWriter;
@@ -40,10 +41,9 @@ import java.io.PrintWriter;
public class PipSizeSpecHandler { public class PipSizeSpecHandler {
private static final String TAG = PipSizeSpecHandler.class.getSimpleName(); private static final String TAG = PipSizeSpecHandler.class.getSimpleName();
@NonNull private final DisplayLayout mDisplayLayout = new DisplayLayout(); @NonNull private final PipDisplayLayoutState mPipDisplayLayoutState;
@VisibleForTesting private final SizeSpecSource mSizeSpecSourceImpl;
final SizeSpecSource mSizeSpecSourceImpl;
/** The preferred minimum (and default minimum) size specified by apps. */ /** The preferred minimum (and default minimum) size specified by apps. */
@Nullable private Size mOverrideMinSize; @Nullable private Size mOverrideMinSize;
@@ -361,8 +361,9 @@ public class PipSizeSpecHandler {
} }
} }
public PipSizeSpecHandler(Context context) { public PipSizeSpecHandler(Context context, PipDisplayLayoutState pipDisplayLayoutState) {
mContext = context; mContext = context;
mPipDisplayLayoutState = pipDisplayLayoutState;
boolean enablePipSizeLargeScreen = SystemProperties boolean enablePipSizeLargeScreen = SystemProperties
.getBoolean("persist.wm.debug.enable_pip_size_large_screen", false); .getBoolean("persist.wm.debug.enable_pip_size_large_screen", false);
@@ -403,15 +404,9 @@ public class PipSizeSpecHandler {
mSizeSpecSourceImpl.reloadResources(); mSizeSpecSourceImpl.reloadResources();
} }
/** Returns the display's bounds. */
@NonNull @NonNull
public Rect getDisplayBounds() { private Rect getDisplayBounds() {
return new Rect(0, 0, mDisplayLayout.width(), mDisplayLayout.height()); return mPipDisplayLayoutState.getDisplayBounds();
}
/** Update the display layout. */
public void setDisplayLayout(@NonNull DisplayLayout displayLayout) {
mDisplayLayout.set(displayLayout);
} }
public Point getScreenEdgeInsets() { public Point getScreenEdgeInsets() {
@@ -423,11 +418,12 @@ public class PipSizeSpecHandler {
*/ */
public Rect getInsetBounds() { public Rect getInsetBounds() {
Rect insetBounds = new Rect(); Rect insetBounds = new Rect();
Rect insets = mDisplayLayout.stableInsets(); DisplayLayout displayLayout = mPipDisplayLayoutState.getDisplayLayout();
Rect insets = displayLayout.stableInsets();
insetBounds.set(insets.left + mScreenEdgeInsets.x, insetBounds.set(insets.left + mScreenEdgeInsets.x,
insets.top + mScreenEdgeInsets.y, insets.top + mScreenEdgeInsets.y,
mDisplayLayout.width() - insets.right - mScreenEdgeInsets.x, displayLayout.width() - insets.right - mScreenEdgeInsets.x,
mDisplayLayout.height() - insets.bottom - mScreenEdgeInsets.y); displayLayout.height() - insets.bottom - mScreenEdgeInsets.y);
return insetBounds; return insetBounds;
} }
@@ -522,8 +518,8 @@ public class PipSizeSpecHandler {
public void dump(PrintWriter pw, String prefix) { public void dump(PrintWriter pw, String prefix) {
final String innerPrefix = prefix + " "; final String innerPrefix = prefix + " ";
pw.println(prefix + TAG); pw.println(prefix + TAG);
pw.println(innerPrefix + "mSizeSpecSourceImpl=" + mSizeSpecSourceImpl.toString()); pw.println(innerPrefix + "mSizeSpecSourceImpl=" + mSizeSpecSourceImpl);
pw.println(innerPrefix + "mDisplayLayout=" + mDisplayLayout);
pw.println(innerPrefix + "mOverrideMinSize=" + mOverrideMinSize); pw.println(innerPrefix + "mOverrideMinSize=" + mOverrideMinSize);
pw.println(innerPrefix + "mScreenEdgeInsets=" + mScreenEdgeInsets);
} }
} }

View File

@@ -31,6 +31,7 @@ import android.view.View;
import com.android.wm.shell.pip.PipBoundsAlgorithm; import com.android.wm.shell.pip.PipBoundsAlgorithm;
import com.android.wm.shell.pip.PipBoundsState; import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipDisplayLayoutState;
import com.android.wm.shell.pip.phone.PipSizeSpecHandler; import com.android.wm.shell.pip.phone.PipSizeSpecHandler;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
@@ -75,8 +76,9 @@ public class TvPipBoundsState extends PipBoundsState {
private Insets mPipMenuTemporaryDecorInsets = Insets.NONE; private Insets mPipMenuTemporaryDecorInsets = Insets.NONE;
public TvPipBoundsState(@NonNull Context context, public TvPipBoundsState(@NonNull Context context,
@NonNull PipSizeSpecHandler pipSizeSpecHandler) { @NonNull PipSizeSpecHandler pipSizeSpecHandler,
super(context, pipSizeSpecHandler); @NonNull PipDisplayLayoutState pipDisplayLayoutState) {
super(context, pipSizeSpecHandler, pipDisplayLayoutState);
mContext = context; mContext = context;
updateDefaultGravity(); updateDefaultGravity();
mPreviousCollapsedGravity = mDefaultGravity; mPreviousCollapsedGravity = mDefaultGravity;

View File

@@ -51,11 +51,11 @@ import com.android.wm.shell.pip.PinnedStackListenerForwarder;
import com.android.wm.shell.pip.Pip; import com.android.wm.shell.pip.Pip;
import com.android.wm.shell.pip.PipAnimationController; import com.android.wm.shell.pip.PipAnimationController;
import com.android.wm.shell.pip.PipAppOpsListener; import com.android.wm.shell.pip.PipAppOpsListener;
import com.android.wm.shell.pip.PipDisplayLayoutState;
import com.android.wm.shell.pip.PipMediaController; import com.android.wm.shell.pip.PipMediaController;
import com.android.wm.shell.pip.PipParamsChangedForwarder; import com.android.wm.shell.pip.PipParamsChangedForwarder;
import com.android.wm.shell.pip.PipTaskOrganizer; import com.android.wm.shell.pip.PipTaskOrganizer;
import com.android.wm.shell.pip.PipTransitionController; import com.android.wm.shell.pip.PipTransitionController;
import com.android.wm.shell.pip.phone.PipSizeSpecHandler;
import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.sysui.ConfigurationChangeListener; import com.android.wm.shell.sysui.ConfigurationChangeListener;
import com.android.wm.shell.sysui.ShellController; import com.android.wm.shell.sysui.ShellController;
@@ -119,7 +119,7 @@ public class TvPipController implements PipTransitionController.PipTransitionCal
private final ShellController mShellController; private final ShellController mShellController;
private final TvPipBoundsState mTvPipBoundsState; private final TvPipBoundsState mTvPipBoundsState;
private final PipSizeSpecHandler mPipSizeSpecHandler; private final PipDisplayLayoutState mPipDisplayLayoutState;
private final TvPipBoundsAlgorithm mTvPipBoundsAlgorithm; private final TvPipBoundsAlgorithm mTvPipBoundsAlgorithm;
private final TvPipBoundsController mTvPipBoundsController; private final TvPipBoundsController mTvPipBoundsController;
private final PipAppOpsListener mAppOpsListener; private final PipAppOpsListener mAppOpsListener;
@@ -154,7 +154,7 @@ public class TvPipController implements PipTransitionController.PipTransitionCal
ShellInit shellInit, ShellInit shellInit,
ShellController shellController, ShellController shellController,
TvPipBoundsState tvPipBoundsState, TvPipBoundsState tvPipBoundsState,
PipSizeSpecHandler pipSizeSpecHandler, PipDisplayLayoutState pipDisplayLayoutState,
TvPipBoundsAlgorithm tvPipBoundsAlgorithm, TvPipBoundsAlgorithm tvPipBoundsAlgorithm,
TvPipBoundsController tvPipBoundsController, TvPipBoundsController tvPipBoundsController,
PipAppOpsListener pipAppOpsListener, PipAppOpsListener pipAppOpsListener,
@@ -174,7 +174,7 @@ public class TvPipController implements PipTransitionController.PipTransitionCal
shellInit, shellInit,
shellController, shellController,
tvPipBoundsState, tvPipBoundsState,
pipSizeSpecHandler, pipDisplayLayoutState,
tvPipBoundsAlgorithm, tvPipBoundsAlgorithm,
tvPipBoundsController, tvPipBoundsController,
pipAppOpsListener, pipAppOpsListener,
@@ -196,7 +196,7 @@ public class TvPipController implements PipTransitionController.PipTransitionCal
ShellInit shellInit, ShellInit shellInit,
ShellController shellController, ShellController shellController,
TvPipBoundsState tvPipBoundsState, TvPipBoundsState tvPipBoundsState,
PipSizeSpecHandler pipSizeSpecHandler, PipDisplayLayoutState pipDisplayLayoutState,
TvPipBoundsAlgorithm tvPipBoundsAlgorithm, TvPipBoundsAlgorithm tvPipBoundsAlgorithm,
TvPipBoundsController tvPipBoundsController, TvPipBoundsController tvPipBoundsController,
PipAppOpsListener pipAppOpsListener, PipAppOpsListener pipAppOpsListener,
@@ -220,10 +220,11 @@ public class TvPipController implements PipTransitionController.PipTransitionCal
DisplayLayout layout = new DisplayLayout(context, context.getDisplay()); DisplayLayout layout = new DisplayLayout(context, context.getDisplay());
mTvPipBoundsState = tvPipBoundsState; mTvPipBoundsState = tvPipBoundsState;
mTvPipBoundsState.setDisplayLayout(layout);
mTvPipBoundsState.setDisplayId(context.getDisplayId()); mPipDisplayLayoutState = pipDisplayLayoutState;
mPipSizeSpecHandler = pipSizeSpecHandler; mPipDisplayLayoutState.setDisplayLayout(layout);
mPipSizeSpecHandler.setDisplayLayout(layout); mPipDisplayLayoutState.setDisplayId(context.getDisplayId());
mTvPipBoundsAlgorithm = tvPipBoundsAlgorithm; mTvPipBoundsAlgorithm = tvPipBoundsAlgorithm;
mTvPipBoundsController = tvPipBoundsController; mTvPipBoundsController = tvPipBoundsController;
mTvPipBoundsController.setListener(this); mTvPipBoundsController.setListener(this);
@@ -392,7 +393,7 @@ public class TvPipController implements PipTransitionController.PipTransitionCal
@Override @Override
public void onKeepClearAreasChanged(int displayId, Set<Rect> restricted, public void onKeepClearAreasChanged(int displayId, Set<Rect> restricted,
Set<Rect> unrestricted) { Set<Rect> unrestricted) {
if (mTvPipBoundsState.getDisplayId() == displayId) { if (mPipDisplayLayoutState.getDisplayId() == displayId) {
boolean unrestrictedAreasChanged = !Objects.equals(unrestricted, boolean unrestrictedAreasChanged = !Objects.equals(unrestricted,
mTvPipBoundsState.getUnrestrictedKeepClearAreas()); mTvPipBoundsState.getUnrestrictedKeepClearAreas());
mTvPipBoundsState.setKeepClearAreas(restricted, unrestricted); mTvPipBoundsState.setKeepClearAreas(restricted, unrestricted);

View File

@@ -28,6 +28,7 @@ import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.pip.PipAnimationController; import com.android.wm.shell.pip.PipAnimationController;
import com.android.wm.shell.pip.PipBoundsAlgorithm; import com.android.wm.shell.pip.PipBoundsAlgorithm;
import com.android.wm.shell.pip.PipBoundsState; import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipDisplayLayoutState;
import com.android.wm.shell.pip.PipMenuController; import com.android.wm.shell.pip.PipMenuController;
import com.android.wm.shell.pip.PipParamsChangedForwarder; import com.android.wm.shell.pip.PipParamsChangedForwarder;
import com.android.wm.shell.pip.PipSurfaceTransactionHelper; import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
@@ -36,7 +37,6 @@ import com.android.wm.shell.pip.PipTransitionController;
import com.android.wm.shell.pip.PipTransitionState; import com.android.wm.shell.pip.PipTransitionState;
import com.android.wm.shell.pip.PipUiEventLogger; import com.android.wm.shell.pip.PipUiEventLogger;
import com.android.wm.shell.pip.PipUtils; import com.android.wm.shell.pip.PipUtils;
import com.android.wm.shell.pip.phone.PipSizeSpecHandler;
import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.splitscreen.SplitScreenController;
import java.util.Objects; import java.util.Objects;
@@ -51,7 +51,7 @@ public class TvPipTaskOrganizer extends PipTaskOrganizer {
@NonNull SyncTransactionQueue syncTransactionQueue, @NonNull SyncTransactionQueue syncTransactionQueue,
@NonNull PipTransitionState pipTransitionState, @NonNull PipTransitionState pipTransitionState,
@NonNull PipBoundsState pipBoundsState, @NonNull PipBoundsState pipBoundsState,
@NonNull PipSizeSpecHandler pipSizeSpecHandler, @NonNull PipDisplayLayoutState pipDisplayLayoutState,
@NonNull PipBoundsAlgorithm boundsHandler, @NonNull PipBoundsAlgorithm boundsHandler,
@NonNull PipMenuController pipMenuController, @NonNull PipMenuController pipMenuController,
@NonNull PipAnimationController pipAnimationController, @NonNull PipAnimationController pipAnimationController,
@@ -63,8 +63,8 @@ public class TvPipTaskOrganizer extends PipTaskOrganizer {
@NonNull PipUiEventLogger pipUiEventLogger, @NonNull PipUiEventLogger pipUiEventLogger,
@NonNull ShellTaskOrganizer shellTaskOrganizer, @NonNull ShellTaskOrganizer shellTaskOrganizer,
ShellExecutor mainExecutor) { ShellExecutor mainExecutor) {
super(context, syncTransactionQueue, pipTransitionState, pipBoundsState, pipSizeSpecHandler, super(context, syncTransactionQueue, pipTransitionState, pipBoundsState,
boundsHandler, pipMenuController, pipAnimationController, pipDisplayLayoutState, boundsHandler, pipMenuController, pipAnimationController,
surfaceTransactionHelper, pipTransitionController, pipParamsChangedForwarder, surfaceTransactionHelper, pipTransitionController, pipParamsChangedForwarder,
splitScreenOptional, displayController, pipUiEventLogger, shellTaskOrganizer, splitScreenOptional, displayController, pipUiEventLogger, shellTaskOrganizer,
mainExecutor); mainExecutor);

View File

@@ -55,25 +55,28 @@ public class PipBoundsAlgorithmTest extends ShellTestCase {
private static final float MAX_ASPECT_RATIO = 2f; private static final float MAX_ASPECT_RATIO = 2f;
private static final int DEFAULT_MIN_EDGE_SIZE = 100; private static final int DEFAULT_MIN_EDGE_SIZE = 100;
/** The minimum possible size of the override min size's width or height */
private static final int OVERRIDABLE_MIN_SIZE = 40;
private PipBoundsAlgorithm mPipBoundsAlgorithm; private PipBoundsAlgorithm mPipBoundsAlgorithm;
private DisplayInfo mDefaultDisplayInfo; private DisplayInfo mDefaultDisplayInfo;
private PipBoundsState mPipBoundsState; private PipBoundsState mPipBoundsState; private PipSizeSpecHandler mPipSizeSpecHandler;
private PipSizeSpecHandler mPipSizeSpecHandler; private PipDisplayLayoutState mPipDisplayLayoutState;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
initializeMockResources(); initializeMockResources();
mPipSizeSpecHandler = new PipSizeSpecHandler(mContext); mPipDisplayLayoutState = new PipDisplayLayoutState(mContext);
mPipBoundsState = new PipBoundsState(mContext, mPipSizeSpecHandler); mPipSizeSpecHandler = new PipSizeSpecHandler(mContext, mPipDisplayLayoutState);
mPipBoundsState = new PipBoundsState(mContext, mPipSizeSpecHandler, mPipDisplayLayoutState);
mPipBoundsAlgorithm = new PipBoundsAlgorithm(mContext, mPipBoundsState, mPipBoundsAlgorithm = new PipBoundsAlgorithm(mContext, mPipBoundsState,
new PipSnapAlgorithm(), new PipKeepClearAlgorithmInterface() {}, new PipSnapAlgorithm(), new PipKeepClearAlgorithmInterface() {},
mPipSizeSpecHandler); mPipSizeSpecHandler);
DisplayLayout layout = DisplayLayout layout =
new DisplayLayout(mDefaultDisplayInfo, mContext.getResources(), true, true); new DisplayLayout(mDefaultDisplayInfo, mContext.getResources(), true, true);
mPipBoundsState.setDisplayLayout(layout); mPipDisplayLayoutState.setDisplayLayout(layout);
mPipSizeSpecHandler.setDisplayLayout(layout);
} }
private void initializeMockResources() { private void initializeMockResources() {
@@ -87,6 +90,9 @@ public class PipBoundsAlgorithmTest extends ShellTestCase {
res.addOverride( res.addOverride(
R.dimen.default_minimal_size_pip_resizable_task, R.dimen.default_minimal_size_pip_resizable_task,
DEFAULT_MIN_EDGE_SIZE); DEFAULT_MIN_EDGE_SIZE);
res.addOverride(
R.dimen.overridable_minimal_size_pip_resizable_task,
OVERRIDABLE_MIN_SIZE);
res.addOverride( res.addOverride(
R.string.config_defaultPictureInPictureScreenEdgeInsets, R.string.config_defaultPictureInPictureScreenEdgeInsets,
"16x16"); "16x16");

View File

@@ -27,11 +27,13 @@ import android.content.ComponentName;
import android.graphics.Rect; import android.graphics.Rect;
import android.testing.AndroidTestingRunner; import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper; import android.testing.TestableLooper;
import android.testing.TestableResources;
import android.util.Size; import android.util.Size;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import com.android.internal.util.function.TriConsumer; import com.android.internal.util.function.TriConsumer;
import com.android.wm.shell.R;
import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.pip.phone.PipSizeSpecHandler; import com.android.wm.shell.pip.phone.PipSizeSpecHandler;
@@ -52,13 +54,23 @@ public class PipBoundsStateTest extends ShellTestCase {
private static final Size DEFAULT_SIZE = new Size(10, 10); private static final Size DEFAULT_SIZE = new Size(10, 10);
private static final float DEFAULT_SNAP_FRACTION = 1.0f; private static final float DEFAULT_SNAP_FRACTION = 1.0f;
/** The minimum possible size of the override min size's width or height */
private static final int OVERRIDABLE_MIN_SIZE = 40;
private PipBoundsState mPipBoundsState; private PipBoundsState mPipBoundsState;
private ComponentName mTestComponentName1; private ComponentName mTestComponentName1;
private ComponentName mTestComponentName2; private ComponentName mTestComponentName2;
@Before @Before
public void setUp() { public void setUp() {
mPipBoundsState = new PipBoundsState(mContext, new PipSizeSpecHandler(mContext)); final TestableResources res = mContext.getOrCreateTestableResources();
res.addOverride(
R.dimen.overridable_minimal_size_pip_resizable_task,
OVERRIDABLE_MIN_SIZE);
PipDisplayLayoutState pipDisplayLayoutState = new PipDisplayLayoutState(mContext);
mPipBoundsState = new PipBoundsState(mContext,
new PipSizeSpecHandler(mContext, pipDisplayLayoutState), pipDisplayLayoutState);
mTestComponentName1 = new ComponentName(mContext, "component1"); mTestComponentName1 = new ComponentName(mContext, "component1");
mTestComponentName2 = new ComponentName(mContext, "component2"); mTestComponentName2 = new ComponentName(mContext, "component2");
} }

View File

@@ -88,6 +88,7 @@ public class PipTaskOrganizerTest extends ShellTestCase {
private PipTransitionState mPipTransitionState; private PipTransitionState mPipTransitionState;
private PipBoundsAlgorithm mPipBoundsAlgorithm; private PipBoundsAlgorithm mPipBoundsAlgorithm;
private PipSizeSpecHandler mPipSizeSpecHandler; private PipSizeSpecHandler mPipSizeSpecHandler;
private PipDisplayLayoutState mPipDisplayLayoutState;
private ComponentName mComponent1; private ComponentName mComponent1;
private ComponentName mComponent2; private ComponentName mComponent2;
@@ -97,15 +98,16 @@ public class PipTaskOrganizerTest extends ShellTestCase {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mComponent1 = new ComponentName(mContext, "component1"); mComponent1 = new ComponentName(mContext, "component1");
mComponent2 = new ComponentName(mContext, "component2"); mComponent2 = new ComponentName(mContext, "component2");
mPipSizeSpecHandler = new PipSizeSpecHandler(mContext); mPipDisplayLayoutState = new PipDisplayLayoutState(mContext);
mPipBoundsState = new PipBoundsState(mContext, mPipSizeSpecHandler); mPipSizeSpecHandler = new PipSizeSpecHandler(mContext, mPipDisplayLayoutState);
mPipBoundsState = new PipBoundsState(mContext, mPipSizeSpecHandler, mPipDisplayLayoutState);
mPipTransitionState = new PipTransitionState(); mPipTransitionState = new PipTransitionState();
mPipBoundsAlgorithm = new PipBoundsAlgorithm(mContext, mPipBoundsState, mPipBoundsAlgorithm = new PipBoundsAlgorithm(mContext, mPipBoundsState,
new PipSnapAlgorithm(), new PipKeepClearAlgorithmInterface() {}, new PipSnapAlgorithm(), new PipKeepClearAlgorithmInterface() {},
mPipSizeSpecHandler); mPipSizeSpecHandler);
mMainExecutor = new TestShellExecutor(); mMainExecutor = new TestShellExecutor();
mPipTaskOrganizer = new PipTaskOrganizer(mContext, mMockSyncTransactionQueue, mPipTaskOrganizer = new PipTaskOrganizer(mContext, mMockSyncTransactionQueue,
mPipTransitionState, mPipBoundsState, mPipSizeSpecHandler, mPipTransitionState, mPipBoundsState, mPipDisplayLayoutState,
mPipBoundsAlgorithm, mMockPhonePipMenuController, mMockPipAnimationController, mPipBoundsAlgorithm, mMockPhonePipMenuController, mMockPipAnimationController,
mMockPipSurfaceTransactionHelper, mMockPipTransitionController, mMockPipSurfaceTransactionHelper, mMockPipTransitionController,
mMockPipParamsChangedForwarder, mMockOptionalSplitScreen, mMockDisplayController, mMockPipParamsChangedForwarder, mMockOptionalSplitScreen, mMockDisplayController,
@@ -259,8 +261,7 @@ public class PipTaskOrganizerTest extends ShellTestCase {
final DisplayInfo info = new DisplayInfo(); final DisplayInfo info = new DisplayInfo();
DisplayLayout layout = new DisplayLayout(info, DisplayLayout layout = new DisplayLayout(info,
mContext.getResources(), true, true); mContext.getResources(), true, true);
mPipBoundsState.setDisplayLayout(layout); mPipDisplayLayoutState.setDisplayLayout(layout);
mPipSizeSpecHandler.setDisplayLayout(layout);
mPipTaskOrganizer.setOneShotAnimationType(PipAnimationController.ANIM_TYPE_ALPHA); mPipTaskOrganizer.setOneShotAnimationType(PipAnimationController.ANIM_TYPE_ALPHA);
mPipTaskOrganizer.setSurfaceControlTransactionFactory( mPipTaskOrganizer.setSurfaceControlTransactionFactory(
MockSurfaceControlHelper::createMockSurfaceControlTransaction); MockSurfaceControlHelper::createMockSurfaceControlTransaction);

View File

@@ -59,6 +59,7 @@ import com.android.wm.shell.pip.PipAnimationController;
import com.android.wm.shell.pip.PipAppOpsListener; import com.android.wm.shell.pip.PipAppOpsListener;
import com.android.wm.shell.pip.PipBoundsAlgorithm; import com.android.wm.shell.pip.PipBoundsAlgorithm;
import com.android.wm.shell.pip.PipBoundsState; import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipDisplayLayoutState;
import com.android.wm.shell.pip.PipMediaController; import com.android.wm.shell.pip.PipMediaController;
import com.android.wm.shell.pip.PipParamsChangedForwarder; import com.android.wm.shell.pip.PipParamsChangedForwarder;
import com.android.wm.shell.pip.PipSnapAlgorithm; import com.android.wm.shell.pip.PipSnapAlgorithm;
@@ -108,6 +109,7 @@ public class PipControllerTest extends ShellTestCase {
@Mock private WindowManagerShellWrapper mMockWindowManagerShellWrapper; @Mock private WindowManagerShellWrapper mMockWindowManagerShellWrapper;
@Mock private PipBoundsState mMockPipBoundsState; @Mock private PipBoundsState mMockPipBoundsState;
@Mock private PipSizeSpecHandler mMockPipSizeSpecHandler; @Mock private PipSizeSpecHandler mMockPipSizeSpecHandler;
@Mock private PipDisplayLayoutState mMockPipDisplayLayoutState;
@Mock private TaskStackListenerImpl mMockTaskStackListener; @Mock private TaskStackListenerImpl mMockTaskStackListener;
@Mock private ShellExecutor mMockExecutor; @Mock private ShellExecutor mMockExecutor;
@Mock private Optional<OneHandedController> mMockOneHandedController; @Mock private Optional<OneHandedController> mMockOneHandedController;
@@ -130,12 +132,12 @@ public class PipControllerTest extends ShellTestCase {
mPipController = new PipController(mContext, mShellInit, mMockShellCommandHandler, mPipController = new PipController(mContext, mShellInit, mMockShellCommandHandler,
mShellController, mMockDisplayController, mMockPipAnimationController, mShellController, mMockDisplayController, mMockPipAnimationController,
mMockPipAppOpsListener, mMockPipBoundsAlgorithm, mMockPipKeepClearAlgorithm, mMockPipAppOpsListener, mMockPipBoundsAlgorithm, mMockPipKeepClearAlgorithm,
mMockPipBoundsState, mMockPipSizeSpecHandler, mMockPipMotionHelper, mMockPipBoundsState, mMockPipSizeSpecHandler, mMockPipDisplayLayoutState,
mMockPipMediaController, mMockPhonePipMenuController, mMockPipTaskOrganizer, mMockPipMotionHelper, mMockPipMediaController, mMockPhonePipMenuController,
mMockPipTransitionState, mMockPipTouchHandler, mMockPipTransitionController, mMockPipTaskOrganizer, mMockPipTransitionState, mMockPipTouchHandler,
mMockWindowManagerShellWrapper, mMockTaskStackListener, mMockPipTransitionController, mMockWindowManagerShellWrapper,
mMockPipParamsChangedForwarder, mMockDisplayInsetsController, mMockTaskStackListener, mMockPipParamsChangedForwarder,
mMockOneHandedController, mMockExecutor); mMockDisplayInsetsController, mMockOneHandedController, mMockExecutor);
mShellInit.init(); mShellInit.init();
when(mMockPipBoundsAlgorithm.getSnapAlgorithm()).thenReturn(mMockPipSnapAlgorithm); when(mMockPipBoundsAlgorithm.getSnapAlgorithm()).thenReturn(mMockPipSnapAlgorithm);
when(mMockPipTouchHandler.getMotionHelper()).thenReturn(mMockPipMotionHelper); when(mMockPipTouchHandler.getMotionHelper()).thenReturn(mMockPipMotionHelper);
@@ -221,12 +223,12 @@ public class PipControllerTest extends ShellTestCase {
assertNull(PipController.create(spyContext, shellInit, mMockShellCommandHandler, assertNull(PipController.create(spyContext, shellInit, mMockShellCommandHandler,
mShellController, mMockDisplayController, mMockPipAnimationController, mShellController, mMockDisplayController, mMockPipAnimationController,
mMockPipAppOpsListener, mMockPipBoundsAlgorithm, mMockPipKeepClearAlgorithm, mMockPipAppOpsListener, mMockPipBoundsAlgorithm, mMockPipKeepClearAlgorithm,
mMockPipBoundsState, mMockPipSizeSpecHandler, mMockPipMotionHelper, mMockPipBoundsState, mMockPipSizeSpecHandler, mMockPipDisplayLayoutState,
mMockPipMediaController, mMockPhonePipMenuController, mMockPipTaskOrganizer, mMockPipMotionHelper, mMockPipMediaController, mMockPhonePipMenuController,
mMockPipTransitionState, mMockPipTouchHandler, mMockPipTransitionController, mMockPipTaskOrganizer, mMockPipTransitionState, mMockPipTouchHandler,
mMockWindowManagerShellWrapper, mMockTaskStackListener, mMockPipTransitionController, mMockWindowManagerShellWrapper,
mMockPipParamsChangedForwarder, mMockDisplayInsetsController, mMockTaskStackListener, mMockPipParamsChangedForwarder,
mMockOneHandedController, mMockExecutor)); mMockDisplayInsetsController, mMockOneHandedController, mMockExecutor));
} }
@Test @Test
@@ -283,8 +285,8 @@ public class PipControllerTest extends ShellTestCase {
when(mMockPipBoundsState.getMinSize()).thenReturn(new Point(1, 1)); when(mMockPipBoundsState.getMinSize()).thenReturn(new Point(1, 1));
when(mMockPipBoundsState.getMaxSize()).thenReturn(new Point(MAX_VALUE, MAX_VALUE)); when(mMockPipBoundsState.getMaxSize()).thenReturn(new Point(MAX_VALUE, MAX_VALUE));
when(mMockPipBoundsState.getBounds()).thenReturn(bounds); when(mMockPipBoundsState.getBounds()).thenReturn(bounds);
when(mMockPipBoundsState.getDisplayId()).thenReturn(displayId); when(mMockPipDisplayLayoutState.getDisplayId()).thenReturn(displayId);
when(mMockPipBoundsState.getDisplayLayout()).thenReturn(mMockDisplayLayout1); when(mMockPipDisplayLayoutState.getDisplayLayout()).thenReturn(mMockDisplayLayout1);
when(mMockDisplayController.getDisplayLayout(displayId)).thenReturn(mMockDisplayLayout2); when(mMockDisplayController.getDisplayLayout(displayId)).thenReturn(mMockDisplayLayout2);
when(mMockPipTaskOrganizer.isInPip()).thenReturn(true); when(mMockPipTaskOrganizer.isInPip()).thenReturn(true);
@@ -299,8 +301,8 @@ public class PipControllerTest extends ShellTestCase {
final int displayId = 1; final int displayId = 1;
final Rect bounds = new Rect(0, 0, 10, 10); final Rect bounds = new Rect(0, 0, 10, 10);
when(mMockPipBoundsAlgorithm.getDefaultBounds()).thenReturn(bounds); when(mMockPipBoundsAlgorithm.getDefaultBounds()).thenReturn(bounds);
when(mMockPipBoundsState.getDisplayId()).thenReturn(displayId); when(mMockPipDisplayLayoutState.getDisplayId()).thenReturn(displayId);
when(mMockPipBoundsState.getDisplayLayout()).thenReturn(mMockDisplayLayout1); when(mMockPipDisplayLayoutState.getDisplayLayout()).thenReturn(mMockDisplayLayout1);
when(mMockDisplayController.getDisplayLayout(displayId)).thenReturn(mMockDisplayLayout2); when(mMockDisplayController.getDisplayLayout(displayId)).thenReturn(mMockDisplayLayout2);
when(mMockPipTaskOrganizer.isInPip()).thenReturn(false); when(mMockPipTaskOrganizer.isInPip()).thenReturn(false);
@@ -314,7 +316,7 @@ public class PipControllerTest extends ShellTestCase {
public void onKeepClearAreasChanged_featureDisabled_pipBoundsStateDoesntChange() { public void onKeepClearAreasChanged_featureDisabled_pipBoundsStateDoesntChange() {
final int displayId = 1; final int displayId = 1;
final Rect keepClearArea = new Rect(0, 0, 10, 10); final Rect keepClearArea = new Rect(0, 0, 10, 10);
when(mMockPipBoundsState.getDisplayId()).thenReturn(displayId); when(mMockPipDisplayLayoutState.getDisplayId()).thenReturn(displayId);
mPipController.mDisplaysChangedListener.onKeepClearAreasChanged( mPipController.mDisplaysChangedListener.onKeepClearAreasChanged(
displayId, Set.of(keepClearArea), Set.of()); displayId, Set.of(keepClearArea), Set.of());
@@ -327,7 +329,7 @@ public class PipControllerTest extends ShellTestCase {
mPipController.setEnablePipKeepClearAlgorithm(true); mPipController.setEnablePipKeepClearAlgorithm(true);
final int displayId = 1; final int displayId = 1;
final Rect keepClearArea = new Rect(0, 0, 10, 10); final Rect keepClearArea = new Rect(0, 0, 10, 10);
when(mMockPipBoundsState.getDisplayId()).thenReturn(displayId); when(mMockPipDisplayLayoutState.getDisplayId()).thenReturn(displayId);
mPipController.mDisplaysChangedListener.onKeepClearAreasChanged( mPipController.mDisplaysChangedListener.onKeepClearAreasChanged(
displayId, Set.of(keepClearArea), Set.of()); displayId, Set.of(keepClearArea), Set.of());

View File

@@ -37,6 +37,7 @@ import com.android.wm.shell.common.FloatingContentCoordinator;
import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.pip.PipBoundsAlgorithm; import com.android.wm.shell.pip.PipBoundsAlgorithm;
import com.android.wm.shell.pip.PipBoundsState; import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipDisplayLayoutState;
import com.android.wm.shell.pip.PipKeepClearAlgorithmInterface; import com.android.wm.shell.pip.PipKeepClearAlgorithmInterface;
import com.android.wm.shell.pip.PipSnapAlgorithm; import com.android.wm.shell.pip.PipSnapAlgorithm;
import com.android.wm.shell.pip.PipTaskOrganizer; import com.android.wm.shell.pip.PipTaskOrganizer;
@@ -87,11 +88,14 @@ public class PipResizeGestureHandlerTest extends ShellTestCase {
private PipSizeSpecHandler mPipSizeSpecHandler; private PipSizeSpecHandler mPipSizeSpecHandler;
private PipDisplayLayoutState mPipDisplayLayoutState;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mPipSizeSpecHandler = new PipSizeSpecHandler(mContext); mPipDisplayLayoutState = new PipDisplayLayoutState(mContext);
mPipBoundsState = new PipBoundsState(mContext, mPipSizeSpecHandler); mPipSizeSpecHandler = new PipSizeSpecHandler(mContext, mPipDisplayLayoutState);
mPipBoundsState = new PipBoundsState(mContext, mPipSizeSpecHandler, mPipDisplayLayoutState);
final PipSnapAlgorithm pipSnapAlgorithm = new PipSnapAlgorithm(); final PipSnapAlgorithm pipSnapAlgorithm = new PipSnapAlgorithm();
final PipKeepClearAlgorithmInterface pipKeepClearAlgorithm = final PipKeepClearAlgorithmInterface pipKeepClearAlgorithm =
new PipKeepClearAlgorithmInterface() {}; new PipKeepClearAlgorithmInterface() {};

View File

@@ -33,6 +33,7 @@ import android.view.DisplayInfo;
import com.android.dx.mockito.inline.extended.StaticMockitoSession; import com.android.dx.mockito.inline.extended.StaticMockitoSession;
import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.pip.PipDisplayLayoutState;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
@@ -74,6 +75,7 @@ public class PipSizeSpecHandlerTest extends ShellTestCase {
@Mock private Context mContext; @Mock private Context mContext;
@Mock private Resources mResources; @Mock private Resources mResources;
private PipDisplayLayoutState mPipDisplayLayoutState;
private PipSizeSpecHandler mPipSizeSpecHandler; private PipSizeSpecHandler mPipSizeSpecHandler;
/** /**
@@ -137,7 +139,6 @@ public class PipSizeSpecHandlerTest extends ShellTestCase {
@Before @Before
public void setUp() { public void setUp() {
initExpectedSizes(); initExpectedSizes();
setUpStaticSystemPropertiesSession();
when(mResources.getDimensionPixelSize(anyInt())).thenReturn(DEFAULT_MIN_EDGE_SIZE); when(mResources.getDimensionPixelSize(anyInt())).thenReturn(DEFAULT_MIN_EDGE_SIZE);
when(mResources.getFloat(anyInt())).thenReturn(OPTIMIZED_ASPECT_RATIO); when(mResources.getFloat(anyInt())).thenReturn(OPTIMIZED_ASPECT_RATIO);
@@ -148,11 +149,6 @@ public class PipSizeSpecHandlerTest extends ShellTestCase {
// set up the mock context for spec handler specifically // set up the mock context for spec handler specifically
when(mContext.getResources()).thenReturn(mResources); when(mContext.getResources()).thenReturn(mResources);
mPipSizeSpecHandler = new PipSizeSpecHandler(mContext);
// no overridden min edge size by default
mPipSizeSpecHandler.setOverrideMinSize(null);
DisplayInfo displayInfo = new DisplayInfo(); DisplayInfo displayInfo = new DisplayInfo();
displayInfo.logicalWidth = DISPLAY_EDGE_SIZE; displayInfo.logicalWidth = DISPLAY_EDGE_SIZE;
displayInfo.logicalHeight = DISPLAY_EDGE_SIZE; displayInfo.logicalHeight = DISPLAY_EDGE_SIZE;
@@ -161,7 +157,14 @@ public class PipSizeSpecHandlerTest extends ShellTestCase {
// this is done to avoid unnecessary mocking while allowing for custom display dimensions // this is done to avoid unnecessary mocking while allowing for custom display dimensions
DisplayLayout displayLayout = new DisplayLayout(displayInfo, getContext().getResources(), DisplayLayout displayLayout = new DisplayLayout(displayInfo, getContext().getResources(),
false, false); false, false);
mPipSizeSpecHandler.setDisplayLayout(displayLayout); mPipDisplayLayoutState = new PipDisplayLayoutState(mContext);
mPipDisplayLayoutState.setDisplayLayout(displayLayout);
setUpStaticSystemPropertiesSession();
mPipSizeSpecHandler = new PipSizeSpecHandler(mContext, mPipDisplayLayoutState);
// no overridden min edge size by default
mPipSizeSpecHandler.setOverrideMinSize(null);
} }
@After @After

View File

@@ -35,6 +35,7 @@ import com.android.wm.shell.common.FloatingContentCoordinator;
import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.pip.PipBoundsAlgorithm; import com.android.wm.shell.pip.PipBoundsAlgorithm;
import com.android.wm.shell.pip.PipBoundsState; import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipDisplayLayoutState;
import com.android.wm.shell.pip.PipKeepClearAlgorithmInterface; import com.android.wm.shell.pip.PipKeepClearAlgorithmInterface;
import com.android.wm.shell.pip.PipSnapAlgorithm; import com.android.wm.shell.pip.PipSnapAlgorithm;
import com.android.wm.shell.pip.PipTaskOrganizer; import com.android.wm.shell.pip.PipTaskOrganizer;
@@ -92,6 +93,7 @@ public class PipTouchHandlerTest extends ShellTestCase {
private PipMotionHelper mMotionHelper; private PipMotionHelper mMotionHelper;
private PipResizeGestureHandler mPipResizeGestureHandler; private PipResizeGestureHandler mPipResizeGestureHandler;
private PipSizeSpecHandler mPipSizeSpecHandler; private PipSizeSpecHandler mPipSizeSpecHandler;
private PipDisplayLayoutState mPipDisplayLayoutState;
private DisplayLayout mDisplayLayout; private DisplayLayout mDisplayLayout;
private Rect mInsetBounds; private Rect mInsetBounds;
@@ -105,8 +107,9 @@ public class PipTouchHandlerTest extends ShellTestCase {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mPipSizeSpecHandler = new PipSizeSpecHandler(mContext); mPipDisplayLayoutState = new PipDisplayLayoutState(mContext);
mPipBoundsState = new PipBoundsState(mContext, mPipSizeSpecHandler); mPipSizeSpecHandler = new PipSizeSpecHandler(mContext, mPipDisplayLayoutState);
mPipBoundsState = new PipBoundsState(mContext, mPipSizeSpecHandler, mPipDisplayLayoutState);
mPipSnapAlgorithm = new PipSnapAlgorithm(); mPipSnapAlgorithm = new PipSnapAlgorithm();
mPipBoundsAlgorithm = new PipBoundsAlgorithm(mContext, mPipBoundsState, mPipSnapAlgorithm, mPipBoundsAlgorithm = new PipBoundsAlgorithm(mContext, mPipBoundsState, mPipSnapAlgorithm,
new PipKeepClearAlgorithmInterface() {}, mPipSizeSpecHandler); new PipKeepClearAlgorithmInterface() {}, mPipSizeSpecHandler);
@@ -124,8 +127,7 @@ public class PipTouchHandlerTest extends ShellTestCase {
mPipTouchHandler.setPipResizeGestureHandler(mPipResizeGestureHandler); mPipTouchHandler.setPipResizeGestureHandler(mPipResizeGestureHandler);
mDisplayLayout = new DisplayLayout(mContext, mContext.getDisplay()); mDisplayLayout = new DisplayLayout(mContext, mContext.getDisplay());
mPipBoundsState.setDisplayLayout(mDisplayLayout); mPipDisplayLayoutState.setDisplayLayout(mDisplayLayout);
mPipSizeSpecHandler.setDisplayLayout(mDisplayLayout);
mInsetBounds = new Rect(mPipBoundsState.getDisplayBounds().left + INSET, mInsetBounds = new Rect(mPipBoundsState.getDisplayBounds().left + INSET,
mPipBoundsState.getDisplayBounds().top + INSET, mPipBoundsState.getDisplayBounds().top + INSET,
mPipBoundsState.getDisplayBounds().right - INSET, mPipBoundsState.getDisplayBounds().right - INSET,

View File

@@ -26,6 +26,7 @@ import static org.junit.Assert.assertEquals;
import android.view.Gravity; import android.view.Gravity;
import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.pip.PipDisplayLayoutState;
import com.android.wm.shell.pip.PipSnapAlgorithm; import com.android.wm.shell.pip.PipSnapAlgorithm;
import com.android.wm.shell.pip.phone.PipSizeSpecHandler; import com.android.wm.shell.pip.phone.PipSizeSpecHandler;
@@ -47,6 +48,7 @@ public class TvPipGravityTest extends ShellTestCase {
private TvPipBoundsState mTvPipBoundsState; private TvPipBoundsState mTvPipBoundsState;
private TvPipBoundsAlgorithm mTvPipBoundsAlgorithm; private TvPipBoundsAlgorithm mTvPipBoundsAlgorithm;
private PipSizeSpecHandler mPipSizeSpecHandler; private PipSizeSpecHandler mPipSizeSpecHandler;
private PipDisplayLayoutState mPipDisplayLayoutState;
@Before @Before
public void setUp() { public void setUp() {
@@ -54,8 +56,10 @@ public class TvPipGravityTest extends ShellTestCase {
return; return;
} }
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mPipSizeSpecHandler = new PipSizeSpecHandler(mContext); mPipDisplayLayoutState = new PipDisplayLayoutState(mContext);
mTvPipBoundsState = new TvPipBoundsState(mContext, mPipSizeSpecHandler); mPipSizeSpecHandler = new PipSizeSpecHandler(mContext, mPipDisplayLayoutState);
mTvPipBoundsState = new TvPipBoundsState(mContext, mPipSizeSpecHandler,
mPipDisplayLayoutState);
mTvPipBoundsAlgorithm = new TvPipBoundsAlgorithm(mContext, mTvPipBoundsState, mTvPipBoundsAlgorithm = new TvPipBoundsAlgorithm(mContext, mTvPipBoundsState,
mMockPipSnapAlgorithm, mPipSizeSpecHandler); mMockPipSnapAlgorithm, mPipSizeSpecHandler);