Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37051aef authored by Wilson Wu's avatar Wilson Wu
Browse files

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
parent 8215d0e1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2312,7 +2312,7 @@ public class InputMethodService extends AbstractInputMethodService {
        if (setVisible) {
            cancelImeSurfaceRemoval();
        }
        mPrivOps.applyImeVisibility(setVisible
        mPrivOps.applyImeVisibilityAsync(setVisible
                ? mCurShowInputToken : mCurHideInputToken, setVisible);
    }

+1 −2
Original line number Diff line number Diff line
@@ -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);
}
+3 −6
Original line number Diff line number Diff line
@@ -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();
        }
+2 −4
Original line number Diff line number Diff line
@@ -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);
        }
    }
}