diff options
| author | 2023-03-10 11:50:25 +0000 | |
|---|---|---|
| committer | 2023-03-10 12:06:27 +0000 | |
| commit | c2e31eb49ac522be4b766d28276142a01e83f4cc (patch) | |
| tree | 6d13bdf65f0610e9c337f9b4889dcf6092076168 | |
| parent | 610ef28a257ff958ac8b5823ed74905a3797ad76 (diff) | |
Fix: Security exception in case of work profile
Test: manual
Bug: 272522906
Change-Id: I9057e793641950e2ad903404d591b4e517e91e38
| -rw-r--r-- | services/core/java/com/android/server/input/KeyboardLayoutManager.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/input/KeyboardLayoutManager.java b/services/core/java/com/android/server/input/KeyboardLayoutManager.java index f873a1b867d2..4d4a87e18664 100644 --- a/services/core/java/com/android/server/input/KeyboardLayoutManager.java +++ b/services/core/java/com/android/server/input/KeyboardLayoutManager.java @@ -65,6 +65,7 @@ import com.android.internal.inputmethod.InputMethodSubtypeHandle; import com.android.internal.messages.nano.SystemMessageProto; import com.android.internal.notification.SystemNotificationChannels; import com.android.internal.util.XmlUtils; +import com.android.server.inputmethod.InputMethodManagerInternal; import libcore.io.Streams; @@ -1226,9 +1227,15 @@ final class KeyboardLayoutManager implements InputManager.InputDeviceListener { mContext.getSystemService(UserManager.class)); InputMethodManager inputMethodManager = Objects.requireNonNull( mContext.getSystemService(InputMethodManager.class)); + // Need to use InputMethodManagerInternal to call getEnabledInputMethodListAsUser() + // instead of using InputMethodManager which uses enforceCallingPermissions() that + // breaks when we are calling the method for work profile user ID since it doesn't check + // self permissions. + InputMethodManagerInternal inputMethodManagerInternal = InputMethodManagerInternal.get(); for (UserHandle userHandle : userManager.getUserHandles(true /* excludeDying */)) { int userId = userHandle.getIdentifier(); - for (InputMethodInfo imeInfo : inputMethodManager.getEnabledInputMethodListAsUser( + for (InputMethodInfo imeInfo : + inputMethodManagerInternal.getEnabledInputMethodListAsUser( userId)) { for (InputMethodSubtype imeSubtype : inputMethodManager.getEnabledInputMethodSubtypeList( |