Merge "Refactor isAnimating to PipAnimationController, and update references." into tm-qpr-dev am: 5e05a02c9c am: 3dfcf6c0b6

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

Change-Id: I7a83223ffa454eeafe9b3116a34bcc0587cecb68
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Mateusz Cicheński
2022-09-28 20:16:27 +00:00
committed by Automerger Merge Worker
5 changed files with 35 additions and 28 deletions

View File

@@ -318,6 +318,7 @@ public abstract class WMShellModule {
ShellCommandHandler shellCommandHandler,
ShellController shellController,
DisplayController displayController,
PipAnimationController pipAnimationController,
PipAppOpsListener pipAppOpsListener,
PipBoundsAlgorithm pipBoundsAlgorithm,
PhonePipKeepClearAlgorithm pipKeepClearAlgorithm,
@@ -337,11 +338,12 @@ public abstract class WMShellModule {
@ShellMainThread ShellExecutor mainExecutor) {
return Optional.ofNullable(PipController.create(
context, shellInit, shellCommandHandler, shellController,
displayController, pipAppOpsListener, pipBoundsAlgorithm, pipKeepClearAlgorithm,
pipBoundsState, pipMotionHelper, pipMediaController, phonePipMenuController,
pipTaskOrganizer, pipTransitionState, pipTouchHandler, pipTransitionController,
windowManagerShellWrapper, taskStackListener, pipParamsChangedForwarder,
displayInsetsController, oneHandedController, mainExecutor));
displayController, pipAnimationController, pipAppOpsListener, pipBoundsAlgorithm,
pipKeepClearAlgorithm, pipBoundsState, pipMotionHelper, pipMediaController,
phonePipMenuController, pipTaskOrganizer, pipTransitionState, pipTouchHandler,
pipTransitionController, windowManagerShellWrapper, taskStackListener,
pipParamsChangedForwarder, displayInsetsController, oneHandedController,
mainExecutor));
}
@WMSingleton

View File

@@ -194,6 +194,17 @@ public class PipAnimationController {
return animator;
}
/**
* Returns true if the PiP window is currently being animated.
*/
public boolean isAnimating() {
PipAnimationController.PipTransitionAnimator animator = getCurrentAnimator();
if (animator != null && animator.isRunning()) {
return true;
}
return false;
}
/**
* Quietly cancel the animator by removing the listeners first.
*/

View File

@@ -324,19 +324,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
return mPipTransitionController;
}
/**
* Returns true if the PiP window is currently being animated.
*/
public boolean isAnimating() {
// TODO(b/183746978) move this to PipAnimationController, and inject that in PipController
PipAnimationController.PipTransitionAnimator animator =
mPipAnimationController.getCurrentAnimator();
if (animator != null && animator.isRunning()) {
return true;
}
return false;
}
public Rect getCurrentOrAnimatingBounds() {
PipAnimationController.PipTransitionAnimator animator =
mPipAnimationController.getCurrentAnimator();

View File

@@ -130,6 +130,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
private DisplayController mDisplayController;
private PipInputConsumer mPipInputConsumer;
private WindowManagerShellWrapper mWindowManagerShellWrapper;
private PipAnimationController mPipAnimationController;
private PipAppOpsListener mAppOpsListener;
private PipMediaController mMediaController;
private PipBoundsAlgorithm mPipBoundsAlgorithm;
@@ -158,7 +159,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
return;
}
// if there is another animation ongoing, wait for it to finish and try again
if (mPipTaskOrganizer.isAnimating()) {
if (mPipAnimationController.isAnimating()) {
mMainExecutor.removeCallbacks(
mMovePipInResponseToKeepClearAreasChangeCallback);
mMainExecutor.executeDelayed(
@@ -368,6 +369,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
ShellCommandHandler shellCommandHandler,
ShellController shellController,
DisplayController displayController,
PipAnimationController pipAnimationController,
PipAppOpsListener pipAppOpsListener,
PipBoundsAlgorithm pipBoundsAlgorithm,
PipKeepClearAlgorithm pipKeepClearAlgorithm,
@@ -392,11 +394,12 @@ public class PipController implements PipTransitionController.PipTransitionCallb
}
return new PipController(context, shellInit, shellCommandHandler, shellController,
displayController, pipAppOpsListener, pipBoundsAlgorithm, pipKeepClearAlgorithm,
pipBoundsState, pipMotionHelper, pipMediaController, phonePipMenuController,
pipTaskOrganizer, pipTransitionState, pipTouchHandler, pipTransitionController,
windowManagerShellWrapper, taskStackListener, pipParamsChangedForwarder,
displayInsetsController, oneHandedController, mainExecutor)
displayController, pipAnimationController, pipAppOpsListener,
pipBoundsAlgorithm, pipKeepClearAlgorithm, pipBoundsState, pipMotionHelper,
pipMediaController, phonePipMenuController, pipTaskOrganizer, pipTransitionState,
pipTouchHandler, pipTransitionController, windowManagerShellWrapper,
taskStackListener, pipParamsChangedForwarder, displayInsetsController,
oneHandedController, mainExecutor)
.mImpl;
}
@@ -405,6 +408,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
ShellCommandHandler shellCommandHandler,
ShellController shellController,
DisplayController displayController,
PipAnimationController pipAnimationController,
PipAppOpsListener pipAppOpsListener,
PipBoundsAlgorithm pipBoundsAlgorithm,
PipKeepClearAlgorithm pipKeepClearAlgorithm,
@@ -445,6 +449,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
mMediaController = pipMediaController;
mMenuController = phonePipMenuController;
mTouchHandler = pipTouchHandler;
mPipAnimationController = pipAnimationController;
mAppOpsListener = pipAppOpsListener;
mOneHandedController = oneHandedController;
mPipTransitionController = pipTransitionController;

