Android source. Edit Key events

Viewed 86

I want to reassign event, when user send KEYEVENT_SEARCH. Now it just start search activities in applications and if you press it second time - it doesn't do anything. I have to redefine the event so that the first click opens the search, and the next time it closes. Where can I find android push responses? I try edit it in frameworks/base/core/java/com/android/internal/policy/PhoneFallbackEventHandler.java , but it doesn't works.

1 Answers

Android keys are processed in the following sequence:

  1. PhoneWindowManager:
  • interceptKeyBeforeQueueing
  • interceptKeyBeforeDispatching
  1. Activity: onKeyDown/onKeyUp. App can override the function to handle keys.
  2. PhoneFallbackEventHandler: onKeyDown/onKeyUp

Currently, the search key is handled in 2. When handling search key in onKeyUp, firstly check whether the search dialog is launched, then choose to startSearch or closeSearch.

Related