Merge "Switch back to sync IInputMethodManager" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-07-02 15:22:21 +00:00
committed by Android (Google) Code Review
7 changed files with 417 additions and 655 deletions

View File

@@ -27,8 +27,6 @@ import android.util.Log;
import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
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.io.PrintWriter; import java.io.PrintWriter;
@@ -92,9 +90,7 @@ public abstract class ImeTracing {
* @param where * @param where
*/ */
public void sendToService(byte[] protoDump, int source, String where) throws RemoteException { public void sendToService(byte[] protoDump, int source, String where) throws RemoteException {
final Completable.Void value = Completable.createVoid(); mService.startProtoDump(protoDump, source, where);
mService.startProtoDump(protoDump, source, where, ResultCallbacks.of(value));
Completable.getResult(value);
} }
/** /**

View File

@@ -24,9 +24,6 @@ import android.util.Log;
import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import com.android.internal.inputmethod.Completable;
import com.android.internal.inputmethod.ResultCallbacks;
import java.io.PrintWriter; import java.io.PrintWriter;
/** /**
@@ -34,9 +31,7 @@ import java.io.PrintWriter;
*/ */
class ImeTracingClientImpl extends ImeTracing { class ImeTracingClientImpl extends ImeTracing {
ImeTracingClientImpl() throws ServiceNotFoundException, RemoteException { ImeTracingClientImpl() throws ServiceNotFoundException, RemoteException {
final Completable.Boolean value = Completable.createBoolean(); sEnabled = mService.isImeTraceEnabled();
mService.isImeTraceEnabled(ResultCallbacks.of(value));
sEnabled = Completable.getResult(value);
} }
@Override @Override

View File

@@ -88,10 +88,8 @@ import android.view.WindowManager.LayoutParams.SoftInputModeFlags;
import android.view.autofill.AutofillManager; import android.view.autofill.AutofillManager;
import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy;
import com.android.internal.inputmethod.Completable;
import com.android.internal.inputmethod.InputMethodDebug; import com.android.internal.inputmethod.InputMethodDebug;
import com.android.internal.inputmethod.InputMethodPrivilegedOperationsRegistry; import com.android.internal.inputmethod.InputMethodPrivilegedOperationsRegistry;
import com.android.internal.inputmethod.ResultCallbacks;
import com.android.internal.inputmethod.SoftInputShowHideReason; import com.android.internal.inputmethod.SoftInputShowHideReason;
import com.android.internal.inputmethod.StartInputFlags; import com.android.internal.inputmethod.StartInputFlags;
import com.android.internal.inputmethod.StartInputReason; import com.android.internal.inputmethod.StartInputReason;
@@ -265,14 +263,6 @@ public final class InputMethodManager {
private static final int NOT_A_SUBTYPE_ID = -1; private static final int NOT_A_SUBTYPE_ID = -1;
/**
* {@code true} to try to avoid blocking apps' UI thread by sending
* {@link StartInputReason#WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION} and
* {@link StartInputReason#WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION} in a truly asynchronous
* way. {@code false} to go back to the previous synchronous semantics.
*/
private static final boolean USE_REPORT_WINDOW_GAINED_FOCUS_ASYNC = true;
/** /**
* A constant that represents Voice IME. * A constant that represents Voice IME.
* *
@@ -686,17 +676,10 @@ public final class InputMethodManager {
+ ", nextFocusIsServedView=" + nextFocusHasConnection); + ", nextFocusIsServedView=" + nextFocusHasConnection);
} }
if (USE_REPORT_WINDOW_GAINED_FOCUS_ASYNC) {
mService.reportWindowGainedFocusAsync(
nextFocusHasConnection, mClient, focusedView.getWindowToken(),
startInputFlags, softInputMode, windowFlags,
mCurRootView.mContext.getApplicationInfo().targetSdkVersion);
} else {
final int startInputReason = nextFocusHasConnection final int startInputReason = nextFocusHasConnection
? WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION ? WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION
: WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION; : WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION;
final Completable.InputBindResult value = // ignore the result
Completable.createInputBindResult();
mService.startInputOrWindowGainedFocus( mService.startInputOrWindowGainedFocus(
startInputReason, mClient, startInputReason, mClient,
focusedView.getWindowToken(), startInputFlags, softInputMode, focusedView.getWindowToken(), startInputFlags, softInputMode,
@@ -704,10 +687,7 @@ public final class InputMethodManager {
null, null,
null, null,
0 /* missingMethodFlags */, 0 /* missingMethodFlags */,
mCurRootView.mContext.getApplicationInfo().targetSdkVersion, mCurRootView.mContext.getApplicationInfo().targetSdkVersion);
ResultCallbacks.of(value));
Completable.getResult(value); // ignore the result
}
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -1249,9 +1229,7 @@ public final class InputMethodManager {
// We intentionally do not use UserHandle.getCallingUserId() here because for system // We intentionally do not use UserHandle.getCallingUserId() here because for system
// services InputMethodManagerInternal.getInputMethodListAsUser() should be used // services InputMethodManagerInternal.getInputMethodListAsUser() should be used
// instead. // instead.
final Completable.InputMethodInfoList value = Completable.createInputMethodInfoList(); return mService.getInputMethodList(UserHandle.myUserId());
mService.getInputMethodList(UserHandle.myUserId(), ResultCallbacks.of(value));
return Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -1269,9 +1247,7 @@ public final class InputMethodManager {
@NonNull @NonNull
public List<InputMethodInfo> getInputMethodListAsUser(@UserIdInt int userId) { public List<InputMethodInfo> getInputMethodListAsUser(@UserIdInt int userId) {
try { try {
final Completable.InputMethodInfoList value = Completable.createInputMethodInfoList(); return mService.getInputMethodList(userId);
mService.getInputMethodList(userId, ResultCallbacks.of(value));
return Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -1289,9 +1265,7 @@ public final class InputMethodManager {
// We intentionally do not use UserHandle.getCallingUserId() here because for system // We intentionally do not use UserHandle.getCallingUserId() here because for system
// services InputMethodManagerInternal.getEnabledInputMethodListAsUser() should be used // services InputMethodManagerInternal.getEnabledInputMethodListAsUser() should be used
// instead. // instead.
final Completable.InputMethodInfoList value = Completable.createInputMethodInfoList(); return mService.getEnabledInputMethodList(UserHandle.myUserId());
mService.getEnabledInputMethodList(UserHandle.myUserId(), ResultCallbacks.of(value));
return Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -1307,9 +1281,7 @@ public final class InputMethodManager {
@RequiresPermission(INTERACT_ACROSS_USERS_FULL) @RequiresPermission(INTERACT_ACROSS_USERS_FULL)
public List<InputMethodInfo> getEnabledInputMethodListAsUser(@UserIdInt int userId) { public List<InputMethodInfo> getEnabledInputMethodListAsUser(@UserIdInt int userId) {
try { try {
final Completable.InputMethodInfoList value = Completable.createInputMethodInfoList(); return mService.getEnabledInputMethodList(userId);
mService.getEnabledInputMethodList(userId, ResultCallbacks.of(value));
return Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -1328,13 +1300,9 @@ public final class InputMethodManager {
public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo imi, public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo imi,
boolean allowsImplicitlySelectedSubtypes) { boolean allowsImplicitlySelectedSubtypes) {
try { try {
final Completable.InputMethodSubtypeList value = return mService.getEnabledInputMethodSubtypeList(
Completable.createInputMethodSubtypeList();
mService.getEnabledInputMethodSubtypeList(
imi == null ? null : imi.getId(), imi == null ? null : imi.getId(),
allowsImplicitlySelectedSubtypes, allowsImplicitlySelectedSubtypes);
ResultCallbacks.of(value));
return Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -1669,15 +1637,12 @@ public final class InputMethodManager {
try { try {
Log.d(TAG, "showSoftInput() view=" + view + " flags=" + flags + " reason=" Log.d(TAG, "showSoftInput() view=" + view + " flags=" + flags + " reason="
+ InputMethodDebug.softInputDisplayReasonToString(reason)); + InputMethodDebug.softInputDisplayReasonToString(reason));
final Completable.Boolean value = Completable.createBoolean(); return mService.showSoftInput(
mService.showSoftInput(
mClient, mClient,
view.getWindowToken(), view.getWindowToken(),
flags, flags,
resultReceiver, resultReceiver,
reason, reason);
ResultCallbacks.of(value));
return Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -1704,15 +1669,12 @@ public final class InputMethodManager {
Log.w(TAG, "No current root view, ignoring showSoftInputUnchecked()"); Log.w(TAG, "No current root view, ignoring showSoftInputUnchecked()");
return; return;
} }
final Completable.Boolean value = Completable.createBoolean();
mService.showSoftInput( mService.showSoftInput(
mClient, mClient,
mCurRootView.getView().getWindowToken(), mCurRootView.getView().getWindowToken(),
flags, flags,
resultReceiver, resultReceiver,
SoftInputShowHideReason.SHOW_SOFT_INPUT, SoftInputShowHideReason.SHOW_SOFT_INPUT);
ResultCallbacks.of(value));
Completable.getResult(value); // ignore the result
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -1791,10 +1753,7 @@ public final class InputMethodManager {
} }
try { try {
final Completable.Boolean value = Completable.createBoolean(); return mService.hideSoftInput(mClient, windowToken, flags, resultReceiver, reason);
mService.hideSoftInput(mClient, windowToken, flags, resultReceiver, reason,
ResultCallbacks.of(value));
return Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -2030,13 +1989,10 @@ public final class InputMethodManager {
+ InputMethodDebug.startInputFlagsToString(startInputFlags)); + InputMethodDebug.startInputFlagsToString(startInputFlags));
} }
try { try {
final Completable.InputBindResult value = Completable.createInputBindResult(); res = mService.startInputOrWindowGainedFocus(
mService.startInputOrWindowGainedFocus(
startInputReason, mClient, windowGainingFocus, startInputFlags, startInputReason, mClient, windowGainingFocus, startInputFlags,
softInputMode, windowFlags, tba, servedContext, missingMethodFlags, softInputMode, windowFlags, tba, servedContext, missingMethodFlags,
view.getContext().getApplicationInfo().targetSdkVersion, view.getContext().getApplicationInfo().targetSdkVersion);
ResultCallbacks.of(value));
res = Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -2144,15 +2100,12 @@ public final class InputMethodManager {
return; return;
} }
try { try {
final Completable.Boolean value = Completable.createBoolean();
mService.hideSoftInput( mService.hideSoftInput(
mClient, mClient,
mCurRootView.getView().getWindowToken(), mCurRootView.getView().getWindowToken(),
HIDE_NOT_ALWAYS, HIDE_NOT_ALWAYS,
null, null,
SoftInputShowHideReason.HIDE_SOFT_INPUT, SoftInputShowHideReason.HIDE_SOFT_INPUT);
ResultCallbacks.of(value));
Completable.getResult(value); // ignore the result
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -2832,10 +2785,7 @@ public final class InputMethodManager {
? SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES ? SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES
: SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES; : SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES;
try { try {
final Completable.Void value = Completable.createVoid(); mService.showInputMethodPickerFromSystem(mClient, mode, displayId);
mService.showInputMethodPickerFromSystem(
mClient, mode, displayId, ResultCallbacks.of(value));
Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -2843,10 +2793,7 @@ public final class InputMethodManager {
private void showInputMethodPickerLocked() { private void showInputMethodPickerLocked() {
try { try {
final Completable.Void value = Completable.createVoid(); mService.showInputMethodPickerFromClient(mClient, SHOW_IM_PICKER_MODE_AUTO);
mService.showInputMethodPickerFromClient(
mClient, SHOW_IM_PICKER_MODE_AUTO, ResultCallbacks.of(value));
Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -2866,9 +2813,7 @@ public final class InputMethodManager {
@TestApi @TestApi
public boolean isInputMethodPickerShown() { public boolean isInputMethodPickerShown() {
try { try {
final Completable.Boolean value = Completable.createBoolean(); return mService.isInputMethodPickerShownForTest();
mService.isInputMethodPickerShownForTest(ResultCallbacks.of(value));
return Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -2882,10 +2827,7 @@ public final class InputMethodManager {
*/ */
public void showInputMethodAndSubtypeEnabler(String imiId) { public void showInputMethodAndSubtypeEnabler(String imiId) {
try { try {
final Completable.Void value = Completable.createVoid(); mService.showInputMethodAndSubtypeEnablerFromClient(mClient, imiId);
mService.showInputMethodAndSubtypeEnablerFromClient(
mClient, imiId, ResultCallbacks.of(value));
Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -2898,9 +2840,7 @@ public final class InputMethodManager {
*/ */
public InputMethodSubtype getCurrentInputMethodSubtype() { public InputMethodSubtype getCurrentInputMethodSubtype() {
try { try {
final Completable.InputMethodSubtype value = Completable.createInputMethodSubtype(); return mService.getCurrentInputMethodSubtype();
mService.getCurrentInputMethodSubtype(ResultCallbacks.of(value));
return Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -2949,11 +2889,7 @@ public final class InputMethodManager {
} }
final List<InputMethodSubtype> enabledSubtypes; final List<InputMethodSubtype> enabledSubtypes;
try { try {
final Completable.InputMethodSubtypeList value = enabledSubtypes = mService.getEnabledInputMethodSubtypeList(imeId, true);
Completable.createInputMethodSubtypeList();
mService.getEnabledInputMethodSubtypeList(
imeId, true, ResultCallbacks.of(value));
enabledSubtypes = Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
return false; return false;
} }
@@ -3021,9 +2957,7 @@ public final class InputMethodManager {
@UnsupportedAppUsage @UnsupportedAppUsage
public int getInputMethodWindowVisibleHeight() { public int getInputMethodWindowVisibleHeight() {
try { try {
final Completable.Int value = Completable.createInt(); return mService.getInputMethodWindowVisibleHeight();
mService.getInputMethodWindowVisibleHeight(ResultCallbacks.of(value));
return Completable.getIntResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -3118,9 +3052,7 @@ public final class InputMethodManager {
@Deprecated @Deprecated
public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) { public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) {
try { try {
final Completable.Void value = Completable.createVoid(); mService.setAdditionalInputMethodSubtypes(imiId, subtypes);
mService.setAdditionalInputMethodSubtypes(imiId, subtypes, ResultCallbacks.of(value));
Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -3128,9 +3060,7 @@ public final class InputMethodManager {
public InputMethodSubtype getLastInputMethodSubtype() { public InputMethodSubtype getLastInputMethodSubtype() {
try { try {
final Completable.InputMethodSubtype value = Completable.createInputMethodSubtype(); return mService.getLastInputMethodSubtype();
mService.getLastInputMethodSubtype(ResultCallbacks.of(value));
return Completable.getResult(value);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }

View File

@@ -24,13 +24,6 @@ import android.view.inputmethod.EditorInfo;
import com.android.internal.view.InputBindResult; import com.android.internal.view.InputBindResult;
import com.android.internal.view.IInputContext; import com.android.internal.view.IInputContext;
import com.android.internal.view.IInputMethodClient; import com.android.internal.view.IInputMethodClient;
import com.android.internal.inputmethod.IBooleanResultCallback;
import com.android.internal.inputmethod.IInputBindResultResultCallback;
import com.android.internal.inputmethod.IInputMethodInfoListResultCallback;
import com.android.internal.inputmethod.IInputMethodSubtypeResultCallback;
import com.android.internal.inputmethod.IInputMethodSubtypeListResultCallback;
import com.android.internal.inputmethod.IIntResultCallback;
import com.android.internal.inputmethod.IVoidResultCallback;
/** /**
* Public interface to the global input method manager, used by all client * Public interface to the global input method manager, used by all client
@@ -41,64 +34,51 @@ interface IInputMethodManager {
int untrustedDisplayId); int untrustedDisplayId);
// TODO: Use ParceledListSlice instead // TODO: Use ParceledListSlice instead
oneway void getInputMethodList(int userId, List<InputMethodInfo> getInputMethodList(int userId);
in IInputMethodInfoListResultCallback resultCallback);
// TODO: Use ParceledListSlice instead // TODO: Use ParceledListSlice instead
oneway void getEnabledInputMethodList(int userId, List<InputMethodInfo> getEnabledInputMethodList(int userId);
in IInputMethodInfoListResultCallback resultCallback); List<InputMethodSubtype> getEnabledInputMethodSubtypeList(in String imiId,
oneway void getEnabledInputMethodSubtypeList(in String imiId, boolean allowsImplicitlySelectedSubtypes);
boolean allowsImplicitlySelectedSubtypes, InputMethodSubtype getLastInputMethodSubtype();
in IInputMethodSubtypeListResultCallback resultCallback);
oneway void getLastInputMethodSubtype(in IInputMethodSubtypeResultCallback resultCallback);
oneway void showSoftInput(in IInputMethodClient client, IBinder windowToken, int flags, boolean showSoftInput(in IInputMethodClient client, IBinder windowToken, int flags,
in ResultReceiver resultReceiver, int reason, in IBooleanResultCallback resultCallback); in ResultReceiver resultReceiver, int reason);
oneway void hideSoftInput(in IInputMethodClient client, IBinder windowToken, int flags, boolean hideSoftInput(in IInputMethodClient client, IBinder windowToken, int flags,
in ResultReceiver resultReceiver, int reason, in IBooleanResultCallback resultCallback); in ResultReceiver resultReceiver, int reason);
// 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
oneway void startInputOrWindowGainedFocus( InputBindResult 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,
/* @android.view.WindowManager.LayoutParams.SoftInputModeFlags */ int softInputMode, /* @android.view.WindowManager.LayoutParams.SoftInputModeFlags */ int softInputMode,
int windowFlags, in EditorInfo attribute, IInputContext inputContext, int windowFlags, in EditorInfo attribute, IInputContext inputContext,
/* @InputConnectionInspector.MissingMethodFlags */ int missingMethodFlags, /* @InputConnectionInspector.MissingMethodFlags */ int missingMethodFlags,
int unverifiedTargetSdkVersion, int unverifiedTargetSdkVersion);
in IInputBindResultResultCallback inputBindResult);
oneway void reportWindowGainedFocusAsync( void showInputMethodPickerFromClient(in IInputMethodClient client,
boolean nextFocusHasConnection, in IInputMethodClient client, in IBinder windowToken, int auxiliarySubtypeMode);
/* @StartInputFlags */ int startInputFlags, void showInputMethodPickerFromSystem(in IInputMethodClient client,
/* @android.view.WindowManager.LayoutParams.SoftInputModeFlags */ int softInputMode, int auxiliarySubtypeMode, int displayId);
int windowFlags, int unverifiedTargetSdkVersion); void showInputMethodAndSubtypeEnablerFromClient(in IInputMethodClient client, String topId);
boolean isInputMethodPickerShownForTest();
oneway void showInputMethodPickerFromClient(in IInputMethodClient client, InputMethodSubtype getCurrentInputMethodSubtype();
int auxiliarySubtypeMode, in IVoidResultCallback resultCallback); void setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes);
oneway void showInputMethodPickerFromSystem(in IInputMethodClient client,
int auxiliarySubtypeMode, int displayId, in IVoidResultCallback resultCallback);
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);
// This is kept due to @UnsupportedAppUsage. // This is kept due to @UnsupportedAppUsage.
// TODO(Bug 113914148): Consider removing this. // TODO(Bug 113914148): Consider removing this.
oneway void getInputMethodWindowVisibleHeight(IIntResultCallback resultCallback); int getInputMethodWindowVisibleHeight();
oneway void reportPerceptibleAsync(in IBinder windowToken, boolean perceptible); oneway void reportPerceptibleAsync(in IBinder windowToken, boolean perceptible);
/** Remove the IME surface. Requires INTERNAL_SYSTEM_WINDOW permission. */ /** Remove the IME surface. Requires INTERNAL_SYSTEM_WINDOW permission. */
oneway void removeImeSurface(in IVoidResultCallback resultCallback); void removeImeSurface();
/** Remove the IME surface. Requires passing the currently focused window. */ /** Remove the IME surface. Requires passing the currently focused window. */
oneway void removeImeSurfaceFromWindowAsync(in IBinder windowToken); oneway void removeImeSurfaceFromWindowAsync(in IBinder windowToken);
oneway void startProtoDump(in byte[] protoDump, int source, String where, void startProtoDump(in byte[] protoDump, int source, String where);
in IVoidResultCallback resultCallback); boolean isImeTraceEnabled();
oneway void isImeTraceEnabled(in IBooleanResultCallback resultCallback);
// Starts an ime trace. // Starts an ime trace.
oneway void startImeTrace(in IVoidResultCallback resultCallback); void startImeTrace();
// Stops an ime trace. // Stops an ime trace.
oneway void stopImeTrace(in IVoidResultCallback resultCallback); void stopImeTrace();
} }

View File

@@ -42,8 +42,6 @@ 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;
@@ -540,9 +538,7 @@ 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.
final Completable.Void value = Completable.createVoid(); imms.removeImeSurface();
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

@@ -157,13 +157,8 @@ import com.android.internal.content.PackageMonitor;
import com.android.internal.inputmethod.CallbackUtils; import com.android.internal.inputmethod.CallbackUtils;
import com.android.internal.inputmethod.IBooleanResultCallback; import com.android.internal.inputmethod.IBooleanResultCallback;
import com.android.internal.inputmethod.IIInputContentUriTokenResultCallback; import com.android.internal.inputmethod.IIInputContentUriTokenResultCallback;
import com.android.internal.inputmethod.IInputBindResultResultCallback;
import com.android.internal.inputmethod.IInputContentUriToken; import com.android.internal.inputmethod.IInputContentUriToken;
import com.android.internal.inputmethod.IInputMethodInfoListResultCallback;
import com.android.internal.inputmethod.IInputMethodPrivilegedOperations; import com.android.internal.inputmethod.IInputMethodPrivilegedOperations;
import com.android.internal.inputmethod.IInputMethodSubtypeListResultCallback;
import com.android.internal.inputmethod.IInputMethodSubtypeResultCallback;
import com.android.internal.inputmethod.IIntResultCallback;
import com.android.internal.inputmethod.IVoidResultCallback; import com.android.internal.inputmethod.IVoidResultCallback;
import com.android.internal.inputmethod.InputMethodDebug; import com.android.internal.inputmethod.InputMethodDebug;
import com.android.internal.inputmethod.SoftInputShowHideReason; import com.android.internal.inputmethod.SoftInputShowHideReason;
@@ -213,7 +208,6 @@ import java.util.Objects;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
/** /**
* This class provides a system service that manages input methods. * This class provides a system service that manages input methods.
@@ -1895,9 +1889,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
@Override @Override
public void getInputMethodList(@UserIdInt int userId, public List<InputMethodInfo> getInputMethodList(@UserIdInt int userId) {
IInputMethodInfoListResultCallback resultCallback) {
CallbackUtils.onResult(resultCallback, () -> {
if (UserHandle.getCallingUserId() != userId) { if (UserHandle.getCallingUserId() != userId) {
mContext.enforceCallingPermission( mContext.enforceCallingPermission(
Manifest.permission.INTERACT_ACROSS_USERS_FULL, null); Manifest.permission.INTERACT_ACROSS_USERS_FULL, null);
@@ -1915,13 +1907,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident);
} }
} }
});
} }
@Override @Override
public void getEnabledInputMethodList(@UserIdInt int userId, public List<InputMethodInfo> getEnabledInputMethodList(@UserIdInt int userId) {
IInputMethodInfoListResultCallback resultCallback) {
CallbackUtils.onResult(resultCallback, () -> {
if (UserHandle.getCallingUserId() != userId) { if (UserHandle.getCallingUserId() != userId) {
mContext.enforceCallingPermission( mContext.enforceCallingPermission(
Manifest.permission.INTERACT_ACROSS_USERS_FULL, null); Manifest.permission.INTERACT_ACROSS_USERS_FULL, null);
@@ -1939,7 +1928,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident);
} }
} }
});
} }
@GuardedBy("mMethodMap") @GuardedBy("mMethodMap")
@@ -2097,13 +2085,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
* @param imiId if null, returns enabled subtypes for the current {@link InputMethodInfo}. * @param imiId if null, returns enabled subtypes for the current {@link InputMethodInfo}.
* @param allowsImplicitlySelectedSubtypes {@code true} to return the implicitly selected * @param allowsImplicitlySelectedSubtypes {@code true} to return the implicitly selected
* subtypes. * subtypes.
* @param resultCallback to callback the result.
*/ */
@Override @Override
public void getEnabledInputMethodSubtypeList(String imiId, public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(String imiId,
boolean allowsImplicitlySelectedSubtypes, boolean allowsImplicitlySelectedSubtypes) {
IInputMethodSubtypeListResultCallback resultCallback) {
CallbackUtils.onResult(resultCallback, () -> {
final int callingUserId = UserHandle.getCallingUserId(); final int callingUserId = UserHandle.getCallingUserId();
synchronized (mMethodMap) { synchronized (mMethodMap) {
final int[] resolvedUserIds = InputMethodUtils.resolveUserId(callingUserId, final int[] resolvedUserIds = InputMethodUtils.resolveUserId(callingUserId,
@@ -2119,7 +2104,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident);
} }
} }
});
} }
@GuardedBy("mMethodMap") @GuardedBy("mMethodMap")
@@ -3067,10 +3051,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
@Override @Override
public void showSoftInput(IInputMethodClient client, IBinder windowToken, int flags, public boolean showSoftInput(IInputMethodClient client, IBinder windowToken, int flags,
ResultReceiver resultReceiver, @SoftInputShowHideReason int reason, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) {
IBooleanResultCallback resultCallback) {
CallbackUtils.onResult(resultCallback, () -> {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.showSoftInput"); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.showSoftInput");
int uid = Binder.getCallingUid(); int uid = Binder.getCallingUid();
ImeTracing.getInstance().triggerManagerServiceDump( ImeTracing.getInstance().triggerManagerServiceDump(
@@ -3104,7 +3086,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
} }
} }
});
} }
@BinderThread @BinderThread
@@ -3186,10 +3167,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
@Override @Override
public void hideSoftInput(IInputMethodClient client, IBinder windowToken, int flags, public boolean hideSoftInput(IInputMethodClient client, IBinder windowToken, int flags,
ResultReceiver resultReceiver, @SoftInputShowHideReason int reason, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) {
IBooleanResultCallback resultCallback) {
CallbackUtils.onResult(resultCallback, () -> {
int uid = Binder.getCallingUid(); int uid = Binder.getCallingUid();
ImeTracing.getInstance().triggerManagerServiceDump( ImeTracing.getInstance().triggerManagerServiceDump(
"InputMethodManagerService#hideSoftInput"); "InputMethodManagerService#hideSoftInput");
@@ -3228,7 +3207,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
} }
} }
});
} }
boolean hideCurrentInputLocked(IBinder windowToken, int flags, ResultReceiver resultReceiver, boolean hideCurrentInputLocked(IBinder windowToken, int flags, ResultReceiver resultReceiver,
@@ -3280,38 +3258,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
@NonNull @NonNull
@Override @Override
public void reportWindowGainedFocusAsync( public InputBindResult startInputOrWindowGainedFocus(
boolean nextFocusHasConnection, IInputMethodClient client, IBinder windowToken,
@StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode,
int windowFlags, int unverifiedTargetSdkVersion) {
final int startInputReason = nextFocusHasConnection
? StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION
: StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION;
try {
startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken,
startInputFlags, softInputMode, windowFlags, null /* attribute */,
null /* inputContext */, 0 /* missingMethods */, unverifiedTargetSdkVersion);
} catch (Throwable t) {
if (client != null) {
try {
client.throwExceptionFromSystem(t.getMessage());
} catch (RemoteException ignore) { }
}
}
}
@NonNull
@Override
public void startInputOrWindowGainedFocus(
@StartInputReason int startInputReason, IInputMethodClient client, IBinder windowToken, @StartInputReason int startInputReason, IInputMethodClient client, IBinder windowToken,
@StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode, @StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode,
int windowFlags, @Nullable EditorInfo attribute, IInputContext inputContext, int windowFlags, @Nullable EditorInfo attribute, IInputContext inputContext,
@MissingMethodFlags int missingMethods, int unverifiedTargetSdkVersion, @MissingMethodFlags int missingMethods, int unverifiedTargetSdkVersion) {
IInputBindResultResultCallback resultCallback) { return startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken,
CallbackUtils.onResult(resultCallback, (Supplier<InputBindResult>) () ->
startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken,
startInputFlags, softInputMode, windowFlags, attribute, inputContext, startInputFlags, softInputMode, windowFlags, attribute, inputContext,
missingMethods, unverifiedTargetSdkVersion)); missingMethods, unverifiedTargetSdkVersion);
} }
@NonNull @NonNull
@@ -3671,9 +3625,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
@Override @Override
public void showInputMethodPickerFromClient(IInputMethodClient client, int auxiliarySubtypeMode, public void showInputMethodPickerFromClient(IInputMethodClient client,
IVoidResultCallback resultCallback) { int auxiliarySubtypeMode) {
CallbackUtils.onResult(resultCallback, () -> {
synchronized (mMethodMap) { synchronized (mMethodMap) {
if (!calledFromValidUserLocked()) { if (!calledFromValidUserLocked()) {
return; return;
@@ -3690,13 +3643,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
MSG_SHOW_IM_SUBTYPE_PICKER, auxiliarySubtypeMode, MSG_SHOW_IM_SUBTYPE_PICKER, auxiliarySubtypeMode,
(mCurClient != null) ? mCurClient.selfReportedDisplayId : DEFAULT_DISPLAY)); (mCurClient != null) ? mCurClient.selfReportedDisplayId : DEFAULT_DISPLAY));
} }
});
} }
@Override @Override
public void showInputMethodPickerFromSystem(IInputMethodClient client, int auxiliarySubtypeMode, public void showInputMethodPickerFromSystem(IInputMethodClient client, int auxiliarySubtypeMode,
int displayId, IVoidResultCallback resultCallback) { int displayId) {
CallbackUtils.onResult(resultCallback, () -> {
if (mContext.checkCallingPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) if (mContext.checkCallingPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
throw new SecurityException( throw new SecurityException(
@@ -3707,18 +3658,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
// picker. // picker.
mHandler.sendMessage(mCaller.obtainMessageII( mHandler.sendMessage(mCaller.obtainMessageII(
MSG_SHOW_IM_SUBTYPE_PICKER, auxiliarySubtypeMode, displayId)); MSG_SHOW_IM_SUBTYPE_PICKER, auxiliarySubtypeMode, displayId));
});
} }
/** /**
* A test API for CTS to make sure that the input method menu is showing. * A test API for CTS to make sure that the input method menu is showing.
*
* @param resultCallback {@code true} while the input method menu is showing UI.
*/ */
public void isInputMethodPickerShownForTest(IBooleanResultCallback resultCallback) { public boolean isInputMethodPickerShownForTest() {
synchronized(mMethodMap) { synchronized(mMethodMap) {
CallbackUtils.onResult( return mMenuController.isisInputMethodPickerShownForTestLocked();
resultCallback, mMenuController::isisInputMethodPickerShownForTestLocked);
} }
} }
@@ -3751,8 +3698,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
@Override @Override
public void showInputMethodAndSubtypeEnablerFromClient( public void showInputMethodAndSubtypeEnablerFromClient(
IInputMethodClient client, String inputMethodId, IVoidResultCallback resultCallback) { IInputMethodClient client, String inputMethodId) {
CallbackUtils.onResult(resultCallback, () -> {
synchronized (mMethodMap) { synchronized (mMethodMap) {
// TODO(yukawa): Should we verify the display ID? // TODO(yukawa): Should we verify the display ID?
if (!calledFromValidUserLocked()) { if (!calledFromValidUserLocked()) {
@@ -3761,7 +3707,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
executeOrSendMessage(mCurMethod, mCaller.obtainMessageO( executeOrSendMessage(mCurMethod, mCaller.obtainMessageO(
MSG_SHOW_IM_SUBTYPE_ENABLER, inputMethodId)); MSG_SHOW_IM_SUBTYPE_ENABLER, inputMethodId));
} }
});
} }
@BinderThread @BinderThread
@@ -3869,8 +3814,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
@Override @Override
public void getLastInputMethodSubtype(IInputMethodSubtypeResultCallback resultCallback) { public InputMethodSubtype getLastInputMethodSubtype() {
CallbackUtils.onResult(resultCallback, () -> {
synchronized (mMethodMap) { synchronized (mMethodMap) {
if (!calledFromValidUserLocked()) { if (!calledFromValidUserLocked()) {
return null; return null;
@@ -3893,13 +3837,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
return null; return null;
} }
} }
});
} }
@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;
@@ -3950,8 +3891,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
} }
} }
return;
});
} }
/** /**
@@ -3963,19 +3902,15 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
* @return {@link WindowManagerInternal#getInputMethodWindowVisibleHeight(int)} * @return {@link WindowManagerInternal#getInputMethodWindowVisibleHeight(int)}
*/ */
@Override @Override
public void getInputMethodWindowVisibleHeight(IIntResultCallback resultCallback) { public int getInputMethodWindowVisibleHeight() {
CallbackUtils.onResult(resultCallback, () -> {
// TODO(yukawa): Should we verify the display ID? // TODO(yukawa): Should we verify the display ID?
return mWindowManagerInternal.getInputMethodWindowVisibleHeight(mCurTokenDisplayId); return mWindowManagerInternal.getInputMethodWindowVisibleHeight(mCurTokenDisplayId);
});
} }
@Override @Override
public void removeImeSurface(IVoidResultCallback resultCallback) { public void removeImeSurface() {
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
@@ -3992,9 +3927,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
*/ */
@BinderThread @BinderThread
@Override @Override
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) { if (protoDump == null && source != IME_TRACING_FROM_IMMS) {
// Dump not triggered from IMMS, but no proto information provided. // Dump not triggered from IMMS, but no proto information provided.
return; return;
@@ -4037,19 +3970,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
return; return;
} }
tracingInstance.addToBuffer(proto, source); tracingInstance.addToBuffer(proto, source);
});
} }
@BinderThread @BinderThread
@Override @Override
public void isImeTraceEnabled(IBooleanResultCallback resultCallback) { public boolean isImeTraceEnabled() {
CallbackUtils.onResult(resultCallback, () -> ImeTracing.getInstance().isEnabled()); return ImeTracing.getInstance().isEnabled();
} }
@BinderThread @BinderThread
@Override @Override
public void startImeTrace(IVoidResultCallback resultCallback) { public void startImeTrace() {
CallbackUtils.onResult(resultCallback, () -> {
ImeTracing.getInstance().startTrace(null /* printwriter */); ImeTracing.getInstance().startTrace(null /* printwriter */);
ArrayMap<IBinder, ClientState> clients; ArrayMap<IBinder, ClientState> clients;
synchronized (mMethodMap) { synchronized (mMethodMap) {
@@ -4064,13 +3995,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
} }
} }
});
} }
@BinderThread @BinderThread
@Override @Override
public void stopImeTrace(IVoidResultCallback resultCallback) { public void stopImeTrace() {
CallbackUtils.onResult(resultCallback, () -> {
ImeTracing.getInstance().stopTrace(null /* printwriter */); ImeTracing.getInstance().stopTrace(null /* printwriter */);
ArrayMap<IBinder, ClientState> clients; ArrayMap<IBinder, ClientState> clients;
synchronized (mMethodMap) { synchronized (mMethodMap) {
@@ -4085,7 +4014,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
} }
} }
});
} }
private void dumpDebug(ProtoOutputStream proto, long fieldId) { private void dumpDebug(ProtoOutputStream proto, long fieldId) {
@@ -4888,12 +4816,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
/** /**
* Gets the current subtype of this input method. * Gets the current subtype of this input method.
*
* @param resultCallback to callback the result.
*/ */
@Override @Override
public void getCurrentInputMethodSubtype(IInputMethodSubtypeResultCallback resultCallback) { public InputMethodSubtype getCurrentInputMethodSubtype() {
CallbackUtils.onResult(resultCallback, () -> {
synchronized (mMethodMap) { synchronized (mMethodMap) {
// TODO: Make this work even for non-current users? // TODO: Make this work even for non-current users?
if (!calledFromValidUserLocked()) { if (!calledFromValidUserLocked()) {
@@ -4901,7 +4826,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
return getCurrentInputMethodSubtypeLocked(); return getCurrentInputMethodSubtypeLocked();
} }
});
} }
InputMethodSubtype getCurrentInputMethodSubtypeLocked() { InputMethodSubtype getCurrentInputMethodSubtypeLocked() {

View File

@@ -72,17 +72,9 @@ import android.view.inputmethod.InputMethodSubtype;
import com.android.internal.R; import com.android.internal.R;
import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.inputmethod.CallbackUtils;
import com.android.internal.inputmethod.IBooleanResultCallback;
import com.android.internal.inputmethod.IInputBindResultResultCallback;
import com.android.internal.inputmethod.IInputMethodInfoListResultCallback;
import com.android.internal.inputmethod.IInputMethodSubtypeListResultCallback;
import com.android.internal.inputmethod.IInputMethodSubtypeResultCallback;
import com.android.internal.inputmethod.IIntResultCallback;
import com.android.internal.inputmethod.IMultiClientInputMethod; import com.android.internal.inputmethod.IMultiClientInputMethod;
import com.android.internal.inputmethod.IMultiClientInputMethodPrivilegedOperations; import com.android.internal.inputmethod.IMultiClientInputMethodPrivilegedOperations;
import com.android.internal.inputmethod.IMultiClientInputMethodSession; import com.android.internal.inputmethod.IMultiClientInputMethodSession;
import com.android.internal.inputmethod.IVoidResultCallback;
import com.android.internal.inputmethod.SoftInputShowHideReason; import com.android.internal.inputmethod.SoftInputShowHideReason;
import com.android.internal.inputmethod.StartInputFlags; import com.android.internal.inputmethod.StartInputFlags;
import com.android.internal.inputmethod.StartInputReason; import com.android.internal.inputmethod.StartInputReason;
@@ -112,7 +104,6 @@ import java.lang.annotation.Retention;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.function.Supplier;
/** /**
* Actual implementation of multi-client InputMethodManagerService. * Actual implementation of multi-client InputMethodManagerService.
@@ -1467,49 +1458,41 @@ public final class MultiClientInputMethodManagerService {
@BinderThread @BinderThread
@Override @Override
public void getInputMethodList(@UserIdInt int userId, public List<InputMethodInfo> getInputMethodList(@UserIdInt int userId) {
IInputMethodInfoListResultCallback resultCallback) {
CallbackUtils.onResult(resultCallback, () -> {
if (UserHandle.getCallingUserId() != userId) { if (UserHandle.getCallingUserId() != userId) {
mContext.enforceCallingPermission(INTERACT_ACROSS_USERS_FULL, null); mContext.enforceCallingPermission(INTERACT_ACROSS_USERS_FULL, null);
} }
return mInputMethodInfoMap.getAsList(userId); return mInputMethodInfoMap.getAsList(userId);
});
} }
@BinderThread @BinderThread
@Override @Override
public void getEnabledInputMethodList(@UserIdInt int userId, public List<InputMethodInfo> getEnabledInputMethodList(@UserIdInt int userId) {
IInputMethodInfoListResultCallback resultCallback) {
CallbackUtils.onResult(resultCallback, () -> {
if (UserHandle.getCallingUserId() != userId) { if (UserHandle.getCallingUserId() != userId) {
mContext.enforceCallingPermission(INTERACT_ACROSS_USERS_FULL, null); mContext.enforceCallingPermission(INTERACT_ACROSS_USERS_FULL, null);
} }
return mInputMethodInfoMap.getAsList(userId); return mInputMethodInfoMap.getAsList(userId);
});
} }
@BinderThread @BinderThread
@Override @Override
public void getEnabledInputMethodSubtypeList(String imiId, public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(String imiId,
boolean allowsImplicitlySelectedSubtypes, boolean allowsImplicitlySelectedSubtypes) {
IInputMethodSubtypeListResultCallback resultCallback) {
reportNotSupported(); reportNotSupported();
CallbackUtils.onResult(resultCallback, Collections::emptyList); return Collections.emptyList();
} }
@BinderThread @BinderThread
@Override @Override
public void getLastInputMethodSubtype(IInputMethodSubtypeResultCallback resultCallback) { public InputMethodSubtype getLastInputMethodSubtype() {
reportNotSupported(); reportNotSupported();
CallbackUtils.onResult(resultCallback, () -> null); return null;
} }
@BinderThread @BinderThread
@Override @Override
public void removeImeSurface(IVoidResultCallback resultCallback) { public void removeImeSurface() {
reportNotSupported(); reportNotSupported();
CallbackUtils.onResult(resultCallback, () -> { });
} }
@BinderThread @BinderThread
@@ -1520,11 +1503,10 @@ public final class MultiClientInputMethodManagerService {
@BinderThread @BinderThread
@Override @Override
public void showSoftInput( public boolean showSoftInput(
IInputMethodClient client, IBinder token, int flags, ResultReceiver resultReceiver, IInputMethodClient client, IBinder token, int flags, ResultReceiver resultReceiver,
@SoftInputShowHideReason int reason, IBooleanResultCallback resultCallback) { @SoftInputShowHideReason int reason) {
CallbackUtils.onResult(resultCallback, return showSoftInputInternal(client, token, flags, resultReceiver);
() -> showSoftInputInternal(client, token, flags, resultReceiver));
} }
@BinderThread @BinderThread
@@ -1575,13 +1557,10 @@ public final class MultiClientInputMethodManagerService {
@BinderThread @BinderThread
@Override @Override
public void hideSoftInput( public boolean hideSoftInput(
IInputMethodClient client, IBinder windowToken, int flags, IInputMethodClient client, IBinder windowToken, int flags,
ResultReceiver resultReceiver, @SoftInputShowHideReason int reason, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) {
IBooleanResultCallback resultCallback) { return hideSoftInputInternal(client, windowToken, flags, resultReceiver);
CallbackUtils.onResult(resultCallback,
() -> hideSoftInputInternal(client, windowToken, flags, resultReceiver));
} }
@BinderThread @BinderThread
@@ -1628,34 +1607,7 @@ public final class MultiClientInputMethodManagerService {
@BinderThread @BinderThread
@Override @Override
public void reportWindowGainedFocusAsync( public InputBindResult startInputOrWindowGainedFocus(
boolean nextFocusHasConnection,
@Nullable IInputMethodClient client,
@Nullable IBinder windowToken,
@StartInputFlags int startInputFlags,
@SoftInputModeFlags int softInputMode,
int windowFlags,
int unverifiedTargetSdkVersion) {
final int startInputReason = nextFocusHasConnection
? StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION
: StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION;
try {
startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken,
startInputFlags, softInputMode, windowFlags, null /* editorInfo */,
null /* inputContext */, 0 /* missingMethods */,
unverifiedTargetSdkVersion);
} catch (Throwable t) {
if (client != null) {
try {
client.throwExceptionFromSystem(t.getMessage());
} catch (RemoteException ignore) { }
}
}
}
@BinderThread
@Override
public void startInputOrWindowGainedFocus(
@StartInputReason int startInputReason, @StartInputReason int startInputReason,
@Nullable IInputMethodClient client, @Nullable IInputMethodClient client,
@Nullable IBinder windowToken, @Nullable IBinder windowToken,
@@ -1665,12 +1617,10 @@ public final class MultiClientInputMethodManagerService {
@Nullable EditorInfo editorInfo, @Nullable EditorInfo editorInfo,
@Nullable IInputContext inputContext, @Nullable IInputContext inputContext,
@MissingMethodFlags int missingMethods, @MissingMethodFlags int missingMethods,
int unverifiedTargetSdkVersion, int unverifiedTargetSdkVersion) {
IInputBindResultResultCallback resultCallback) { return startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken,
CallbackUtils.onResult(resultCallback, (Supplier<InputBindResult>) () ->
startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken,
startInputFlags, softInputMode, windowFlags, editorInfo, inputContext, startInputFlags, softInputMode, windowFlags, editorInfo, inputContext,
missingMethods, unverifiedTargetSdkVersion)); missingMethods, unverifiedTargetSdkVersion);
} }
@BinderThread @BinderThread
@@ -1812,54 +1762,49 @@ public final class MultiClientInputMethodManagerService {
@BinderThread @BinderThread
@Override @Override
public void showInputMethodPickerFromClient(IInputMethodClient client, public void showInputMethodPickerFromClient(IInputMethodClient client,
int auxiliarySubtypeMode, IVoidResultCallback resultCallback) { int auxiliarySubtypeMode) {
reportNotSupported(); reportNotSupported();
CallbackUtils.onResult(resultCallback, () -> { });
} }
@BinderThread @BinderThread
@Override @Override
public void showInputMethodPickerFromSystem(IInputMethodClient client, public void showInputMethodPickerFromSystem(IInputMethodClient client,
int auxiliarySubtypeMode, int displayId, IVoidResultCallback resultCallback) { int auxiliarySubtypeMode, int displayId) {
reportNotSupported(); reportNotSupported();
CallbackUtils.onResult(resultCallback, () -> { });
} }
@BinderThread @BinderThread
@Override @Override
public void showInputMethodAndSubtypeEnablerFromClient(IInputMethodClient client, public void showInputMethodAndSubtypeEnablerFromClient(IInputMethodClient client,
String inputMethodId, IVoidResultCallback resultCallback) { String inputMethodId) {
reportNotSupported(); reportNotSupported();
CallbackUtils.onResult(resultCallback, () -> { });
} }
@BinderThread @BinderThread
@Override @Override
public void isInputMethodPickerShownForTest(IBooleanResultCallback resultCallback) { public boolean isInputMethodPickerShownForTest() {
reportNotSupported(); reportNotSupported();
CallbackUtils.onResult(resultCallback, () -> false); return false;
} }
@BinderThread @BinderThread
@Override @Override
public void getCurrentInputMethodSubtype(IInputMethodSubtypeResultCallback resultCallback) { public InputMethodSubtype getCurrentInputMethodSubtype() {
reportNotSupported(); reportNotSupported();
CallbackUtils.onResult(resultCallback, () -> null); return null;
} }
@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
@Override @Override
public void getInputMethodWindowVisibleHeight(IIntResultCallback resultCallback) { public int getInputMethodWindowVisibleHeight() {
reportNotSupported(); reportNotSupported();
CallbackUtils.onResult(resultCallback, () -> 0); return 0;
} }
@BinderThread @BinderThread
@@ -1891,27 +1836,23 @@ public final class MultiClientInputMethodManagerService {
@BinderThread @BinderThread
@Override @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 @BinderThread
@Override @Override
public void isImeTraceEnabled(IBooleanResultCallback resultCallback) { public boolean isImeTraceEnabled() {
CallbackUtils.onResult(resultCallback, () -> false); return false;
} }
@BinderThread @BinderThread
@Override @Override
public void startImeTrace(IVoidResultCallback resultCallback) { public void startImeTrace() {
CallbackUtils.onResult(resultCallback, () -> { });
} }
@BinderThread @BinderThread
@Override @Override
public void stopImeTrace(IVoidResultCallback resultCallback) { public void stopImeTrace() {
CallbackUtils.onResult(resultCallback, () -> { });
} }
} }
} }