History log of /frameworks/base/core/java/android/view/inputmethod/InputConnection.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
9f9afe526d1f8ad17c628fc9e1e839725ffe913e 30-Mar-2016 Yohei Yukawa <yukawa@google.com> Add IC#closeConnection().

It turns out that BaseInputConnection has still depended on a private
API named BaseInputConnection#reportFinish(), which was introduced
4 years ago to work around a UI freeze due to an unbalanced batch edit
count [1]. Note that such an unbalanced batch edit count cannot always
be avoidable. It can easily occur in the following situations.
- The current IME crashed during batch edit.
- The user changed the View focus during batch edit.
- The current IME called IMM#switchToNextInputMethod() during batch
edit.

The remaining problem is that #reportFinish() is still an internal API
and only subclasses of BaseInputConnection can implement it, and IMM
calls it when and only when the current InputConnection is
BaseInputConnection or its subclass. InputConnectionWrapper and any
other InputConnection implementations will never receive such a callback
to clean up InputConnection#{begin, end}BatchEdit(), which is considered
to be a major contributor to UI freeze.

To address the above issue, we unhide BaseInputConnection#reportFinish()
as InputConnection#closeConnection() so that application developers can
receive an appropriate callback to clean up internal state including
unfinished batch edit.

[1] I5525d776916f0c42d5e6d4a4282aed590d7f0e9a
9d69ecbf61a4a142c3f4cbb9d5659faa6f85e832

Bug: 24688781
Bug: 25332806
Change-Id: I234309c5880c9fe0b299b8bd0f8862796d4dda0d
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
19a80a1e807acd00bec999eaac7812da6ffce954 15-Mar-2016 Yohei Yukawa <yukawa@google.com> Tell IMS about missing InputConnection methods.

Summary:
This CL introduces a unified mechanism to deal with the situation
where the application directly implements InputConnection but some of
methods are not implemented. Note that there should be zero overhead
when the application extends BaseInputConnection or
InputConnectionWrapper.

Background:
When ever we add a new method to InputConnection, there has been a
risk that existing applications that directly implement
InputConnection can get java.lang.AbstractMethodError exception at
runtime, because older SDKs do not require the application developer
to implement the methods that are newly added in later SDKs. Because
of this we strongly discouraged developers to directly implement
InputConnection interface, and encouraged them to subclass
BaseInputConnection or InputConnectionWrapper instead. That said, as
requested in Bug 26945674, there is a certain demand to be able to
implement InputConnection without depending on BaseInputConnection.
The goal of this CL is to provide a reliable and sustainable solution
to above missing method scenario in InputConnection.

One of the reasons why dealing with missing InputConnection methods is
so difficult is that what InputMethodService receives to communicate
with the target application is actually a proxy class
com.android.internal.view.InputConnectionWrapper
that runs in the IME process and immediately returns true for most of
methods in InputConnection such as #commitText() and
#finishComposingText(). Because of this asynchronous nature, it is
too late to change the actual return value that the IME receives when
the application receives those one-way asynchronous IPC calls.

Solution:
To handle those cases, this CL checks the availability of
InputConnection methods that did not exist in the initial release
before the target application calls startInput(), and let the
application to send its availability bits to IMMS so that
InputConnectionWrapper running in the IME process can be initialized
with such availability bits. Note that we do know that
BaseInputConnection and its subclasses support all the InputConnection
methods, hence for most of applications we can just assume that all
the methods are available without reflection.

With such availability bits, InputConnectionWrapper is now able to
gracefully return failure code to the IME because the availability of
those methods is immutable, except for a tricky case where the
application relies on a proxy object that dynamically changes the
dispatch target.

Here is the list of APIs that we start checking the availability in
this CL.
[API Level 9+]
- InputConnection#getSelectedText(int)
- InputConnection#setComposingRegion(int, int)
[API Level 11+]
- InputConnection#commitCorrection(CorrectionInfo)
[API Level 21+]
- InputConnection#requestCursorUpdates(int)}
[API Level 24+]
- InputConnection#deleteSurroundingTextInCodePoints(int, int)
- InputConnection#getHandler()

Ideas alternatively considered: Default methods in InputConnection
We once considered having default methods in InputConnection but
abandoned this idea because it does not directly solve the problem
about how to tell the that the API does not take effect.
Also having default methods would make it difficult for application
developers to be aware of newly added methods in InputConnection.

