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

Commit 26b594af authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Optimize InputConnectionProtoDumper a bit

This is a mechanical refactoring CL that has no behavior change.

Currently all the utility methods defined in
InputConnectionProtoDumper return ProtoOutputStream, while the
returned instances will always be converted into byte[] eventually.
With this CL, those utility methods return byte[] instances directly,
which is expected to make it easier for ART/dexpreopt to do more
optimizations such as code inlining because instances of
ProtoOutputStream will no longer be escaped from those methods.

Bug: 192412909
Test: atest CtsInputMethodTestCases
Test: Manually verified that IME tracing still works
Change-Id: I7b24aee5428da312972aa86b8658429b421490f8
parent 3beeb3e3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ public abstract class AbstractInputMethodService extends WindowProviderService
     * @hide
     */
    @SuppressWarnings("HiddenAbstractMethod")
    public abstract void dumpProtoInternal(ProtoOutputStream proto, ProtoOutputStream icProto);
    public abstract void dumpProtoInternal(ProtoOutputStream proto, @Nullable byte[] icProto);

    /**
     * Implement this to handle {@link android.os.Binder#dump Binder.dump()}
+2 −2
Original line number Diff line number Diff line
@@ -3415,7 +3415,7 @@ public class InputMethodService extends AbstractInputMethodService {
     * @hide
     */
    @Override
    public final void dumpProtoInternal(ProtoOutputStream proto, ProtoOutputStream icProto) {
    public final void dumpProtoInternal(ProtoOutputStream proto, byte[] icProto) {
        final long token = proto.start(InputMethodServiceTraceProto.INPUT_METHOD_SERVICE);
        mWindow.dumpDebug(proto, SOFT_INPUT_WINDOW);
        proto.write(VIEWS_CREATED, mViewsCreated);
@@ -3445,7 +3445,7 @@ public class InputMethodService extends AbstractInputMethodService {
        mTmpInsets.dumpDebug(proto, LAST_COMPUTED_INSETS);
        proto.write(SETTINGS_OBSERVER, Objects.toString(mSettingsObserver));
        if (icProto != null) {
            proto.write(INPUT_CONNECTION_CALL, icProto.getBytes());
            proto.write(INPUT_CONNECTION_CALL, icProto);
        }
        proto.end(token);
    }
+8 −9
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Bundle;
import android.os.Handler;
import android.util.proto.ProtoOutputStream;
import android.view.KeyEvent;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
@@ -93,8 +92,8 @@ final class RemoteInputConnection implements InputConnection {

        final AbstractInputMethodService inputMethodService = mInputMethodService.get();
        if (inputMethodService != null && ImeTracing.getInstance().isEnabled()) {
            ProtoOutputStream icProto = InputConnectionProtoDumper.buildGetTextAfterCursorProto(
                    length, flags, result);
            final byte[] icProto = InputConnectionProtoDumper.buildGetTextAfterCursorProto(length,
                    flags, result);
            ImeTracing.getInstance().triggerServiceDump(TAG + "#getTextAfterCursor",
                    inputMethodService, icProto);
        }
@@ -118,8 +117,8 @@ final class RemoteInputConnection implements InputConnection {

        final AbstractInputMethodService inputMethodService = mInputMethodService.get();
        if (inputMethodService != null && ImeTracing.getInstance().isEnabled()) {
            ProtoOutputStream icProto = InputConnectionProtoDumper.buildGetTextBeforeCursorProto(
                    length, flags, result);
            final byte[] icProto = InputConnectionProtoDumper.buildGetTextBeforeCursorProto(length,
                    flags, result);
            ImeTracing.getInstance().triggerServiceDump(TAG + "#getTextBeforeCursor",
                    inputMethodService, icProto);
        }
@@ -143,7 +142,7 @@ final class RemoteInputConnection implements InputConnection {

        final AbstractInputMethodService inputMethodService = mInputMethodService.get();
        if (inputMethodService != null && ImeTracing.getInstance().isEnabled()) {
            ProtoOutputStream icProto = InputConnectionProtoDumper.buildGetSelectedTextProto(flags,
            final byte[] icProto = InputConnectionProtoDumper.buildGetSelectedTextProto(flags,
                    result);
            ImeTracing.getInstance().triggerServiceDump(TAG + "#getSelectedText",
                    inputMethodService, icProto);
@@ -182,7 +181,7 @@ final class RemoteInputConnection implements InputConnection {

        final AbstractInputMethodService inputMethodService = mInputMethodService.get();
        if (inputMethodService != null && ImeTracing.getInstance().isEnabled()) {
            ProtoOutputStream icProto = InputConnectionProtoDumper.buildGetSurroundingTextProto(
            final byte[] icProto = InputConnectionProtoDumper.buildGetSurroundingTextProto(
                    beforeLength, afterLength, flags, result);
            ImeTracing.getInstance().triggerServiceDump(TAG + "#getSurroundingText",
                    inputMethodService, icProto);
@@ -203,7 +202,7 @@ final class RemoteInputConnection implements InputConnection {

        final AbstractInputMethodService inputMethodService = mInputMethodService.get();
        if (inputMethodService != null && ImeTracing.getInstance().isEnabled()) {
            ProtoOutputStream icProto = InputConnectionProtoDumper.buildGetCursorCapsModeProto(
            final byte[] icProto = InputConnectionProtoDumper.buildGetCursorCapsModeProto(
                    reqModes, result);
            ImeTracing.getInstance().triggerServiceDump(TAG + "#getCursorCapsMode",
                    inputMethodService, icProto);
@@ -224,7 +223,7 @@ final class RemoteInputConnection implements InputConnection {

        final AbstractInputMethodService inputMethodService = mInputMethodService.get();
        if (inputMethodService != null && ImeTracing.getInstance().isEnabled()) {
            ProtoOutputStream icProto = InputConnectionProtoDumper.buildGetExtractedTextProto(
            final byte[] icProto = InputConnectionProtoDumper.buildGetExtractedTextProto(
                    request, flags, result);
            ImeTracing.getInstance().triggerServiceDump(TAG + "#getExtractedText",
                    inputMethodService, icProto);
+2 −2
Original line number Diff line number Diff line
@@ -3210,7 +3210,7 @@ public final class InputMethodManager {
     * @hide
     */
    @GuardedBy("mH")
    public void dumpDebug(ProtoOutputStream proto, ProtoOutputStream icProto) {
    public void dumpDebug(ProtoOutputStream proto, @Nullable byte[] icProto) {
        if (mCurrentInputMethodSession == null) {
            return;
        }
@@ -3236,7 +3236,7 @@ public final class InputMethodManager {
                mServedInputConnectionWrapper.dumpDebug(proto, INPUT_CONNECTION);
            }
            if (icProto != null) {
                proto.write(INPUT_CONNECTION_CALL, icProto.getBytes());
                proto.write(INPUT_CONNECTION_CALL, icProto);
            }
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ public abstract class ImeTracing {
     * @param icProto {@link android.view.inputmethod.InputConnection} call data in proto format.
     */
    public abstract void triggerClientDump(String where, InputMethodManager immInstance,
            ProtoOutputStream icProto);
            @Nullable byte[] icProto);

    /**
     * Starts a proto dump of the currently connected InputMethodService information.
@@ -114,7 +114,7 @@ public abstract class ImeTracing {
     * @param icProto {@link android.view.inputmethod.InputConnection} call data in proto format.
     */
    public abstract void triggerServiceDump(String where, AbstractInputMethodService service,
            ProtoOutputStream icProto);
            @Nullable byte[] icProto);

    /**
     * Starts a proto dump of the InputMethodManagerService information.
Loading