From 08995525569dbc61fc897d31b53cb74e35ff3ecb Mon Sep 17 00:00:00 2001 From: Wilson Wu Date: Wed, 14 Sep 2022 11:27:07 +0800 Subject: [PATCH] Deprecate InputMethodInterface methods IME developers have no strong reason to override InputMethodImpl and InputMethodSessionImpl methods. Add deprecated annotation to these methods with suggested alternatives. Bug: 148086656 Test: presubmit Change-Id: I4e970404a1cbf15d6b40760b7808825c0eb94736 --- core/api/current.txt | 4 ++-- .../inputmethodservice/InputMethodService.java | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index fb0cff5fe53a5..43b0f3950b5c9 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -18919,8 +18919,8 @@ package android.inputmethodservice { method public android.view.View onCreateCandidatesView(); method public android.view.View onCreateExtractTextView(); method @Nullable public android.view.inputmethod.InlineSuggestionsRequest onCreateInlineSuggestionsRequest(@NonNull android.os.Bundle); - method public android.inputmethodservice.AbstractInputMethodService.AbstractInputMethodImpl onCreateInputMethodInterface(); - method public android.inputmethodservice.AbstractInputMethodService.AbstractInputMethodSessionImpl onCreateInputMethodSessionInterface(); + method @Deprecated public android.inputmethodservice.AbstractInputMethodService.AbstractInputMethodImpl onCreateInputMethodInterface(); + method @Deprecated public android.inputmethodservice.AbstractInputMethodService.AbstractInputMethodSessionImpl onCreateInputMethodSessionInterface(); method public android.view.View onCreateInputView(); method protected void onCurrentInputMethodSubtypeChanged(android.view.inputmethod.InputMethodSubtype); method public void onDisplayCompletions(android.view.inputmethod.CompletionInfo[]); diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 3a157d30d4c40..7436601f5352f 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -1744,7 +1744,16 @@ public class InputMethodService extends AbstractInputMethodService { /** * Implement to return our standard {@link InputMethodImpl}. Subclasses * can override to provide their own customized version. + * + * @deprecated IME developers don't need to override this method to get callbacks information. + * Most methods in {@link InputMethodImpl} have corresponding callbacks. + * Use {@link InputMethodService#onBindInput()}, {@link InputMethodService#onUnbindInput()}, + * {@link InputMethodService#onWindowShown()}, {@link InputMethodService#onWindowHidden()}, etc. + * + *

Starting from Android U and later, override this method won't guarantee that IME works + * as previous platform behavior.

*/ + @Deprecated @Override public AbstractInputMethodImpl onCreateInputMethodInterface() { return new InputMethodImpl(); @@ -1753,7 +1762,15 @@ public class InputMethodService extends AbstractInputMethodService { /** * Implement to return our standard {@link InputMethodSessionImpl}. Subclasses * can override to provide their own customized version. + * + * @deprecated IME developers don't need to override this method to get callbacks information. + * Most methods in {@link InputMethodSessionImpl} have corresponding callbacks. + * Use {@link InputMethodService#onFinishInput()}, + * {@link InputMethodService#onDisplayCompletions(CompletionInfo[])}, + * {@link InputMethodService#onUpdateExtractedText(int, ExtractedText)}, + * {@link InputMethodService#onUpdateSelection(int, int, int, int, int, int)} instead. */ + @Deprecated @Override public AbstractInputMethodSessionImpl onCreateInputMethodSessionInterface() { return new InputMethodSessionImpl();