From eec552e9e9c453a7921463e5a0ade959e030f9a0 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Sun, 9 Sep 2018 20:48:41 -0700 Subject: Allow IMM to forward API calls to IMS This is one further step towards deprecating 8 IME APIs that were accidentally defined InputMethodManager (IMM) instead of InputMethodService (IMS). With this CL, API calls to those 8 deprecated ones in IMM will be forwarded to IMS so that we can completely remove corresponding IPC methods from IInputMethodManager.aidl. This guarantees that processes that have no InputMethodService running there become unable to access IPC methods behind such IME APIs that are intended to be used only from IMEs. One tricky thing is that the following 4 public APIs have been allowed to processes that have WRITE_SECURE_SETTINGS permission, even if such a process does not have active InputMethodService. * InputMethodManager.setInputMethod * InputMethodManager.setInputMethodAndSubtype * InputMethodManager.switchToLastInputMethod * InputMethodManager.switchToNextInputMethod In general, user mode apps should not have WRITE_SECURE_SETTINGS permission. Thus it might be not that difficult for us to simply deprecate such a special rule. Bug 114488811 is tracking that effort. For now, this CL preserves the existing behavior when a null IME token is specified to those 4 APIs. Bug: 114418674 Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases Change-Id: If762714b2003fa6477e1318110f63e13968c1d7e --- core/java/android/inputmethodservice/InputMethodService.java | 6 ++++++ 1 file changed, 6 insertions(+) (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 7f259e2f9f4c..aa5cf09f396b 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -458,6 +458,7 @@ public class InputMethodService extends AbstractInputMethodService { public final void initializeInternal(IBinder token, IInputMethodPrivilegedOperations privilegedOperations) { mPrivOps.set(privilegedOperations); + mImm.registerInputMethodPrivOps(token, mPrivOps); attachToken(token); } @@ -1000,6 +1001,11 @@ public class InputMethodService extends AbstractInputMethodService { mSettingsObserver.unregister(); mSettingsObserver = null; } + 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); + } } /** -- cgit v1.2.3