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

Commit df401875 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Reject pseudo userId in IMM#get*InputMethodList()

As a preparation before removing the dependency on ImfLock.class from
IME query APIs defined in InputMethodManager, this CL aims to clarify
that pseudo userIds (e.g. UserHandle#USER_ALL) have never been
supported in these APIs.

Note that this refinement should be invisible to app developers, who
cannot directly pass the userId to the underlying IPC methods such as

  IInputMethodManager#getCurrentInputMethodInfoAsUser().

Bug: 354323416
Test: presubmit
Flag: EXEMPT refactor
Change-Id: I93e6a6ba80cfe393b2d39ea03a5d7f97c091aed3
parent ebb7fb76
Loading
Loading
Loading
Loading
+16 −25
Original line number Diff line number Diff line
@@ -1483,17 +1483,15 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            mContext.enforceCallingOrSelfPermission(
                    Manifest.permission.INTERACT_ACROSS_USERS_FULL, null);
        }
        synchronized (ImfLock.class) {
            final int[] resolvedUserIds = InputMethodUtils.resolveUserId(userId,
                    mCurrentUserId, null);
            if (resolvedUserIds.length != 1) {
        if (!mUserManagerInternal.exists(userId)) {
            return InputMethodInfoSafeList.empty();
        }
        synchronized (ImfLock.class) {
            final int callingUid = Binder.getCallingUid();
            final long ident = Binder.clearCallingIdentity();
            try {
                return InputMethodInfoSafeList.create(getInputMethodListLocked(
                        resolvedUserIds[0], directBootAwareness, callingUid));
                        userId, directBootAwareness, callingUid));
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
@@ -1508,17 +1506,15 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            mContext.enforceCallingOrSelfPermission(
                    Manifest.permission.INTERACT_ACROSS_USERS_FULL, null);
        }
        synchronized (ImfLock.class) {
            final int[] resolvedUserIds = InputMethodUtils.resolveUserId(userId,
                    mCurrentUserId, null);
            if (resolvedUserIds.length != 1) {
        if (!mUserManagerInternal.exists(userId)) {
            return InputMethodInfoSafeList.empty();
        }
        synchronized (ImfLock.class) {
            final int callingUid = Binder.getCallingUid();
            final long ident = Binder.clearCallingIdentity();
            try {
                return InputMethodInfoSafeList.create(
                        getEnabledInputMethodListLocked(resolvedUserIds[0], callingUid));
                        getEnabledInputMethodListLocked(userId, callingUid));
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
@@ -1534,17 +1530,14 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            mContext.enforceCallingOrSelfPermission(
                    Manifest.permission.INTERACT_ACROSS_USERS_FULL, null);
        }
        synchronized (ImfLock.class) {
            final int[] resolvedUserIds = InputMethodUtils.resolveUserId(userId,
                    mCurrentUserId, null);
            if (resolvedUserIds.length != 1) {
        if (!mUserManagerInternal.exists(userId)) {
            return Collections.emptyList();
        }
        synchronized (ImfLock.class) {
            final int callingUid = Binder.getCallingUid();
            final long ident = Binder.clearCallingIdentity();
            try {
                return getInputMethodListLocked(
                        resolvedUserIds[0], directBootAwareness, callingUid);
                return getInputMethodListLocked(userId, directBootAwareness, callingUid);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
@@ -1559,16 +1552,14 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            mContext.enforceCallingOrSelfPermission(
                    Manifest.permission.INTERACT_ACROSS_USERS_FULL, null);
        }
        synchronized (ImfLock.class) {
            final int[] resolvedUserIds = InputMethodUtils.resolveUserId(userId,
                    mCurrentUserId, null);
            if (resolvedUserIds.length != 1) {
        if (!mUserManagerInternal.exists(userId)) {
            return Collections.emptyList();
        }
        synchronized (ImfLock.class) {
            final int callingUid = Binder.getCallingUid();
            final long ident = Binder.clearCallingIdentity();
            try {
                return getEnabledInputMethodListLocked(resolvedUserIds[0], callingUid);
                return getEnabledInputMethodListLocked(userId, callingUid);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }