1

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 Answers1

0

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.

Yong
  • 1,529
  • 12
  • 21
  • Way 2 does not fit. I cannot change the code of every application. I need to make a default reaction for all applications at once in my android assembly – Ayaz Hadoken Aug 16 '21 at 13:13
  • You can change frameworks/base/core/java/android/app/Activity.java. Then it will take effect for all apps. And some apps will intend to override Activity.onKeyDown to handle search key by itself. – Yong Aug 17 '21 at 02:09