Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64785d2b authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

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
parent 7fe1f0d4
Loading
Loading
Loading
Loading
+0 −28
Original line number Diff line number Diff line
@@ -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);
    }