diff --git a/core/java/android/view/inputmethod/IInputMethodManagerInvoker.java b/core/java/android/view/inputmethod/IInputMethodManagerInvoker.java new file mode 100644 index 0000000000000..4b472ed183258 --- /dev/null +++ b/core/java/android/view/inputmethod/IInputMethodManagerInvoker.java @@ -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 getInputMethodList(@UserIdInt int userId) { + try { + return mTarget.getInputMethodList(userId); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + @AnyThread + List getAwareLockedInputMethodList(@UserIdInt int userId, + @DirectBootAwareness int directBootAwareness) { + try { + return mTarget.getAwareLockedInputMethodList(userId, directBootAwareness); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + @AnyThread + List getEnabledInputMethodList(@UserIdInt int userId) { + try { + return mTarget.getEnabledInputMethodList(userId); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + @AnyThread + List 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(); + } + } +} diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index ed2b28201f83e..59d3314257edf 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -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; @@ -395,10 +394,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 @@ -637,11 +643,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 @@ -738,30 +740,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); } } @@ -1274,9 +1272,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); } @@ -1314,8 +1310,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; @@ -1405,14 +1402,10 @@ public final class InputMethodManager { * @return {@link List} of {@link InputMethodInfo}. */ public List 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()); } /** @@ -1446,11 +1439,7 @@ public final class InputMethodManager { } return false; } - try { - return mService.isStylusHandwritingAvailableAsUser(userId); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } + return mServiceInvoker.isStylusHandwritingAvailableAsUser(userId); } /** @@ -1464,11 +1453,7 @@ public final class InputMethodManager { @RequiresPermission(INTERACT_ACROSS_USERS_FULL) @NonNull public List getInputMethodListAsUser(@UserIdInt int userId) { - try { - return mService.getInputMethodList(userId); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } + return mServiceInvoker.getInputMethodList(userId); } /** @@ -1484,11 +1469,7 @@ public final class InputMethodManager { @NonNull public List getInputMethodListAsUser(@UserIdInt int userId, @DirectBootAwareness int directBootAwareness) { - try { - return mService.getAwareLockedInputMethodList(userId, directBootAwareness); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } + return mServiceInvoker.getAwareLockedInputMethodList(userId, directBootAwareness); } /** @@ -1499,14 +1480,10 @@ public final class InputMethodManager { * @return {@link List} of {@link InputMethodInfo}. */ public List 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()); } /** @@ -1518,11 +1495,7 @@ public final class InputMethodManager { */ @RequiresPermission(INTERACT_ACROSS_USERS_FULL) public List getEnabledInputMethodListAsUser(@UserIdInt int userId) { - try { - return mService.getEnabledInputMethodList(userId); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } + return mServiceInvoker.getEnabledInputMethodList(userId); } /** @@ -1537,13 +1510,9 @@ public final class InputMethodManager { */ public List 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); } /** @@ -1906,18 +1875,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); } } @@ -1933,26 +1898,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); } } @@ -2027,11 +1988,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); } } @@ -2088,13 +2046,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? } } @@ -2417,17 +2371,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" @@ -2554,16 +2504,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); } } @@ -2634,13 +2580,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); } } } @@ -2652,11 +2594,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); } } @@ -3257,19 +3195,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); } /** @@ -3285,11 +3215,7 @@ public final class InputMethodManager { */ @TestApi public boolean isInputMethodPickerShown() { - try { - return mService.isInputMethodPickerShownForTest(); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } + return mServiceInvoker.isInputMethodPickerShownForTest(); } /** @@ -3299,11 +3225,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); } /** @@ -3312,11 +3234,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(); } /** @@ -3360,12 +3278,8 @@ public final class InputMethodManager { // Null or invalid IME ID format. return false; } - final List enabledSubtypes; - try { - enabledSubtypes = mService.getEnabledInputMethodSubtypeList(imeId, true); - } catch (RemoteException e) { - return false; - } + final List enabledSubtypes = + mServiceInvoker.getEnabledInputMethodSubtypeList(imeId, true); final int numSubtypes = enabledSubtypes.size(); for (int i = 0; i < numSubtypes; ++i) { final InputMethodSubtype enabledSubtype = enabledSubtypes.get(i); @@ -3430,11 +3344,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); } /** @@ -3447,18 +3357,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); } /** @@ -3562,19 +3468,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(); } /**