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

Commit 4baf2915 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Make IInputMethodManager#reportActivityViewAsync() truly async

It turns out that IInputMethodManager#reportActivityView() [1], which
was added a few years ago to support CursorAnchorInfo API on edit
fields hosted on an ActivityView [1], is now also used by task
organizer [2].  This means that we would continue living with this
@hide API for a while even after ActivityView gets completely removed
at Bug 179161778.  Then, converting this IPC into truly asynchronous
would probably make sense.

There should be no behavior change unless the target IME client is
running on an embedded display environment.

 [1]: Id0411a80456182111bb5b681c6d1230b58e7ec2e
      b4f328a2
 [2]: Id422bb2547197c617f914ed7cf5085e02a1c3fb5
      a1f869d1

Fix: 186874025
Test: atest CtsWindowManagerDeviceTestCases:ActivityViewTest
Change-Id: I0463e8e9daaa8ab6d3eadb395843ca5e6bc1bb5e
parent 2c389bf6
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -3106,10 +3106,7 @@ public final class InputMethodManager {
                matrixValues = new float[9];
                matrix.getValues(matrixValues);
            }
            final Completable.Void value = Completable.createVoid();
            mService.reportActivityView(
                    mClient, childDisplayId, matrixValues, ResultCallbacks.of(value));
            Completable.getResult(value);
            mService.reportActivityViewAsync(mClient, childDisplayId, matrixValues);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+2 −2
Original line number Diff line number Diff line
@@ -88,8 +88,8 @@ interface IInputMethodManager {
    // TODO(Bug 113914148): Consider removing this.
    oneway void getInputMethodWindowVisibleHeight(IIntResultCallback resultCallback);

    oneway void reportActivityView(in IInputMethodClient parentClient, int childDisplayId,
            in float[] matrixValues, in IVoidResultCallback resultCallback);
    oneway void reportActivityViewAsync(in IInputMethodClient parentClient, int childDisplayId,
            in float[] matrixValues);

    oneway void reportPerceptibleAsync(in IBinder windowToken, boolean perceptible);
    /** Remove the IME surface. Requires INTERNAL_SYSTEM_WINDOW permission. */
+11 −4
Original line number Diff line number Diff line
@@ -4046,9 +4046,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    }

    @Override
    public void reportActivityView(IInputMethodClient parentClient, int childDisplayId,
            float[] matrixValues, IVoidResultCallback resultCallback) {
        CallbackUtils.onResult(resultCallback, () -> {
    public void reportActivityViewAsync(IInputMethodClient parentClient, int childDisplayId,
            float[] matrixValues) {
        try {
            final DisplayInfo displayInfo = mDisplayManagerInternal.getDisplayInfo(childDisplayId);
            if (displayInfo == null) {
                throw new IllegalArgumentException(
@@ -4127,7 +4127,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    displayId = info.mParentClient.selfReportedDisplayId;
                }
            }
        });
        } catch (Throwable t) {
            if (parentClient != null) {
                try {
                    parentClient.throwExceptionFromSystem(t.toString());
                } catch (RemoteException e) {
                }
            }
        }
    }

    @Override
+2 −3
Original line number Diff line number Diff line
@@ -1864,10 +1864,9 @@ public final class MultiClientInputMethodManagerService {

        @BinderThread
        @Override
        public void reportActivityView(IInputMethodClient parentClient, int childDisplayId,
                float[] matrixValues, IVoidResultCallback resultCallback) {
        public void reportActivityViewAsync(IInputMethodClient parentClient, int childDisplayId,
                float[] matrixValues) {
            reportNotSupported();
            CallbackUtils.onResult(resultCallback, () -> { });
        }

        @BinderThread