Bug: 27407234
Bug: 27642734
Bug: 27650039
Change-Id: I3c58fadd924fad72cb984f0c23d3099fd0295c64
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
612cce92ad96eda1146c3abd2afa7aaa4d4f2b3f 12-Feb-2016 Yohei Yukawa <yukawa@google.com> Introduce InputConnection#getHandler().

Currently there is an internal hidden class named
ControlledInputConnectionWrapper which works as a proxy in the
application process to receive incoming binder calls from input method
and dispatch those method calls again on an appropriate thread.
Although this is a kind of implementation details, basically you can see
the same design everywhere in the Android.

Currently ControlledInputConnectionWrapper is initialized with
view.getHandler(), where the view here is the View which was used to
call View#onCreateInputConnection(). This is actually a reasonable
behavior because we have generally assumed that there the only
reasonable way to implement InputConnection is to extend
BaseInputConnection, which is designed to be able to work only on the
UI-thread associated with the target view.

However, on Android N and onward, we are going to ensure that
BaseInputConnection can be re-implemented on top of public APIs [1].
Although most of applications should not try to do that, for certain
applications such as web browsers and WebView it may make sense to let
custom InputConnection implementation run with a custom Handler so that
the application can respond to the IME without blocking the UI thread.

To do that, this CL introduces a new method
InputConnection#getHandler(), which changes nothing as long as it
returns null, but if it returns non-null Handler, InputMethodManager
will use it to initialize ControlledInputConnectionWrapper.

Note that InputConnection#getHandler() is not for IME developers.
It just returns null when called in the IME process.

[1] See Bug 24688781 for details.

Bug: 26945674
Change-Id: Id9e579bb3e2966986cdcb1c34bc8cacfeca2e1a9
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
c89e22a6ff227089fde26daea186346029d1b32c 14-Jan-2016 Yohei Yukawa <yukawa@google.com> Introdude IC#deleteSurroundingTextInCodePoints().

This CL introduces a API variant of IC#deleteSurroundingText(), named
IC#deleteSurroundingTextInCodePoints(). Major differences from
the existing one are:
- The lengths are supplied in code points rather than code units.
- This API does nothing if there are one or more invalid surrogate
pairs in the requested range. (Failure Atomicity)

Note that due to the asynchronous nature of the input method
architecture in Android, implementing the same logic in the input method
side basically ends up with unreliable and unpredictable results.

Bug: 6526420
Change-Id: I7f6a2c5d3d52079ae71623fd5e40d60c688dd5fb
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
5f137933d130e8e5f9d0d2285f6799e459befb5a 07-Jan-2016 Yohei Yukawa <yukawa@google.com> Enrich JavaDoc for IC#deleteSurroundingText().

As a preparation work for Bug 6526420, where we are going to
introduce a new variant of IC#deleteSurroundingText(), this CL attempts
to clarify about the expected behavior of IC#deleteSurroundingText().

With this CL, the expected behavior when the number of existing
characters is smaller than the number of characters to be deleted is
now documented by simply describing the current behavior of
BaseInputConnection, that is, IC#deleteSurroundingText() will delete
characters until it deletes requested number of characters in code units
or reaches to an end.

This is purely documentation work. No behavior change is intended.

Bug: 6526420
Change-Id: I7280dec07e1c043bd26b3b12fd866b9d8b6186cc
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
4465d1a03ee5fddc5987c19fc36b0bb79e19572f 26-Nov-2013 Newton Allen <newt@google.com> Fix some documentation typos.

Change-Id: I747a0ade5c7b9c45d4465bf327952338bbc1cfaa
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
3fadee479107f0494e1e190aba2a1eea12cb0a75 08-Sep-2014 Yohei Yukawa <yukawa@google.com> API Review: Clean up removed APIs

This CL removes old API signatures marked as @removed
in the follow CLs.
- Ic8c6fab58c01206872a34e7ee604cdda1581364d
- Ia8cbb9f6b41cd9509fc0147fd68763dfde593ffc
- I772c48ff18918e48a81e807b48ff907614485c09

This is just a clean-up CL. No behavior change is intended.

BUG: 17200900
BUG: 17320996
BUG: 17365414
Change-Id: Ibfbd5cc1cdebb8851c73477cff55c9b2d631fdea
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
d8636ea7ca78df83d6b04088eab7853f15f3e999 03-Sep-2014 Yohei Yukawa <yukawa@google.com> API Review: InputConnection

This CL does nothing but rename some L API candidates
in InputConnection class, as per requested.

