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

Commit 0bd8e641 authored by Cosmin Băieș's avatar Cosmin Băieș Committed by Android (Google) Code Review
Browse files

Merge "Modify getShouldShowImeWithHardKeyboard return val" into main

parents b0f18015 2cbdbc42
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1660,13 +1660,14 @@ public class InputMethodService extends AbstractInputMethodService {

    /**
     * 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.
     * through {@link Settings.Secure#SHOW_IME_WITH_HARD_KEYBOARD}, for testing purposes only. If
     * {@link #mSettingsObserver} is {@code null}, this will also return {@code null}.
     *
     * @hide
     */
    @VisibleForTesting
    public final boolean getShouldShowImeWithHardKeyboardForTesting() {
        return mSettingsObserver.shouldShowImeWithHardKeyboard();
    public final Boolean getShouldShowImeWithHardKeyboardForTesting() {
        return mSettingsObserver != null ? mSettingsObserver.shouldShowImeWithHardKeyboard() : null;
    }

    /**
+11 −4
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import android.view.inputmethod.Flags;
import android.view.inputmethod.InputMethodManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
import androidx.test.platform.app.InstrumentationRegistry;
@@ -162,7 +163,8 @@ public class InputMethodServiceTest {
    private TestActivity mActivity;
    private InputMethodServiceWrapper mInputMethodService;
    private boolean mOriginalVerboseImeTrackerLoggingEnabled;
    private boolean mOriginalShowImeWithHardKeyboardEnabled;
    @Nullable
    private Boolean mOriginalShowImeWithHardKeyboardEnabled;

    @Before
    public void setUp() throws Exception {
@@ -212,7 +214,9 @@ public class InputMethodServiceTest {
            setVerboseImeTrackerLogging(false);
        }
        // Change back the original value of show_ime_with_hard_keyboard in Settings.
        if (mOriginalShowImeWithHardKeyboardEnabled != null) {
            setShowImeWithHardKeyboard(mOriginalShowImeWithHardKeyboardEnabled);
        }
        executeShellCommand("ime disable " + mInputMethodId);
    }

@@ -1393,9 +1397,12 @@ public class InputMethodServiceTest {
            return;
        }

        final boolean currentEnabled =
        final Boolean currentEnabled =
                mInputMethodService.getShouldShowImeWithHardKeyboardForTesting();
        if (currentEnabled != enable) {
        if (currentEnabled == null) {
            // IME is being destroyed, reset the system property without checking the set value.
            executeShellCommand(SET_SHOW_IME_WITH_HARD_KEYBOARD_CMD + " " + (enable ? "1" : "0"));
        } else if (currentEnabled != enable) {
            executeShellCommand(SET_SHOW_IME_WITH_HARD_KEYBOARD_CMD + " " + (enable ? "1" : "0"));
            eventually(() -> assertWithMessage("showImeWithHardKeyboard updated")
                    .that(mInputMethodService.getShouldShowImeWithHardKeyboardForTesting())