Make IInputMethodPrivilegedOperations to async (6/N)

-. Remove VoidResultCallback of applyImeVisibility.
   and let it be truly asynchronous.
-. Rename this method to applyImeVisibilityAsync.

Bug: 183587528
Test: atest CtsInputMethodTestCases
Change-Id: Ica564c526223d32641a2485c0c0f3490fe4bfd39
This commit is contained in:
Wilson Wu
2021-04-28 16:28:26 +08:00
parent 8215d0e109
commit 37051aef38
4 changed files with 7 additions and 13 deletions

View File

@@ -2312,7 +2312,7 @@ public class InputMethodService extends AbstractInputMethodService {
if (setVisible) {
cancelImeSurfaceRemoval();
}
mPrivOps.applyImeVisibility(setVisible
mPrivOps.applyImeVisibilityAsync(setVisible
? mCurShowInputToken : mCurHideInputToken, setVisible);
}

View File

@@ -44,6 +44,5 @@ oneway interface IInputMethodPrivilegedOperations {
void switchToNextInputMethod(boolean onlyCurrentIme, in IBooleanResultCallback resultCallback);
void shouldOfferSwitchingToNextInputMethod(in IBooleanResultCallback resultCallback);
void notifyUserActionAsync();
void applyImeVisibility(IBinder showOrHideInputToken, boolean setVisible,
in IVoidResultCallback resultCallback);
void applyImeVisibilityAsync(IBinder showOrHideInputToken, boolean setVisible);
}

View File

@@ -375,8 +375,7 @@ public final class InputMethodPrivilegedOperations {
}
/**
* Calls {@link IInputMethodPrivilegedOperations#applyImeVisibility(IBinder, boolean,
* IVoidResultCallback)}.
* Calls {@link IInputMethodPrivilegedOperations#applyImeVisibilityAsync(IBinder, boolean)}.
*
* @param showOrHideInputToken placeholder token that maps to window requesting
* {@link android.view.inputmethod.InputMethodManager#showSoftInput(View, int)} or
@@ -385,15 +384,13 @@ public final class InputMethodPrivilegedOperations {
* @param setVisible {@code true} to set IME visible, else hidden.
*/
@AnyThread
public void applyImeVisibility(IBinder showOrHideInputToken, boolean setVisible) {
public void applyImeVisibilityAsync(IBinder showOrHideInputToken, boolean setVisible) {
final IInputMethodPrivilegedOperations ops = mOps.getAndWarnIfNull();
if (ops == null) {
return;
}
try {
final Completable.Void value = Completable.createVoid();
ops.applyImeVisibility(showOrHideInputToken, setVisible, ResultCallbacks.of(value));
Completable.getResult(value);
ops.applyImeVisibilityAsync(showOrHideInputToken, setVisible);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}

View File

@@ -6123,10 +6123,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
@BinderThread
@Override
public void applyImeVisibility(IBinder windowToken, boolean setVisible,
IVoidResultCallback resultCallback) {
CallbackUtils.onResult(resultCallback,
() -> mImms.applyImeVisibility(mToken, windowToken, setVisible));
public void applyImeVisibilityAsync(IBinder windowToken, boolean setVisible) {
mImms.applyImeVisibility(mToken, windowToken, setVisible);
}
}
}