summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Taran Singh <tarandeep@google.com> 2022-08-04 11:38:32 -0700
committer Taran Singh <tarandeep@google.com> 2022-08-11 14:27:09 -0700
commitec9266d4acdc0a4c014a31f170eccf85f5b74939 (patch)
treee4f3e485d4e1bd2d84b77a94619d3c8b6093d6f6
parent688a65880d9ae2337861f6043defb60d5da5cf26 (diff)
Few improvements for Companion widget APIs
1. reset ViewRootImpl#mLastClickToolType for KeyEvents 2. move EditorInfo#mInitialToolType initialization so we dont explicitly hold lock for one line of code. Bug: 233108064 Test: atest CtsInputMethodTestCases Change-Id: I76d3c4c14928a2eb4c1cda48dd3b9a866963d06f
-rw-r--r--core/java/android/view/ViewRootImpl.java6
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java5
2 files changed, 8 insertions, 3 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index f79f0d49959d..c90d6161acb0 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -6403,6 +6403,12 @@ public final class ViewRootImpl implements ViewParent,
// Make sure the fallback event policy sees all keys that will be
// delivered to the view hierarchy.
mFallbackEventHandler.preDispatchKeyEvent(event);
+
+ // Reset last tracked MotionEvent click toolType.
+ if (event.getAction() == KeyEvent.ACTION_DOWN) {
+ mLastClickToolType = MotionEvent.TOOL_TYPE_UNKNOWN;
+ }
+
return FORWARD;
}
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 0c03d109f649..7addf36308f3 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -2341,9 +2341,6 @@ public final class InputMethodManager {
editorInfo.packageName = view.getContext().getOpPackageName();
editorInfo.autofillId = view.getAutofillId();
editorInfo.fieldId = view.getId();
- synchronized (mH) {
- editorInfo.setInitialToolType(mCurRootView.getLastClickToolType());
- }
InputConnection ic = view.onCreateInputConnection(editorInfo);
if (DEBUG) Log.v(TAG, "Starting input: editorInfo=" + editorInfo + " ic=" + ic);
@@ -2383,6 +2380,8 @@ public final class InputMethodManager {
startInputFlags |= StartInputFlags.INITIAL_CONNECTION;
}
+ editorInfo.setInitialToolType(mCurRootView.getLastClickToolType());
+
// Hook 'em up and let 'er rip.
mCurrentEditorInfo = editorInfo.createCopyInternal();
// Store the previously served connection so that we can determine whether it is safe