Introduce IInputMethodManagerInvoker

This helps us consolidate binder-related boilerplate code from

  InputMethodManager.java

to a separate utility class.

This is a mechanical refactoring CL. There should be no observable
behavior change.

Bug: 234882948
Test: presubmit
Change-Id: Ifdb676cf0e37165eb4992f649ac0b694590afc7c
This commit is contained in:
Yohei Yukawa
2022-07-01 11:10:43 -07:00
parent bc1fe9dda4
commit 1e1f765fda
2 changed files with 368 additions and 210 deletions

View File

@@ -0,0 +1,260 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.view.inputmethod;
import android.annotation.AnyThread;
import android.annotation.NonNull;
import android.annotation.UserIdInt;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.window.ImeOnBackInvokedDispatcher;
import com.android.internal.inputmethod.DirectBootAwareness;
import com.android.internal.inputmethod.IInputMethodClient;
import com.android.internal.inputmethod.IRemoteAccessibilityInputConnection;
import com.android.internal.inputmethod.IRemoteInputConnection;
import com.android.internal.inputmethod.InputBindResult;
import com.android.internal.inputmethod.SoftInputShowHideReason;
import com.android.internal.inputmethod.StartInputFlags;
import com.android.internal.inputmethod.StartInputReason;
import com.android.internal.view.IInputMethodManager;
import java.util.List;
/**
* A wrapper class to invoke IPCs defined in {@link IInputMethodManager}.
*/
final class IInputMethodManagerInvoker {
@NonNull
private final IInputMethodManager mTarget;
private IInputMethodManagerInvoker(@NonNull IInputMethodManager target) {
mTarget = target;
}
@AnyThread
@NonNull
static IInputMethodManagerInvoker create(@NonNull IInputMethodManager imm) {
return new IInputMethodManagerInvoker(imm);
}
@AnyThread
void addClient(IInputMethodClient client, IRemoteInputConnection fallbackInputConnection,
int untrustedDisplayId) {
try {
mTarget.addClient(client, fallbackInputConnection, untrustedDisplayId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
List<InputMethodInfo> getInputMethodList(@UserIdInt int userId) {
try {
return mTarget.getInputMethodList(userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
List<InputMethodInfo> getAwareLockedInputMethodList(@UserIdInt int userId,
@DirectBootAwareness int directBootAwareness) {
try {
return mTarget.getAwareLockedInputMethodList(userId, directBootAwareness);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
List<InputMethodInfo> getEnabledInputMethodList(@UserIdInt int userId) {
try {
return mTarget.getEnabledInputMethodList(userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
List<InputMethodSubtype> getEnabledInputMethodSubtypeList(String imiId,
boolean allowsImplicitlySelectedSubtypes) {
try {
return mTarget.getEnabledInputMethodSubtypeList(imiId,
allowsImplicitlySelectedSubtypes);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
InputMethodSubtype getLastInputMethodSubtype() {
try {
return mTarget.getLastInputMethodSubtype();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
boolean showSoftInput(IInputMethodClient client, IBinder windowToken,
int flags, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) {
try {
return mTarget.showSoftInput(client, windowToken, flags, resultReceiver, reason);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
boolean hideSoftInput(IInputMethodClient client, IBinder windowToken,
int flags, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) {
try {
return mTarget.hideSoftInput(client, windowToken, flags, resultReceiver, reason);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
InputBindResult startInputOrWindowGainedFocus(@StartInputReason int startInputReason,
IInputMethodClient client, IBinder windowToken,
@StartInputFlags int startInputFlags,
@android.view.WindowManager.LayoutParams.SoftInputModeFlags int softInputMode,
int windowFlags, EditorInfo editorInfo, IRemoteInputConnection remoteInputConnection,
IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection,
int unverifiedTargetSdkVersion, ImeOnBackInvokedDispatcher imeDispatcher) {
try {
return mTarget.startInputOrWindowGainedFocus(startInputReason, client, windowToken,
startInputFlags, softInputMode, windowFlags, editorInfo, remoteInputConnection,
remoteAccessibilityInputConnection, unverifiedTargetSdkVersion, imeDispatcher);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
void showInputMethodPickerFromClient(IInputMethodClient client, int auxiliarySubtypeMode) {
try {
mTarget.showInputMethodPickerFromClient(client, auxiliarySubtypeMode);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
void showInputMethodPickerFromSystem(IInputMethodClient client, int auxiliarySubtypeMode,
int displayId) {
try {
mTarget.showInputMethodPickerFromSystem(client, auxiliarySubtypeMode, displayId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
void showInputMethodAndSubtypeEnablerFromClient(IInputMethodClient client, String imeId) {
try {
mTarget.showInputMethodAndSubtypeEnablerFromClient(client, imeId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
boolean isInputMethodPickerShownForTest() {
try {
return mTarget.isInputMethodPickerShownForTest();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
InputMethodSubtype getCurrentInputMethodSubtype() {
try {
return mTarget.getCurrentInputMethodSubtype();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
void setAdditionalInputMethodSubtypes(String imeId, InputMethodSubtype[] subtypes) {
try {
mTarget.setAdditionalInputMethodSubtypes(imeId, subtypes);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
int getInputMethodWindowVisibleHeight(IInputMethodClient client) {
try {
return mTarget.getInputMethodWindowVisibleHeight(client);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
void reportVirtualDisplayGeometryAsync(IInputMethodClient client, int childDisplayId,
float[] matrixValues) {
try {
mTarget.reportVirtualDisplayGeometryAsync(client, childDisplayId, matrixValues);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
void reportPerceptibleAsync(IBinder windowToken, boolean perceptible) {
try {
mTarget.reportPerceptibleAsync(windowToken, perceptible);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
void removeImeSurfaceFromWindowAsync(IBinder windowToken) {
try {
mTarget.removeImeSurfaceFromWindowAsync(windowToken);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
void startStylusHandwriting(IInputMethodClient client) {
try {
mTarget.startStylusHandwriting(client);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@AnyThread
boolean isStylusHandwritingAvailableAsUser(@UserIdInt int userId) {
try {
return mTarget.isStylusHandwritingAvailableAsUser(userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
}

View File

@@ -65,7 +65,6 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceManager;
import android.os.ServiceManager.ServiceNotFoundException;
@@ -394,10 +393,17 @@ public final class InputMethodManager {
@EnabledSince(targetSdkVersion = Build.VERSION_CODES.TIRAMISU)
public static final long CLEAR_SHOW_FORCED_FLAG_WHEN_LEAVING = 214016041L; // This is a bug id.
/**
* @deprecated Use {@link #mServiceInvoker} instead.
*/
@Deprecated
@UnsupportedAppUsage
final IInputMethodManager mService;
final Looper mMainLooper;
@NonNull
private final IInputMethodManagerInvoker mServiceInvoker;
// For scheduling work on the main thread. This also serves as our
// global lock.
// Remark on @UnsupportedAppUsage: there were context leaks on old versions
@@ -636,11 +642,7 @@ public final class InputMethodManager {
* @hide
*/
public void reportPerceptible(IBinder windowToken, boolean perceptible) {
try {
mService.reportPerceptibleAsync(windowToken, perceptible);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
mServiceInvoker.reportPerceptibleAsync(windowToken, perceptible);
}
private final class DelegateImpl implements
@@ -737,30 +739,26 @@ public final class InputMethodManager {
synchronized (mH) {
// For some reason we didn't do a startInput + windowFocusGain, so
// we'll just do a window focus gain and call it a day.
try {
View servedView = controller.getServedView();
boolean nextFocusHasConnection = servedView != null && servedView == focusedView
&& hasActiveConnection(focusedView);
if (DEBUG) {
Log.v(TAG, "Reporting focus gain, without startInput"
+ ", nextFocusIsServedView=" + nextFocusHasConnection);
}
final int startInputReason = nextFocusHasConnection
? WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION
: WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION;
// ignore the result
mService.startInputOrWindowGainedFocus(
startInputReason, mClient,
focusedView.getWindowToken(), startInputFlags, softInputMode,
windowFlags,
null,
null, null,
mCurRootView.mContext.getApplicationInfo().targetSdkVersion,
mImeDispatcher);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
View servedView = controller.getServedView();
boolean nextFocusHasConnection = servedView != null && servedView == focusedView
&& hasActiveConnection(focusedView);
if (DEBUG) {
Log.v(TAG, "Reporting focus gain, without startInput"
+ ", nextFocusIsServedView=" + nextFocusHasConnection);
}
final int startInputReason = nextFocusHasConnection
? WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION
: WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION;
// ignore the result
mServiceInvoker.startInputOrWindowGainedFocus(
startInputReason, mClient,
focusedView.getWindowToken(), startInputFlags, softInputMode,
windowFlags,
null,
null, null,
mCurRootView.mContext.getApplicationInfo().targetSdkVersion,
mImeDispatcher);
}
}
@@ -1273,9 +1271,7 @@ public final class InputMethodManager {
// 1) doing so has no effect for A and 2) doing so is sufficient for B.
final long identity = Binder.clearCallingIdentity();
try {
service.addClient(imm.mClient, imm.mFallbackInputConnection, displayId);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
imm.mServiceInvoker.addClient(imm.mClient, imm.mFallbackInputConnection, displayId);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -1313,8 +1309,9 @@ public final class InputMethodManager {
return new InputMethodManager(stubInterface, displayId, looper);
}
private InputMethodManager(IInputMethodManager service, int displayId, Looper looper) {
mService = service;
private InputMethodManager(@NonNull IInputMethodManager service, int displayId, Looper looper) {
mService = service; // For @UnsupportedAppUsage
mServiceInvoker = IInputMethodManagerInvoker.create(service);
mMainLooper = looper;
mH = new H(looper);
mDisplayId = displayId;
@@ -1404,14 +1401,10 @@ public final class InputMethodManager {
* @return {@link List} of {@link InputMethodInfo}.
*/
public List<InputMethodInfo> getInputMethodList() {
try {
// We intentionally do not use UserHandle.getCallingUserId() here because for system
// services InputMethodManagerInternal.getInputMethodListAsUser() should be used
// instead.
return mService.getInputMethodList(UserHandle.myUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
// We intentionally do not use UserHandle.getCallingUserId() here because for system
// services InputMethodManagerInternal.getInputMethodListAsUser() should be used
// instead.
return mServiceInvoker.getInputMethodList(UserHandle.myUserId());
}
/**
@@ -1445,11 +1438,7 @@ public final class InputMethodManager {
}
return false;
}
try {
return mService.isStylusHandwritingAvailableAsUser(userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mServiceInvoker.isStylusHandwritingAvailableAsUser(userId);
}
/**
@@ -1463,11 +1452,7 @@ public final class InputMethodManager {
@RequiresPermission(INTERACT_ACROSS_USERS_FULL)
@NonNull
public List<InputMethodInfo> getInputMethodListAsUser(@UserIdInt int userId) {
try {
return mService.getInputMethodList(userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mServiceInvoker.getInputMethodList(userId);
}
/**
@@ -1483,11 +1468,7 @@ public final class InputMethodManager {
@NonNull
public List<InputMethodInfo> getInputMethodListAsUser(@UserIdInt int userId,
@DirectBootAwareness int directBootAwareness) {
try {
return mService.getAwareLockedInputMethodList(userId, directBootAwareness);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mServiceInvoker.getAwareLockedInputMethodList(userId, directBootAwareness);
}
/**
@@ -1498,14 +1479,10 @@ public final class InputMethodManager {
* @return {@link List} of {@link InputMethodInfo}.
*/
public List<InputMethodInfo> getEnabledInputMethodList() {
try {
// We intentionally do not use UserHandle.getCallingUserId() here because for system
// services InputMethodManagerInternal.getEnabledInputMethodListAsUser() should be used
// instead.
return mService.getEnabledInputMethodList(UserHandle.myUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
// We intentionally do not use UserHandle.getCallingUserId() here because for system
// services InputMethodManagerInternal.getEnabledInputMethodListAsUser() should be used
// instead.
return mServiceInvoker.getEnabledInputMethodList(UserHandle.myUserId());
}
/**
@@ -1517,11 +1494,7 @@ public final class InputMethodManager {
*/
@RequiresPermission(INTERACT_ACROSS_USERS_FULL)
public List<InputMethodInfo> getEnabledInputMethodListAsUser(@UserIdInt int userId) {
try {
return mService.getEnabledInputMethodList(userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mServiceInvoker.getEnabledInputMethodList(userId);
}
/**
@@ -1536,13 +1509,9 @@ public final class InputMethodManager {
*/
public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo imi,
boolean allowsImplicitlySelectedSubtypes) {
try {
return mService.getEnabledInputMethodSubtypeList(
imi == null ? null : imi.getId(),
allowsImplicitlySelectedSubtypes);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mServiceInvoker.getEnabledInputMethodSubtypeList(
imi == null ? null : imi.getId(),
allowsImplicitlySelectedSubtypes);
}
/**
@@ -1905,18 +1874,14 @@ public final class InputMethodManager {
// Makes sure to call ImeInsetsSourceConsumer#onShowRequested on the UI thread.
// TODO(b/229426865): call WindowInsetsController#show instead.
mH.executeOrSendMessage(Message.obtain(mH, MSG_ON_SHOW_REQUESTED));
try {
Log.d(TAG, "showSoftInput() view=" + view + " flags=" + flags + " reason="
+ InputMethodDebug.softInputDisplayReasonToString(reason));
return mService.showSoftInput(
mClient,
view.getWindowToken(),
flags,
resultReceiver,
reason);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
Log.d(TAG, "showSoftInput() view=" + view + " flags=" + flags + " reason="
+ InputMethodDebug.softInputDisplayReasonToString(reason));
return mServiceInvoker.showSoftInput(
mClient,
view.getWindowToken(),
flags,
resultReceiver,
reason);
}
}
@@ -1932,26 +1897,22 @@ public final class InputMethodManager {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768499)
public void showSoftInputUnchecked(int flags, ResultReceiver resultReceiver) {
synchronized (mH) {
try {
Log.w(TAG, "showSoftInputUnchecked() is a hidden method, which will be"
+ " removed soon. If you are using androidx.appcompat.widget.SearchView,"
+ " please update to version 26.0 or newer version.");
if (mCurRootView == null || mCurRootView.getView() == null) {
Log.w(TAG, "No current root view, ignoring showSoftInputUnchecked()");
return;
}
// Makes sure to call ImeInsetsSourceConsumer#onShowRequested on the UI thread.
// TODO(b/229426865): call WindowInsetsController#show instead.
mH.executeOrSendMessage(Message.obtain(mH, MSG_ON_SHOW_REQUESTED));
mService.showSoftInput(
mClient,
mCurRootView.getView().getWindowToken(),
flags,
resultReceiver,
SoftInputShowHideReason.SHOW_SOFT_INPUT);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
Log.w(TAG, "showSoftInputUnchecked() is a hidden method, which will be"
+ " removed soon. If you are using androidx.appcompat.widget.SearchView,"
+ " please update to version 26.0 or newer version.");
if (mCurRootView == null || mCurRootView.getView() == null) {
Log.w(TAG, "No current root view, ignoring showSoftInputUnchecked()");
return;
}
// Makes sure to call ImeInsetsSourceConsumer#onShowRequested on the UI thread.
// TODO(b/229426865): call WindowInsetsController#show instead.
mH.executeOrSendMessage(Message.obtain(mH, MSG_ON_SHOW_REQUESTED));
mServiceInvoker.showSoftInput(
mClient,
mCurRootView.getView().getWindowToken(),
flags,
resultReceiver,
SoftInputShowHideReason.SHOW_SOFT_INPUT);
}
}
@@ -2026,11 +1987,8 @@ public final class InputMethodManager {
return false;
}
try {
return mService.hideSoftInput(mClient, windowToken, flags, resultReceiver, reason);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mServiceInvoker.hideSoftInput(mClient, windowToken, flags, resultReceiver,
reason);
}
}
@@ -2087,13 +2045,9 @@ public final class InputMethodManager {
mDisplayId);
}
try {
mService.startStylusHandwriting(mClient);
// TODO(b/210039666): do we need any extra work for supporting non-native
// UI toolkits?
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
mServiceInvoker.startStylusHandwriting(mClient);
// TODO(b/210039666): do we need any extra work for supporting non-native
// UI toolkits?
}
}
@@ -2408,17 +2362,13 @@ public final class InputMethodManager {
+ ic + " tba=" + tba + " startInputFlags="
+ InputMethodDebug.startInputFlagsToString(startInputFlags));
}
try {
res = mService.startInputOrWindowGainedFocus(
startInputReason, mClient, windowGainingFocus, startInputFlags,
softInputMode, windowFlags, tba, servedInputConnection,
servedInputConnection == null ? null
: servedInputConnection.asIRemoteAccessibilityInputConnection(),
view.getContext().getApplicationInfo().targetSdkVersion,
mImeDispatcher);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
res = mServiceInvoker.startInputOrWindowGainedFocus(
startInputReason, mClient, windowGainingFocus, startInputFlags,
softInputMode, windowFlags, tba, servedInputConnection,
servedInputConnection == null ? null
: servedInputConnection.asIRemoteAccessibilityInputConnection(),
view.getContext().getApplicationInfo().targetSdkVersion,
mImeDispatcher);
if (DEBUG) Log.v(TAG, "Starting input: Bind result=" + res);
if (res == null) {
Log.wtf(TAG, "startInputOrWindowGainedFocus must not return"
@@ -2545,16 +2495,12 @@ public final class InputMethodManager {
Log.w(TAG, "No current root view, ignoring closeCurrentInput()");
return;
}
try {
mService.hideSoftInput(
mClient,
mCurRootView.getView().getWindowToken(),
HIDE_NOT_ALWAYS,
null,
SoftInputShowHideReason.HIDE_SOFT_INPUT);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
mServiceInvoker.hideSoftInput(
mClient,
mCurRootView.getView().getWindowToken(),
HIDE_NOT_ALWAYS,
null,
SoftInputShowHideReason.HIDE_SOFT_INPUT);
}
}
@@ -2625,13 +2571,9 @@ public final class InputMethodManager {
synchronized (mH) {
if (isImeSessionAvailableLocked() && mCurRootView != null
&& mCurRootView.getWindowToken() == windowToken) {
try {
mService.hideSoftInput(mClient, windowToken, 0 /* flags */,
null /* resultReceiver */,
SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
mServiceInvoker.hideSoftInput(mClient, windowToken, 0 /* flags */,
null /* resultReceiver */,
SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API);
}
}
}
@@ -2643,11 +2585,7 @@ public final class InputMethodManager {
*/
public void removeImeSurface(IBinder windowToken) {
synchronized (mH) {
try {
mService.removeImeSurfaceFromWindowAsync(windowToken);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
mServiceInvoker.removeImeSurfaceFromWindowAsync(windowToken);
}
}
@@ -3248,19 +3186,11 @@ public final class InputMethodManager {
final int mode = showAuxiliarySubtypes
? SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES
: SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES;
try {
mService.showInputMethodPickerFromSystem(mClient, mode, displayId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
mServiceInvoker.showInputMethodPickerFromSystem(mClient, mode, displayId);
}
private void showInputMethodPickerLocked() {
try {
mService.showInputMethodPickerFromClient(mClient, SHOW_IM_PICKER_MODE_AUTO);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
mServiceInvoker.showInputMethodPickerFromClient(mClient, SHOW_IM_PICKER_MODE_AUTO);
}
/**
@@ -3276,11 +3206,7 @@ public final class InputMethodManager {
*/
@TestApi
public boolean isInputMethodPickerShown() {
try {
return mService.isInputMethodPickerShownForTest();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mServiceInvoker.isInputMethodPickerShownForTest();
}
/**
@@ -3290,11 +3216,7 @@ public final class InputMethodManager {
* subtypes of all input methods will be shown.
*/
public void showInputMethodAndSubtypeEnabler(String imiId) {
try {
mService.showInputMethodAndSubtypeEnablerFromClient(mClient, imiId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
mServiceInvoker.showInputMethodAndSubtypeEnablerFromClient(mClient, imiId);
}
/**
@@ -3303,11 +3225,7 @@ public final class InputMethodManager {
* have any input method subtype.
*/
public InputMethodSubtype getCurrentInputMethodSubtype() {
try {
return mService.getCurrentInputMethodSubtype();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mServiceInvoker.getCurrentInputMethodSubtype();
}
/**
@@ -3351,12 +3269,8 @@ public final class InputMethodManager {
// Null or invalid IME ID format.
return false;
}
final List<InputMethodSubtype> enabledSubtypes;
try {
enabledSubtypes = mService.getEnabledInputMethodSubtypeList(imeId, true);
} catch (RemoteException e) {
return false;
}
final List<InputMethodSubtype> enabledSubtypes =
mServiceInvoker.getEnabledInputMethodSubtypeList(imeId, true);
final int numSubtypes = enabledSubtypes.size();
for (int i = 0; i < numSubtypes; ++i) {
final InputMethodSubtype enabledSubtype = enabledSubtypes.get(i);
@@ -3421,11 +3335,7 @@ public final class InputMethodManager {
@UnsupportedAppUsage(trackingBug = 204906124, maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
publicAlternatives = "Use {@link android.view.WindowInsets} instead")
public int getInputMethodWindowVisibleHeight() {
try {
return mService.getInputMethodWindowVisibleHeight(mClient);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mServiceInvoker.getInputMethodWindowVisibleHeight(mClient);
}
/**
@@ -3438,18 +3348,14 @@ public final class InputMethodManager {
* @hide
*/
public void reportVirtualDisplayGeometry(int childDisplayId, @Nullable Matrix matrix) {
try {
final float[] matrixValues;
if (matrix == null) {
matrixValues = null;
} else {
matrixValues = new float[9];
matrix.getValues(matrixValues);
}
mService.reportVirtualDisplayGeometryAsync(mClient, childDisplayId, matrixValues);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
final float[] matrixValues;
if (matrix == null) {
matrixValues = null;
} else {
matrixValues = new float[9];
matrix.getValues(matrixValues);
}
mServiceInvoker.reportVirtualDisplayGeometryAsync(mClient, childDisplayId, matrixValues);
}
/**
@@ -3553,19 +3459,11 @@ public final class InputMethodManager {
*/
@Deprecated
public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) {
try {
mService.setAdditionalInputMethodSubtypes(imiId, subtypes);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
mServiceInvoker.setAdditionalInputMethodSubtypes(imiId, subtypes);
}
public InputMethodSubtype getLastInputMethodSubtype() {
try {
return mService.getLastInputMethodSubtype();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mServiceInvoker.getLastInputMethodSubtype();
}
/**