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

Commit 70a234ad authored by Antonio Kantek's avatar Antonio Kantek
Browse files

Extract ClientState to a top level class

This CL represents a preparation step for FocusController.

This is a pure mechanical refactoring (moving mCurFocusedWindow to
FocusController), therefore no feature flag is required.

Bug: 314150112
Test: atest CtsInputMethodTestCases FrameworksServicesTests
Test: atest FrameworksInputMethodSystemServerTests
Test: atest --host FrameworksInputMethodSystemServerTests_host
Change-Id: Id650f03d9f20c842062018aa20913726d291ea85
parent 060ab1e5
Loading
Loading
Loading
Loading
+0 −46
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import android.content.pm.PackageManagerInternal;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.ArrayMap;
import android.util.SparseArray;
import android.view.inputmethod.InputBinding;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
@@ -156,48 +154,4 @@ final class ClientController {
        return InputMethodUtils.checkIfPackageBelongsToUid(
                mPackageManagerInternal, cs.mUid, packageName);
    }

    static final class ClientState {
        final IInputMethodClientInvoker mClient;
        final IRemoteInputConnection mFallbackInputConnection;
        final int mUid;
        final int mPid;
        final int mSelfReportedDisplayId;
        final InputBinding mBinding;
        final IBinder.DeathRecipient mClientDeathRecipient;

        @GuardedBy("ImfLock.class")
        boolean mSessionRequested;

        @GuardedBy("ImfLock.class")
        boolean mSessionRequestedForAccessibility;

        @GuardedBy("ImfLock.class")
        InputMethodManagerService.SessionState mCurSession;

        @GuardedBy("ImfLock.class")
        SparseArray<InputMethodManagerService.AccessibilitySessionState> mAccessibilitySessions =
                new SparseArray<>();

        @Override
        public String toString() {
            return "ClientState{" + Integer.toHexString(
                    System.identityHashCode(this)) + " mUid=" + mUid
                    + " mPid=" + mPid + " mSelfReportedDisplayId=" + mSelfReportedDisplayId + "}";
        }

        ClientState(IInputMethodClientInvoker client,
                IRemoteInputConnection fallbackInputConnection,
                int uid, int pid, int selfReportedDisplayId,
                IBinder.DeathRecipient clientDeathRecipient) {
            mClient = client;
            mFallbackInputConnection = fallbackInputConnection;
            mUid = uid;
            mPid = pid;
            mSelfReportedDisplayId = selfReportedDisplayId;
            mBinding = new InputBinding(null /*conn*/, mFallbackInputConnection.asBinder(), mUid,
                    mPid);
            mClientDeathRecipient = clientDeathRecipient;
        }
    }
}
+68 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.inputmethod;

import android.os.IBinder;
import android.util.SparseArray;
import android.view.inputmethod.InputBinding;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.inputmethod.IRemoteInputConnection;

final class ClientState {
    final IInputMethodClientInvoker mClient;
    final IRemoteInputConnection mFallbackInputConnection;
    final int mUid;
    final int mPid;
    final int mSelfReportedDisplayId;
    final InputBinding mBinding;
    final IBinder.DeathRecipient mClientDeathRecipient;

    @GuardedBy("ImfLock.class")
    boolean mSessionRequested;

    @GuardedBy("ImfLock.class")
    boolean mSessionRequestedForAccessibility;

    @GuardedBy("ImfLock.class")
    InputMethodManagerService.SessionState mCurSession;

    @GuardedBy("ImfLock.class")
    SparseArray<InputMethodManagerService.AccessibilitySessionState> mAccessibilitySessions =
            new SparseArray<>();

    @Override
    public String toString() {
        return "ClientState{" + Integer.toHexString(
                System.identityHashCode(this)) + " mUid=" + mUid
                + " mPid=" + mPid + " mSelfReportedDisplayId=" + mSelfReportedDisplayId + "}";
    }

    ClientState(IInputMethodClientInvoker client,
            IRemoteInputConnection fallbackInputConnection,
            int uid, int pid, int selfReportedDisplayId,
            IBinder.DeathRecipient clientDeathRecipient) {
        mClient = client;
        mFallbackInputConnection = fallbackInputConnection;
        mUid = uid;
        mPid = pid;
        mSelfReportedDisplayId = selfReportedDisplayId;
        mBinding = new InputBinding(null /*conn*/, mFallbackInputConnection.asBinder(), mUid,
                mPid);
        mClientDeathRecipient = clientDeathRecipient;
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.DISPLAY_IME_POLICY_HIDE;
import static android.view.WindowManager.DISPLAY_IME_POLICY_LOCAL;

import static com.android.server.inputmethod.ClientController.ClientState;
import static com.android.server.inputmethod.ImeVisibilityStateComputer.ImeTargetWindowState;
import static com.android.server.inputmethod.ImeVisibilityStateComputer.ImeVisibilityResult;
import static com.android.server.inputmethod.ImeVisibilityStateComputer.STATE_HIDE_IME;
@@ -2183,7 +2182,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
    /**
     * Hide the IME if the removed user is the current user.
     */
    private void onClientRemoved(ClientController.ClientState client) {
    private void onClientRemoved(ClientState client) {
        synchronized (ImfLock.class) {
            clearClientSessionLocked(client);
            clearClientSessionForAccessibilityLocked(client);
+0 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
package com.android.server.inputmethod;

import static com.android.server.inputmethod.ClientController.ClientControllerCallback;
import static com.android.server.inputmethod.ClientController.ClientState;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VI
import static com.android.internal.inputmethod.SoftInputShowHideReason.HIDE_SOFT_INPUT;
import static com.android.internal.inputmethod.SoftInputShowHideReason.HIDE_SWITCH_USER;
import static com.android.internal.inputmethod.SoftInputShowHideReason.SHOW_SOFT_INPUT;
import static com.android.server.inputmethod.ClientController.ClientState;
import static com.android.server.inputmethod.ImeVisibilityStateComputer.STATE_HIDE_IME;
import static com.android.server.inputmethod.ImeVisibilityStateComputer.STATE_HIDE_IME_EXPLICIT;
import static com.android.server.inputmethod.ImeVisibilityStateComputer.STATE_HIDE_IME_NOT_ALWAYS;