- requestUpdateCursorAnchorInfo()
-> requestCursorUpdates()
- REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE
-> CURSOR_UPDATE_IMMEDIATE
- REQUEST_UPDATE_CURSOR_ANCHOR_INFO_MONITOR
-> CURSOR_UPDATE_MONITOR

BUG: 17320996
Change-Id: I772c48ff18918e48a81e807b48ff907614485c09
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
a277db28e990d1f6f74ace0c32fe92401660a840 22-Aug-2014 Yohei Yukawa <yukawa@google.com> Remove CursorAnchorInfoRequest and related stuff

This CL removes CursorAnchorInfoRequest and related stuff
in favor of InputConnection.requestUpdateCursorAnchorInfo,
which is more easy to understand. This CL also deprecates
InputMethodManager#updateCursor and related stuff.

Rationale:
1. The spec of #updateCursor says that it provides the cursor
position in local coordinates, while the input method
requires it in the screen coordinates.
2. #updateCursor has never been enabled in AOSP, because
InputMethodManager#isWatchingCursor always returned false.
3. There has been no way to let
InputMethodManager#isWatchingCursor return true.
4. In L, InputMethodManager#updateCursorAnchorInfo is
introduced to address all the issues above.

Given that we no longer need to support #updateCursor,
CursorAnchorInfoRequest is overkill when we need to convey
just a couple of parameters.

BUG: 17185263
BUG: 17182367

Change-Id: I4a577bfd02b37b9e56c80b8b41bb25afa95dd8ef
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
0023d0e0c4f5339b299d1eacbd4e7181c2fd271f 10-Jul-2014 Yohei Yukawa <yukawa@google.com> Polish new IME API for L part 2: CursorAnchorInfo

This CL addresses feedbacks from internal customers for new
input method APIs that are mainly used for physical keyboard
support in L.

For performance reasons, #onUpdateCursorAnchorInfo is not called
back by default and each input method has to enable this
event notification explicitly whenever fine-grained character
locations are needed.

In L-preview, InputMethodSession#setCursorAnchorMonitorMode was
introduced for this purpose. However, we got several feedbacks
to be addressed.
- The effect of #setCursorAnchorMonitorMode is not preserved
during focus change. IMEs need to call
#setCursorAnchorMonitorMode every time when #onStartInput is
called. This is tricky and hard to understand.
- As #onUpdateCursorAnchorInfo is a new API, not all
applications/text editors have supported it. Therefore IMEs
can't always rely on it. However, there is no way to query
if the attached target is supporting this new API or not.
It would helpful for IME authors if we can provide a
reliable way to query if the attached input target is
supporting the new API or not.

In order to address these issues, the triggering method has
moved from InputMethodSession to InputConnection in this CL,
as an analogy of existing InputConnection#getExtractedText API,
which has provided similar functionality including optional
reactive event callbacks from the application to the IME.

BUG: 15812658
BUG: 16118603
Change-Id: I3c6b69bd9d79b199afe68d838f25effa6048e5cc
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
c1a11f17a2de18911317d235ff75fa17e098a962 11-Nov-2013 Jean Chalard <jchalard@google.com> Improve documentation for InputType and EditorInfo.

Bug: 11245912
Change-Id: Ie92ba20079461f7f0e30d969ba3692fec3a3b97f
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
4510eb40491d60acb62ed0588b40e1d229d75bf6 26-Sep-2013 Jean Chalard <jchalard@google.com> Fix conflicting/unclear documentation in InputConnection.

Bug: 10247660
Change-Id: I88f36a3764d5e6dee4e864cb9f6df713dde5e0f5
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
e811de2d6cd736b36a2a2ff552e6893a4a021045 24-May-2013 Jean Chalard <jchalard@google.com> Improve the documentation for InputConnection.

- Add many details to most methods.
- Add comments specific to IME authors and to editor authors.
- Add missing return value docs.
- Straighten out single-spacing vs double spacing.

Bug: 8843866
Change-Id: If1f6dcf0457d5332a7ebb1ebfb1967c6ff0df722
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
405bc51c5dc73846a4abdc325cd234eb2d37469f 29-May-2012 Jean Chalard <jchalard@google.com> Add/refine comments to reflect key event policies

Make clearer how the platform is handling key events following some
unfortunate uses by third party applications. Also highlight the
changes in Jelly Bean default keyboard.

