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
      b4f328a2f3
 [2]: Id422bb2547197c617f914ed7cf5085e02a1c3fb5
      a1f869d10e

Fix: 186874025
Test: atest CtsWindowManagerDeviceTestCases:ActivityViewTest
Change-Id: I0463e8e9daaa8ab6d3eadb395843ca5e6bc1bb5e
This commit is contained in:
Yohei Yukawa
2021-04-30 12:29:39 -07:00
parent 2c389bf6ef
commit 4baf2915d8
4 changed files with 16 additions and 13 deletions

View File

@@ -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();
}

View File

@@ -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. */

View File

@@ -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

View File

@@ -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