Clean up gesture monitor pid collection

We no longer need to store the pids of gesture monitors, because the
dispatcher will tell us explicitly about the pids that are unresponsive
or responsive.

Bug: 175593831
Test: atest inputflinger_tests
Change-Id: Ie191d79ed4f82c3f3d328c3be560d1fed11cbeef
This commit is contained in:
Siarhei Vishniakou
2020-12-15 07:18:49 +00:00
parent 7fe1f0d4ef
commit 64785d2b06

View File

@@ -217,10 +217,6 @@ public class InputManagerService extends IInputManager.Stub
IInputFilter mInputFilter; // guarded by mInputFilterLock
InputFilterHost mInputFilterHost; // guarded by mInputFilterLock
private final Object mGestureMonitorPidsLock = new Object();
@GuardedBy("mGestureMonitorPidsLock")
private final ArrayMap<IBinder, Integer> mGestureMonitorPidsByToken = new ArrayMap<>();
// The associations of input devices to displays by port. Maps from input device port (String)
// to display id (int). Currently only accessed by InputReader.
private final Map<String, Integer> mStaticAssociations;
@@ -616,9 +612,6 @@ public class InputManagerService extends IInputManager.Stub
InputChannel inputChannel = nativeCreateInputMonitor(
mPtr, displayId, true /*isGestureMonitor*/, inputChannelName, pid);
InputMonitorHost host = new InputMonitorHost(inputChannel.getToken());
synchronized (mGestureMonitorPidsLock) {
mGestureMonitorPidsByToken.put(inputChannel.getToken(), pid);
}
return new InputMonitor(inputChannel, host);
} finally {
Binder.restoreCallingIdentity(ident);
@@ -642,9 +635,6 @@ public class InputManagerService extends IInputManager.Stub
if (connectionToken == null) {
throw new IllegalArgumentException("connectionToken must not be null.");
}
synchronized (mGestureMonitorPidsLock) {
mGestureMonitorPidsByToken.remove(connectionToken);
}
nativeRemoveInputChannel(mPtr, connectionToken);
}
@@ -2052,7 +2042,6 @@ public class InputManagerService extends IInputManager.Stub
if (dumpStr != null) {
pw.println(dumpStr);
dumpAssociations(pw);
dumpGestureMonitorPidsByToken(pw);
}
}
@@ -2076,19 +2065,6 @@ public class InputManagerService extends IInputManager.Stub
}
}
private void dumpGestureMonitorPidsByToken(PrintWriter pw) {
synchronized (mGestureMonitorPidsLock) {
if (!mGestureMonitorPidsByToken.isEmpty()) {
pw.println("Gesture monitor pids by token:");
for (int i = 0; i < mGestureMonitorPidsByToken.size(); i++) {
pw.print(" " + i + ": ");
pw.print(" token: " + mGestureMonitorPidsByToken.keyAt(i));
pw.println(" pid: " + mGestureMonitorPidsByToken.valueAt(i));
}
}
}
}
private boolean checkCallingPermission(String permission, String func) {
// Quick check: if the calling permission is me, it's all okay.
if (Binder.getCallingPid() == Process.myPid()) {
@@ -2111,7 +2087,6 @@ public class InputManagerService extends IInputManager.Stub
public void monitor() {
synchronized (mInputFilterLock) { }
synchronized (mAssociationsLock) { /* Test if blocked by associations lock. */}
synchronized (mGestureMonitorPidsLock) { /* Test if blocked by gesture monitor pids lock */}
synchronized (mLidSwitchLock) { /* Test if blocked by lid switch lock. */ }
nativeMonitor(mPtr);
}
@@ -2181,9 +2156,6 @@ public class InputManagerService extends IInputManager.Stub
// Native callback.
private void notifyInputChannelBroken(IBinder token) {
synchronized (mGestureMonitorPidsLock) {
mGestureMonitorPidsByToken.remove(token);
}
mWindowManagerCallbacks.notifyInputChannelBroken(token);
}