From 874f00fd290ecf7dc63b5df0abce9620b97487bb Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Mon, 20 Sep 2021 11:10:44 -0700 Subject: [PATCH] Revert "InputManagerService: Do not remove input channel when disposing monitor" This reverts commit b3c3021841c9ddcdf51568f7ee1ab48d73abc8ff. The bug in Looper was fixed in AOSP, so we can now undo the workaround. Bug: 195020232 Bug: 189135695 Test: None Change-Id: Icc831d9bf63b0695899f163b70d1ccfd81b772be --- .../android/server/input/InputManagerService.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java index eb457c90ed6b6..86d7dcd10cf08 100644 --- a/services/core/java/com/android/server/input/InputManagerService.java +++ b/services/core/java/com/android/server/input/InputManagerService.java @@ -3230,7 +3230,7 @@ public class InputManagerService extends IInputManager.Stub * Interface for the system to handle request from InputMonitors. */ private final class InputMonitorHost extends IInputMonitorHost.Stub { - private IBinder mToken; + private final IBinder mToken; InputMonitorHost(IBinder token) { mToken = token; @@ -3238,23 +3238,12 @@ public class InputManagerService extends IInputManager.Stub @Override public void pilferPointers() { - if (mToken == null) { - throw new IllegalStateException( - "Illegal call to pilferPointers after InputMonitorHost is disposed."); - } nativePilferPointers(mPtr, mToken); } @Override public void dispose() { - // We do not remove the input monitor here by calling nativeRemoveInputChannel because - // it causes a race in InputDispatcher between the removal of the InputChannel through - // that call and the InputChannel#dispose call (which causes an FD hangup) from the - // client (b/189135695). - // - // NOTE: This means the client is responsible for properly closing the InputMonitor by - // disposing the InputChannel and all its duplicates. - mToken = null; + nativeRemoveInputChannel(mPtr, mToken); } }