Add PipBoundsState to manage current pip bounds

This change adds a basic state class and migrates
mLastReportedBounds from PipTaskOrg into it. It'll
eventually become the holder of all bounds-related state
such as movements bounds, reentry bounds/fraction and
aspect ratio.

Bug: 169373982
Test: atest com.android.wm.shell.pip
Change-Id: I43c530f4f3ab192756964022417f39f3085e593e
This commit is contained in:
jorgegil@google.com
2020-10-09 10:37:12 -07:00
parent d1fec2c75e
commit 9366e26361
11 changed files with 143 additions and 49 deletions

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2020 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.annotation.NonNull;
import android.graphics.Rect;
import java.io.PrintWriter;
/**
* Singleton source of truth for the current state of PIP bounds.
*/
public final class PipBoundsState {
private static final String TAG = PipBoundsState.class.getSimpleName();
private final @NonNull Rect mBounds = new Rect();
void setBounds(@NonNull Rect bounds) {
mBounds.set(bounds);
}
@NonNull
public Rect getBounds() {
return new Rect(mBounds);
}
/**
* Dumps internal state.
*/
public void dump(PrintWriter pw, String prefix) {
final String innerPrefix = prefix + " ";
pw.println(prefix + TAG);
pw.println(innerPrefix + "mBounds=" + mBounds);
}
}

View File

