android reboot 过程

本文详细介绍了Android系统软件重启的过程,从应用层的触发到内核的响应,涉及ShutdownThread、Power.java、reboot.c等关键文件,以及kernel_restart、machine_restart等函数,最后讲解了重启后的启动流程,包括irom初始化、BL1、BL2加载和u-boot跳转。
摘要由CSDN通过智能技术生成

转载请标注原文地址:http://blog.csdn.net/uranus_wm/article/details/10542715

 

这里说的reboot是指software restart,常用场景有两种:

1.android应用层出现关键进程挂起,如system进程挂起引起的reboot

2.直接通过tty控制台输入reboot

 

以android4.0.4版本,samsung-exynos-4412+s5p8767(PMU)为例:

 

Android部分:

文件位置:/frameworks/base/core/java/com/android/internal/app/ShutdownThread.java

文件中有一个单例模式class ShutdownThread,包含reboot和shutdown两个静态方法。

 

public final class ShutdownThread extends Thread {

    /**
     * Request a clean shutdown, waiting for subsystems to clean up their
     * state etc.  Must be called from a Looper thread in which its UI
     * is shown.
     *
     * @param context Context used to display the shutdown progress dialog.
     * @param reason code to pass to the kernel (e.g. "recovery"), or null.
     * @param confirm true if user confirmation is needed before shutting down.
     */
    public static void reboot(final Context context, String reason, boolean confirm) {
        mReboot = true;
        mRebootReason = reason;
        shutdown(context, confirm);
    }
}


通过调用内部方法rebootOrShutdown会再调用到静态类Power.java的reboot方法

文件位置:/frameworks/base/core/java/android/os/power.java

    /**
     * Reboot the device.
     * @param reason code to pass to the kernel (e.g. "recovery"), or null.
     *
     * @throws IOException if reboot fails for some reason (eg, lack of
     *         permission)
     */
    public static void reboot(String reason) throws IOException
    {
        rebootNative(reason);
    }

    private static native void rebootNative(String reason) throws IOException ;

 

通过jni调用,一层层跟踪发现最终调用到

文件位置: /bionic/libc/unistd/reboot.c

int reboot (int  mode) 
{
    return __reboot( LINUX_R
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值