From 2742a030a673a49ee355d262747a0fe8de591ad3 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Mon, 24 Jan 2022 19:00:36 -0800 Subject: [PATCH] Replace mHandler.sendMessage() with sendToTarget() This CL mechanically replace mHandler.sendMessage(msg) with msg.sendToTarget(). This should be safe because we always use obtain Message objects from the same Handler object in InputMethodManagerService. There should be no observable behavior change. Bug: 192412909 Test: presubmit Change-Id: I9fa657cfff18c4111e0fad4d4e354c011c368772 --- .../InputMethodManagerService.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index a63e8057b0ca4..8a6aa0d8f9283 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -1524,8 +1524,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @Override public void onUserUnlocking(@NonNull TargetUser user) { // Called on ActivityManager thread. - mService.mHandler.sendMessage(mService.mHandler.obtainMessage(MSG_SYSTEM_UNLOCK_USER, - /* arg1= */ user.getUserIdentifier(), /* arg2= */ 0)); + mService.mHandler.obtainMessage(MSG_SYSTEM_UNLOCK_USER, user.getUserIdentifier(), 0) + .sendToTarget(); } } @@ -2221,7 +2221,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // We probably should create a simple wrapper of IInputMethodClient as the first step // to get rid of executeOrSendMessage() then should prohibit system_server to be the // IME client for long term. - mHandler.sendMessage(msg); + msg.sendToTarget(); } else { handleMessage(msg); msg.recycle(); @@ -3652,9 +3652,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // Always call subtype picker, because subtype picker is a superset of input method // picker. - mHandler.sendMessage(mHandler.obtainMessage( - MSG_SHOW_IM_SUBTYPE_PICKER, auxiliarySubtypeMode, - (mCurClient != null) ? mCurClient.selfReportedDisplayId : DEFAULT_DISPLAY)); + final int displayId = + (mCurClient != null) ? mCurClient.selfReportedDisplayId : DEFAULT_DISPLAY; + mHandler.obtainMessage(MSG_SHOW_IM_SUBTYPE_PICKER, auxiliarySubtypeMode, displayId) + .sendToTarget(); } } @@ -3669,8 +3670,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } // Always call subtype picker, because subtype picker is a superset of input method // picker. - mHandler.sendMessage(mHandler.obtainMessage( - MSG_SHOW_IM_SUBTYPE_PICKER, auxiliarySubtypeMode, displayId)); + mHandler.obtainMessage(MSG_SHOW_IM_SUBTYPE_PICKER, auxiliarySubtypeMode, displayId) + .sendToTarget(); } /** @@ -3927,7 +3928,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @Override public void removeImeSurface() { mContext.enforceCallingPermission(Manifest.permission.INTERNAL_SYSTEM_WINDOW, null); - mHandler.sendMessage(mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE)); + mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE).sendToTarget(); } @Override @@ -4959,14 +4960,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @Override public void removeImeSurface() { - mService.mHandler.sendMessage(mService.mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE)); + mService.mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE).sendToTarget(); } @Override public void updateImeWindowStatus(boolean disableImeIcon) { - mService.mHandler.sendMessage( - mService.mHandler.obtainMessage(MSG_UPDATE_IME_WINDOW_STATUS, - disableImeIcon ? 1 : 0, 0)); + mService.mHandler.obtainMessage(MSG_UPDATE_IME_WINDOW_STATUS, disableImeIcon ? 1 : 0, 0) + .sendToTarget(); } }