@ Normal Linux suspend
- Source code : kernel_src/kernel/main.c
kernel_src/kernel/arch/arm/mach-xxx/pm.c
- userspace interface: /sys/power/state
You can trace kernel_src/kernel/main.c
echo mem > /sys/power/state
echo standby > /sys/power/syste
- Process
1. suspend_prepare()
2. suspend_freeze_processes(): freeze all process.
3. suspend all devices : suppend_device_and_enter() at kernel/power/suspend.c suspend_device_and_enter() {
.......
dpm_suspend_start(PMSG_SUSPEND)
.......
}
dpm_suspend_start(PMSG_SUSPEND)
{
.......
dpm_suspend()
......
}
dpm_suspend()
{
......
;call all device callback function suspend()
get_device(dev);
device_suspend(dev);
......
}
4. Resume:
1. Get wake up event
2. Resume the devices /sys/devices/system
3. call suspend_ops -> finish() and let it start resume
4. call every devices resume in suspend_devices_and_enter()
5. call suspend_ops -> end()
6. call suspend_finish which will thaw the process and enter user mode helper
@ Android suspend : request_suspend_state() in kernel/power/earlysuspend.c
- Early suspend function
- wakelock function
You can study
- kernel_src/kernel/power/main.c
- kernel_src/kernel/power/earlysuspend.c
- kernel-src/kernel/power/wakelock.c
Definition:
http://kzjblog.appspot.com/2010/11/20/suspend-en.html
- Early Suspend
Early suspend is a mechanism that android introduced into linux kernel.
This state is btween really suspend, and trun off screen. After Screen is off,
several device such as LCD backlight, gsensor, touchscreen will stop for battery life and functional requirement.
- Late Resume
Late resume is a mechinism pairs to early suspend, executed after the kernel and system resume finished.
It will resume the devices suspended during early suspend.
- Wake Lock
Wake lock acts as a core member in android power management system.
wake lock is a lock can be hold by kernel space ,system servers and applications with or without timeout.
In an android patched linux kernel (referenced as android kernel below) will timing how many and how long the lock have.
If there isn't any of wake lock prevent suspend(WAKE_LOCK_SUSPEND),
android kernel will call linux suspend (pm_suspend()) to let entire system going to suspend.
Trace code :
Early suspend :
- state_store() /kernel/power/main()
you write "mem > /sys/power/state" and it will call this function
- state_store(){
request_suspend_state(); ---> call early_suspend_work -> early_suspend()
}
- early_suspend()
{
call early_suspend_handler () function in evenry deivces
}
Late Resume:
After all the kernel resume is finished,
the user space process and service is running, the wake up of system for these reasons:
* If In Calling, the modem will send command to rild (RING command),
and rild will send message to WindowManager and Application to deal with in call event,
PowerManagerSerivce also will write "on" to interface to let kernel execute late resume.
* User Key EventWhen system waked by a key event, such as a power key, or menu key,
these key event will send to WindowManager, and it will deal with it, if the key is not the key can wake up system,
such as return key/home key, the WindowManager will drop the wake lock to let system going to suspend again.
if the key is a wake key, the WindowManager will RPC PowerManagerSerivce interface to execute late resume.
* Late Resume will call the resume func in list of early suspend devices.
* Android power management :
reference:http://www.netmite.com/android/mydroid/development/pdk/docs/power_management.html
- Flow:
Application layer : application using wl.newWakeLock(), wl.acquire() and wl.release()
Application framwork: PowerManagement (Android.os.PowerManager)
Power (Android.os.Power)
PowerManagerService (Android.server.PowerManageService)
JNI layer : Power (lib/hardware/power.c)
Linux kernel : Android Power Management (driver/android/power.c)
Linux driver (android_register_early_suspend(), android_register_early_resume())
Linux power Management
- source :
frameworks/base/core/java/android/os/PowerManager.java
frameworks/base/services/java/com/android/server/PowerManagerService.java
frameworks/base/core/java/android/os/Power.java
frameworks/base/core/jni/android_os_power.cpp
hardware/libhardware/power/power.c
2011年8月31日 星期三
2011年8月18日 星期四
change bash when build android source code
build android error
--> dash can't run source
solution 1:
Added "SHELL=/bin/bash" into Makefile
--> dash can't run source
solution 1:
sudo dpkg-reconfigure dash ->選No
把default sh改成bash。
solution2 :Added "SHELL=/bin/bash" into Makefile
2011年8月7日 星期日
Using search and replace in vi
============================================================================
Using vi to search and replace
This is about as complicated as it gets in vi, since search and replace sytnax is taken from the UNIX sed (stream editor) command.
>> Global search and replace --> :1,$ s/old/new/g
^ ^ ^ ^ ^
In english, this means: | | | | |
| | | | |
From 1 to $ (end of file) | | | |
| | | |
substitute -----------------/ | | |
| | |
occurrences of "old" ----------/ | |
| |
with occurrences of "new" --------/ |
|
globally (i.e., all instances of "old")
========================================================================
Using sed command to replace string in file
#sed -i 's/old/new/g' filename.txt
Using vi to search and replace
This is about as complicated as it gets in vi, since search and replace sytnax is taken from the UNIX sed (stream editor) command.
>> Global search and replace --> :1,$ s/old/new/g
^ ^ ^ ^ ^
In english, this means: | | | | |
| | | | |
From 1 to $ (end of file) | | | |
| | | |
substitute -----------------/ | | |
| | |
occurrences of "old" ----------/ | |
| |
with occurrences of "new" --------/ |
|
globally (i.e., all instances of "old")
========================================================================
Using sed command to replace string in file
#sed -i 's/old/new/g' filename.txt
linux find command
find command:
;find string in current folder all files
#find . -exec grep 'test' {} \;
*{}: this list all files
*\ : this is ending word
The -exec action takes a Unix command (along with its options) as an argument.
The arguments should contain {} (usually quoted), which is replaced in the command with the name of the currently found file.
The command is terminated by a semicolon, which must be quoted ("escaped") so the shell will pass it literally to the find command.
;rm file in current folder all files
#find . -name oo.txt -print -exec rm -f {} \;
;find 00.txt file only looking for file under this folder
#find . -name oo.txt -type f
;find 00.txt file only looking for folder type under this folder
#find . -name 00.txt -type d
using xargs command in find command
#find whatever....| args commnad
xargs is command to execute commnd line from standard input.
;list file
#find . -name xx.txt -print | xargs ls -l
;rmmove files from test folder
#find ./test -type f -print0 | xargs -0 rm
more information in "http://en.wikipedia.org/wiki/Xargs"
;find string in current folder all files
#find . -exec grep 'test' {} \;
*{}: this list all files
*\ : this is ending word
The -exec action takes a Unix command (along with its options) as an argument.
The arguments should contain {} (usually quoted), which is replaced in the command with the name of the currently found file.
The command is terminated by a semicolon, which must be quoted ("escaped") so the shell will pass it literally to the find command.
;rm file in current folder all files
#find . -name oo.txt -print -exec rm -f {} \;
;find 00.txt file only looking for file under this folder
#find . -name oo.txt -type f
;find 00.txt file only looking for folder type under this folder
#find . -name 00.txt -type d
using xargs command in find command
#find whatever....| args commnad
xargs is command to execute commnd line from standard input.
;list file
#find . -name xx.txt -print | xargs ls -l
;rmmove files from test folder
#find ./test -type f -print0 | xargs -0 rm
more information in "http://en.wikipedia.org/wiki/Xargs"
Android Makefile follow
reference:http://tw.myblog.yahoo.com/blue-comic/article?mid=676
Android Makefile follow:
Makefile -> build/core/main.mk -> build/core/config.mk -> build/core/envsetup.mk -> build/core/product_config.mk
由 build/core/config.mk 所進行。
build/core/envsetup.mk 檢查 developer 的設定 (buildspec.mk) ,並檢查執行環境,以決定輸出目錄、項目。
build/core/config.mk 本身還依據參數,決定解譯時的相關參數。像是 compiler 的路徑、flags, lex 、yacc 的路徑參數等。
關於 product 的相關設定,則是由 build/core/product_config.mk 所處理,使用 build/core/product.mk 提供之 macro 載入。根據 AndroidProduct.mk 的內容, product_config.mk 決定了
Android Makefile follow:
Makefile -> build/core/main.mk -> build/core/config.mk -> build/core/envsetup.mk -> build/core/product_config.mk
由 build/core/config.mk 所進行。
build/core/envsetup.mk 檢查 developer 的設定 (buildspec.mk) ,並檢查執行環境,以決定輸出目錄、項目。
build/core/config.mk 本身還依據參數,決定解譯時的相關參數。像是 compiler 的路徑、flags, lex 、yacc 的路徑參數等。
關於 product 的相關設定,則是由 build/core/product_config.mk 所處理,使用 build/core/product.mk 提供之 macro 載入。根據 AndroidProduct.mk 的內容, product_config.mk 決定了
android keycode
android keycode :
reference:
http://wadefs.blogspot.com/2010/12/android-remote-control-keyevent.html
http://blog.yam.com/hansonlin211/article/19171413
input keyevent xx
input text "xxx"
reference:
http://wadefs.blogspot.com/2010/12/android-remote-control-keyevent.html
http://blog.yam.com/hansonlin211/article/19171413
input keyevent xx
input text "xxx"
2011年8月4日 星期四
android boot process
reference:
Android boot process :
reference:
http://www.androidenea.com/2009/06/android-boot-process-from-power-on.html
http://huenlil.pixnet.net/blog/post/23862982
Android boot process :
reference:
http://www.androidenea.com/2009/06/android-boot-process-from-power-on.html
http://huenlil.pixnet.net/blog/post/23862982
訂閱:
文章 (Atom)