How does Android OS listen for a Power Button press?

I am looking for an implementation in android source of how to display the power button to turn off the screen. I am working on a custom ROM and am trying to find the connection between two events (key press and screen off). I found the screen state is changing in frameworks / base / services / java / com / android / server / PowerManagerService.java , but I can't see anything related to the power button itself.

Thank you for your help.

+3


source to share


1 answer


Have a look at com.android.internal.policy.impl.WindowManagerPolicy.java. This handles dispatching key events to the appropriate location and also provides custom handling of the power button.



In particular, you might be interested in interceptKeyBeforeQueueing () or just search for KEYCODE_POWER .

+1


source







All Articles