您的位置:首页 > 移动开发 > Android开发

Android系统手机重启与恢复出产设置源代码跟踪

2012-12-13 10:58 330 查看
Android系统中重启与恢复出产设置源代码跟踪

系统的重启和恢复产出设置主要是在 RecoverySystem.java [Path:framework\base\core\java\android\os]这个类中实现的

跟踪源代码:

// Having written the command file, go ahead and reboot
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
pm.reboot("recovery");
这段代码就是实现系统的重启与恢复出产设置,如何区别重启或出产设置由reboot();参数确定,继续跟踪代码reboot();
[path:framework\base\core\java\android\os\PowerManager.java]

/**
* Reboot the device.  Will not return if the reboot is
* successful.  Requires the {@link android.Manifest.permission#REBOOT}
* permission.
*
* @param reason code to pass to the kernel (e.g., "recovery") to
*               request special boot modes, or null.
*/
public void reboot(String reason)
{
try {
mService.reboot(reason);
} catch (RemoteException e) {
}
}
跟踪reboot();可以发现reboot()方法参数为String类型。

如果String为recovery[如:reboot("recovery")]则系统重启就会走恢复出产值重启方式。

如果String为空字符[如:reboot("")]则系统找不到recovery则直接重启设备。

注意要带双引号。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: