From d746a7e89386e87a234c4bfda7afb2fe79e8b832 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Tue, 18 Sep 2018 18:55:02 -0700 Subject: Let InputMethodPrivilegedOperationsRegistry deal with its singleton-ness This is a preparation to allow InputMethodManager to have per-display instances rather than the current per-process singleton instance. When I introduced InputMethodPrivilegedOperationsRegistry [1], there was an assumption that InputMethodManager was a per-process global singleton object. Now that we are going to break up that global per-process instance into multiple per-display instances, having multiple InputMethodPrivilegedOperationsRegistry instances probably does not make much sense, because it would likely to increases the risk of compability issues in existing IMEs. Although IME developers soon really need to use the right Context to obtain the right instance of InputMethodManager anyway, unnecessarily introducing compatibility pitfalls that can be avoided in the Framework side is not my intention. With this CL, following 9 methods can continue to work no matter whether InputMethodManager is a per-process singleton or not. This is fine because those APIs had been mistakenly exposed in InputMethodManager and already deprecated in favor of newly added ones in InputMethodService. * InputMethodManager.hideSoftInputFromInputMethod * InputMethodManager.hideStatusIcon * InputMethodManager.setInputMethod * InputMethodManager.setInputMethodAndSubtype * InputMethodManager.shouldOfferSwitchingToNextInputMethod * InputMethodManager.showSoftInputFromInputMethod * InputMethodManager.showStatusIcon * InputMethodManager.switchToLastInputMethod * InputMethodManager.switchToNextInputMethod [1]: If762714b2003fa6477e1318110f63e13968c1d7e eec552e9e9c453a7921463e5a0ade959e030f9a0 Bug: 115893206 Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases Change-Id: I4a61470f06ffac5f7a512536f8431489db0108f4 --- core/java/android/inputmethodservice/InputMethodService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'core/java/android/inputmethodservice/InputMethodService.java') diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 34fa5b6b9842..b94840279cea 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -85,6 +85,7 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.inputmethod.IInputContentUriToken; import com.android.internal.inputmethod.IInputMethodPrivilegedOperations; import com.android.internal.inputmethod.InputMethodPrivilegedOperations; +import com.android.internal.inputmethod.InputMethodPrivilegedOperationsRegistry; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -465,7 +466,7 @@ public class InputMethodService extends AbstractInputMethodService { public final void initializeInternal(IBinder token, int displayId, IInputMethodPrivilegedOperations privilegedOperations) { mPrivOps.set(privilegedOperations); - mImm.registerInputMethodPrivOps(token, mPrivOps); + InputMethodPrivilegedOperationsRegistry.put(token, mPrivOps); updateInputMethodDisplay(displayId); attachToken(token); } @@ -1031,7 +1032,7 @@ public class InputMethodService extends AbstractInputMethodService { if (mToken != null) { // This is completely optional, but allows us to show more explicit error messages // when IME developers are doing something unsupported. - mImm.unregisterInputMethodPrivOps(mToken); + InputMethodPrivilegedOperationsRegistry.remove(mToken); } } -- cgit v1.2.3