@@ -134,11 +134,11 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
private final Handler mMainHandler;
private final Handler mUpdateHandler;
private final PipBoundsState mPipBoundsState;
private final PipBoundsHandler mPipBoundsHandler;
private final PipAnimationController mPipAnimationController;
private final PipUiEventLogger mPipUiEventLoggerLogger;
private final List<PipTransitionCallback> mPipTransitionCallbacks = new ArrayList<>();
private final Rect mLastReportedBounds = new Rect();
private final int mEnterExitAnimationDuration;
private final PipSurfaceTransactionHelper mSurfaceTransactionHelper;
private final Map<IBinder, Configuration> mInitialState = new HashMap<>();
@@ -262,7 +262,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
*/
private boolean mShouldIgnoreEnteringPipTransition;
public PipTaskOrganizer(Context context, @NonNull PipBoundsHandler boundsHandler,
public PipTaskOrganizer(Context context, @NonNull PipBoundsState pipBoundsState,
@NonNull PipBoundsHandler boundsHandler,
@NonNull PipSurfaceTransactionHelper surfaceTransactionHelper,
Optional<SplitScreen> splitScreenOptional,
@NonNull DisplayController displayController,
@@ -270,6 +271,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
@NonNull ShellTaskOrganizer shellTaskOrganizer) {
mMainHandler = new Handler(Looper.getMainLooper());
mUpdateHandler = new Handler(PipUpdateThread.get().getLooper(), mUpdateCallbacks);
mPipBoundsState = pipBoundsState;
mPipBoundsHandler = boundsHandler;
mEnterExitAnimationDuration = context.getResources()
.getInteger(R.integer.config_pipResizeAnimationDuration);
@@ -292,17 +294,13 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
return mUpdateHandler;
}
public Rect getLastReportedBounds() {
return new Rect(mLastReportedBounds);
}
public Rect getCurrentOrAnimatingBounds() {
PipAnimationController.PipTransitionAnimator animator =
mPipAnimationController.getCurrentAnimator();
if (animator != null && animator.isRunning()) {
return new Rect(animator.getDestinationBounds());
}
return getLastReportedBounds();
return mPipBoundsState.getBounds();
}
public boolean isInPip() {
@@ -347,7 +345,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
* Expect {@link #onTaskAppeared(ActivityManager.RunningTaskInfo, SurfaceControl)} afterwards.
*/
public void stopSwipePipToHome(ComponentName componentName, Rect destinationBounds) {
mLastReportedBounds.set(destinationBounds);
mPipBoundsState.setBounds(destinationBounds);
}
/**
@@ -394,7 +392,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
final SurfaceControl.Transaction tx =
mSurfaceControlTransactionFactory.getTransaction();
mSurfaceTransactionHelper.scale(tx, mLeash, destinationBounds,
mLastReportedBounds);
mPipBoundsState.getBounds());
tx.setWindowCrop(mLeash, destinationBounds.width(), destinationBounds.height());
// We set to fullscreen here for now, but later it will be set to UNDEFINED for
// the proper windowing mode to take place. See #applyWindowingModeChangeOnExit.
@@ -408,9 +406,9 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
@Override
public void onTransactionReady(int id, SurfaceControl.Transaction t) {
t.apply();
scheduleAnimateResizePip(mLastReportedBounds, destinationBounds,
getValidSourceHintRect(mTaskInfo, destinationBounds), direction,
animationDurationMs, null /* updateBoundsCallback */);
scheduleAnimateResizePip(mPipBoundsState.getBounds(),
destinationBounds, getValidSourceHintRect(mTaskInfo, destinationBounds),
direction, animationDurationMs, null /* updateBoundsCallback */);
mState = State.EXITING_PIP;
}
});
@@ -441,7 +439,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
// removePipImmediately is expected when the following animation finishes.
mUpdateHandler.post(() -> mPipAnimationController
.getAnimator(mLeash, mLastReportedBounds, 1f, 0f)
.getAnimator(mLeash, mPipBoundsState.getBounds(), 1f, 0f)
.setTransitionDirection(TRANSITION_DIRECTION_REMOVE_STACK)
.setPipAnimationCallback(mPipAnimationCallback)
.setDuration(mEnterExitAnimationDuration)
@@ -480,7 +478,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
if (mShouldIgnoreEnteringPipTransition) {
// Animation has been finished together with Recents, directly apply the sync
// transaction to PiP here.
applyEnterPipSyncTransaction(mLastReportedBounds, () -> {
applyEnterPipSyncTransaction(mPipBoundsState.getBounds(), () -> {
mState = State.ENTERED_PIP;
});
mShouldIgnoreEnteringPipTransition = false;
@@ -572,7 +570,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
private void sendOnPipTransitionStarted(
@PipAnimationController.TransitionDirection int direction) {
final Rect pipBounds = new Rect(mLastReportedBounds);
final Rect pipBounds = mPipBoundsState.getBounds();
runOnMainHandler(() -> {
for (int i = mPipTransitionCallbacks.size() - 1; i >= 0; i--) {
final PipTransitionCallback callback = mPipTransitionCallbacks.get(i);
@@ -701,7 +699,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
}
final Rect destinationBounds = mPipBoundsHandler.getDestinationBounds(
info.topActivity, getAspectRatioOrDefault(newParams),
mLastReportedBounds, getMinimalSize(info.topActivityInfo),
mPipBoundsState.getBounds(), getMinimalSize(info.topActivityInfo),
true /* userCurrentMinEdgeSize */);
Objects.requireNonNull(destinationBounds, "Missing destination bounds");
scheduleAnimateResizePip(destinationBounds, mEnterExitAnimationDuration,
@@ -759,7 +757,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
sendOnPipTransitionCancelled(direction);
sendOnPipTransitionFinished(direction);
}
mLastReportedBounds.set(destinationBoundsOut);
mPipBoundsState.setBounds(destinationBoundsOut);
// Create a reset surface transaction for the new bounds and update the window
// container transaction
@@ -774,8 +772,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
destinationBoundsOut.set(animator.getDestinationBounds());
}
} else {
if (!mLastReportedBounds.isEmpty()) {
destinationBoundsOut.set(mLastReportedBounds);
if (!mPipBoundsState.getBounds().isEmpty()) {
destinationBoundsOut.set(mPipBoundsState.getBounds());
}
}
}
@@ -827,7 +825,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
Log.d(TAG, "skip scheduleAnimateResizePip, entering pip deferred");
return;
}
scheduleAnimateResizePip(mLastReportedBounds, toBounds, null /* sourceHintRect */,
scheduleAnimateResizePip(mPipBoundsState.getBounds(), toBounds, null /* sourceHintRect */,
TRANSITION_DIRECTION_NONE, duration, updateBoundsCallback);
}
@@ -963,7 +961,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
Log.w(TAG, "Abort animation, invalid leash");
return;
}
mLastReportedBounds.set(destinationBounds);
mPipBoundsState.setBounds(destinationBounds);
final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction();
mSurfaceTransactionHelper
.crop(tx, mLeash, destinationBounds)
@@ -999,7 +997,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
throw new RuntimeException("Callers should call scheduleResizePip() instead of this "
+ "directly");
}
mLastReportedBounds.set(destinationBounds);
mPipBoundsState.setBounds(destinationBounds);
if (direction == TRANSITION_DIRECTION_REMOVE_STACK) {
removePipImmediately();
return;
@@ -1141,7 +1139,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
pw.println(innerPrefix + "mState=" + mState);
pw.println(innerPrefix + "mOneShotAnimationType=" + mOneShotAnimationType);
pw.println(innerPrefix + "mPictureInPictureParams=" + mPictureInPictureParams);
pw.println(innerPrefix + "mLastReportedBounds=" + mLastReportedBounds);
pw.println(innerPrefix + "mInitialState:");
for (Map.Entry<IBinder, Configuration> e : mInitialState.entrySet()) {
pw.println(innerPrefix + " binder=" + e.getKey()

View File

@@ -15,6 +15,7 @@
*/
package com.android.wm.shell.pip.phone;
import android.annotation.NonNull;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.Region;
@@ -28,6 +29,7 @@ import android.view.accessibility.IAccessibilityInteractionConnection;
import android.view.accessibility.IAccessibilityInteractionConnectionCallback;
import com.android.wm.shell.R;
import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipSnapAlgorithm;
import com.android.wm.shell.pip.PipTaskOrganizer;
@@ -50,6 +52,7 @@ public class PipAccessibilityInteractionConnection
private Context mContext;
private Handler mHandler;
private final @NonNull PipBoundsState mPipBoundsState;
private PipMotionHelper mMotionHelper;
private PipTaskOrganizer mTaskOrganizer;
private PipSnapAlgorithm mSnapAlgorithm;
@@ -62,12 +65,14 @@ public class PipAccessibilityInteractionConnection
private final Rect mExpandedMovementBounds = new Rect();
private Rect mTmpBounds = new Rect();
public PipAccessibilityInteractionConnection(Context context, PipMotionHelper motionHelper,
public PipAccessibilityInteractionConnection(Context context,
@NonNull PipBoundsState pipBoundsState, PipMotionHelper motionHelper,
PipTaskOrganizer taskOrganizer, PipSnapAlgorithm snapAlgorithm,
AccessibilityCallbacks callbacks, Runnable updateMovementBoundCallback,
Handler handler) {
mContext = context;
mHandler = handler;
mPipBoundsState = pipBoundsState;
mMotionHelper = motionHelper;
mTaskOrganizer = taskOrganizer;
mSnapAlgorithm = snapAlgorithm;
@@ -148,7 +153,7 @@ public class PipAccessibilityInteractionConnection
private void setToExpandedBounds() {
float savedSnapFraction = mSnapAlgorithm.getSnapFraction(
new Rect(mTaskOrganizer.getLastReportedBounds()), mNormalMovementBounds);
mPipBoundsState.getBounds(), mNormalMovementBounds);
mSnapAlgorithm.applySnapFraction(mExpandedBounds, mExpandedMovementBounds,
savedSnapFraction);
mTaskOrganizer.scheduleFinishResizePip(mExpandedBounds, (Rect bounds) -> {
@@ -159,7 +164,7 @@ public class PipAccessibilityInteractionConnection
private void setToNormalBounds() {
float savedSnapFraction = mSnapAlgorithm.getSnapFraction(
new Rect(mTaskOrganizer.getLastReportedBounds()), mExpandedMovementBounds);
mPipBoundsState.getBounds(), mExpandedMovementBounds);
mSnapAlgorithm.applySnapFraction(mNormalBounds, mNormalMovementBounds, savedSnapFraction);
mTaskOrganizer.scheduleFinishResizePip(mNormalBounds, (Rect bounds) -> {
mMotionHelper.synchronizePinnedStackBounds();

View File

@@ -20,6 +20,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static com.android.wm.shell.pip.PipAnimationController.isOutPipDirection;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.PictureInPictureParams;
@@ -44,6 +45,7 @@ import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.pip.PinnedStackListenerForwarder;
import com.android.wm.shell.pip.Pip;
import com.android.wm.shell.pip.PipBoundsHandler;
import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipTaskOrganizer;
import java.io.PrintWriter;
@@ -65,6 +67,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
private DisplayController mDisplayController;
private PipAppOpsListener mAppOpsListener;
private PipBoundsHandler mPipBoundsHandler;
private @NonNull PipBoundsState mPipBoundsState;
private PipMediaController mMediaController;
private PipTouchHandler mTouchHandler;
private Consumer<Boolean> mPinnedStackAnimationRecentsCallback;
@@ -97,7 +100,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
// If the pip was in the offset zone earlier, adjust the new bounds to the bottom of the
// movement bounds
mTouchHandler.adjustBoundsForRotation(mTmpNormalBounds,
mPipTaskOrganizer.getLastReportedBounds(), mTmpInsetBounds);
mPipBoundsState.getBounds(), mTmpInsetBounds);
// The bounds are being applied to a specific snap fraction, so reset any known offsets
// for the previous orientation before updating the movement bounds.
@@ -196,6 +199,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
DisplayController displayController,
PipAppOpsListener pipAppOpsListener,
PipBoundsHandler pipBoundsHandler,
@NonNull PipBoundsState pipBoundsState,
PipMediaController pipMediaController,
PipMenuActivityController pipMenuActivityController,
PipTaskOrganizer pipTaskOrganizer,
@@ -206,7 +210,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
if (PipUtils.hasSystemFeature(mContext)) {
initController(context, displayController, pipAppOpsListener, pipBoundsHandler,
pipMediaController, pipMenuActivityController, pipTaskOrganizer,
pipBoundsState, pipMediaController, pipMenuActivityController, pipTaskOrganizer,
pipTouchHandler, windowManagerShellWrapper);
} else {
Log.w(TAG, "Device not support PIP feature");
@@ -217,6 +221,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
DisplayController displayController,
PipAppOpsListener pipAppOpsListener,
PipBoundsHandler pipBoundsHandler,
@NonNull PipBoundsState pipBoundsState,
PipMediaController pipMediaController,
PipMenuActivityController pipMenuActivityController,
PipTaskOrganizer pipTaskOrganizer,
@@ -232,6 +237,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
mWindowManagerShellWrapper = windowManagerShellWrapper;
mDisplayController = displayController;
mPipBoundsHandler = pipBoundsHandler;
mPipBoundsState = pipBoundsState;
mPipTaskOrganizer = pipTaskOrganizer;
mPipTaskOrganizer.registerPipTransitionCallback(this);
mMediaController = pipMediaController;
@@ -360,7 +366,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
final boolean changed = mPipBoundsHandler.setShelfHeight(visible, shelfHeight);
if (changed) {
mTouchHandler.onShelfVisibilityChanged(visible, shelfHeight);
updateMovementBounds(mPipTaskOrganizer.getLastReportedBounds(),
updateMovementBounds(mPipBoundsState.getBounds(),
false /* fromRotation */, false /* fromImeAdjustment */,
true /* fromShelfAdjustment */, null /* windowContainerTransaction */);
}
@@ -445,5 +451,6 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
mTouchHandler.dump(pw, innerPrefix);
mPipBoundsHandler.dump(pw, innerPrefix);
mPipTaskOrganizer.dump(pw, innerPrefix);
mPipBoundsState.dump(pw, innerPrefix);
}
}

View File

@@ -37,6 +37,7 @@ import com.android.wm.shell.animation.FloatProperties;
import com.android.wm.shell.animation.PhysicsAnimator;
import com.android.wm.shell.common.FloatingContentCoordinator;
import com.android.wm.shell.common.magnetictarget.MagnetizedObject;
import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipSnapAlgorithm;
import com.android.wm.shell.pip.PipTaskOrganizer;
@@ -66,6 +67,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
private final Context mContext;
private final PipTaskOrganizer mPipTaskOrganizer;
private final @NonNull PipBoundsState mPipBoundsState;
private PipMenuActivityController mMenuController;
private PipSnapAlgorithm mSnapAlgorithm;
@@ -178,11 +180,12 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
public void onPipTransitionCanceled(ComponentName activity, int direction) {}
};
public PipMotionHelper(Context context, PipTaskOrganizer pipTaskOrganizer,
PipMenuActivityController menuController, PipSnapAlgorithm snapAlgorithm,
FloatingContentCoordinator floatingContentCoordinator) {
public PipMotionHelper(Context context, @NonNull PipBoundsState pipBoundsState,
PipTaskOrganizer pipTaskOrganizer, PipMenuActivityController menuController,
PipSnapAlgorithm snapAlgorithm, FloatingContentCoordinator floatingContentCoordinator) {
mContext = context;
mPipTaskOrganizer = pipTaskOrganizer;
mPipBoundsState = pipBoundsState;
mMenuController = menuController;
mSnapAlgorithm = snapAlgorithm;
mFloatingContentCoordinator = floatingContentCoordinator;
@@ -220,7 +223,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
*/
void synchronizePinnedStackBounds() {
cancelAnimations();
mBounds.set(mPipTaskOrganizer.getLastReportedBounds());
mBounds.set(mPipBoundsState.getBounds());
mTemporaryBounds.setEmpty();
if (mPipTaskOrganizer.isInPip()) {

View File

@@ -22,6 +22,7 @@ import static com.android.wm.shell.pip.phone.PipMenuActivityController.MENU_STAT
import static com.android.wm.shell.pip.phone.PipMenuActivityController.MENU_STATE_FULL;
import static com.android.wm.shell.pip.phone.PipMenuActivityController.MENU_STATE_NONE;
import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Context;
@@ -48,6 +49,7 @@ import com.android.wm.shell.R;
import com.android.wm.shell.common.FloatingContentCoordinator;
import com.android.wm.shell.pip.PipAnimationController;
import com.android.wm.shell.pip.PipBoundsHandler;
import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipTaskOrganizer;
import com.android.wm.shell.pip.PipUiEventLogger;
@@ -70,6 +72,7 @@ public class PipTouchHandler {
private final boolean mEnableResize;
private final Context mContext;
private final PipBoundsHandler mPipBoundsHandler;
private final @NonNull PipBoundsState mPipBoundsState;
private final PipUiEventLogger mPipUiEventLogger;
private final PipDismissTargetHandler mPipDismissTargetHandler;
@@ -161,6 +164,7 @@ public class PipTouchHandler {
public PipTouchHandler(Context context,
PipMenuActivityController menuController,
PipBoundsHandler pipBoundsHandler,
@NonNull PipBoundsState pipBoundsState,
PipTaskOrganizer pipTaskOrganizer,
FloatingContentCoordinator floatingContentCoordinator,
PipUiEventLogger pipUiEventLogger) {
@@ -168,11 +172,12 @@ public class PipTouchHandler {
mContext = context;
mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
mPipBoundsHandler = pipBoundsHandler;
mPipBoundsState = pipBoundsState;
mMenuController = menuController;
mMenuController.addListener(new PipMenuListener());
mGesture = new DefaultPipTouchGesture();
mMotionHelper = new PipMotionHelper(mContext, pipTaskOrganizer, mMenuController,
mPipBoundsHandler.getSnapAlgorithm(), floatingContentCoordinator);
mMotionHelper = new PipMotionHelper(mContext, pipBoundsState, pipTaskOrganizer,
mMenuController, mPipBoundsHandler.getSnapAlgorithm(), floatingContentCoordinator);
mPipResizeGestureHandler =
new PipResizeGestureHandler(context, pipBoundsHandler, mMotionHelper,
pipTaskOrganizer, this::getMovementBounds,
@@ -189,8 +194,8 @@ public class PipTouchHandler {
reloadResources();
mFloatingContentCoordinator = floatingContentCoordinator;
mConnection = new PipAccessibilityInteractionConnection(mContext, mMotionHelper,
pipTaskOrganizer, mPipBoundsHandler.getSnapAlgorithm(),
mConnection = new PipAccessibilityInteractionConnection(mContext, pipBoundsState,
mMotionHelper, pipTaskOrganizer, mPipBoundsHandler.getSnapAlgorithm(),
this::onAccessibilityShowMenu, this::updateMovementBounds, mHandler);
mPipUiEventLogger = pipUiEventLogger;

View File

@@ -34,6 +34,7 @@ import android.testing.TestableLooper;
import com.android.wm.shell.WindowManagerShellWrapper;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.pip.PipBoundsHandler;
import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipTaskOrganizer;
import com.android.wm.shell.pip.PipTestCase;
import com.android.wm.shell.pip.phone.PipAppOpsListener;
@@ -67,10 +68,12 @@ public class PipControllerTest extends PipTestCase {
@Mock private PipTaskOrganizer mMockPipTaskOrganizer;
@Mock private PipTouchHandler mMockPipTouchHandler;
@Mock private WindowManagerShellWrapper mMockWindowManagerShellWrapper;
private PipBoundsState mPipBoundsState;
@Before
public void setUp() throws RemoteException {
MockitoAnnotations.initMocks(this);
mPipBoundsState = new PipBoundsState();
mSpiedContext = spy(mContext);
@@ -78,9 +81,9 @@ public class PipControllerTest extends PipTestCase {
when(mSpiedContext.getPackageManager()).thenReturn(mPackageManager);
mPipController = new PipController(mSpiedContext, mMockdDisplayController,
mMockPipAppOpsListener, mMockPipBoundsHandler, mMockPipMediaController,
mMockPipMenuActivityController, mMockPipTaskOrganizer, mMockPipTouchHandler,
mMockWindowManagerShellWrapper);
mMockPipAppOpsListener, mMockPipBoundsHandler, mPipBoundsState,
mMockPipMediaController, mMockPipMenuActivityController, mMockPipTaskOrganizer,
mMockPipTouchHandler, mMockWindowManagerShellWrapper);
}
@Test

View File

@@ -35,6 +35,7 @@ import android.testing.TestableLooper;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.pip.PipBoundsHandler;
import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
import com.android.wm.shell.pip.PipTaskOrganizer;
import com.android.wm.shell.pip.PipTestCase;
@@ -66,19 +67,21 @@ public class PipTaskOrganizerTest extends PipTestCase {
@Mock private PipUiEventLogger mMockPipUiEventLogger;
@Mock private Optional<SplitScreen> mMockOptionalSplitScreen;
@Mock private ShellTaskOrganizer mMockShellTaskOrganizer;
private PipBoundsState mPipBoundsState;
@Before
public void setUp() throws RemoteException {
MockitoAnnotations.initMocks(this);
mPipBoundsState = new PipBoundsState();
mSpiedContext = spy(mContext);
when(mPackageManager.hasSystemFeature(FEATURE_PICTURE_IN_PICTURE)).thenReturn(false);
when(mSpiedContext.getPackageManager()).thenReturn(mPackageManager);
mSpiedPipTaskOrganizer = spy(new PipTaskOrganizer(mSpiedContext, mMockPipBoundsHandler,
mMockPipSurfaceTransactionHelper, mMockOptionalSplitScreen, mMockdDisplayController,
mMockPipUiEventLogger, mMockShellTaskOrganizer));
mSpiedPipTaskOrganizer = spy(new PipTaskOrganizer(mSpiedContext, mPipBoundsState,
mMockPipBoundsHandler, mMockPipSurfaceTransactionHelper, mMockOptionalSplitScreen,
mMockdDisplayController, mMockPipUiEventLogger, mMockShellTaskOrganizer));
}
@Test

View File

@@ -33,6 +33,7 @@ import androidx.test.filters.SmallTest;
import com.android.wm.shell.R;
import com.android.wm.shell.common.FloatingContentCoordinator;
import com.android.wm.shell.pip.PipBoundsHandler;
import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipSnapAlgorithm;
import com.android.wm.shell.pip.PipTaskOrganizer;
import com.android.wm.shell.pip.PipTestCase;
@@ -74,6 +75,7 @@ public class PipTouchHandlerTest extends PipTestCase {
@Mock
private PipUiEventLogger mPipUiEventLogger;
private PipBoundsState mPipBoundsState;
private PipBoundsHandler mPipBoundsHandler;
private PipSnapAlgorithm mPipSnapAlgorithm;
private PipMotionHelper mMotionHelper;
@@ -90,11 +92,12 @@ public class PipTouchHandlerTest extends PipTestCase {
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mPipBoundsState = new PipBoundsState();
mPipBoundsHandler = new PipBoundsHandler(mContext);
mPipSnapAlgorithm = mPipBoundsHandler.getSnapAlgorithm();
mPipSnapAlgorithm = new PipSnapAlgorithm(mContext);
mPipTouchHandler = new PipTouchHandler(mContext, mPipMenuActivityController,
mPipBoundsHandler, mPipTaskOrganizer, mFloatingContentCoordinator,
mPipBoundsHandler, mPipBoundsState, mPipTaskOrganizer, mFloatingContentCoordinator,
mPipUiEventLogger);
mMotionHelper = Mockito.spy(mPipTouchHandler.getMotionHelper());
mPipResizeGestureHandler = Mockito.spy(mPipTouchHandler.getPipResizeGestureHandler());

View File

@@ -26,6 +26,7 @@ import com.android.wm.shell.WindowManagerShellWrapper;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.pip.Pip;
import com.android.wm.shell.pip.PipBoundsHandler;
import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
import com.android.wm.shell.pip.PipTaskOrganizer;
import com.android.wm.shell.pip.PipUiEventLogger;
@@ -84,14 +85,21 @@ public abstract class TvPipModule {
return new PipBoundsHandler(context);
}
@SysUISingleton
@Provides
static PipBoundsState providePipBoundsState() {
return new PipBoundsState();
}
@SysUISingleton
@Provides
static PipTaskOrganizer providePipTaskOrganizer(Context context,
PipBoundsState pipBoundsState,
PipBoundsHandler pipBoundsHandler,
PipSurfaceTransactionHelper pipSurfaceTransactionHelper,
Optional<SplitScreen> splitScreenOptional, DisplayController displayController,
PipUiEventLogger pipUiEventLogger, ShellTaskOrganizer shellTaskOrganizer) {
return new PipTaskOrganizer(context, pipBoundsHandler,
return new PipTaskOrganizer(context, pipBoundsState, pipBoundsHandler,
pipSurfaceTransactionHelper, splitScreenOptional, displayController,
pipUiEventLogger, shellTaskOrganizer);
}

View File

@@ -32,6 +32,7 @@ import com.android.wm.shell.common.SystemWindows;
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.pip.Pip;
import com.android.wm.shell.pip.PipBoundsHandler;
import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
import com.android.wm.shell.pip.PipTaskOrganizer;
import com.android.wm.shell.pip.PipUiEventLogger;
@@ -71,14 +72,16 @@ public class WMShellModule {
DisplayController displayController,
PipAppOpsListener pipAppOpsListener,
PipBoundsHandler pipBoundsHandler,
PipBoundsState pipBoundsState,
PipMediaController pipMediaController,
PipMenuActivityController pipMenuActivityController,
PipTaskOrganizer pipTaskOrganizer,
PipTouchHandler pipTouchHandler,
WindowManagerShellWrapper windowManagerShellWrapper) {
return new PipController(context, displayController,
pipAppOpsListener, pipBoundsHandler, pipMediaController, pipMenuActivityController,
pipTaskOrganizer, pipTouchHandler, windowManagerShellWrapper);
pipAppOpsListener, pipBoundsHandler, pipBoundsState, pipMediaController,
pipMenuActivityController, pipTaskOrganizer, pipTouchHandler,
windowManagerShellWrapper);
}
@SysUISingleton
@@ -92,6 +95,12 @@ public class WMShellModule {
displayImeController, handler, transactionPool, shellTaskOrganizer, syncQueue);
}
@SysUISingleton
@Provides
static PipBoundsState providePipBoundsState() {
return new PipBoundsState();
}
@SysUISingleton
@Provides
static PipBoundsHandler providesPipBoundsHandler(Context context) {
@@ -109,21 +118,23 @@ public class WMShellModule {
@Provides
static PipTouchHandler providesPipTouchHandler(Context context,
PipMenuActivityController menuActivityController, PipBoundsHandler pipBoundsHandler,
PipBoundsState pipBoundsState,
PipTaskOrganizer pipTaskOrganizer,
FloatingContentCoordinator floatingContentCoordinator,
PipUiEventLogger pipUiEventLogger) {
return new PipTouchHandler(context, menuActivityController, pipBoundsHandler,
pipTaskOrganizer, floatingContentCoordinator, pipUiEventLogger);
pipBoundsState, pipTaskOrganizer, floatingContentCoordinator, pipUiEventLogger);
}
@SysUISingleton
@Provides
static PipTaskOrganizer providesPipTaskOrganizer(Context context,
PipBoundsState pipBoundsState,
PipBoundsHandler pipBoundsHandler,
PipSurfaceTransactionHelper pipSurfaceTransactionHelper,
Optional<SplitScreen> splitScreenOptional, DisplayController displayController,
PipUiEventLogger pipUiEventLogger, ShellTaskOrganizer shellTaskOrganizer) {
return new PipTaskOrganizer(context, pipBoundsHandler,
return new PipTaskOrganizer(context, pipBoundsState, pipBoundsHandler,
pipSurfaceTransactionHelper, splitScreenOptional, displayController,
pipUiEventLogger, shellTaskOrganizer);
}