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

Commit 069aad30 authored by Antonio Kantek's avatar Antonio Kantek
Browse files

Move up the check if the editor belongs to the current user

This CL is a preparation for FocusController. It moves up the
editor info package verification. This refactoring is meant to
make the startInput logic move to FocusController easier.

This is just a refactoring CL, no behavior change is expected.

Bug: 314149476
Test: atest CtsInputMethodTestCases InputMethodSystemServerTests
Change-Id: If4eb15e2fce947aafd9f40b0f3f7695e742b306c
parent 2526d8cb
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -2385,12 +2385,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            @StartInputReason int startInputReason,
            int unverifiedTargetSdkVersion,
            @NonNull ImeOnBackInvokedDispatcher imeDispatcher) {
        if (!InputMethodUtils.checkIfPackageBelongsToUid(mPackageManagerInternal, cs.mUid,
                editorInfo.packageName)) {
            Slog.e(TAG, "Rejecting this client as it reported an invalid package name."
                    + " uid=" + cs.mUid + " package=" + editorInfo.packageName);
            return InputBindResult.INVALID_PACKAGE_NAME;
        }

        // Compute the final shown display ID with validated cs.selfReportedDisplayId for this
        // session & other conditions.
@@ -3763,6 +3757,13 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                        return InputBindResult.INVALID_USER;
                    }

                    if (editorInfo != null && !InputMethodUtils.checkIfPackageBelongsToUid(
                            mPackageManagerInternal, cs.mUid, editorInfo.packageName)) {
                        Slog.e(TAG, "Rejecting this client as it reported an invalid package name."
                                + " uid=" + cs.mUid + " package=" + editorInfo.packageName);
                        return InputBindResult.INVALID_PACKAGE_NAME;
                    }

                    result = startInputOrWindowGainedFocusInternalLocked(startInputReason,
                            client, windowToken, startInputFlags, softInputMode, windowFlags,
                            editorInfo, inputConnection, remoteAccessibilityInputConnection,