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

Commit c84b3e15 authored by Wilson Wu's avatar Wilson Wu
Browse files

Make IInputMethodPrivilegedOperations to async (3/N)

-. Remove VoidResultCallback of reportFullscreenMode
   and let it be truly asynchronous.
-. Rename this method to reportFullscreenModeAsync.

Bug: 183587528
Test: atest CtsInputMethodTestCases
Test: Manually verified as follows.
   1. Build flame-userdebug and flash it.
   2. Make sure that the screen rotation is enabled.
   3. make -j SoftKeyboard
   4. adb install -r $OUT/system/app/SoftKeyboard/SoftKeyboard.apk
   5. adb shell ime enable com.example.android.softkeyboard/.SoftKeyboard
   6. adb shell ime set com.example.android.softkeyboard/.SoftKeyboard
   7. make -j EditTextVariations
   8. adb install -r $ANDROID_TARGET_OUT_TESTCASES/EditTextVariations/arm64/EditTextVariations.apk
   9. adb shell am start -n com.android.inputmethod.tools.edittextvariations/.EditTextVariations
  10. Make sure that the device is in the landscape mode,
      and the SoftKeyboard sample IME is not yet shown.
  11. adb shell dumpsys input_method | grep mFullscreenMode
      Then make sure the mFullscreenMode is "false"
  12. Tap the first edit field then make sure that SoftKeyboard
      sample IME becomes visible in the fullscreen mode.
  13. adb shell dumpsys input_method | grep mFullscreenMode
      Then make sure the mFullscreenMode is "true"
  14. Tap the down button on the navbar to hide the SoftKeyboard
      sample IME.
  15. adb shell dumpsys input_method | grep mFullscreenMode
      Then make sure the mFullscreenMode is "false"

Change-Id: I92e8b0d420be3dd16cc4f3ba29e0bde5f12ab2ce
parent 60f71b5b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1628,7 +1628,7 @@ public class InputMethodService extends AbstractInputMethodService {
    }

    private void reportFullscreenMode() {
        mPrivOps.reportFullscreenMode(mIsFullscreen);
        mPrivOps.reportFullscreenModeAsync(mIsFullscreen);
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ oneway interface IInputMethodPrivilegedOperations {
    void reportStartInput(in IBinder startInputToken, in IVoidResultCallback resultCallback);
    void createInputContentUriToken(in Uri contentUri, in String packageName,
            in IIInputContentUriTokenResultCallback resultCallback);
    void reportFullscreenMode(boolean fullscreen, in IVoidResultCallback resultCallback);
    void reportFullscreenModeAsync(boolean fullscreen);
    void setInputMethod(String id, in IVoidResultCallback resultCallback);
    void setInputMethodAndSubtype(String id, in InputMethodSubtype subtype,
            in IVoidResultCallback resultCallback);
+3 −6
Original line number Diff line number Diff line
@@ -172,21 +172,18 @@ public final class InputMethodPrivilegedOperations {
    }

    /**
     * Calls {@link IInputMethodPrivilegedOperations#reportFullscreenMode(boolean,
     * IVoidResultCallback)}.
     * Calls {@link IInputMethodPrivilegedOperations#reportFullscreenModeAsync(boolean)}.
     *
     * @param fullscreen {@code true} if the IME enters full screen mode
     */
    @AnyThread
    public void reportFullscreenMode(boolean fullscreen) {
    public void reportFullscreenModeAsync(boolean fullscreen) {
        final IInputMethodPrivilegedOperations ops = mOps.getAndWarnIfNull();
        if (ops == null) {
            return;
        }
        try {
            final Completable.Void value = Completable.createVoid();
            ops.reportFullscreenMode(fullscreen, ResultCallbacks.of(value));
            Completable.getResult(value);
            ops.reportFullscreenModeAsync(fullscreen);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+2 −3
Original line number Diff line number Diff line
@@ -6007,9 +6007,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

        @BinderThread
        @Override
        public void reportFullscreenMode(boolean fullscreen, IVoidResultCallback resultCallback) {
            CallbackUtils.onResult(resultCallback,
                    () -> mImms.reportFullscreenMode(mToken, fullscreen));
        public void reportFullscreenModeAsync(boolean fullscreen) {
            mImms.reportFullscreenMode(mToken, fullscreen);
        }

        @BinderThread