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

Commit 06c39985 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Inline InputMethodMenuController.HardKeyboardListener

This is a follow up CL to our previous CL [1], which introduced

   InputMethodManagerService.HardKeyboardListener,

which was later moved to

   InputMethodMenuController.HardKeyboardListener

as part of refactoring [2].

This CL mechanically inlines it to InputMethodManagerService as it
allows us to achieve the same behavior with fewer lines of code.

This is mechanical refactoring. There should be no observable behavior
change.

 [1]: Ica768083f95c33dc1e494a28ba7d8b6eb989b0ef
      01038492
 [2]: Ief3c691029b14d848f6ad4a5ec8a8743760c7cda
      c88452c3

Bug: 192412909
Test: Manually verified by attaching/detaching a hardware keyboard.
Change-Id: I9cce75011a8564c9da8307c5555d87bcba4db2cb
parent 0467d70d
Loading
Loading
Loading
Loading
+7 −12
Original line number Diff line number Diff line
@@ -246,10 +246,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    private static final int MSG_SET_INTERACTIVE = 3030;
    private static final int MSG_REPORT_FULLSCREEN_MODE = 3045;

    /**
     * package-private because this is also used by {@link InputMethodMenuController}.
     */
    static final int MSG_HARD_KEYBOARD_SWITCH_CHANGED = 4000;
    private static final int MSG_HARD_KEYBOARD_SWITCH_CHANGED = 4000;

    private static final int MSG_SYSTEM_UNLOCK_USER = 5000;
    private static final int MSG_DISPATCH_ON_INPUT_METHOD_LIST_UPDATED = 5010;
@@ -284,7 +281,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

    final Context mContext;
    final Resources mRes;
    final Handler mHandler;
    private final Handler mHandler;
    final InputMethodSettings mSettings;
    final SettingsObserver mSettingsObserver;
    final IWindowManager mIWindowManager;
@@ -1812,10 +1809,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                mShowOngoingImeSwitcherForPhones = mRes.getBoolean(
                        com.android.internal.R.bool.show_ongoing_ime_switcher);
                if (mShowOngoingImeSwitcherForPhones) {
                    final InputMethodMenuController.HardKeyboardListener hardKeyboardListener =
                            mMenuController.getHardKeyboardListener();
                    mWindowManagerInternal.setOnHardKeyboardStatusChangeListener(
                            hardKeyboardListener);
                    mWindowManagerInternal.setOnHardKeyboardStatusChangeListener(available -> {
                        mHandler.obtainMessage(MSG_HARD_KEYBOARD_SWITCH_CHANGED, available ? 1 : 0)
                                .sendToTarget();
                    });
                }

                mMyPackageMonitor.register(mContext, null, UserHandle.ALL, true);
@@ -4422,9 +4419,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

            // --------------------------------------------------------------
            case MSG_HARD_KEYBOARD_SWITCH_CHANGED:
                final InputMethodMenuController.HardKeyboardListener hardKeyboardListener =
                        mMenuController.getHardKeyboardListener();
                hardKeyboardListener.handleHardKeyboardStatusChange(msg.arg1 == 1);
                mMenuController.handleHardKeyboardStatusChange(msg.arg1 == 1);
                return true;
            case MSG_SYSTEM_UNLOCK_USER: {
                final int userId = msg.arg1;
+9 −27
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.server.inputmethod;

import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;
import static com.android.server.inputmethod.InputMethodManagerService.DEBUG;
import static com.android.server.inputmethod.InputMethodManagerService.MSG_HARD_KEYBOARD_SWITCH_CHANGED;
import static com.android.server.inputmethod.InputMethodUtils.NOT_A_SUBTYPE_ID;

import android.app.ActivityThread;
@@ -28,7 +27,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.IBinder;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -62,10 +60,8 @@ public class InputMethodMenuController {
    private final InputMethodManagerService mService;
    private final InputMethodUtils.InputMethodSettings mSettings;
    private final InputMethodSubtypeSwitchingController mSwitchingController;
    private final Handler mHandler;
    private final ArrayMap<String, InputMethodInfo> mMethodMap;
    private final KeyguardManager mKeyguardManager;
    private final HardKeyboardListener mHardKeyboardListener;
    private final WindowManagerInternal mWindowManagerInternal;

    private Context mSettingsContext;
@@ -83,10 +79,8 @@ public class InputMethodMenuController {
        mService = service;
        mSettings = mService.mSettings;
        mSwitchingController = mService.mSwitchingController;
        mHandler = mService.mHandler;
        mMethodMap = mService.mMethodMap;
        mKeyguardManager = mService.mKeyguardManager;
        mHardKeyboardListener = new HardKeyboardListener();
        mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
    }

@@ -271,10 +265,6 @@ public class InputMethodMenuController {
        }
    }

    HardKeyboardListener getHardKeyboardListener() {
        return mHardKeyboardListener;
    }

    AlertDialog getSwitchingDialogLocked() {
        return mSwitchingDialog;
    }
@@ -290,14 +280,7 @@ public class InputMethodMenuController {
        return mSwitchingDialog.isShowing();
    }

    class HardKeyboardListener implements WindowManagerInternal.OnHardKeyboardStatusChangeListener {
        @Override
        public void onHardKeyboardStatusChange(boolean available) {
            mHandler.sendMessage(mHandler.obtainMessage(MSG_HARD_KEYBOARD_SWITCH_CHANGED,
                    available ? 1 : 0));
        }

        public void handleHardKeyboardStatusChange(boolean available) {
    void handleHardKeyboardStatusChange(boolean available) {
        if (DEBUG) {
            Slog.w(TAG, "HardKeyboardStatusChanged: available=" + available);
        }
@@ -310,7 +293,6 @@ public class InputMethodMenuController {
            }
        }
    }
    }

    private static class ImeSubtypeListAdapter extends ArrayAdapter<ImeSubtypeListItem> {
        private final LayoutInflater mInflater;