diff options
| author | 2024-05-15 18:13:52 +0000 | |
|---|---|---|
| committer | 2024-05-15 18:24:17 +0000 | |
| commit | 21f20ab0590b3812d45b3ce019afe6bbf839c2bd (patch) | |
| tree | f9848c5dff189e53038c508c098a97111918da61 | |
| parent | 441a51ddc45e493559b87c923bd1a34fd0227679 (diff) | |
Bind userId with ImeBindingState
By binding userId with ImeBindingState, IMMS will be able to know who
exactly owns the currently focused window (some windows may be owned by
system user, therefore is not always possible to find out who is the real
user who owns certain window).
This CL represents an internal refactoring and shouldn't introduce any
observable breakage.
Bug: 314149476
Test: atest FrameworksInputMethodSystemServerTests
Test: atest --host FrameworksInputMethodSystemServerTestsRavenwood
Change-Id: I79e2f6463192a39ef7c6820751b2908b460d9e37
| -rw-r--r-- | services/core/java/com/android/server/inputmethod/ImeBindingState.java | 10 | ||||
| -rw-r--r-- | services/core/java/com/android/server/inputmethod/InputMethodManagerService.java | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/inputmethod/ImeBindingState.java b/services/core/java/com/android/server/inputmethod/ImeBindingState.java index 4c20c3b9784a..f78ea84efb77 100644 --- a/services/core/java/com/android/server/inputmethod/ImeBindingState.java +++ b/services/core/java/com/android/server/inputmethod/ImeBindingState.java @@ -21,7 +21,9 @@ import static android.server.inputmethod.InputMethodManagerServiceProto.CUR_FOCU import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED; import android.annotation.Nullable; +import android.annotation.UserIdInt; import android.os.IBinder; +import android.os.UserHandle; import android.util.Printer; import android.util.proto.ProtoOutputStream; import android.view.WindowManager; @@ -36,6 +38,9 @@ import com.android.server.wm.WindowManagerInternal; */ final class ImeBindingState { + @UserIdInt + final int mUserId; + /** * The last window token that we confirmed to be focused. This is always updated upon * reports from the input method client. If the window state is already changed before the @@ -90,6 +95,7 @@ final class ImeBindingState { static ImeBindingState newEmptyState() { return new ImeBindingState( + /*userId=*/ UserHandle.USER_NULL, /*focusedWindow=*/ null, /*focusedWindowSoftInputMode=*/ SOFT_INPUT_STATE_UNSPECIFIED, /*focusedWindowClient=*/ null, @@ -97,10 +103,12 @@ final class ImeBindingState { ); } - ImeBindingState(@Nullable IBinder focusedWindow, + ImeBindingState(@UserIdInt int userId, + @Nullable IBinder focusedWindow, @SoftInputModeFlags int focusedWindowSoftInputMode, @Nullable ClientState focusedWindowClient, @Nullable EditorInfo focusedWindowEditorInfo) { + mUserId = userId; mFocusedWindow = focusedWindow; mFocusedWindowSoftInputMode = focusedWindowSoftInputMode; mFocusedWindowClient = focusedWindowClient; diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 691145c500d9..7d34d5e7d18c 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -3712,7 +3712,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. null, null, null, null, -1, false); } - mImeBindingState = new ImeBindingState(windowToken, softInputMode, cs, editorInfo); + mImeBindingState = new ImeBindingState(userData.mUserId, windowToken, softInputMode, cs, + editorInfo); mFocusedWindowPerceptible.put(windowToken, true); // We want to start input before showing the IME, but after closing |