Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wake up android phone on an interrupt, on a GPIO

On Android development board, I am trying to wake up the AP based on an interrupt received on a GPIO, can anybody help me with this?

My understanding on this is:

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

Please let me know if my understanding is correct? If yes, then can you tell me which kind of input device needs to be registered (EV_PWR, EV_KEY ..), how the application will get a notification, and can we wake up the AP from the driver?

like image 337
kumar Avatar asked Jun 24 '14 18:06

kumar


1 Answers

General input event propagation model (simplified): When an input occurs an event is generated by the kernel. The input event is read by input event handler and it is dispatched to the foreground application. Few keys are sent to some specific application instead of being sent to foreground application. For example Windows button in keyboard is sent to start menu, play / pause button is sent to media player app even if it is not in foreground.

In case of Android system_server reads events from kernel, it is passes to foreground application / view. This is done for all input events except for power key, home button etc which is handled by Android's window manager or systemui. PhoneWindowManager.java has the window manager code, it gets KEYCODE_POWER event when power key is pressed. In that case if the screen is on and no wake lock for display is held then screen is locked (by calling goToSleep in PowerManager), similarly if the screen is off then screen is turned on (by calling wakeUp in 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 power button is pressed & released. The code will call wakeUp or goToSleep depending on the current screen state.

like image 101
prasannatsm Avatar answered Oct 04 '22 09:10

prasannatsm