Merge "Fix null surface crash when switch split" into tm-qpr-dev
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java
index 214b304..c634198 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java
@@ -403,5 +403,10 @@
}
return true;
}
+
+ @Override
+ public boolean onDoubleTapEvent(@NonNull MotionEvent e) {
+ return true;
+ }
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitDecorManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitDecorManager.java
index c836b95..a9d3c9f 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitDecorManager.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitDecorManager.java
@@ -74,7 +74,8 @@
private boolean mShown;
private boolean mIsResizing;
- private final Rect mBounds = new Rect();
+ private final Rect mOldBounds = new Rect();
+ private final Rect mResizingBounds = new Rect();
private final Rect mTempRect = new Rect();
private ValueAnimator mFadeAnimator;
@@ -158,6 +159,8 @@
mResizingIconView = null;
mIsResizing = false;
mShown = false;
+ mOldBounds.setEmpty();
+ mResizingBounds.setEmpty();
}
/** Showing resizing hint. */
@@ -170,13 +173,14 @@
if (!mIsResizing) {
mIsResizing = true;
- mBounds.set(newBounds);
+ mOldBounds.set(newBounds);
}
+ mResizingBounds.set(newBounds);
mOffsetX = offsetX;
mOffsetY = offsetY;
final boolean show =
- newBounds.width() > mBounds.width() || newBounds.height() > mBounds.height();
+ newBounds.width() > mOldBounds.width() || newBounds.height() > mOldBounds.height();
final boolean update = show != mShown;
if (update && mFadeAnimator != null && mFadeAnimator.isRunning()) {
// If we need to animate and animator still running, cancel it before we ensure both
@@ -193,8 +197,8 @@
if (mGapBackgroundLeash == null && !immediately) {
final boolean isLandscape = newBounds.height() == sideBounds.height();
- final int left = isLandscape ? mBounds.width() : 0;
- final int top = isLandscape ? 0 : mBounds.height();
+ final int left = isLandscape ? mOldBounds.width() : 0;
+ final int top = isLandscape ? 0 : mOldBounds.height();
mGapBackgroundLeash = SurfaceUtils.makeColorLayer(mHostLeash,
GAP_BACKGROUND_SURFACE_NAME, mSurfaceSession);
// Fill up another side bounds area.
@@ -272,6 +276,8 @@
mIsResizing = false;
mOffsetX = 0;
mOffsetY = 0;
+ mOldBounds.setEmpty();
+ mResizingBounds.setEmpty();
if (mFadeAnimator != null && mFadeAnimator.isRunning()) {
if (!mShown) {
// If fade-out animation is running, just add release callback to it.
@@ -303,8 +309,8 @@
/** Screenshot host leash and attach on it if meet some conditions */
public void screenshotIfNeeded(SurfaceControl.Transaction t) {
- if (!mShown && mIsResizing) {
- mTempRect.set(mBounds);
+ if (!mShown && mIsResizing && !mOldBounds.equals(mResizingBounds)) {
+ mTempRect.set(mOldBounds);
mTempRect.offsetTo(0, 0);
mScreenshot = ScreenshotUtils.takeScreenshot(t, mHostLeash, mTempRect,
Integer.MAX_VALUE - 1);
@@ -315,7 +321,7 @@
public void setScreenshotIfNeeded(SurfaceControl screenshot, SurfaceControl.Transaction t) {
if (screenshot == null || !screenshot.isValid()) return;
- if (!mShown && mIsResizing) {
+ if (!mShown && mIsResizing && !mOldBounds.equals(mResizingBounds)) {
mScreenshot = screenshot;
t.reparent(screenshot, mHostLeash);
t.setLayer(screenshot, Integer.MAX_VALUE - 1);