Merge "Make IInputMethodManager to oneway (10/N)" into sc-dev am: 299897e9ba

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13410419

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I58254b02602f6cd0b34329d4cb1a850bdc01adac
This commit is contained in:
Wilson Wu
2021-01-28 02:09:39 +00:00
committed by Automerger Merge Worker
6 changed files with 107 additions and 80 deletions

View File

@@ -2307,7 +2307,9 @@ public final class InputMethodManager {
public void removeImeSurface(IBinder windowToken) { public void removeImeSurface(IBinder windowToken) {
synchronized (mH) { synchronized (mH) {
try { try {
mService.removeImeSurfaceFromWindow(windowToken); final Completable.Void value = Completable.createVoid();
mService.removeImeSurfaceFromWindow(windowToken, ResultCallbacks.of(value));
Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -3239,7 +3241,9 @@ public final class InputMethodManager {
@Deprecated @Deprecated
public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) { public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) {
try { try {
mService.setAdditionalInputMethodSubtypes(imiId, subtypes); final Completable.Void value = Completable.createVoid();
mService.setAdditionalInputMethodSubtypes(imiId, subtypes, ResultCallbacks.of(value));
Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }

View File

@@ -41,22 +41,24 @@ interface IInputMethodManager {
int untrustedDisplayId); int untrustedDisplayId);
// TODO: Use ParceledListSlice instead // TODO: Use ParceledListSlice instead
void getInputMethodList(int userId, in IInputMethodInfoListResultCallback resultCallback); oneway void getInputMethodList(int userId,
// TODO: Use ParceledListSlice instead
void getEnabledInputMethodList(int userId,
in IInputMethodInfoListResultCallback resultCallback); in IInputMethodInfoListResultCallback resultCallback);
void getEnabledInputMethodSubtypeList(in String imiId, boolean allowsImplicitlySelectedSubtypes, // TODO: Use ParceledListSlice instead
oneway void getEnabledInputMethodList(int userId,
in IInputMethodInfoListResultCallback resultCallback);
oneway void getEnabledInputMethodSubtypeList(in String imiId,
boolean allowsImplicitlySelectedSubtypes,
in IInputMethodSubtypeListResultCallback resultCallback); in IInputMethodSubtypeListResultCallback resultCallback);
void getLastInputMethodSubtype(in IInputMethodSubtypeResultCallback resultCallback); oneway void getLastInputMethodSubtype(in IInputMethodSubtypeResultCallback resultCallback);
void showSoftInput(in IInputMethodClient client, IBinder windowToken, int flags, oneway void showSoftInput(in IInputMethodClient client, IBinder windowToken, int flags,
in ResultReceiver resultReceiver, in IBooleanResultCallback resultCallback); in ResultReceiver resultReceiver, in IBooleanResultCallback resultCallback);
void hideSoftInput(in IInputMethodClient client, IBinder windowToken, int flags, oneway void hideSoftInput(in IInputMethodClient client, IBinder windowToken, int flags,
in ResultReceiver resultReceiver, in IBooleanResultCallback resultCallback); in ResultReceiver resultReceiver, in IBooleanResultCallback resultCallback);
// If windowToken is null, this just does startInput(). Otherwise this reports that a window // If windowToken is null, this just does startInput(). Otherwise this reports that a window
// has gained focus, and if 'attribute' is non-null then also does startInput. // has gained focus, and if 'attribute' is non-null then also does startInput.
// @NonNull // @NonNull
void startInputOrWindowGainedFocus( oneway void startInputOrWindowGainedFocus(
/* @StartInputReason */ int startInputReason, /* @StartInputReason */ int startInputReason,
in IInputMethodClient client, in IBinder windowToken, in IInputMethodClient client, in IBinder windowToken,
/* @StartInputFlags */ int startInputFlags, /* @StartInputFlags */ int startInputFlags,
@@ -66,29 +68,31 @@ interface IInputMethodManager {
int unverifiedTargetSdkVersion, int unverifiedTargetSdkVersion,
in IInputBindResultResultCallback inputBindResult); in IInputBindResultResultCallback inputBindResult);
void showInputMethodPickerFromClient(in IInputMethodClient client, oneway void showInputMethodPickerFromClient(in IInputMethodClient client,
int auxiliarySubtypeMode, in IVoidResultCallback resultCallback); int auxiliarySubtypeMode, in IVoidResultCallback resultCallback);
void showInputMethodPickerFromSystem(in IInputMethodClient client, int auxiliarySubtypeMode, oneway void showInputMethodPickerFromSystem(in IInputMethodClient client,
int displayId, in IVoidResultCallback resultCallback); int auxiliarySubtypeMode, int displayId, in IVoidResultCallback resultCallback);
void showInputMethodAndSubtypeEnablerFromClient(in IInputMethodClient client, String topId, oneway void showInputMethodAndSubtypeEnablerFromClient(in IInputMethodClient client,
String topId, in IVoidResultCallback resultCallback);
oneway void isInputMethodPickerShownForTest(in IBooleanResultCallback resultCallback);
oneway void getCurrentInputMethodSubtype(in IInputMethodSubtypeResultCallback resultCallback);
oneway void setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes,
in IVoidResultCallback resultCallback); in IVoidResultCallback resultCallback);
void isInputMethodPickerShownForTest(in IBooleanResultCallback resultCallback);
void getCurrentInputMethodSubtype(in IInputMethodSubtypeResultCallback resultCallback);
void setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes);
// This is kept due to @UnsupportedAppUsage. // This is kept due to @UnsupportedAppUsage.
// TODO(Bug 113914148): Consider removing this. // TODO(Bug 113914148): Consider removing this.
void getInputMethodWindowVisibleHeight(IIntResultCallback resultCallback); oneway void getInputMethodWindowVisibleHeight(IIntResultCallback resultCallback);
void reportActivityView(in IInputMethodClient parentClient, int childDisplayId, oneway void reportActivityView(in IInputMethodClient parentClient, int childDisplayId,
in float[] matrixValues, in IVoidResultCallback resultCallback); in float[] matrixValues, in IVoidResultCallback resultCallback);
oneway void reportPerceptible(in IBinder windowToken, boolean perceptible); oneway void reportPerceptible(in IBinder windowToken, boolean perceptible);
/** Remove the IME surface. Requires INTERNAL_SYSTEM_WINDOW permission. */ /** Remove the IME surface. Requires INTERNAL_SYSTEM_WINDOW permission. */
void removeImeSurface(); oneway void removeImeSurface(in IVoidResultCallback resultCallback);
/** Remove the IME surface. Requires passing the currently focused window. */ /** Remove the IME surface. Requires passing the currently focused window. */
void removeImeSurfaceFromWindow(in IBinder windowToken); oneway void removeImeSurfaceFromWindow(in IBinder windowToken,
in IVoidResultCallback resultCallback);
void startProtoDump(in byte[] protoDump, int source, String where); void startProtoDump(in byte[] protoDump, int source, String where);
void isImeTraceEnabled(in IBooleanResultCallback resultCallback); oneway void isImeTraceEnabled(in IBooleanResultCallback resultCallback);
// Starts an ime trace. // Starts an ime trace.
void startImeTrace(); void startImeTrace();

View File

@@ -42,6 +42,8 @@ import android.view.animation.PathInterpolator;
import androidx.annotation.BinderThread; import androidx.annotation.BinderThread;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import com.android.internal.inputmethod.Completable;
import com.android.internal.inputmethod.ResultCallbacks;
import com.android.internal.view.IInputMethodManager; import com.android.internal.view.IInputMethodManager;
import java.util.ArrayList; import java.util.ArrayList;
@@ -506,7 +508,9 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
try { try {
// Remove the IME surface to make the insets invisible for // Remove the IME surface to make the insets invisible for
// non-client controlled insets. // non-client controlled insets.
imms.removeImeSurface(); final Completable.Void value = Completable.createVoid();
imms.removeImeSurface(ResultCallbacks.of(value));
Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Failed to remove IME surface.", e); Slog.e(TAG, "Failed to remove IME surface.", e);
} }

View File

@@ -65,6 +65,8 @@ public class DisplayImeControllerTest {
public IInputMethodManager getImms() { public IInputMethodManager getImms() {
return mMock; return mMock;
} }
@Override
void removeImeSurface() { }
}.new PerDisplay(DEFAULT_DISPLAY, ROTATION_0); }.new PerDisplay(DEFAULT_DISPLAY, ROTATION_0);
} }

View File

@@ -3947,7 +3947,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
@Override @Override
public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) { public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes,
IVoidResultCallback resultCallback) {
CallbackUtils.onResult(resultCallback, () -> {
// By this IPC call, only a process which shares the same uid with the IME can add // By this IPC call, only a process which shares the same uid with the IME can add
// additional input method subtypes to the IME. // additional input method subtypes to the IME.
if (TextUtils.isEmpty(imiId) || subtypes == null) return; if (TextUtils.isEmpty(imiId) || subtypes == null) return;
@@ -3999,6 +4001,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
} }
return; return;
});
} }
/** /**
@@ -4103,16 +4106,21 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
@Override @Override
public void removeImeSurface() { public void removeImeSurface(IVoidResultCallback resultCallback) {
CallbackUtils.onResult(resultCallback, () -> {
mContext.enforceCallingPermission(Manifest.permission.INTERNAL_SYSTEM_WINDOW, null); mContext.enforceCallingPermission(Manifest.permission.INTERNAL_SYSTEM_WINDOW, null);
mHandler.sendMessage(mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE)); mHandler.sendMessage(mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE));
});
} }
@Override @Override
public void removeImeSurfaceFromWindow(IBinder windowToken) { public void removeImeSurfaceFromWindow(IBinder windowToken,
IVoidResultCallback resultCallback) {
CallbackUtils.onResult(resultCallback, () -> {
// No permission check, because we'll only execute the request if the calling window is // No permission check, because we'll only execute the request if the calling window is
// also the current IME client. // also the current IME client.
mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE_FROM_WINDOW, windowToken).sendToTarget(); mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE_FROM_WINDOW, windowToken).sendToTarget();
});
} }
/** /**

View File

@@ -1502,14 +1502,17 @@ public final class MultiClientInputMethodManagerService {
@BinderThread @BinderThread
@Override @Override
public void removeImeSurface() { public void removeImeSurface(IVoidResultCallback resultCallback) {
reportNotSupported(); reportNotSupported();
CallbackUtils.onResult(resultCallback, () -> { });
} }
@BinderThread @BinderThread
@Override @Override
public void removeImeSurfaceFromWindow(IBinder windowToken) { public void removeImeSurfaceFromWindow(IBinder windowToken,
IVoidResultCallback resultCallback) {
reportNotSupported(); reportNotSupported();
CallbackUtils.onResult(resultCallback, () -> { });
} }
@BinderThread @BinderThread
@@ -1815,8 +1818,10 @@ public final class MultiClientInputMethodManagerService {
@BinderThread @BinderThread
@Override @Override
public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) { public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes,
IVoidResultCallback resultCallback) {
reportNotSupported(); reportNotSupported();
CallbackUtils.onResult(resultCallback, () -> { });
} }
@BinderThread @BinderThread