Bug: 6566711
Change-Id: Ibcdaf54c6d629fd0733529bfe2fffc82f555f084
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
39d23bddef15cd3f5fd2f336afe193c912d32ac3 25-Jan-2012 Fabrice Di Meglio <fdimeglio@google.com> Update Javadoc for InputConnection.deleteSurroundingText()

- give more precision about how the text is considered

Change-Id: Ie2f09bb3338e7dc0e98da0595d1500a6352d09d3
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
0c95dd3f4f02564fab9b86a221bbcbb4aafc2981 24-Jan-2012 Fabrice Di Meglio <fdimeglio@google.com> Fix bug # 5863709 API request: Change param names of deleteSurroundingText to "before" and "after"

Change-Id: I727fad9a59cda915899674569bfabd29b9f5da60
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
9567a66a5e6f49dd8495fb5f6e2efb9f32e84b35 20-Apr-2011 Dianne Hackborn <hackbod@google.com> Deprecate a bunch of APIs.

And clean up some documentation.

Change-Id: I7882183b3daf883b7ac6098d19f88dc7cfbcdf61
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
e3797a15fbf769a0abcbe121cfd33b4b658aea1e 21-Mar-2011 satok <satok@google.com> Removed APIs for setCorrectionSpan from InputConnection

("setCorrectionSpan" was added in Id3abc9ea4d11753cd )

Also..
- Added a class java doc for CorrectionSpan
- Removed FLAG_DEFAULT
- Changed the return type of getSuggestions from Array<CharSequence> to String[]

Change-Id: If5eb091e307a7a40c5b4a70ec1fe6059ecd9fb2d
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
adb435835fb9a5f2bb74d29930b239dde18504a7 09-Mar-2011 satok <satok@google.com> Add CorrectionSpan and APIs to pass a secure CorrectionSpan to TextView

- CorrectionSpan is a span which has suggestions made by IME.
This has a function to change the current IME to other IME specified
in this span. For security reasons, only the current IME
is allowed to use this function through InputConnection.
(IME token is used for checking the validity of it.).

- CorrectionSpan stores following information:

flags, subtype Id, InputMethodInfo Id, suggests, locale, original string

Change-Id: Id3abc9ea4d11753cdc4f483a2bb3128f49ba198a
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
cf9cf2f40efc4ccf3f73e6fdb07725d9c00c4f91 09-Dec-2010 Gilles Debunne <debunne@google.com> New API in InputConnection to signal IME's text correction.

Scafolding so that the IME team can start working on this feature.

The animation part in the TextView is missing.

Change-Id: I8225538564370fba1500e3539742a8ab79bdd199
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
a90b7f0125389b9e1040d2be82aad4ef74ea6071 26-Aug-2010 Amith Yamasani <yamasani@google.com> Add methods to InputConnection: setComposingRegion() to select a region of text for correction, and getSelectedText()
to return the selected text.

setComposingRegion:

The TextView may choose to highlight the text in some way (underline for now) to indicate
that the text is selected for correction, if the IME wants to provider alternatives.

Choosing an alternative in the IME can then call IC.commitText() to replace the highlighted
(not selected) text with a different candidate.

This change also ensures that any existing spans/styles are not wiped out. So we can now
correct rich text as well.

getSelectedText:

This is a convenience to get the selected text instead of using extracted text that is
more heavy weight. Existing getTextBeforeCursor() and getTextAfterCursor() fail to
retrieve the selected text, only what's before and after the selection.

Change-Id: Ieb5ecd5ff947ea04958589f501e7bd5228e00fb5
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
b2a3dd88a53cc8c6d19f6dc8ec4f3d6c4abd9b54 09-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@137197
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
9066cfe9886ac131c34d59ed0e2d287b0e3c0087 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
076357b8567458d4b6dfdcf839ef751634cd2bfb 03-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@132589
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
3dec7d563a2f3e1eb967ce2054a00b6620e3558c 03-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@137055
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
3001a035439d8134a7d70d796376d1dfbff3cdcd 19-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@132276
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
da996f390e17e16f2dfa60e972e7ebc4f868f37e 13-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@131421
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
d24b8183b93e781080b2c16c487e60d51c12da31 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
f1e484acb594a726fb57ad0ae4cfe902c7f35858 22-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@127436
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
b798689749c64baba81f02e10cf2157c747d6b46 10-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@125939
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java
f013e1afd1e68af5e3b868c26a653bbfb39538f8 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
/frameworks/base/core/java/android/view/inputmethod/InputConnection.java