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

Commit 8aff2d23 authored by Antonio Kantek's avatar Antonio Kantek
Browse files

Move the system readiness verification up

Move the system readiness verification from private
`startInputUncheckedLocked` up to public
`startInputOrWindowGainedFocus`.

This CL is a preparation for FocusController. It moves a necessary
verification up, making it easier to extract startInput logic into
FocusController later.

Note: this is just a refactoring CL, no behavior change is expected.

Bug: 314150112
Test: atest CtsInputMethodTestCases FrameworksServicesTests
Change-Id: If6202f0259b3fe0478ae127fde343423975a6397
parent 060ab1e5
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -2407,16 +2407,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            @StartInputReason int startInputReason,
            int unverifiedTargetSdkVersion,
            @NonNull ImeOnBackInvokedDispatcher imeDispatcher) {
        String selectedMethodId = getSelectedMethodIdLocked();

        if (!mSystemReady) {
            // If the system is not yet ready, we shouldn't be running third
            // party code.
            return new InputBindResult(
                    InputBindResult.ResultCode.ERROR_SYSTEM_NOT_READY,
                    null, null, null, selectedMethodId, getSequenceNumberLocked(), false);
        }

        if (!InputMethodUtils.checkIfPackageBelongsToUid(mPackageManagerInternal, cs.mUid,
                editorInfo.packageName)) {
            Slog.e(TAG, "Rejecting this client as it reported an invalid package name."
@@ -2437,6 +2427,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub

        // Potentially override the selected input method if the new display belongs to a virtual
        // device with a custom IME.
        String selectedMethodId = getSelectedMethodIdLocked();
        if (oldDisplayIdToShowIme != mDisplayIdToShowIme) {
            final String deviceMethodId = computeCurrentDeviceMethodIdLocked(selectedMethodId);
            if (deviceMethodId == null) {
@@ -3681,7 +3672,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                        + "specified for cross-user startInputOrWindowGainedFocus()");
            }
        }

        if (windowToken == null) {
            Slog.e(TAG, "windowToken cannot be null.");
            return InputBindResult.NULL;
@@ -3693,6 +3683,14 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                    "InputMethodManagerService#startInputOrWindowGainedFocus");
            final InputBindResult result;
            synchronized (ImfLock.class) {
                if (!mSystemReady) {
                    // If the system is not yet ready, we shouldn't be running third arty code.
                    return new InputBindResult(
                            InputBindResult.ResultCode.ERROR_SYSTEM_NOT_READY,
                            null /* method */, null /* accessibilitySessions */, null /* channel */,
                            getSelectedMethodIdLocked(), getSequenceNumberLocked(),
                            false /* isInputMethodSuppressingSpellChecker */);
                }
                final long ident = Binder.clearCallingIdentity();
                try {
                    result = startInputOrWindowGainedFocusInternalLocked(startInputReason,