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

Commit 21f20ab0 authored by Antonio Kantek's avatar Antonio Kantek
Browse files

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
parent 441a51dd
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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;
+2 −1
Original line number Diff line number Diff line
@@ -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