分类: 嵌入式
2011-12-08 00:13:10
android 2.3.4 关机流程和以前版本应该也差不多,但是以前也没记录,所以忘记了
跑到framework 下secach "power" 找到一堆power* 文件
从PowerDialog.java 往下跟了下,好记心不如烂笔头,记录一下大概流程如下:
长按power key 进入 (logcat -s ShutdownThread:I 看下java dbug msg)
------------------------------------------------------------------------
(PowerDialog.java)
选择power off
=>ShutdownThread.shutdown(getContext(), true);
------------------------------------------------------------------------
(frameworks\base\core\java\com\android\internal\app\ShutdownThread.java)
=>public static void shutdown(final Context context, boolean confirm)
=>beginShutdownSequence
=> new Handler
=>public void run()
=> rebootOrShutdown(mReboot, mRebootReason);
=> Power.shutdown(); (reboot=>Power.reboot(reason);)
------------------------------------------------------------------------
(Power.java) jni java 接口
=> shutdown
------------------------------------------------------------------------
(android_os_Power.cpp) jni navtive
=> shutdown
=> android_os_Power_shutdown
=> reboot(RB_POWER_OFF); => LINUX_REBOOT_CMD_POWER_OFF
=> __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
LINUX_REBOOT_CMD_POWER_OFF, (char*) reason);
------------------------------------------------------------------------
(sys.c) 进入kernel
SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
void __user *, arg)
=>kernel_power_off()
reboot 走这里:
(Power.java) jni java 接口
=> reboot => rebootNative
------------------------------------------------------------------------
(android_os_Power.cpp) jni navtive
=> rebootNative
=> android_os_Power_reboot
=> __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
LINUX_REBOOT_CMD_RESTART2, (char*) reason);
------------------------------------------------------------------------
(bionic\libc\arch-arm\syscalls\__reboot.S) bonic libc
ldr r7, =__NR_reboot
swi #0
------------------------------------------------------------------------
进入 kernel
------------------------------------------------------------------------