Chinaunix首页 | 论坛 | 博客
  • 博客访问: 405376
  • 博文数量: 53
  • 博客积分: 1910
  • 博客等级: 中尉
  • 技术积分: 1130
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-10 14:56
文章分类

全部博文(53)

文章存档

2013年(1)

2012年(17)

2011年(33)

2010年(2)

分类: 嵌入式

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 
   ------------------------------------------------------------------------
 
  

阅读(2201) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~