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

Commit 93421018 authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Add shouldShowImeSwitcherButton test API

This adds a test API to check whether the IME Switcher button should be
shown when the IME is shown. This will be used in the tests for the
onCustomImeSwitcherButtonRequestedVisible API, added in [1], to check
whether the button is visible at the start of the test.

This check is done as an assumption rather than an assertion, to relax
the restriction against OEM changes in computing the IME Switcher button
requested visibility.

    [1]: I87e87cd30e45f3eb73b009a13cffb1676e067590

Flag: EXEMPT test API
Bug: 384484869
Test: atest InputMethodServiceTest#testOnCustomImeSwitcherButtonRequestedVisible_gestureNav
  InputMethodServiceTest#testOnCustomImeSwitcherButtonRequestedVisible_threeButtonNav
Change-Id: I395715cf642dc0b4534f243c58b2e83977195d86
parent 9856bf30
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4135,6 +4135,7 @@ package android.view.inputmethod {
    method @RequiresPermission(android.Manifest.permission.TEST_INPUT_METHOD) public boolean isInputMethodPickerShown();
    method @NonNull @RequiresPermission(value=android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional=true) public boolean isStylusHandwritingAvailableAsUser(@NonNull android.os.UserHandle);
    method @RequiresPermission(android.Manifest.permission.TEST_INPUT_METHOD) public void setStylusWindowIdleTimeoutForTest(long);
    method @RequiresPermission(android.Manifest.permission.TEST_INPUT_METHOD) public boolean shouldShowImeSwitcherButtonForTest();
    field public static final long CLEAR_SHOW_FORCED_FLAG_WHEN_LEAVING = 214016041L; // 0xcc1a029L
  }

+14 −0
Original line number Diff line number Diff line
@@ -489,6 +489,20 @@ final class IInputMethodManagerGlobalInvoker {
        }
    }

    @AnyThread
    @RequiresPermission(Manifest.permission.TEST_INPUT_METHOD)
    static boolean shouldShowImeSwitcherButtonForTest() {
        final IInputMethodManager service = getService();
        if (service == null) {
            return false;
        }
        try {
            return service.shouldShowImeSwitcherButtonForTest();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    @AnyThread
    @Nullable
    @RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
+13 −0
Original line number Diff line number Diff line
@@ -4536,6 +4536,19 @@ public final class InputMethodManager {
        IInputMethodManagerGlobalInvoker.onImeSwitchButtonClickFromSystem(displayId);
    }

    /**
     * A test API for CTS to check whether the IME Switcher button should be shown when the IME
     * is shown.
     *
     * @hide
     */
    @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
    @TestApi
    @RequiresPermission(Manifest.permission.TEST_INPUT_METHOD)
    public boolean shouldShowImeSwitcherButtonForTest() {
        return IInputMethodManagerGlobalInvoker.shouldShowImeSwitcherButtonForTest();
    }

    /**
     * A test API for CTS to check whether there are any pending IME visibility requests.
     *
+9 −0
Original line number Diff line number Diff line
@@ -149,6 +149,15 @@ interface IInputMethodManager {
    + "permission.WRITE_SECURE_SETTINGS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})")
    oneway void onImeSwitchButtonClickFromSystem(int displayId);

    /**
     * A test API for CTS to check whether the IME Switcher button should be shown when the IME
     * is shown.
     */
    @EnforcePermission("TEST_INPUT_METHOD")
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
            + "android.Manifest.permission.TEST_INPUT_METHOD)")
    boolean shouldShowImeSwitcherButtonForTest();

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
            + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
    @nullable InputMethodSubtype getCurrentInputMethodSubtype(int userId);
+11 −0
Original line number Diff line number Diff line
@@ -159,6 +159,9 @@ final class IInputMethodManagerImpl extends IInputMethodManager.Stub {
                Manifest.permission.WRITE_SECURE_SETTINGS})
        void onImeSwitchButtonClickFromSystem(int displayId);

        @PermissionVerified(Manifest.permission.TEST_INPUT_METHOD)
        boolean shouldShowImeSwitcherButtonForTest();

        InputMethodSubtype getCurrentInputMethodSubtype(@UserIdInt int userId);

        void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes,
@@ -380,6 +383,14 @@ final class IInputMethodManagerImpl extends IInputMethodManager.Stub {
        mCallback.onImeSwitchButtonClickFromSystem(displayId);
    }

    @EnforcePermission(Manifest.permission.TEST_INPUT_METHOD)
    @Override
    public boolean shouldShowImeSwitcherButtonForTest() {
        super.shouldShowImeSwitcherButtonForTest_enforcePermission();

        return mCallback.shouldShowImeSwitcherButtonForTest();
    }

    @Override
    public InputMethodSubtype getCurrentInputMethodSubtype(@UserIdInt int userId) {
        return mCallback.getCurrentInputMethodSubtype(userId);
Loading