View File

@@ -48,6 +48,7 @@ import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.TaskStackListenerImpl;
import com.android.wm.shell.onehanded.OneHandedController;
import com.android.wm.shell.pip.PipAnimationController;
import com.android.wm.shell.pip.PipAppOpsListener;
import com.android.wm.shell.pip.PipBoundsAlgorithm;
import com.android.wm.shell.pip.PipBoundsState;
@@ -85,6 +86,7 @@ public class PipControllerTest extends ShellTestCase {
@Mock private ShellCommandHandler mMockShellCommandHandler;
@Mock private DisplayController mMockDisplayController;
@Mock private PhonePipMenuController mMockPhonePipMenuController;
@Mock private PipAnimationController mMockPipAnimationController;
@Mock private PipAppOpsListener mMockPipAppOpsListener;
@Mock private PipBoundsAlgorithm mMockPipBoundsAlgorithm;
@Mock private PhonePipKeepClearAlgorithm mMockPipKeepClearAlgorithm;
@@ -117,8 +119,8 @@ public class PipControllerTest extends ShellTestCase {
mShellController = spy(new ShellController(mShellInit, mMockShellCommandHandler,
mMockExecutor));
mPipController = new PipController(mContext, mShellInit, mMockShellCommandHandler,
mShellController, mMockDisplayController, mMockPipAppOpsListener,
mMockPipBoundsAlgorithm, mMockPipKeepClearAlgorithm,
mShellController, mMockDisplayController, mMockPipAnimationController,
mMockPipAppOpsListener, mMockPipBoundsAlgorithm, mMockPipKeepClearAlgorithm,
mMockPipBoundsState, mMockPipMotionHelper, mMockPipMediaController,
mMockPhonePipMenuController, mMockPipTaskOrganizer, mMockPipTransitionState,
mMockPipTouchHandler, mMockPipTransitionController, mMockWindowManagerShellWrapper,
@@ -183,8 +185,8 @@ public class PipControllerTest extends ShellTestCase {
ShellInit shellInit = new ShellInit(mMockExecutor);
assertNull(PipController.create(spyContext, shellInit, mMockShellCommandHandler,
mShellController, mMockDisplayController, mMockPipAppOpsListener,
mMockPipBoundsAlgorithm, mMockPipKeepClearAlgorithm,
mShellController, mMockDisplayController, mMockPipAnimationController,
mMockPipAppOpsListener, mMockPipBoundsAlgorithm, mMockPipKeepClearAlgorithm,
mMockPipBoundsState, mMockPipMotionHelper, mMockPipMediaController,
mMockPhonePipMenuController, mMockPipTaskOrganizer, mMockPipTransitionState,
mMockPipTouchHandler, mMockPipTransitionController, mMockWindowManagerShellWrapper,