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

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

Restore initial config and await secure setting

Some tests in InputMethodServiceTest manually modify the IME's
configuration to setup various hardware keyboard scenarios. However,
the configuration is not reset at the end of the test, and the values
persist across test runs in this class. This wraps the tests in
try-finally blocks and restore the initial config.

Aditionally, some tests rely on setting the show_ime_with_hard_keyboard
value, but don't wait for this to be applied. This adds a check that
eventually the new value takes effect. To make this more efficient, a
test API is added to IME to directly read the value of the secure
setting as cached by the IME.

Flag: EXEMPT testfix
Bug: 394328311
Test: atest InputMethodServiceTest
Change-Id: Id97df01a5603ed8ed1201da4d7ecde6ffb44650a
parent eeccf514
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -1725,9 +1725,21 @@ public class InputMethodService extends AbstractInputMethodService {
            return "SettingsObserver{mShowImeWithHardKeyboard=" + mShowImeWithHardKeyboard  + "}";
        }
    }

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private SettingsObserver mSettingsObserver;

    /**
     * Checks whether the IME should be shown when a hardware keyboard is connected, as configured
     * through {@link Settings.Secure#SHOW_IME_WITH_HARD_KEYBOARD}, for testing purposes only.
     *
     * @hide
     */
    @VisibleForTesting
    public final boolean getShouldShowImeWithHardKeyboardForTesting() {
        return mSettingsObserver.shouldShowImeWithHardKeyboard();
    }

    /**
     * You can call this to customize the theme used by your IME's window.
     * This theme should typically be one that derives from
@@ -4454,7 +4466,7 @@ public class InputMethodService extends AbstractInputMethodService {
     *
     * @hide
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    @VisibleForTesting
    public final boolean isImeNavigationBarShownForTesting() {
        return mNavigationBarController.isShown();
    }
+216 −174

File changed.

Preview size limit exceeded, changes collapsed.