When a translated Activity is destroyed or translation is finished
(e.g., finishTranslation() call), we also have to remove the entry in
the active translations we are keeping track in
TranslationManagerService. Prior to this change, we were not removing
the entry in the Activity destroyed case, and this caused problems when
a new callback is registered (e.g., Gboard) because it would incorrectly
get an onStarted() call for the now-inactive translation.
This can happen relatively frequently when the device has a work
profile, since switching to apps across profiles re-creates the IME, and
in the case of Gboard, it registers a callback every time.
Also added additional logging on Activity destroyed and when callbacks
are registered and triggered.
Bug: 245911471
Test: atest UiTranslationManagerTest
Change-Id: If1881fd4588725021d38e5b9336c3e69bca17039
Found many logs in bugreport that call sendEvents() even the buffer
is empty. We should avoid unnecessary API call to reduce ipc spam.
This change doesn't fix the potential ipc spam issue, only mitigates
the issue.
Bug: 231313913
Test: manual. Local add log and see the empty api call is skipped
Change-Id: I9c8afc5ae2d06074900886cf5743b1ec61ccb973
This will be used to denote the single-finger touches that
TouchInputMapper creates to simulate scrolling when the user makes
two-finger swipes on the touchpad.
Bug: 246758376
Test: check new value is sent to a test app when scrolling on a touchpad
Change-Id: Id93cba764522e36d850f7013ab8a117f64716fac
Add InputConnecton#replaceText(int, int, CharSequence, int, TextAttribute) API to support replacing the specific range in the editor with suggested text.
Add default implementation in InputConnection which delegates to call
finishComposingText()+setSelection()+commitText().
Add implementation in BaseInputConnection which will address the issue
of selection flash.
Bug: 241503197
Test: atest FrameworksCoreTests:BaseInputConnectionTest
Test: atest CtsInputMethodTestCases:BaseInputConnectionTest
Change-Id: Ia0e42270cfae112fcf19205a7151e4ab4ac4afdd
The API overrideHdrTypes should be per display. Add an API into DMS so
DMS can set the override with the correct displayToken. Remove usage of
getInternalDisplayToken in DisplayTests
Test: DisplayTest
Bug: 242714168
Change-Id: Ib338624a71a897d8d718080850f672a219f9627e
This reverts commit 975dd2c513.
Reason for revert: This is too risky for tm-qpr1
Bug: 161810301
Bug: 175861564
Change-Id: If906b4d538885fca407ce0bd7039c9d35b507032
Set VIEW_STATE_FOCUSED state when view and window gain focus or it could
draw a wrong highlight hint on non-focused window.
Bug: 244273901
Test: atest DefaultFocusHighlightTest
Test: multi-window, use dpad key to navigate focus
Change-Id: Iabf58f41fe376d5921b679d53ec82c67650d4988
If the crop value passed in the args for captureDisplay is invalid, use
the display bounds instead.
Test: WindowManagerServiceTests#testCaptureDisplay
Bug: 242714168
Change-Id: Iebe42fd35c5f49b6e711699aa1b986a556a5a5f8
As isRestartOnNextWindowFocus is to check
InputMethodManager#mRestartOnNextWindowFocus flag if the input
connection is needed to force re-start when calling
startInputAsyncOnWindowFocusGain during gaining the window focus
from ImeFocusController#onPostWindowFocus next time.
(e.g. Switching IME apps from IME picker dialog)
Since in startInputOnWindowAyncFocusGain can just check
mRestartOnNextWindowFocus directly without exposing
isRestartOnNextWindowFocus, we could just simplied with inlining
the check logic.
Also, noticed in startInputAsyncOnWindowFocusGain has already reverted
CL[1]'s asynchronize starting input logic for some reasons, as a result,
renaming to startInputOnWindowFocusGain in case misleading.
[1]: I6aa4a664cfd0c86f75cee2457715317194bbe5e2
Bug: 244504062
Test: atest CtsInputMethodTestCases
Change-Id: I9335262136950021efb7b4b73c7eeb930e1333bb
As CL[1] added InputMethodManagerDelegate#getLockObject that used for
protecting mServedView/mNextServedView in ImeFocusController when we
exposed getServedView/getNextServedView for InputMethodManager to access
with thread safty.
Add synchornize block for all places that accessing
{mServedView, mNextServedView} in ImeFocusController.
[1]: I9c072b829d1db1e68b65e766d764ee71cb16e6a2
Bug: 244504062
Test: atest CtsInputMethodTestCases
Change-Id: I8357bfafeaf0a40e3b74eec2fc59a47309451f18
As ImeFocusController#set{Served, NextServed}View originally exposes to
InputMethodManager is only for clearing the served view in
IMM#finishInputLocked() with a special code logic:
```
setNextServedView(null);
if (getServedView() != null) {
// do finish input
setServedView(null);
}
```
which isn't necessary and can be clean-up with a method to notify
ImeFocusController to clear the served / next served view, then doing
the rest of finshing logic when the method has cleared the served view:
```
if (controller.clearServedViewsLocked() != null) {
// do finish input
}
```
With this change, we can simply remove the set{Served, NextServed}View
to get rid of this dependency with InputMethodManager.
Bug: 244504062
Test: atest CtsInputMethodTestCases
Change-Id: Ibcde35765c0e2e6c372aa64dbc7e774a8d860543
As CL[1] introduces per-window based ImeFocusController for handling
the IME served view focus update logic.
However, for InputMethodManager APIs requires to access
ImeFocusController#{mServedView, mNextServedView} for starting the input
connection or checking the caller's validity, which needs a lock for
thread safety.
As a result, it would make sense to expose mH for ImeFocusController
through an new method InputMethodManagerDelegate#getLockObject
to protect the data consistancy during InputMethodMananger APIs
invoking to access the served view.
Also, renaming the methods (and update the javadoc) with "Locked" sufix:
- ImeFocusController#get{Served, NextServed}View
- ImeFocusController#set{Served, NextServed}View
Note that this is a refactoring preperation CL with added a TODO that
will use getLockObject in the follow-up CL.
[1]: Ib455704fe1e9d243f93190a84f230210dbceac2a
Bug: 244504062
Test: atest CtsInputMethodTestCases
Change-Id: I9c072b829d1db1e68b65e766d764ee71cb16e6a2
Sometimes, views may not be visible for the user immediately after
laid out, so add flag for do the evaluation once the view is visible.
Bug: 234429643
Test: Manual, check the fill dialog is appeared
Change-Id: I6b96b68ffc4a4b1ee5f5056848c5c4996d21ae73
Allow clients to request a display screen capture using a specified
displayId. The caller can pass in their own required arguments and they
will get the screenshot via an async callback directly from SF.
Test: ScreenshotTests
Bug: 242714168
Change-Id: I387f58d342f01ae71b85311fbf0634f0e7901f7d