public class SystemRestore extends Object
These interfaces are used to restore factory settings, clear the cache partition, and verify and install an OTA upgrade package.
| 构造器 | 说明 |
|---|---|
SystemRestore() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static boolean |
rebootAndCleanCache(Context context) |
Reboots a device and clears its cache partition in system restore mode.
|
static boolean |
rebootAndCleanUserData(Context context) |
Reboots a device and clears its user partition in system restore mode.
|
static void |
rebootAndInstallUpgradePackage(Context context,
File upgradeFile) |
Installs the upgrade package after a device is rebooted.
|
static void |
verifyUpgradePackage(File upgradeFile,
ISystemRestoreProgressListener listener,
File deviceCertsZipFile) |
Checks whether the upgrade package is valid before an upgrade.
|
public static boolean rebootAndCleanCache(Context context) throws SystemRestoreException
To use this method, applications must have permissions to access system components, and to reboot and restore the system.
context - Indicates the system context.false if input parameters are incorrect;
returns a specific exception if any exception occurs on the current module;
returns true if the rebooted device enters the cache clear mode,
but there is no chance that you will see the value in this case.SystemRestoreException - Throws a system restore exception you have defined,
such as a system context error, no permissions to access system components,
or no permissions to reboot or restore the system.public static boolean rebootAndCleanUserData(Context context) throws SystemRestoreException
To use this method, applications must have permissions to access system components, and to reboot and restore the system.
context - Indicates the system context.false if input parameters are incorrect;
returns a specific exception if any exception occurs on the current module;
returns true if factory settings of the rebooted device can be restored,
but there is no chance that you will see the value in this case.SystemRestoreException - Throws a system restore exception you have defined,
such as a system context error, no permissions to access system components,
no permissions to reboot or restore the system,
or no permissions to send or receive broadcasts of restoring factory settings.public static void verifyUpgradePackage(File upgradeFile, ISystemRestoreProgressListener listener, File deviceCertsZipFile) throws SystemRestoreException
Before installing the upgrade package, an application checks whether the private key in the upgrade package matches the imported public key file. If they match each other, no exception will be thrown. The application must also verify the upgrade package if the device is rebooted and enters the system restore mode.
It may take an extended period to verify the upgrade package. If the execution of this method interrupts a thread, a defined exception will be thrown. Therefore, you are advised not to call this method from any UI threads.
upgradeFile - Indicates the upgrade package to be verified.listener - Indicates the interface to call back the verification progress.
This parameter can be null. For details, see ISystemRestoreProgressListener.deviceCertsZipFile - Indicates the compressed file of the public key certificate.
This parameter can be null. If it is null,
the default system file /system/etc/security/otacerts.zip is used.SystemRestoreException - Throws a system restore exception you have defined,
such as a failure to read the upgrade package, a failure to read the public key file,
or a verification failure.public static void rebootAndInstallUpgradePackage(Context context, File upgradeFile) throws SystemRestoreException
To use this method, applications must have permissions to access system components, and to reboot and restore the system.
context - Indicates the system context.upgradeFile - Indicates the upgrade package.SystemRestoreException - Throws a system restore exception you have defined,
such as a system context error, a failure to read the upgrade package,
no permissions to access system components, or no permissions to reboot or restore the system.