summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java6
-rw-r--r--core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java22
2 files changed, 24 insertions, 4 deletions
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 72981b1296f2..bcc56514edfb 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -2827,8 +2827,8 @@ public final class InputMethodManager {
}
// If immediate bit is set, we will call updateCursorAnchorInfo() even when the data has
// not been changed from the previous call.
- final boolean isImmediate = (mRequestUpdateCursorAnchorInfoMonitorMode &
- CURSOR_UPDATE_IMMEDIATE) != 0;
+ final boolean isImmediate = mServedInputConnection != null
+ && mServedInputConnection.resetHasPendingImmediateCursorAnchorInfoUpdate();
if (!isImmediate && Objects.equals(mCursorAnchorInfo, cursorAnchorInfo)) {
// TODO: Consider always emitting this message once we have addressed redundant
// calls of this method from android.widget.Editor.
@@ -2847,8 +2847,6 @@ public final class InputMethodManager {
mCurrentInputMethodSession.updateCursorAnchorInfo(cursorAnchorInfo);
}
mCursorAnchorInfo = cursorAnchorInfo;
- // Clear immediate bit (if any).
- mRequestUpdateCursorAnchorInfoMonitorMode &= ~CURSOR_UPDATE_IMMEDIATE;
}
}
diff --git a/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java b/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java
index 09394c1ebf41..2bef10f1aee5 100644
--- a/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java
+++ b/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java
@@ -177,6 +177,8 @@ public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub
private final AtomicBoolean mHasPendingInvalidation = new AtomicBoolean();
private final AtomicBoolean mIsCursorAnchorInfoMonitoring = new AtomicBoolean(false);
+ private final AtomicBoolean mHasPendingImmediateCursorAnchorInfoUpdate =
+ new AtomicBoolean(false);
public RemoteInputConnectionImpl(@NonNull Looper looper,
@NonNull InputConnection inputConnection,
@@ -225,6 +227,23 @@ public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub
}
/**
+ * Gets and resets {@link #mHasPendingImmediateCursorAnchorInfoUpdate}.
+ *
+ * <p>Calling this method resets {@link #mHasPendingImmediateCursorAnchorInfoUpdate}. This
+ * means that the second call of this method returns {@code false} unless the IME requests
+ * {@link android.view.inputmethod.CursorAnchorInfo} again with
+ * {@link InputConnection#CURSOR_UPDATE_IMMEDIATE} flag.</p>
+ *
+ * @return {@code true} if there is any pending request for
+ * {@link android.view.inputmethod.CursorAnchorInfo} with
+ * {@link InputConnection#CURSOR_UPDATE_IMMEDIATE} flag.
+ */
+ @AnyThread
+ public boolean resetHasPendingImmediateCursorAnchorInfoUpdate() {
+ return mHasPendingImmediateCursorAnchorInfoUpdate.getAndSet(false);
+ }
+
+ /**
* @return {@code true} if there is any active request for
* {@link android.view.inputmethod.CursorAnchorInfo} with
* {@link InputConnection#CURSOR_UPDATE_MONITOR} flag.
@@ -1010,6 +1029,8 @@ public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub
// requestCursorUpdates() is not currently supported across displays.
return false;
}
+ final boolean hasImmediate =
+ (cursorUpdateMode & InputConnection.CURSOR_UPDATE_IMMEDIATE) != 0;
final boolean hasMonitoring =
(cursorUpdateMode & InputConnection.CURSOR_UPDATE_MONITOR) != 0;
boolean result = false;
@@ -1020,6 +1041,7 @@ public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub
// TODO(b/199934664): See if we can remove this by providing a default impl.
return false;
} finally {
+ mHasPendingImmediateCursorAnchorInfoUpdate.set(result && hasImmediate);
mIsCursorAnchorInfoMonitoring.set(result && hasMonitoring);
}
}