Wake up Android phone to interrupt, on GPIO

On the Android development platform, I'm trying to wake up an AP based on an interrupt received in GPIO, can someone help me with this?

My understanding:

We need to create an input device and update the event to this device based on the received interrupt. Then from the application, I believe that the OS will send an event notification, and then we should use wakelock to wake up the access point.

Please let me know if my understanding is correct? If so, can you tell me what type of input device you need to register (EV_PWR, EV_KEY ..), how will the application receive a notification, and can we wake up the AP from the driver?

+6
source share
1 answer

General event propagation model (simplified): when an input occurs, the kernel generates an event. The input event is read by the event handler and sent to the foreground application. Several keys are sent to a particular application instead of being sent to the foreground application. For example, the Windows button on the keyboard is sent to the Start menu, the play / pause button is sent to the media player application, even if it is not in the foreground.

In the case when Android system_server reads events from the kernel, it goes to the foreground view / view. This is done for all input events, with the exception of the power key, home button, etc., which is handled by the Android window manager or system. PhoneWindowManager.java has the window manager code; it receives the KEYCODE_POWER event when the power key is pressed. In this case, if the screen is turned on and the lock for display is not saved, the screen is locked (by calling goToSleep in the PowerManager), similarly, if the screen is turned off, then the screen turns on (by calling wakeUp in the PowerManager).

isWakeKey at http://androidxref.com/5.1.0_r1/xref/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java#4512 will be set to true when you press and release the power button. The code will call wakeUp or goToSleep depending on the current state of the screen.

+1
source

Source: https://habr.com/ru/post/971302/


All Articles