Fix PIP window moving outside screen bounds

Bug: 162343657
Test: atest CtsSystemUiTestCases:FlickerPipTests#pipWindow_doesNotLeaveTheScreen_onKeyboardOpenClose
Change-Id: I046f09ea73f2a17a563b9bd19b389c8c7595dd16
This commit is contained in:
Nikolas Havrikov
2020-08-11 14:21:28 +02:00
parent 5fed70ab92
commit b0ec57cb6c

View File

@@ -186,20 +186,23 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
private class PipManagerPinnedStackListener extends PinnedStackListener {
@Override
public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {
if (mState == STATE_PIP) {
if (mImeVisible != imeVisible) {
if (imeVisible) {
// Save the IME height adjustment, and offset to not occlude the IME
mPipBounds.offset(0, -imeHeight);
mImeHeightAdjustment = imeHeight;
} else {
// Apply the inverse adjustment when the IME is hidden
mPipBounds.offset(0, mImeHeightAdjustment);
mHandler.post(() -> {
mPipBoundsHandler.onImeVisibilityChanged(imeVisible, imeHeight);
if (mState == STATE_PIP) {
if (mImeVisible != imeVisible) {
if (imeVisible) {
// Save the IME height adjustment, and offset to not occlude the IME
mPipBounds.offset(0, -imeHeight);
mImeHeightAdjustment = imeHeight;
} else {
// Apply the inverse adjustment when the IME is hidden
mPipBounds.offset(0, mImeHeightAdjustment);
}
mImeVisible = imeVisible;
resizePinnedStack(STATE_PIP);
}
mImeVisible = imeVisible;
resizePinnedStack(STATE_PIP);
}
}
});
}
@Override