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

Commit 724c5bb8 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Allow the active IME to see the target app package

This CL ensures that API calls from IMEs will not be blocked by the
package visibility restriction introduced in Android 11, as long as
the IME is or was interacting with the target app.

This types of special allow rules are called "implicit visibility"
internally, because explicit <queries> elements in
ApplicationManifest.xml aren't required in such cases, and this CL
adds one more case to this "implicit visibility" scenario so that IMEs
can have "implicit visibility" to the target apps.

Fix: 152909969
Test: atest CtsInputMethodTestCases:PackageVisibilityTest
Test: atest CtsInputMethodTestCases:PackageVisibilityTest --instant
Change-Id: I28ccdd7409d167cb6d277135e9ebaed5b2422d79
parent 8a9a2f80
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2352,6 +2352,16 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        mImeTargetWindowMap.put(startInputToken, mCurFocusedWindow);
        mStartInputHistory.addEntry(info);

        // Seems that PackageManagerInternal#grantImplicitAccess() doesn't handle cross-user
        // implicit visibility (e.g. IME[user=10] -> App[user=0]) thus we do this only for the
        // same-user scenarios.
        // That said ignoring cross-user scenario will never affect IMEs that do not have
        // INTERACT_ACROSS_USERS(_FULL) permissions, which is actually almost always the case.
        if (mSettings.getCurrentUserId() == UserHandle.getUserId(mCurClient.uid)) {
            mPackageManagerInternal.grantImplicitAccess(mSettings.getCurrentUserId(),
                    null /* intent */, UserHandle.getAppId(mCurMethodUid), mCurClient.uid, true);
        }

        final SessionState session = mCurClient.curSession;
        executeOrSendMessage(session.method, mCaller.obtainMessageIIOOOO(
                MSG_START_INPUT, mCurInputContextMissingMethods, initial ? 0 : 1 /* restarting */,