Wake up android phone on an interrupt, on a GPIO
Asked Answered
E

1

6

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?

Electroscope answered 24/6, 2014 at 18:48 Comment(3)
Hi, I am able to wake up the AP based on interrupt. I have created input device which gives a KEY_POWER event on an interrupt, and the android power policy code will take care of waking up the AP.Electroscope
I am trying to understand how this is done. Can you give a little more details on your solution. Some example would be appreciated or at least links to documentation and examples.Maleate
I want to wake up Android from battery charger driver, for example when device is put in the cradle. Is there a way without creating input device?Caffey
C
2

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.

Commode answered 30/6, 2016 at 15:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.