@@ -198,10 +198,6 @@ void FakeInputDispatcherPolicy::assertNotifyInputChannelBrokenWasCalled(const sp
198198 ASSERT_EQ (token, *receivedToken);
199199}
200200
201- void FakeInputDispatcherPolicy::setInterceptKeyTimeout (std::chrono::milliseconds timeout) {
202- mInterceptKeyTimeout = timeout;
203- }
204-
205201std::chrono::nanoseconds FakeInputDispatcherPolicy::getKeyWaitingForEventsTimeout () {
206202 return 500ms;
207203}
@@ -210,8 +206,9 @@ void FakeInputDispatcherPolicy::setStaleEventTimeout(std::chrono::nanoseconds ti
210206 mStaleEventTimeout = timeout;
211207}
212208
213- void FakeInputDispatcherPolicy::setConsumeKeyBeforeDispatching (bool consumeKeyBeforeDispatching) {
214- mConsumeKeyBeforeDispatching = consumeKeyBeforeDispatching;
209+ void FakeInputDispatcherPolicy::setInterceptKeyBeforeDispatchingResult (
210+ std::variant<nsecs_t , inputdispatcher::KeyEntry::InterceptKeyResult> result) {
211+ mInterceptKeyBeforeDispatchingResult = result;
215212}
216213
217214void FakeInputDispatcherPolicy::assertFocusedDisplayNotified (ui::LogicalDisplayId expectedDisplay) {
@@ -404,7 +401,9 @@ bool FakeInputDispatcherPolicy::filterInputEvent(const InputEvent& inputEvent,
404401void FakeInputDispatcherPolicy::interceptKeyBeforeQueueing (const KeyEvent& inputEvent, uint32_t &) {
405402 if (inputEvent.getAction () == AKEY_EVENT_ACTION_UP) {
406403 // Clear intercept state when we handled the event.
407- mInterceptKeyTimeout = 0ms;
404+ if (std::holds_alternative<nsecs_t >(mInterceptKeyBeforeDispatchingResult )) {
405+ mInterceptKeyBeforeDispatchingResult = nsecs_t (0 );
406+ }
408407 }
409408}
410409
@@ -414,17 +413,20 @@ void FakeInputDispatcherPolicy::interceptMotionBeforeQueueing(ui::LogicalDisplay
414413std::variant<nsecs_t , inputdispatcher::KeyEntry::InterceptKeyResult>
415414FakeInputDispatcherPolicy::interceptKeyBeforeDispatching (const sp<IBinder>&, const KeyEvent&,
416415 uint32_t ) {
417- if (mConsumeKeyBeforeDispatching ) {
418- return inputdispatcher::KeyEntry::InterceptKeyResult::SKIP;
416+ if (std::holds_alternative<inputdispatcher::KeyEntry::InterceptKeyResult>(
417+ mInterceptKeyBeforeDispatchingResult )) {
418+ return mInterceptKeyBeforeDispatchingResult ;
419419 }
420420
421- nsecs_t delay = std::chrono::nanoseconds (mInterceptKeyTimeout ).count ();
421+ nsecs_t delay =
422+ std::chrono::nanoseconds (std::get<nsecs_t >(mInterceptKeyBeforeDispatchingResult ))
423+ .count ();
422424 if (delay == 0 ) {
423425 return inputdispatcher::KeyEntry::InterceptKeyResult::CONTINUE;
424426 }
425427
426428 // Clear intercept state so we could dispatch the event in next wake.
427- mInterceptKeyTimeout = 0ms ;
429+ mInterceptKeyBeforeDispatchingResult = nsecs_t ( 0 ) ;
428430 return delay;
429431}
430432
0 commit comments