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

Commit f226a79f authored by Wilson Wu's avatar Wilson Wu
Browse files

Make IInputMethodManager to oneway (11/N)

Comply following methods to IVoidResultCallback to emulate
current behavior and apply them to one-way.

-. startProtoDump
-. startImeTrace
-. stopImeTrace

Bug: 163453493
Test: atest CtsInputMethodTestCases
Test: 1) Enable the Winscope Trace tile
      2) Do some actions like open keyboard
      3) Disable the Winscope Trace tile
      4) Grad a bugreport and verify trace on go/Winscope
Change-Id: I3eafbc28ed3acf3ba859885bf201cb06b3149b94
parent 8241f19a
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ import android.util.Log;
import android.util.proto.ProtoOutputStream;
import android.view.inputmethod.InputMethodManager;

import com.android.internal.inputmethod.Completable;
import com.android.internal.inputmethod.ResultCallbacks;
import com.android.internal.view.IInputMethodManager;

import java.io.PrintWriter;
@@ -91,7 +93,9 @@ public abstract class ImeTracing {
     * @param where
     */
    public void sendToService(byte[] protoDump, int source, String where) throws RemoteException {
        mService.startProtoDump(protoDump, source, where);
        final Completable.Void value = Completable.createVoid();
        mService.startProtoDump(protoDump, source, where, ResultCallbacks.of(value));
        Completable.getResult(value);
    }

    /**
+4 −3
Original line number Diff line number Diff line
@@ -91,11 +91,12 @@ interface IInputMethodManager {
    /** Remove the IME surface. Requires passing the currently focused window. */
    oneway void removeImeSurfaceFromWindow(in IBinder windowToken,
            in IVoidResultCallback resultCallback);
    void startProtoDump(in byte[] protoDump, int source, String where);
    oneway void startProtoDump(in byte[] protoDump, int source, String where,
            in IVoidResultCallback resultCallback);
    oneway void isImeTraceEnabled(in IBooleanResultCallback resultCallback);

    // Starts an ime trace.
    void startImeTrace();
    oneway void startImeTrace(in IVoidResultCallback resultCallback);
    // Stops an ime trace.
    void stopImeTrace();
    oneway void stopImeTrace(in IVoidResultCallback resultCallback);
}
+75 −67
Original line number Diff line number Diff line
@@ -4131,7 +4131,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    @BinderThread
    @Override
    @GuardedBy("mMethodMap")
    public void startProtoDump(byte[] protoDump, int source, String where) {
    public void startProtoDump(byte[] protoDump, int source, String where,
            IVoidResultCallback resultCallback) {
        CallbackUtils.onResult(resultCallback, () -> {
            if (protoDump == null && source != IME_TRACING_FROM_IMMS) {
                // Dump not triggered from IMMS, but no proto information provided.
                return;
@@ -4165,7 +4167,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    proto.write(InputMethodManagerServiceTraceProto.ELAPSED_REALTIME_NANOS,
                            SystemClock.elapsedRealtimeNanos());
                    proto.write(InputMethodManagerServiceTraceProto.WHERE, where);
                dumpDebug(proto, InputMethodManagerServiceTraceProto.INPUT_METHOD_MANAGER_SERVICE);
                    dumpDebug(proto,
                            InputMethodManagerServiceTraceProto.INPUT_METHOD_MANAGER_SERVICE);
                    proto.end(managerservice_token);
                    break;
                default:
@@ -4173,6 +4176,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    return;
            }
            tracingInstance.addToBuffer(proto, source);
        });
    }

    @BinderThread
@@ -4183,7 +4187,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

    @BinderThread
    @Override
    public void startImeTrace() {
    public void startImeTrace(IVoidResultCallback resultCallback) {
        CallbackUtils.onResult(resultCallback, () -> {
            ImeTracing.getInstance().startTrace(null /* printwriter */);
            ArrayMap<IBinder, ClientState> clients;
            synchronized (mMethodMap) {
@@ -4198,11 +4203,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    }
                }
            }
        });
    }

    @BinderThread
    @Override
    public void stopImeTrace() {
    public void stopImeTrace(IVoidResultCallback resultCallback) {
        CallbackUtils.onResult(resultCallback, () -> {
            ImeTracing.getInstance().stopTrace(null /* printwriter */);
            ArrayMap<IBinder, ClientState> clients;
            synchronized (mMethodMap) {
@@ -4217,6 +4224,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    }
                }
            }
        });
    }

    @GuardedBy("mMethodMap")
+7 −3
Original line number Diff line number Diff line
@@ -1868,7 +1868,9 @@ public final class MultiClientInputMethodManagerService {

        @BinderThread
        @Override
        public void startProtoDump(byte[] clientProtoDump, int source, String where) {
        public void startProtoDump(byte[] clientProtoDump, int source, String where,
                IVoidResultCallback resultCallback) {
            CallbackUtils.onResult(resultCallback, () -> { });
        }

        @BinderThread
@@ -1879,12 +1881,14 @@ public final class MultiClientInputMethodManagerService {

        @BinderThread
        @Override
        public void startImeTrace() {
        public void startImeTrace(IVoidResultCallback resultCallback) {
            CallbackUtils.onResult(resultCallback, () -> { });
        }

        @BinderThread
        @Override
        public void stopImeTrace() {
        public void stopImeTrace(IVoidResultCallback resultCallback) {
            CallbackUtils.onResult(resultCallback, () -> { });
        }
    }
}