2011年8月29日 星期一

Android Power Management, partial wake lock parts

Android 當在 running mode 按第一次 Power 鍵,關螢幕後,Linux kernel 應該是在early_suspend mode,因此如果跟第一次間隔很短(幾秒?)馬上按第二次 Power 鍵 resume 是直接回到關螢幕前的應用程式 intent。

但是如果第二次間隔跟第一次間隔時間,差距到讓 Linux kernel 進入 suspend mode,則resume 時會看到 Launcher 的螢幕鎖頭。

而卡在 early_suspend 會不會進入 suspend mode,則跟 Android 層是否有要 partial wake lock 有關。

目前已知有取得 partial wake lock 的服務(原來有這麼多 XD):

Android eclair-release branch

同步也會卡...

frameworks/base/core/java/android/content/SyncManager.java

正在關機

frameworks/base/core/java/com/android/internal/app/ShutdownThread.java

SD 卡格式化

frameworks/base/core/java/com/android/internal/os/storage/ExternalStorageFormatter.java

使用者互動

frameworks/base/libs/ui/EventHub.cpp

frameworks/base/services/java/com/android/server/WindowManagerService.java

frameworks/base/services/java/com/android/server/NotificationPlayer.java

鬧鐘
frameworks/base/services/java/com/android/server/AlarmManagerService.java

frameworks/base/media/java/android/media/AsyncPlayer.java

使用電話功能

frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

frameworks/base/telephony/java/com/android/internal/telephony/RIL.java

frameworks/base/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java

frameworks/base/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java

frameworks/base/telephony/java/com/android/internal/telephony/cdma/CdmaConnection.java

frameworks/base/telephony/java/com/android/internal/telephony/gsm/GsmConnection.java

frameworks/base/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java

RIL HAL driver
hardware/ril/libril/ril.cpp

frameworks/base/voip/java/com/android/server/sip/SipWakeLock.java

簡訊

frameworks/base/telephony/java/com/android/internal/telephony/SMSDispatcher.java
螢幕鎖

frameworks/base/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java

開啟 GPS 定位服務
frameworks/base/services/jni/com_android_server_location_GpsLocationProvider.cpp
frameworks/base/services/java/com/android/server/LocationManagerService.java
frameworks/base/services/java/com/android/server/location/GpsLocationProvider.java

聽音樂
frameworks/base/services/audioflinger/AudioPolicyService.cpp

藍芽耳機

frameworks/base/core/java/android/bluetooth/HeadsetBase.java

frameworks/base/core/java/android/bluetooth/ScoSocket.java

(有線?)耳機
frameworks/base/services/java/com/android/server/HeadsetObserver.java
frameworks/base/services/java/com/android/server/DevicePolicyManagerService.java

震動也會鎖

frameworks/base/services/java/com/android/server/VibratorService.java

開 Wifi 會鎖

frameworks/base/services/java/com/android/server/WifiService.java
frameworks/base/wifi/java/android/net/wifi/WifiStateTracker.java

備份??

frameworks/base/services/java/com/android/server/BackupManagerService.java

??
frameworks/base/services/java/com/android/server/am/ActivityStack.java

??
frameworks/base/tests/BatteryWaster/src/com/android/batterywaster/BatteryWaster.java

實作的檔案如下:

frameworks/base/core/java/android/os/Power.java

frameworks/base/core/java/android/os/PowerManager.java

frameworks/base/services/java/com/android/server/PowerManagerService.java

JNI 介接層:

frameworks/base/core/jni/android_os_Power.cpp

hardware/libhardware_legacy/include/hardware_legacy/power.h

hardware/libhardware_legacy/power/power.c