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

Commit 2c08825b authored by Antonio Kantek's avatar Antonio Kantek Committed by Android (Google) Code Review
Browse files

Merge "Use lambda when iterating over clients" into main

parents e746322b 6e2d54e0
Loading
Loading
Loading
Loading
+27 −53
Original line number Diff line number Diff line
@@ -2901,16 +2901,12 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
    @GuardedBy("ImfLock.class")
    void clearClientSessionsLocked() {
        if (getCurMethodLocked() != null) {
            // TODO(b/322816970): Replace this with lambda.
            mClientController.forAllClients(new Consumer<ClientState>() {

                @GuardedBy("ImfLock.class")
                @Override
                public void accept(ClientState c) {
            // TODO(b/324907325): Remove the suppress warnings once b/324907325 is fixed.
            @SuppressWarnings("GuardedBy") Consumer<ClientState> clearClientSession = c -> {
                clearClientSessionLocked(c);
                clearClientSessionForAccessibilityLocked(c);
                }
            });
            };
            mClientController.forAllClients(clearClientSession);

            finishSessionLocked(mEnabledSession);
            for (int i = 0; i < mEnabledAccessibilitySessions.size(); i++) {
@@ -4653,15 +4649,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
        super.startImeTrace_enforcePermission();
        ImeTracing.getInstance().startTrace(null /* printwriter */);
        synchronized (ImfLock.class) {
            // TODO(b/322816970): Replace this with lambda.
            mClientController.forAllClients(new Consumer<ClientState>() {

                @GuardedBy("ImfLock.class")
                @Override
                public void accept(ClientState c) {
                    c.mClient.setImeTraceEnabled(true /* enabled */);
                }
            });
            mClientController.forAllClients(c -> c.mClient.setImeTraceEnabled(true /* enabled */));
        }
    }

@@ -4673,15 +4661,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub

        ImeTracing.getInstance().stopTrace(null /* printwriter */);
        synchronized (ImfLock.class) {
            // TODO(b/322816970): Replace this with lambda.
            mClientController.forAllClients(new Consumer<ClientState>() {

                @GuardedBy("ImfLock.class")
                @Override
                public void accept(ClientState c) {
                    c.mClient.setImeTraceEnabled(false /* enabled */);
                }
            });
            mClientController.forAllClients(c -> c.mClient.setImeTraceEnabled(false /* enabled */));
        }
    }

@@ -5916,15 +5896,12 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                // We only have sessions when we bound to an input method. Remove this session
                // from all clients.
                if (getCurMethodLocked() != null) {
                    // TODO(b/322816970): Replace this with lambda.
                    mClientController.forAllClients(new Consumer<ClientState>() {
                    // TODO(b/324907325): Remove the suppress warnings once b/324907325 is fixed.
                    @SuppressWarnings("GuardedBy") Consumer<ClientState> clearClientSession =
                            c -> clearClientSessionForAccessibilityLocked(c,
                                    accessibilityConnectionId);
                    mClientController.forAllClients(clearClientSession);

                        @GuardedBy("ImfLock.class")
                        @Override
                        public void accept(ClientState c) {
                            clearClientSessionForAccessibilityLocked(c, accessibilityConnectionId);
                        }
                    });
                    AccessibilitySessionState session = mEnabledAccessibilitySessions.get(
                            accessibilityConnectionId);
                    if (session != null) {
@@ -6126,12 +6103,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            }
            // Dump ClientController#mClients
            p.println("  ClientStates:");
            // TODO(b/322816970): Replace this with lambda.
            mClientController.forAllClients(new Consumer<ClientState>() {

                @GuardedBy("ImfLock.class")
                @Override
                public void accept(ClientState c) {
            // TODO(b/324907325): Remove the suppress warnings once b/324907325 is fixed.
            @SuppressWarnings("GuardedBy") Consumer<ClientState> clientControllerDump = c -> {
                p.println("  " + c + ":");
                p.println("    client=" + c.mClient);
                p.println("    fallbackInputConnection="
@@ -6142,8 +6115,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                        "    sessionRequestedForAccessibility="
                                + c.mSessionRequestedForAccessibility);
                p.println("    curSession=" + c.mCurSession);
                }
            });
            };
            mClientController.forAllClients(clientControllerDump);

            p.println("  mCurMethodId=" + getSelectedMethodIdLocked());
            client = mCurClient;
            p.println("  mCurClient=" + client + " mCurSeq=" + getSequenceNumberLocked());