RecoverySystem
public class RecoverySystem
extends Object
RecoverySystem包含与Android恢复系统交互的方法(可用于安装系统更新,擦除用户数据的单独分区等)
Summary
Public methods
installPackage
void installPackage (Context context,
File packageFile)
重新启动设备以安装给定的更新包。 需要REBOOT
权限。
Parameters |
context |
Context : the Context to use |
packageFile |
File : the update package to install. Must be on a partition mountable by recovery. (The set of partitions known to recovery may vary from device to device. Generally, /cache and /data are safe.) |
Throws |
IOException |
if writing the recovery command file fails, or if the reboot itself fails. |
rebootWipeCache
void rebootWipeCache (Context context)
重新引导到恢复系统以擦除/缓存分区。
Parameters |
context |
Context
|
rebootWipeUserData
void rebootWipeUserData (Context context)
重新启动设备并清除用户数据和缓存分区。 这有时被称为“工厂重置”,这是不恰当的,因为系统分区没有恢复到出厂状态。 需要REBOOT
权限。
Parameters |
context |
Context : the Context to use |
Throws |
IOException |
if writing the recovery command file fails, or if the reboot itself fails. |
SecurityException |
if the current user is not allowed to wipe data. |
verifyPackage
void verifyPackage (File packageFile,
RecoverySystem.ProgressListener listener,
File deviceCertsZipFile)
在安装之前验证系统更新包的加密签名。 请注意,一旦设备重新启动进入恢复系统,安装程序也会单独验证该软件包。 这个函数只有在包被成功验证的情况下才会返回; 否则会抛出异常。 验证包可能需要很长时间,所以不应该从UI线程调用此函数。 当此函数正在进行时中断线程将导致SecurityException被抛出(并且线程的中断标志将被清除)。
Parameters |
packageFile |
File : the package to be verified |
listener |
RecoverySystem.ProgressListener : an object to receive periodic progress updates as verification proceeds. May be null. |
deviceCertsZipFile |
File : the zip file of certificates whose public keys we will accept. Verification succeeds if the package is signed by the private key corresponding to any public key in this file. May be null to use the system default file (currently "/system/etc/security/otacerts.zip"). |