Merge "Clean up setInputChannelLocked"
This commit is contained in:
@@ -921,7 +921,7 @@ public final class InputMethodManager {
|
||||
mRequestUpdateCursorAnchorInfoMonitorMode =
|
||||
REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE;
|
||||
|
||||
setInputChannelLocked(res.channel);
|
||||
updateInputChannelLocked(res.channel);
|
||||
mCurMethod = res.method; // for @UnsupportedAppUsage
|
||||
mCurBindState = new BindState(res);
|
||||
mCurId = res.id; // for @UnsupportedAppUsage
|
||||
@@ -1623,7 +1623,7 @@ public final class InputMethodManager {
|
||||
void clearBindingLocked() {
|
||||
if (DEBUG) Log.v(TAG, "Clearing binding!");
|
||||
clearConnectionLocked();
|
||||
setInputChannelLocked(null);
|
||||
updateInputChannelLocked(null);
|
||||
mCurId = null; // for @UnsupportedAppUsage
|
||||
mCurMethod = null; // for @UnsupportedAppUsage
|
||||
// We only reset sequence number for input method, but not accessibility.
|
||||
@@ -1648,28 +1648,38 @@ public final class InputMethodManager {
|
||||
mAccessibilityInputMethodSession.clear();
|
||||
}
|
||||
|
||||
void setInputChannelLocked(InputChannel channel) {
|
||||
if (mCurChannel == channel) {
|
||||
return;
|
||||
}
|
||||
if (mCurChannel != null && channel != null
|
||||
&& mCurChannel.getToken() == channel.getToken()) {
|
||||
// channel is a dupe of 'mCurChannel', because they have the same token, and represent
|
||||
// the same connection. Ignore the incoming channel and keep using 'mCurChannel' to
|
||||
// avoid confusing the InputEventReceiver.
|
||||
@GuardedBy("mH")
|
||||
private void updateInputChannelLocked(InputChannel channel) {
|
||||
if (areSameInputChannel(mCurChannel, channel)) {
|
||||
return;
|
||||
}
|
||||
// TODO(b/238720598) : Requirements when design a new protocol for InputChannel
|
||||
// channel is a dupe of 'mCurChannel', because they have the same token, and represent
|
||||
// the same connection. Ignore the incoming channel and keep using 'mCurChannel' to
|
||||
// avoid confusing the InputEventReceiver.
|
||||
if (mCurSender != null) {
|
||||
flushPendingEventsLocked();
|
||||
mCurSender.dispose();
|
||||
mCurSender = null;
|
||||
}
|
||||
|
||||
if (mCurChannel != null) {
|
||||
mCurChannel.dispose();
|
||||
}
|
||||
mCurChannel = channel;
|
||||
}
|
||||
|
||||
private static boolean areSameInputChannel(@Nullable InputChannel lhs,
|
||||
@Nullable InputChannel rhs) {
|
||||
if (lhs == rhs) {
|
||||
return true;
|
||||
}
|
||||
if (lhs == null || rhs == null) {
|
||||
return false;
|
||||
}
|
||||
return lhs.getToken() == rhs.getToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all of the state associated with a served view being connected
|
||||
* to an input method
|
||||
@@ -2384,7 +2394,7 @@ public final class InputMethodManager {
|
||||
}
|
||||
mVirtualDisplayToScreenMatrix = res.getVirtualDisplayToScreenMatrix();
|
||||
if (res.id != null) {
|
||||
setInputChannelLocked(res.channel);
|
||||
updateInputChannelLocked(res.channel);
|
||||
mCurMethod = res.method; // for @UnsupportedAppUsage
|
||||
mCurBindState = new BindState(res);
|
||||
mAccessibilityInputMethodSession.clear();
|
||||
|
||||
Reference in New Issue
Block a user