Make InputMethodManagerService#MSG_INITIALIZE_IME private

With this CL, all the message IDs defined as IMMS#MSG_* become private
constants.  Message formats used in

   InputMethodManagerService#handleMessage()

are now completely encapsulated within InputMethodManagerService.

As a bonus, we can also make the following field and method private.

  * InputMethodManagerService#mCaller
  * InputMethodManagerService#executeOrSendMessage()

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

Bug: 192412909
Test: presubmit
Change-Id: I37a4bf39e21955af0e677e576e4eb87d3105c8c6
This commit is contained in:
Yohei Yukawa
2022-01-17 09:34:20 -08:00
parent 06c3998532
commit 2070234cce
2 changed files with 12 additions and 13 deletions

View File

@@ -18,8 +18,6 @@ package com.android.server.inputmethod;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static com.android.server.inputmethod.InputMethodManagerService.MSG_INITIALIZE_IME;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.PendingIntent;
@@ -311,11 +309,8 @@ final class InputMethodBindingController {
if (DEBUG) Slog.v(TAG, "Initiating attach with token: " + mCurToken);
final InputMethodInfo info = mMethodMap.get(mSelectedMethodId);
mSupportsStylusHw = info.supportsStylusHandwriting();
// Dispatch display id for InputMethodService to update context display.
mService.executeOrSendMessage(mCurMethod,
mService.mCaller.obtainMessageIOOO(MSG_INITIALIZE_IME,
info.getConfigChanges(), mCurMethod, mCurToken,
mSupportsStylusHw));
mService.executeOrSendInitializeIme(mCurMethod, mCurToken,
info.getConfigChanges(), mSupportsStylusHw);
mService.scheduleNotifyImeUidToAudioService(mCurMethodUid);
mService.reRequestCurrentClientSessionLocked();
}

View File

@@ -228,10 +228,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
private static final int MSG_SHOW_SOFT_INPUT = 1020;
private static final int MSG_HIDE_SOFT_INPUT = 1030;
private static final int MSG_HIDE_CURRENT_INPUT_METHOD = 1035;
/**
* package-private because this is also used by {@link InputMethodBindingController}.
*/
static final int MSG_INITIALIZE_IME = 1040;
private static final int MSG_INITIALIZE_IME = 1040;
private static final int MSG_CREATE_SESSION = 1050;
private static final int MSG_REMOVE_IME_SURFACE = 1060;
private static final int MSG_REMOVE_IME_SURFACE_FROM_WINDOW = 1061;
@@ -288,7 +285,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
final WindowManagerInternal mWindowManagerInternal;
final PackageManagerInternal mPackageManagerInternal;
final InputManagerInternal mInputManagerInternal;
final HandlerCaller mCaller;
private final HandlerCaller mCaller;
final boolean mHasFeature;
private final ArrayMap<String, List<InputMethodSubtype>> mAdditionalSubtypeMap =
new ArrayMap<>();
@@ -2244,7 +2241,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
}
void executeOrSendMessage(IInterface target, Message msg) {
private void executeOrSendMessage(IInterface target, Message msg) {
if (target.asBinder() instanceof Binder) {
mCaller.sendMessage(msg);
} else {
@@ -2529,6 +2526,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
}
@AnyThread
void executeOrSendInitializeIme(@NonNull IInputMethod inputMethod, @NonNull IBinder token,
@android.content.pm.ActivityInfo.Config int configChanges, boolean supportStylusHw) {
executeOrSendMessage(inputMethod, mCaller.obtainMessageIOOO(MSG_INITIALIZE_IME,
configChanges, inputMethod, token, supportStylusHw));
}
@AnyThread
void scheduleNotifyImeUidToAudioService(int uid) {
mCaller.removeMessages(MSG_NOTIFY_IME_UID_TO_AUDIO_SERVICE);