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

Commit 530a44f4 authored by Daniel Norman's avatar Daniel Norman Committed by Android (Google) Code Review
Browse files

Merge "Fixes canEnableDisableInputMethod to use correct user handle." into main

parents badee29d e6d6411e
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -405,10 +405,9 @@ public class AccessibilitySecurityPolicy {
     * @throws SecurityException if the input method is not in the same package as the service.
     */
    @AccessibilityService.SoftKeyboardController.EnableImeResult
    int canEnableDisableInputMethod(String imeId, AbstractAccessibilityServiceConnection service)
            throws SecurityException {
    int canEnableDisableInputMethod(String imeId, AbstractAccessibilityServiceConnection service,
            int callingUserId) throws SecurityException {
        final String servicePackageName = service.getComponentName().getPackageName();
        final int callingUserId = UserHandle.getCallingUserId();

        InputMethodInfo inputMethodInfo = null;
        List<InputMethodInfo> inputMethodInfoList =
+1 −3
Original line number Diff line number Diff line
@@ -410,9 +410,7 @@ class AccessibilityServiceConnection extends AbstractAccessibilityServiceConnect
        final @AccessibilityService.SoftKeyboardController.EnableImeResult int checkResult;
        final long identity = Binder.clearCallingIdentity();
        try {
            synchronized (mLock) {
                checkResult = mSecurityPolicy.canEnableDisableInputMethod(imeId, this);
            }
            checkResult = mSecurityPolicy.canEnableDisableInputMethod(imeId, this, callingUserId);
            if (checkResult != ENABLE_IME_SUCCESS) {
                return checkResult;
            }
+10 −0
Original line number Diff line number Diff line
@@ -448,4 +448,14 @@ public class AccessibilityServiceConnectionTest {
        mConnection.binderDied();
        assertThat(mConnection.getServiceInfo().flags & flag).isEqualTo(0);
    }

    @Test
    public void setInputMethodEnabled_checksAccessWithProvidedImeIdAndUserId() {
        final String imeId = "test_ime_id";
        final int callingUserId = UserHandle.getCallingUserId();
        mConnection.setInputMethodEnabled(imeId, true);

        verify(mMockSecurityPolicy).canEnableDisableInputMethod(
                eq(imeId), any(), eq(callingUserId));
    }
}