diff options
| author | Tao Bao <tbao@google.com> | 2016-06-02 08:47:56 -0700 |
|---|---|---|
| committer | Tao Bao <tbao@google.com> | 2016-06-09 16:57:54 -0700 |
| commit | 1327a97a076d67f296f338653678cc383ebfa002 (patch) | |
| tree | 535bc857be2f59031633e27d4893e10379a8663f /core/java/android/os/RecoverySystem.java | |
| parent | 711629a27dcc547b708ae00bbcb736f0b39eeb00 (diff) | |
Add RecoverySystem.rebootWipeAb() system API.
It reboots into recovery and securely wipes an A/B device.
Bug: 27253717
Bug: 29159185
Change-Id: I8252894db5c1df48bc4a8728b7f0e0f18aebc44c
Diffstat (limited to 'core/java/android/os/RecoverySystem.java')
| -rw-r--r-- | core/java/android/os/RecoverySystem.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java index acb24e1ccf9e..1979a3f7da79 100644 --- a/core/java/android/os/RecoverySystem.java +++ b/core/java/android/os/RecoverySystem.java @@ -662,6 +662,31 @@ public class RecoverySystem { } /** + * Reboot into recovery and wipe the A/B device. + * + * @param Context the Context to use. + * @param packageFile the wipe package to be applied. + * @param reason the reason to wipe. + * + * @throws IOException if something goes wrong. + * + * @hide + */ + @SystemApi + public static void rebootWipeAb(Context context, File packageFile, String reason) + throws IOException { + String reasonArg = null; + if (!TextUtils.isEmpty(reason)) { + reasonArg = "--reason=" + sanitizeArg(reason); + } + + final String filename = packageFile.getCanonicalPath(); + final String filenameArg = "--wipe_package=" + filename; + final String localeArg = "--locale=" + Locale.getDefault().toString(); + bootCommand(context, "--wipe_ab", filenameArg, reasonArg, localeArg); + } + + /** * Reboot into the recovery system with the supplied argument. * @param args to pass to the recovery utility. * @throws IOException if something goes wrong. |
