Introduce ImeEventStream
This CL introduces ImeEventStream that represents the event stream of
ImeEvent objects. This is similar to read-only file stream, except
that some of methods do support timeout operation.
try(MockImeSession imeSession = MockImeSession.create(
InstrumentationRegistry.getContext(),
InstrumentationRegistry.getInstrumentation().getUiAutomation(),
new ImeSettings.Builder()) {
final ImeEventStream stream = imeSession.openEventStream();
final Optional<ImeEvent> result = stream.seekToFirst(event -> {
if (!TextUtils.equals("bindInput", event.getEventName())) {
return false;
}
final InputBinding binding =
event.getArguments().getParcelable("binding");
return binding.getPid() == Process.myPid();
}, TIMEOUT);
// Create a new stream that has the same stream position.
final ImeEventStream newStream = stream.copy();
// Moving the current position of "stream" does not affect the
// current position of "newStream".
stream.skip(1);
}
Further operations will be added in subsequent CLs.
Bug: 69845539
Test: atest CtsInputMethodTestCases
Change-Id: I1595f0747621871b7cc47e905b2ad3931779955a
2 files changed