History log of /frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
9d69ecbf61a4a142c3f4cbb9d5659faa6f85e832 25-Feb-2012 Gilles Debunne <debunne@google.com> InputConnection is warned when finished

As said in https://android-git.corp.google.com/g/#/c/155992
finishComposingText is indeed too broad of a method.

Introducing a new dedicated method to warn the InputConnection.

Should solve the problems with a negative counter value.

Change-Id: I5525d776916f0c42d5e6d4a4282aed590d7f0e9a
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
c478c171e92b2f255e9699d9c9306b001368ac20 20-Dec-2011 Gilles Debunne <debunne@google.com> Unbalanced batch edit begin and end leave TextView unresponsive

This is a fix for http://code.google.com/p/android/issues/detail?id=17508

Adding some logs and a forced GC, I'm now reliably able to reproduce it. Here is the scenario.

1. The IME handles an event. It retrieves the current InputConnection (IC) using
ic = getCurrentInputConnection() and calls ic.beginBatchEdit();
2. The call is propagated to the UI thread and TextView's mBatchEditNesting
is correctly increased through beginBatchEdit()
3. A listener calls setText(), which imm.restartInput(this);
4. As a result, the InputMethodManager creates a new ControlledInputConnectionWrapper
with a new InputConnection from the TextView
5. A GC happens at that point. The previous InputConnection is no longeri
referenced by the InputMethodManager's mServedInputConnection.
The weak reference in the previous ControlledInputConnectionWrapper is nulled.
6. The IME thread finishes its process and calls ic.endBatchEdit(); on its version
of the original InputConnection.
7. The message is passed through the InputConnect, but when the weak reference in the
original IInputConnectionWrapper is dereferenced, we get a null InputConnection in
executeMessage().
8. As a result, the TextView's endBatchEdit() method is not called, leaving this TextView
with a non zero mBatchEditNesting.
9. From now on, all edit actions on this TextView will be considered part of a nested edition
and no invalidation is performed, which is the visible manifestation of this bug.

The core problem is that the begin/end batch edit contract is broken when:
1. These are initiated by the IME thread (as opposed to the UI thread)
2. The input connection is reset between these calls
3. A GC happens in the mean time and the WeakReference is lost (otherwise
calling endBatchEdit on a no longer active InputConnection is fine

Solution to keep TextView's mBatchEditNesting balanced:

- The IMM should notify the IC when it is no longer used. We're using the
existing FINISH_INPUT_CONNECTION to do that.
- The InputConnection should keep track of its nesting contribution to the TextView.
When finished the IC makes sure its contribution is reset to 0.
Moreover, further asynchonous calls to begin/endBatchEdit that may arrive from the IME
should be ignored. This is achieved using a negative value as a flag.

Notes:

- finishComposingText may be too broad of a method to perform such a cleaning step
but is seems to only be called in cases where the IC will not be used anymore.
If that's too broad, we have to introduce a new method in the IC interface.

- This is has been implemented in EditableInputConnection and not in a more general
BaseInputConnection because this is where we have a notion of TextEdit, and the
nesting problem is here specific to TextView.
However, the same unbalanced begin/end problem will happen in these classes. They
should override finishComposingText as has been done here if that matters.

- We cannot re-use the TextView's mBatchEditNesting since it may take into account
batch edit from various sources and resetting it on InputConnection close could
then lead to an inconsistent negative count value.

Patch Set 2: added synchronized blocks around mBatchEditNesting

Change-Id: I1ec5518fdc16fb0551fbce9d13f5d92eb4bc78c0
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
f9f01008624e2d28c15a90d942fa36f98c8c967d 19-May-2011 satok <satok@google.com> Add Apis to send notifications when the suggestion was picked

- Due to a strong request from VoiceIME

Bug: 4443922

Change-Id: Ia539de0acf66053e0349daec459d75e36805f6bf
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
b3fc1a5b8b8f88eaf00b05957523cbdc0944b24b 06-Apr-2011 satok <satok@google.com> Rename CorrectionSpan to SuggestionSpan

Change-Id: I004b2e012b2de4de959a31da1f55b63ca7c14199
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.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/com/android/internal/widget/EditableInputConnection.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/com/android/internal/widget/EditableInputConnection.java
b7fc63f7aac3689696f7f84953009b5928ac3db3 28-Jan-2011 Gilles Debunne <debunne@google.com> Fix for TextView's error popup behavior when using soft keyboard.

Bug 3370191

The documented behavior is to hide the error when the text changes.
However, this should not be the case if the error was reset by a text watcher.

Comparing errorBefore and errorAfter as was done before is not sufficient in the
case where the error is reset to the same value. String pool optimization will re-use
the same Object and it will look like the error has not been modified (hence the
blinking behavior reported in the bug).

For this reason, TextView has a mErrorWasChanged flag. The fix is to export methods
that can use this flag as in done inside TextView when a physical keyboard is used.

These methods are hidden.

Change-Id: Ie3ec59a368f3b1588b81242890b971ac48e8ff7e
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
a85467bc8da8d4cecd47ed30da04c72c4f7bd842 20-Jan-2011 Gilles Debunne <debunne@google.com> Error popup no longer flickers in TextViews.

The removed lines were committed by the Android Open Source Project.
Their intent was probably: the message was there before, it is identical
after a text change, let's remove it to not annoy the user who already saw it.

The behavior however is that the message is displayed then hidden, then displayed
as the user types.

Bug 3365016

Change-Id: Ie820f8e5465ad8ab5890272c42627686e0d7961b
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.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/com/android/internal/widget/EditableInputConnection.java
51bf077883df4f5cc816fbfec6d19eedffc26d70 25-Mar-2009 Dianne Hackborn <> Automated import from //branches/master/...@141004,141004
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
9066cfe9886ac131c34d59ed0e2d287b0e3c0087 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
076357b8567458d4b6dfdcf839ef751634cd2bfb 03-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@132589
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
3dec7d563a2f3e1eb967ce2054a00b6620e3558c 03-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@137055
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
3001a035439d8134a7d70d796376d1dfbff3cdcd 19-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@132276
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
d24b8183b93e781080b2c16c487e60d51c12da31 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
f1e484acb594a726fb57ad0ae4cfe902c7f35858 22-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@127436
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
b798689749c64baba81f02e10cf2157c747d6b46 10-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@125939
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java
f013e1afd1e68af5e3b868c26a653bbfb39538f8 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
/frameworks/base/core/java/com/android/internal/widget/EditableInputConnection.java