android Power鍵按下後的函式流程
android手機中power鍵按下後控制著螢幕的喚醒與休眠,可以說是最重要的按鍵。它的運轉流程跟以下幾個檔案有關
InputDispatcher.cpp
void InputDispatcher::notifyKey(const NotifyKeyArgs* args)
com_android_server_input_InputManagerService.cpp
void NativeInputManager::interceptKeyBeforeQueueing(const KeyEvent* keyEvent,
uint32_t& policyFlags)
void NativeInputManager::handleInterceptActions(jint wmActions, nsecs_t when,
uint32_t& policyFlags)
PhoneWindowManager.java
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn)
com_android_server_power_PowerManagerService.cpp
void android_server_PowerManagerService_goToSleep(nsecs_t eventTime)
void android_server_PowerManagerService_wakeUp(nsecs_t eventTime)
PowerManagerService.java.
private void wakeUpFromNative(long eventTime)
private void goToSleepFromNative(long eventTime, int reason)
按以上排列的順序一路走下來,然後在PowerManagerService中設定相關標誌位,開關螢幕