Merge "Deprecate mRequestUpdateCursorAnchorInfoMonitorMode part 2"
This commit is contained in:
committed by
Android (Google) Code Review
commit
f0122ad578
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
@@ -224,6 +226,23 @@ public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub
|
||||
return mServedView.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user