From cf09181b88e5bd20730e9c4f959d87b36456ee16 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 31 Jul 2019 01:08:30 +0800 Subject: [PATCH] Release input surface of drag completely Once the input surface needs to be hidden, it never shows again, so the surface can be removed when the drag is done. Bug: 138656611 Test: atest DragDropControllerTests Test: After a drag and drop operation is done, there won't have lots of error log when constantly touching screen: "Window handle drag has no registered input channel". And the CloseGuard of the input surface won't complain when finalizing. Change-Id: I262867c118aeb1a6d091132fac15056dee5fa3f1 --- .../core/java/com/android/server/wm/DragState.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/wm/DragState.java b/services/core/java/com/android/server/wm/DragState.java index 553b0ffa6999c..c8f7af5b10c8a 100644 --- a/services/core/java/com/android/server/wm/DragState.java +++ b/services/core/java/com/android/server/wm/DragState.java @@ -147,12 +147,6 @@ class DragState { return mIsClosing; } - private void hideInputSurface() { - if (mInputSurface != null) { - mTransaction.hide(mInputSurface).apply(); - } - } - private void showInputSurface() { if (mInputSurface == null) { mInputSurface = mService.makeSurfaceBuilder( @@ -198,8 +192,6 @@ class DragState { mInputInterceptor = null; } - hideInputSurface(); - // Send drag end broadcast if drag start has been sent. if (mDragInProgress) { final int myPid = Process.myPid(); @@ -239,6 +231,10 @@ class DragState { } // Clear the internal variables. + if (mInputSurface != null) { + mTransaction.remove(mInputSurface).apply(); + mInputSurface = null; + } if (mSurfaceControl != null) { mTransaction.reparent(mSurfaceControl, null).apply(); mSurfaceControl = null;