- If a user taps the PiP quickly multiple times, you can hit a case where
you expand the PIP, which triggers the re-registration of the
InputConsumer, but doesn't disable touches until the pinned stack
animation starts. If the user taps in between that time, it can trigger
a resizing of the stack what aborts the expand animation
- Also adding additional debugging logs
Bug:
37657050
Test: Quickly tap the PiP
Change-Id: Ib0088a3aa8e917aca3214c289a0787bdf7e66199
import android.content.pm.ParceledListSlice;
import android.graphics.Rect;
import android.os.Bundle;
+import android.os.Debug;
import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
public void showMenu(int menuState, Rect stackBounds, Rect movementBounds,
boolean allowMenuTimeout) {
if (DEBUG) {
- Log.d(TAG, "showMenu() hasActivity=" + (mToActivityMessenger != null));
+ Log.d(TAG, "showMenu() state=" + menuState
+ + " hasActivity=" + (mToActivityMessenger != null)
+ + " callers=\n" + Debug.getCallers(5, " "));
}
if (mToActivityMessenger != null) {
Bundle data = new Bundle();
*/
public void hideMenu() {
if (DEBUG) {
- Log.d(TAG, "hideMenu() hasActivity=" + (mToActivityMessenger != null));
+ Log.d(TAG, "hideMenu() state=" + mMenuState
+ + " hasActivity=" + (mToActivityMessenger != null)
+ + " callers=\n" + Debug.getCallers(5, " "));
}
if (mToActivityMessenger != null) {
Message m = Message.obtain();
}
/**
- * @return the current menu state.
- */
- public int getMenuState() {
- return mMenuState;
- }
-
- /**
* Sets the menu actions to the actions provided by the current PiP activity.
*/
public void setAppActions(ParceledListSlice appActions) {
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
+import android.os.Debug;
import android.os.Handler;
import android.os.RemoteException;
import android.util.Log;
public class PipMotionHelper {
private static final String TAG = "PipMotionHelper";
+ private static final boolean DEBUG = false;
private static final RectEvaluator RECT_EVALUATOR = new RectEvaluator(new Rect());
* Resizes the pinned stack back to fullscreen.
*/
void expandPip(boolean skipAnimation) {
+ if (DEBUG) {
+ Log.d(TAG, "expandPip: skipAnimation=" + skipAnimation
+ + " callers=\n" + Debug.getCallers(5, " "));
+ }
cancelAnimations();
mMenuController.hideMenuWithoutResize();
mHandler.post(() -> {
* Dismisses the pinned stack.
*/
void dismissPip() {
+ if (DEBUG) {
+ Log.d(TAG, "dismissPip: callers=\n" + Debug.getCallers(5, " "));
+ }
cancelAnimations();
mMenuController.hideMenuWithoutResize();
mHandler.post(() -> {
* Directly resizes the PiP to the given {@param bounds}.
*/
private void resizePipUnchecked(Rect toBounds) {
+ if (DEBUG) {
+ Log.d(TAG, "resizePipUnchecked: toBounds=" + toBounds
+ + " callers=\n" + Debug.getCallers(5, " "));
+ }
if (!toBounds.equals(mBounds)) {
mVsyncChoreographer.scheduleAtSfVsync(() -> {
try {
* Directly resizes the PiP to the given {@param bounds}.
*/
private void resizeAndAnimatePipUnchecked(Rect toBounds, int duration) {
+ if (DEBUG) {
+ Log.d(TAG, "resizeAndAnimatePipUnchecked: toBounds=" + toBounds
+ + " duration=" + duration + " callers=\n" + Debug.getCallers(5, " "));
+ }
if (!toBounds.equals(mBounds)) {
mHandler.post(() -> {
try {
// Try and restore the PiP to the closest edge, using the saved snap fraction
// if possible
if (resize) {
- // This is a very special case: when the menu is expanded and visible, navigating to
- // another activity can trigger auto-enter PiP, and if the revealed activity has a
- // forced rotation set, then the controller will get updated with the new rotation
- // of the display. However, at the same time, SystemUI will try to hide the menu by
- // creating an animation to the normal bounds which are now stale. In such a case
- // we defer the animation to the normal bounds until after the next
- // onMovementBoundsChanged() call to get the bounds in the new orientation
if (mDeferResizeToNormalBoundsUntilRotation == -1) {
+ // This is a very special case: when the menu is expanded and visible,
+ // navigating to another activity can trigger auto-enter PiP, and if the
+ // revealed activity has a forced rotation set, then the controller will get
+ // updated with the new rotation of the display. However, at the same time,
+ // SystemUI will try to hide the menu by creating an animation to the normal
+ // bounds which are now stale. In such a case we defer the animation to the
+ // normal bounds until after the next onMovementBoundsChanged() call to get the
+ // bounds in the new orientation
try {
int displayRotation = mPinnedStackController.getDisplayRotation();
if (mDisplayRotation != displayRotation) {
mSavedSnapFraction = -1f;
}
} else {
+ // If resizing is not allowed, then the PiP should be frozen until the transition
+ // ends as well
+ setTouchEnabled(false);
mSavedSnapFraction = -1f;
}
}