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

Commit 50ddd32e authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Android (Google) Code Review
Browse files

Merge "Make InputMethodManagerService#mMethodMap private" into main

parents 1952dd31 c94aff24
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.ArrayMap;
import android.util.Slog;
import android.view.autofill.AutofillId;
import android.view.inputmethod.InlineSuggestionsRequest;
@@ -40,7 +39,6 @@ final class AutofillSuggestionsController {
    private static final String TAG = AutofillSuggestionsController.class.getSimpleName();

    @NonNull private final InputMethodManagerService mService;
    @NonNull private final ArrayMap<String, InputMethodInfo> mMethodMap;
    @NonNull private final InputMethodUtils.InputMethodSettings mSettings;

    private static final class CreateInlineSuggestionsRequest {
@@ -78,7 +76,6 @@ final class AutofillSuggestionsController {

    AutofillSuggestionsController(@NonNull InputMethodManagerService service) {
        mService = service;
        mMethodMap = mService.mMethodMap;
        mSettings = mService.mSettings;
    }

@@ -88,7 +85,8 @@ final class AutofillSuggestionsController {
            boolean touchExplorationEnabled) {
        clearPendingInlineSuggestionsRequest();
        mInlineSuggestionsRequestCallback = callback;
        final InputMethodInfo imi = mMethodMap.get(mService.getSelectedMethodIdLocked());
        final InputMethodInfo imi = mService.queryInputMethodForCurrentUserLocked(
                mService.getSelectedMethodIdLocked());
        try {
            if (userId == mSettings.getCurrentUserId()
                    && imi != null && isInlineSuggestionsEnabled(imi, touchExplorationEnabled)) {
+3 −5
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.ArrayMap;
import android.util.EventLog;
import android.util.Slog;
import android.view.WindowManager;
@@ -64,7 +63,6 @@ final class InputMethodBindingController {

    @NonNull private final InputMethodManagerService mService;
    @NonNull private final Context mContext;
    @NonNull private final ArrayMap<String, InputMethodInfo> mMethodMap;
    @NonNull private final InputMethodUtils.InputMethodSettings mSettings;
    @NonNull private final PackageManagerInternal mPackageManagerInternal;
    @NonNull private final WindowManagerInternal mWindowManagerInternal;
@@ -115,7 +113,6 @@ final class InputMethodBindingController {
            int imeConnectionBindFlags, CountDownLatch latchForTesting) {
        mService = service;
        mContext = mService.mContext;
        mMethodMap = mService.mMethodMap;
        mSettings = mService.mSettings;
        mPackageManagerInternal = mService.mPackageManagerInternal;
        mWindowManagerInternal = mService.mWindowManagerInternal;
@@ -295,7 +292,8 @@ final class InputMethodBindingController {
                        return;
                    }
                    if (DEBUG) Slog.v(TAG, "Initiating attach with token: " + mCurToken);
                    final InputMethodInfo info = mMethodMap.get(mSelectedMethodId);
                    final InputMethodInfo info =
                            mService.queryInputMethodForCurrentUserLocked(mSelectedMethodId);
                    boolean supportsStylusHwChanged =
                            mSupportsStylusHw != info.supportsStylusHandwriting();
                    mSupportsStylusHw = info.supportsStylusHandwriting();
@@ -410,7 +408,7 @@ final class InputMethodBindingController {
            return InputBindResult.NO_IME;
        }

        InputMethodInfo info = mMethodMap.get(mSelectedMethodId);
        InputMethodInfo info = mService.queryInputMethodForCurrentUserLocked(mSelectedMethodId);
        if (info == null) {
            throw new IllegalArgumentException("Unknown id: " + mSelectedMethodId);
        }
+7 −1
Original line number Diff line number Diff line
@@ -310,7 +310,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub

    // All known input methods.
    final ArrayList<InputMethodInfo> mMethodList = new ArrayList<>();
    final ArrayMap<String, InputMethodInfo> mMethodMap = new ArrayMap<>();
    private final ArrayMap<String, InputMethodInfo> mMethodMap = new ArrayMap<>();
    final InputMethodSubtypeSwitchingController mSwitchingController;
    final HardwareKeyboardShortcutController mHardwareKeyboardShortcutController =
            new HardwareKeyboardShortcutController();
@@ -500,6 +500,12 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
        mBindingController.advanceSequenceNumber();
    }

    @GuardedBy("ImfLock.class")
    @Nullable
    InputMethodInfo queryInputMethodForCurrentUserLocked(@NonNull String imeId) {
        return mMethodMap.get(imeId);
    }

    /**
     * The client that is currently bound to an input method.
     */
+2 −4
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Slog;
import android.view.LayoutInflater;
import android.view.View;
@@ -54,7 +53,6 @@ final class InputMethodMenuController {
    private final InputMethodManagerService mService;
    private final InputMethodUtils.InputMethodSettings mSettings;
    private final InputMethodSubtypeSwitchingController mSwitchingController;
    private final ArrayMap<String, InputMethodInfo> mMethodMap;
    private final WindowManagerInternal mWindowManagerInternal;

    private AlertDialog.Builder mDialogBuilder;
@@ -73,7 +71,6 @@ final class InputMethodMenuController {
        mService = service;
        mSettings = mService.mSettings;
        mSwitchingController = mService.mSwitchingController;
        mMethodMap = mService.mMethodMap;
        mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
    }

@@ -101,7 +98,8 @@ final class InputMethodMenuController {
                        mService.getCurrentInputMethodSubtypeLocked();
                if (currentSubtype != null) {
                    final String curMethodId = mService.getSelectedMethodIdLocked();
                    final InputMethodInfo currentImi = mMethodMap.get(curMethodId);
                    final InputMethodInfo currentImi =
                            mService.queryInputMethodForCurrentUserLocked(curMethodId);
                    lastInputMethodSubtypeId = SubtypeUtils.getSubtypeIdFromHashCode(
                            currentImi, currentSubtype.hashCode());
                }
+2 −1
Original line number Diff line number Diff line
@@ -133,10 +133,11 @@ public class InputMethodBindingControllerTest extends InputMethodManagerServiceT
    }

    private void testBindCurrentMethodWithMainConnection() throws Exception {
        final InputMethodInfo info;
        synchronized (ImfLock.class) {
            mBindingController.setSelectedMethodId(TEST_IME_ID);
            info = mInputMethodManagerService.queryInputMethodForCurrentUserLocked(TEST_IME_ID);
        }
        InputMethodInfo info = mInputMethodManagerService.mMethodMap.get(TEST_IME_ID);
        assertThat(info).isNotNull();
        assertThat(info.getId()).isEqualTo(TEST_IME_ID);
        assertThat(info.getServiceName()).isEqualTo(TEST_SERVICE_NAME);