From 678024f0253e987d473c5801f19d64963656b379 Mon Sep 17 00:00:00 2001 From: Arthur Hung Date: Wed, 16 Jan 2019 20:58:51 +0800 Subject: [PATCH] Fix the window can't receive input still recevied events In split mode, while primary window enter minimized for another window is home or enter recent app. The primary window would be set as can't receive any touch input. But the input info in SurfaceFlinger is still keeping, that result the InputFlinger can still send the events to the window. This patch would provide a fake invalid window handle with a null token, so SurfaceFlinger would not update any input info to InputFlinger if the window can't receive any input. Test: Split mode, swipe to show the recent app or back to launcher on secondary window, test touch on secondary window. Bug: 122272676 Change-Id: I7212e3cf1a685313b6cdec25237cc714d93309e7 --- .../java/com/android/server/wm/InputMonitor.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java index 632db3842839a..3c5d911903e74 100644 --- a/services/core/java/com/android/server/wm/InputMonitor.java +++ b/services/core/java/com/android/server/wm/InputMonitor.java @@ -46,7 +46,6 @@ import android.view.InputChannel; import android.view.InputEventReceiver; import android.view.InputWindowHandle; import android.view.SurfaceControl; -import android.view.animation.Animation; import com.android.server.AnimationThread; import com.android.server.policy.WindowManagerPolicy; @@ -70,8 +69,7 @@ final class InputMonitor { private boolean mDisableWallpaperTouchEvents; private final Rect mTmpRect = new Rect(); - private final UpdateInputForAllWindowsConsumer mUpdateInputForAllWindowsConsumer = - new UpdateInputForAllWindowsConsumer(); + private final UpdateInputForAllWindowsConsumer mUpdateInputForAllWindowsConsumer; private final int mDisplayId; private final DisplayContent mDisplayContent; @@ -165,6 +163,7 @@ final class InputMonitor { mDisplayId = displayId; mInputTransaction = mDisplayContent.getPendingTransaction(); mHandler = AnimationThread.getHandler(); + mUpdateInputForAllWindowsConsumer = new UpdateInputForAllWindowsConsumer(); } void onDisplayRemoved() { @@ -407,6 +406,9 @@ final class InputMonitor { boolean inDrag; WallpaperController wallpaperController; + // An invalid window handle that tells SurfaceFlinger not update the input info. + final InputWindowHandle mInvalidInputWindow = new InputWindowHandle(null, null, mDisplayId); + private void updateInputWindows(boolean inDrag) { Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "updateInputWindows"); @@ -445,6 +447,10 @@ final class InputMonitor { final InputWindowHandle inputWindowHandle = w.mInputWindowHandle; if (inputChannel == null || inputWindowHandle == null || w.mRemoved || w.cantReceiveTouchInput()) { + if (w.mWinAnimator.hasSurface()) { + mInputTransaction.setInputWindowInfo( + w.mWinAnimator.mSurfaceController.mSurfaceControl, mInvalidInputWindow); + } // Skip this window because it cannot possibly receive input. return; }