public class RecoverySystem extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
RecoverySystem.ProgressListener
Interface definition for a callback to be invoked regularly as
verification proceeds.
|
Modifier and Type | Field and Description |
---|---|
static File |
BLOCK_MAP_FILE
The recovery image uses this file to identify the location (i.e. blocks)
of an OTA package on the /data partition.
|
static File |
UNCRYPT_PACKAGE_FILE
UNCRYPT_PACKAGE_FILE stores the filename to be uncrypt'd, which will be
read by uncrypt.
|
static File |
UNCRYPT_STATUS_FILE
UNCRYPT_STATUS_FILE stores the time cost (and error code in the case of a failure)
of uncrypt.
|
Constructor and Description |
---|
RecoverySystem() |
RecoverySystem(IRecoverySystem service) |
Modifier and Type | Method and Description |
---|---|
static void |
cancelScheduledUpdate(Context context)
Cancel any scheduled update by clearing up the BCB (bootloader control
block).
|
static String |
handleAftermath(Context context)
Called after booting to process and remove recovery-related files.
|
static void |
installPackage(Context context,
File packageFile)
Reboots the device in order to install the given update
package.
|
static void |
installPackage(Context context,
File packageFile,
boolean processed)
If the package hasn't been processed (i.e. uncrypt'd), set up
UNCRYPT_PACKAGE_FILE and delete BLOCK_MAP_FILE to trigger uncrypt during the
reboot.
|
static void |
processPackage(Context context,
File packageFile,
RecoverySystem.ProgressListener listener)
Process a given package with uncrypt.
|
static void |
processPackage(Context context,
File packageFile,
RecoverySystem.ProgressListener listener,
Handler handler)
Process a given package with uncrypt.
|
static void |
rebootWipeAb(Context context,
File packageFile,
String reason)
Reboot into recovery and wipe the A/B device.
|
static void |
rebootWipeCache(Context context)
Reboot into the recovery system to wipe the /cache partition.
|
static void |
rebootWipeCache(Context context,
String reason) |
static void |
rebootWipeUserData(Context context)
Reboots the device and wipes the user data and cache
partitions.
|
static void |
rebootWipeUserData(Context context,
boolean shutdown) |
static void |
rebootWipeUserData(Context context,
boolean shutdown,
String reason,
boolean force)
Reboots the device and wipes the user data and cache
partitions.
|
static void |
rebootWipeUserData(Context context,
String reason) |
static void |
scheduleUpdateOnBoot(Context context,
File packageFile)
Schedule to install the given package on next boot.
|
static void |
verifyPackage(File packageFile,
RecoverySystem.ProgressListener listener,
File deviceCertsZipFile)
Verify the cryptographic signature of a system update package
before installing it.
|
public static final File BLOCK_MAP_FILE
public static final File UNCRYPT_PACKAGE_FILE
public static final File UNCRYPT_STATUS_FILE
public RecoverySystem()
public RecoverySystem(IRecoverySystem service)
public static void verifyPackage(File packageFile, RecoverySystem.ProgressListener listener, File deviceCertsZipFile) throws IOException, GeneralSecurityException
packageFile
- the package to be verifiedlistener
- an object to receive periodic progress
updates as verification proceeds. May be null.deviceCertsZipFile
- 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").IOException
- if there were any errors reading the
package or certs files.GeneralSecurityException
- if verification failedpublic static void processPackage(Context context, File packageFile, RecoverySystem.ProgressListener listener, Handler handler) throws IOException
Context
- the Context to usepackageFile
- the package to be processedlistener
- an object to receive periodic progress updates as
processing proceeds. May be null.handler
- the Handler upon which the callbacks will be
executed.IOException
- if there were any errors processing the package file.public static void processPackage(Context context, File packageFile, RecoverySystem.ProgressListener listener) throws IOException
Context
- the Context to usepackageFile
- the package to be processedlistener
- an object to receive periodic progress updates as
processing proceeds. May be null.IOException
- if there were any errors processing the package file.public static void installPackage(Context context, File packageFile) throws IOException
android.Manifest.permission#REBOOT
permission.context
- the Context to usepackageFile
- 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.)IOException
- if writing the recovery command file
fails, or if the reboot itself fails.public static void installPackage(Context context, File packageFile, boolean processed) throws IOException
context
- the Context to usepackageFile
- the update package to install. Must be on a
partition mountable by recovery.processed
- if the package has been processed (uncrypt'd).IOException
- if writing the recovery command file fails, or if
the reboot itself fails.public static void scheduleUpdateOnBoot(Context context, File packageFile) throws IOException
Context
- the Context to use.packageFile
- the package to be installed.IOException
- if there were any errors setting up the BCB.public static void cancelScheduledUpdate(Context context) throws IOException
Context
- the Context to use.IOException
- if there were any errors clearing up the BCB.public static void rebootWipeUserData(Context context) throws IOException
android.Manifest.permission#REBOOT
permission.context
- the Context to useIOException
- if writing the recovery command file
fails, or if the reboot itself fails.SecurityException
- if the current user is not allowed to wipe data.public static void rebootWipeUserData(Context context, String reason) throws IOException
IOException
public static void rebootWipeUserData(Context context, boolean shutdown) throws IOException
IOException
public static void rebootWipeUserData(Context context, boolean shutdown, String reason, boolean force) throws IOException
android.Manifest.permission#REBOOT
permission.context
- the Context to useshutdown
- if true, the device will be powered down after
the wipe completes, rather than being rebooted
back to the regular system.reason
- the reason for the wipe that is visible in the logsforce
- whether the UserManager.DISALLOW_FACTORY_RESET
user restriction
should be ignoredIOException
- if writing the recovery command file
fails, or if the reboot itself fails.SecurityException
- if the current user is not allowed to wipe data.public static void rebootWipeCache(Context context) throws IOException
IOException
- if something goes wrong.public static void rebootWipeCache(Context context, String reason) throws IOException
IOException
public static void rebootWipeAb(Context context, File packageFile, String reason) throws IOException
Context
- the Context to use.packageFile
- the wipe package to be applied.reason
- the reason to wipe.IOException
- if something goes wrong.