From 75338fd3ca5bee5f1def56f7a4c28cac24b1b4e6 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Sun, 18 Jul 2021 23:35:20 -0700 Subject: [PATCH] Declare IMM#mIInputContext with its concrete type This is a small refactoring that changes no semantics but just reduces some boilerplate code in InputMethodManager. We know that IMM#mIInputContext is guaranteed to be an instance of IInputConnectionWrapper, we can reduce some boilerplate code by using its concrete class when declaring it. Using its concrete type would also helps the runtime and AOT compiler do optimizations such as devirtualization because IInputConnectionWrapper is already declared as a final class. Other that such code reduction and plausible performance implications, there should be no behavior change in this CL. Bug: 192412909 Test: presubmit Change-Id: I2ee22292feeb6c806d2949bc05f2780923597e1b --- .../android/view/inputmethod/InputMethodManager.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 80a6c02f6389d..8e0d9bc2ade0a 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -366,7 +366,7 @@ public final class InputMethodManager { final H mH; // Our generic input connection if the current target does not have its own. - final IInputContext mIInputContext; + private final IInputConnectionWrapper mIInputContext; private final int mDisplayId; @@ -920,12 +920,9 @@ public final class InputMethodManager { // that this happened and make sure our own editor's // state is reset. mRestartOnNextWindowFocus = true; - try { - // Note that finishComposingText() is allowed to run - // even when we are not active. - mIInputContext.finishComposingText(); - } catch (RemoteException e) { - } + // Note that finishComposingText() is allowed to run + // even when we are not active. + mIInputContext.finishComposingText(); } // Check focus again in case that "onWindowFocus" is called before // handling this message.