I'm looking for the implementation in the Android source on how the power button is mapped to turning the screen off. I am working on a custom ROM and am trying to find the relationship between the two events (short key press and screen turning off). I am finding that the screen state changes in frameworks/base/services/java/com/android/server/PowerManagerService.java, but I don't see anything related to the power button itself.

Thank you for your help.

有帮助吗?

解决方案

Look in com.android.internal.policy.impl.WindowManagerPolicy.java. This handles dispatching of key events to the appropriate place and also provides custom handling of the power button.

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top