Android系统手机重启与恢复出产设置源代码跟踪
16lz
2021-01-23
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则直接重启设备。
注意要带双引号。
更多相关文章
- Android 4.0 事件输入(Event Input)系统
- android打开系统设置或信息界面
- android apk获得系统权限
- Android系统应用调用Aidl
- android 实用javamail发送邮件(非系统自带)
- Eclipse中跟踪调试Android Framework源代码
- Android - 小功能 - Android系统详解之获取图片和视频的缩略图
- Android操作系统简介