Disable batching in InputEventReceiver for inking

Use unbatched events in IMF for lower latency.

Bug: 289864334
Bug: 287109569
Test: Manually using logcat & HandwritingIme

Change-Id: I11af096da743dadfa3361c236c224fceb7f7562b
This commit is contained in:
Taran Singh
2023-07-06 22:42:34 +00:00
parent d3813b1887
commit cadc2c2c66

View File

@@ -103,11 +103,10 @@ import android.util.PrintWriterPrinter;
import android.util.Printer;
import android.util.Xml;
import android.util.proto.ProtoOutputStream;
import android.view.BatchedInputEventReceiver.SimpleBatchedInputEventReceiver;
import android.view.Choreographer;
import android.view.Gravity;
import android.view.InputChannel;
import android.view.InputDevice;
import android.view.InputEvent;
import android.view.InputEventReceiver;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
@@ -1052,17 +1051,22 @@ public class InputMethodService extends AbstractInputMethodService {
stylusEvents.forEach(InputMethodService.this::onStylusHandwritingMotionEvent);
// create receiver for channel
mHandwritingEventReceiver = new SimpleBatchedInputEventReceiver(
channel,
Looper.getMainLooper(), Choreographer.getInstance(),
event -> {
mHandwritingEventReceiver = new InputEventReceiver(channel, Looper.getMainLooper()) {
@Override
public void onInputEvent(InputEvent event) {
boolean handled = false;
try {
if (!(event instanceof MotionEvent)) {
return false;
return;
}
onStylusHandwritingMotionEvent((MotionEvent) event);
scheduleHandwritingSessionTimeout();
return true;
});
handled = true;
} finally {
finishInputEvent(event, handled);
}
}
};
scheduleHandwritingSessionTimeout();
}