Merge "Deprecates the animatingBounds from WM to SysUI" into rvc-dev am: c3721ac874
Change-Id: I0d931ea2289e9167342045b18cc51222c7536d78
This commit is contained in:
@@ -37,13 +37,9 @@ oneway interface IPinnedStackListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the window manager has detected a change that would cause the movement bounds
|
* Called when the window manager has detected a change that would cause the movement bounds
|
||||||
* to be changed (ie. after configuration change, aspect ratio change, etc). It then provides
|
* to be changed (ie. after configuration change, aspect ratio change, etc).
|
||||||
* the components that allow the listener to calculate the movement bounds itself.
|
|
||||||
* The {@param animatingBounds} are provided to indicate the current target bounds of the
|
|
||||||
* pinned stack (the final bounds if animating, the current bounds if not),
|
|
||||||
* which may be helpful in calculating dependent animation bounds.
|
|
||||||
*/
|
*/
|
||||||
void onMovementBoundsChanged(in Rect animatingBounds, boolean fromImeAdjustment);
|
void onMovementBoundsChanged(boolean fromImeAdjustment);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when window manager decides to adjust the pinned stack bounds because of the IME, or
|
* Called when window manager decides to adjust the pinned stack bounds because of the IME, or
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package com.android.systemui.shared.system;
|
|||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.pm.ParceledListSlice;
|
import android.content.pm.ParceledListSlice;
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.view.DisplayInfo;
|
import android.view.DisplayInfo;
|
||||||
import android.view.IPinnedStackController;
|
import android.view.IPinnedStackController;
|
||||||
import android.view.IPinnedStackListener;
|
import android.view.IPinnedStackListener;
|
||||||
@@ -53,9 +52,9 @@ public class PinnedStackListenerForwarder extends IPinnedStackListener.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMovementBoundsChanged(Rect animatingBounds, boolean fromImeAdjustment) {
|
public void onMovementBoundsChanged(boolean fromImeAdjustment) {
|
||||||
for (PinnedStackListener listener : mListeners) {
|
for (PinnedStackListener listener : mListeners) {
|
||||||
listener.onMovementBoundsChanged(animatingBounds, fromImeAdjustment);
|
listener.onMovementBoundsChanged(fromImeAdjustment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +107,7 @@ public class PinnedStackListenerForwarder extends IPinnedStackListener.Stub {
|
|||||||
public static class PinnedStackListener {
|
public static class PinnedStackListener {
|
||||||
public void onListenerRegistered(IPinnedStackController controller) {}
|
public void onListenerRegistered(IPinnedStackController controller) {}
|
||||||
|
|
||||||
public void onMovementBoundsChanged(Rect animatingBounds, boolean fromImeAdjustment) {}
|
public void onMovementBoundsChanged(boolean fromImeAdjustment) {}
|
||||||
|
|
||||||
public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {}
|
public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {}
|
||||||
|
|
||||||
|
|||||||
@@ -317,17 +317,22 @@ public class PipTaskOrganizer extends TaskOrganizer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO(b/152809058): consolidate the display info handling logic in SysUI
|
* TODO(b/152809058): consolidate the display info handling logic in SysUI
|
||||||
|
*
|
||||||
|
* @param destinationBoundsOut the current destination bounds will be populated to this param
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void onMovementBoundsChanged(boolean fromImeAdjustment, boolean fromShelfAdjustment) {
|
public void onMovementBoundsChanged(Rect destinationBoundsOut,
|
||||||
|
boolean fromImeAdjustment, boolean fromShelfAdjustment) {
|
||||||
final PipAnimationController.PipTransitionAnimator animator =
|
final PipAnimationController.PipTransitionAnimator animator =
|
||||||
mPipAnimationController.getCurrentAnimator();
|
mPipAnimationController.getCurrentAnimator();
|
||||||
|
destinationBoundsOut.set(mLastReportedBounds);
|
||||||
if (animator == null || !animator.isRunning()
|
if (animator == null || !animator.isRunning()
|
||||||
|| animator.getTransitionDirection() != TRANSITION_DIRECTION_TO_PIP) {
|
|| animator.getTransitionDirection() != TRANSITION_DIRECTION_TO_PIP) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Rect currentDestinationBounds = animator.getDestinationBounds();
|
final Rect currentDestinationBounds = animator.getDestinationBounds();
|
||||||
|
destinationBoundsOut.set(currentDestinationBounds);
|
||||||
if (!fromImeAdjustment && !fromShelfAdjustment
|
if (!fromImeAdjustment && !fromShelfAdjustment
|
||||||
&& mPipBoundsHandler.getDisplayBounds().contains(currentDestinationBounds)) {
|
&& mPipBoundsHandler.getDisplayBounds().contains(currentDestinationBounds)) {
|
||||||
// no need to update the destination bounds, bail early
|
// no need to update the destination bounds, bail early
|
||||||
@@ -342,6 +347,7 @@ public class PipTaskOrganizer extends TaskOrganizer {
|
|||||||
animator.updateEndValue(newDestinationBounds);
|
animator.updateEndValue(newDestinationBounds);
|
||||||
}
|
}
|
||||||
animator.setDestinationBounds(newDestinationBounds);
|
animator.setDestinationBounds(newDestinationBounds);
|
||||||
|
destinationBoundsOut.set(newDestinationBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
|
|||||||
|
|
||||||
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_FULLSCREEN;
|
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_FULLSCREEN;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityTaskManager;
|
import android.app.ActivityTaskManager;
|
||||||
import android.app.IActivityManager;
|
import android.app.IActivityManager;
|
||||||
@@ -160,9 +161,9 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMovementBoundsChanged(Rect animatingBounds, boolean fromImeAdjustment) {
|
public void onMovementBoundsChanged(boolean fromImeAdjustment) {
|
||||||
mHandler.post(() -> updateMovementBounds(animatingBounds, fromImeAdjustment,
|
mHandler.post(() -> updateMovementBounds(null /* toBounds */,
|
||||||
false /* fromShelfAdjustment */));
|
fromImeAdjustment, false /* fromShelfAdjustment */));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -352,17 +353,19 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
mMenuController.onPinnedStackAnimationEnded();
|
mMenuController.onPinnedStackAnimationEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMovementBounds(Rect animatingBounds, boolean fromImeAdjustment,
|
private void updateMovementBounds(@Nullable Rect toBounds,
|
||||||
boolean fromShelfAdjustment) {
|
boolean fromImeAdjustment, boolean fromShelfAdjustment) {
|
||||||
// Populate inset / normal bounds and DisplayInfo from mPipBoundsHandler before
|
// Populate inset / normal bounds and DisplayInfo from mPipBoundsHandler before
|
||||||
// passing to mTouchHandler, mTouchHandler would rely on the bounds calculated by
|
// passing to mTouchHandler/mPipTaskOrganizer
|
||||||
// mPipBoundsHandler with up-to-dated information
|
final Rect outBounds = new Rect(toBounds);
|
||||||
mPipBoundsHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
|
mPipBoundsHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
|
||||||
animatingBounds, mTmpDisplayInfo);
|
outBounds, mTmpDisplayInfo);
|
||||||
|
// mTouchHandler would rely on the bounds populated from mPipTaskOrganizer
|
||||||
|
mPipTaskOrganizer.onMovementBoundsChanged(outBounds,
|
||||||
|
fromImeAdjustment, fromShelfAdjustment);
|
||||||
mTouchHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
|
mTouchHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
|
||||||
animatingBounds, fromImeAdjustment, fromShelfAdjustment,
|
outBounds, fromImeAdjustment, fromShelfAdjustment,
|
||||||
mTmpDisplayInfo.rotation);
|
mTmpDisplayInfo.rotation);
|
||||||
mPipTaskOrganizer.onMovementBoundsChanged(fromImeAdjustment, fromShelfAdjustment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dump(PrintWriter pw) {
|
public void dump(PrintWriter pw) {
|
||||||
|
|||||||
@@ -380,11 +380,18 @@ public class PipTouchHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Re-calculate the expanded bounds
|
// Re-calculate the expanded bounds
|
||||||
mNormalBounds = normalBounds;
|
mNormalBounds.set(normalBounds);
|
||||||
Rect normalMovementBounds = new Rect();
|
Rect normalMovementBounds = new Rect();
|
||||||
mSnapAlgorithm.getMovementBounds(mNormalBounds, insetBounds, normalMovementBounds,
|
mSnapAlgorithm.getMovementBounds(mNormalBounds, insetBounds, normalMovementBounds,
|
||||||
bottomOffset);
|
bottomOffset);
|
||||||
|
|
||||||
|
if (mMovementBounds.isEmpty()) {
|
||||||
|
// mMovementBounds is not initialized yet and a clean movement bounds without
|
||||||
|
// bottom offset shall be used later in this function.
|
||||||
|
mSnapAlgorithm.getMovementBounds(curBounds, insetBounds, mMovementBounds,
|
||||||
|
0 /* bottomOffset */);
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate the expanded size
|
// Calculate the expanded size
|
||||||
float aspectRatio = (float) normalBounds.width() / normalBounds.height();
|
float aspectRatio = (float) normalBounds.width() / normalBounds.height();
|
||||||
Point displaySize = new Point();
|
Point displaySize = new Point();
|
||||||
@@ -430,8 +437,8 @@ public class PipTouchHandler {
|
|||||||
|
|
||||||
// Update the movement bounds after doing the calculations based on the old movement bounds
|
// Update the movement bounds after doing the calculations based on the old movement bounds
|
||||||
// above
|
// above
|
||||||
mNormalMovementBounds = normalMovementBounds;
|
mNormalMovementBounds.set(normalMovementBounds);
|
||||||
mExpandedMovementBounds = expandedMovementBounds;
|
mExpandedMovementBounds.set(expandedMovementBounds);
|
||||||
mDisplayRotation = displayRotation;
|
mDisplayRotation = displayRotation;
|
||||||
mInsetBounds.set(insetBounds);
|
mInsetBounds.set(insetBounds);
|
||||||
updateMovementBounds();
|
updateMovementBounds();
|
||||||
|
|||||||
@@ -208,12 +208,13 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMovementBoundsChanged(Rect animatingBounds, boolean fromImeAdjustment) {
|
public void onMovementBoundsChanged(boolean fromImeAdjustment) {
|
||||||
mHandler.post(() -> {
|
mHandler.post(() -> {
|
||||||
// Populate the inset / normal bounds and DisplayInfo from mPipBoundsHandler first.
|
// Populate the inset / normal bounds and DisplayInfo from mPipBoundsHandler first.
|
||||||
|
final Rect destinationBounds = new Rect();
|
||||||
mPipBoundsHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
|
mPipBoundsHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
|
||||||
animatingBounds, mTmpDisplayInfo);
|
destinationBounds, mTmpDisplayInfo);
|
||||||
mDefaultPipBounds.set(animatingBounds);
|
mDefaultPipBounds.set(destinationBounds);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import android.graphics.Rect;
|
|||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
import android.testing.TestableLooper;
|
import android.testing.TestableLooper;
|
||||||
import android.util.Size;
|
import android.util.Size;
|
||||||
import android.view.DisplayInfo;
|
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
@@ -59,12 +58,8 @@ import org.mockito.MockitoAnnotations;
|
|||||||
@SmallTest
|
@SmallTest
|
||||||
@TestableLooper.RunWithLooper(setAsMainLooper = true)
|
@TestableLooper.RunWithLooper(setAsMainLooper = true)
|
||||||
public class PipTouchHandlerTest extends SysuiTestCase {
|
public class PipTouchHandlerTest extends SysuiTestCase {
|
||||||
private static final int ROUNDING_ERROR_MARGIN = 10;
|
|
||||||
private static final float DEFAULT_ASPECT_RATIO = 1f;
|
|
||||||
private static final Rect EMPTY_CURRENT_BOUNDS = null;
|
|
||||||
|
|
||||||
private PipTouchHandler mPipTouchHandler;
|
private PipTouchHandler mPipTouchHandler;
|
||||||
private DisplayInfo mDefaultDisplayInfo;
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private IActivityManager mActivityManager;
|
private IActivityManager mActivityManager;
|
||||||
@@ -90,18 +85,17 @@ public class PipTouchHandlerTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private DeviceConfigProxy mDeviceConfigProxy;
|
private DeviceConfigProxy mDeviceConfigProxy;
|
||||||
|
|
||||||
|
|
||||||
private PipSnapAlgorithm mPipSnapAlgorithm;
|
private PipSnapAlgorithm mPipSnapAlgorithm;
|
||||||
private PipMotionHelper mMotionHelper;
|
private PipMotionHelper mMotionHelper;
|
||||||
private PipResizeGestureHandler mPipResizeGestureHandler;
|
private PipResizeGestureHandler mPipResizeGestureHandler;
|
||||||
|
|
||||||
Rect mInsetBounds;
|
private Rect mInsetBounds;
|
||||||
Rect mMinBounds;
|
private Rect mMinBounds;
|
||||||
Rect mCurBounds;
|
private Rect mCurBounds;
|
||||||
boolean mFromImeAdjustment;
|
private boolean mFromImeAdjustment;
|
||||||
boolean mFromShelfAdjustment;
|
private boolean mFromShelfAdjustment;
|
||||||
int mDisplayRotation;
|
private int mDisplayRotation;
|
||||||
|
private int mImeHeight;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@@ -121,10 +115,11 @@ public class PipTouchHandlerTest extends SysuiTestCase {
|
|||||||
mInsetBounds = new Rect(10, 10, 990, 990);
|
mInsetBounds = new Rect(10, 10, 990, 990);
|
||||||
// minBounds of 100x100 bottom right corner
|
// minBounds of 100x100 bottom right corner
|
||||||
mMinBounds = new Rect(890, 890, 990, 990);
|
mMinBounds = new Rect(890, 890, 990, 990);
|
||||||
mCurBounds = new Rect();
|
mCurBounds = new Rect(mMinBounds);
|
||||||
mFromImeAdjustment = false;
|
mFromImeAdjustment = false;
|
||||||
mFromShelfAdjustment = false;
|
mFromShelfAdjustment = false;
|
||||||
mDisplayRotation = 0;
|
mDisplayRotation = 0;
|
||||||
|
mImeHeight = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -162,6 +157,8 @@ public class PipTouchHandlerTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void updateMovementBounds_withImeAdjustment_movesPip() {
|
public void updateMovementBounds_withImeAdjustment_movesPip() {
|
||||||
mFromImeAdjustment = true;
|
mFromImeAdjustment = true;
|
||||||
|
mPipTouchHandler.onImeVisibilityChanged(true /* imeVisible */, mImeHeight);
|
||||||
|
|
||||||
mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mMinBounds, mCurBounds,
|
mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mMinBounds, mCurBounds,
|
||||||
mFromImeAdjustment, mFromShelfAdjustment, mDisplayRotation);
|
mFromImeAdjustment, mFromShelfAdjustment, mDisplayRotation);
|
||||||
|
|
||||||
|
|||||||
@@ -3407,18 +3407,6 @@ class ActivityStack extends Task {
|
|||||||
outBounds.set(mBoundsAnimationSourceHintBounds);
|
outBounds.set(mBoundsAnimationSourceHintBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the final animation bounds if the task stack is currently being animated, or the
|
|
||||||
* current stack bounds otherwise.
|
|
||||||
*/
|
|
||||||
void getAnimationOrCurrentBounds(Rect outBounds) {
|
|
||||||
if ((mBoundsAnimatingRequested || mBoundsAnimating) && !mBoundsAnimationTarget.isEmpty()) {
|
|
||||||
getFinalAnimationBounds(outBounds);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
getBounds(outBounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Bounds of the stack with other system factors taken into consideration. */
|
/** Bounds of the stack with other system factors taken into consideration. */
|
||||||
void getDimBounds(Rect out) {
|
void getDimBounds(Rect out) {
|
||||||
getBounds(out);
|
getBounds(out);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import android.app.RemoteAction;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.pm.ParceledListSlice;
|
import android.content.pm.ParceledListSlice;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -285,13 +284,7 @@ class PinnedStackController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final Rect animatingBounds = new Rect();
|
mPinnedStackListener.onMovementBoundsChanged(fromImeAdjustment);
|
||||||
final ActivityStack pinnedStack = mDisplayContent.getDefaultTaskDisplayArea()
|
|
||||||
.getRootPinnedTask();
|
|
||||||
if (pinnedStack != null) {
|
|
||||||
pinnedStack.getAnimationOrCurrentBounds(animatingBounds);
|
|
||||||
}
|
|
||||||
mPinnedStackListener.onMovementBoundsChanged(animatingBounds, fromImeAdjustment);
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.e(TAG_WM, "Error delivering actions changed event.", e);
|
Slog.e(TAG_WM, "Error delivering actions changed event.", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user