OSDN Git Service

Add RecoverySystem.rebootWipeAb() system API.
authorTao Bao <tbao@google.com>
Thu, 2 Jun 2016 15:47:56 +0000 (08:47 -0700)
committerTao Bao <tbao@google.com>
Thu, 9 Jun 2016 23:57:54 +0000 (16:57 -0700)
It reboots into recovery and securely wipes an A/B device.

Bug: 27253717
Bug: 29159185
Change-Id: I8252894db5c1df48bc4a8728b7f0e0f18aebc44c

api/system-current.txt
core/java/android/os/RecoverySystem.java

index e2a0516..e9b4c8a 100644 (file)
@@ -31663,6 +31663,7 @@ package android.os {
     method public static void installPackage(android.content.Context, java.io.File, boolean) throws java.io.IOException;
     method public static void processPackage(android.content.Context, java.io.File, android.os.RecoverySystem.ProgressListener, android.os.Handler) throws java.io.IOException;
     method public static void processPackage(android.content.Context, java.io.File, android.os.RecoverySystem.ProgressListener) throws java.io.IOException;
+    method public static void rebootWipeAb(android.content.Context, java.io.File, java.lang.String) throws java.io.IOException;
     method public static void rebootWipeCache(android.content.Context) throws java.io.IOException;
     method public static void rebootWipeUserData(android.content.Context) throws java.io.IOException;
     method public static void scheduleUpdateOnBoot(android.content.Context, java.io.File) throws java.io.IOException;
index acb24e1..1979a3f 100644 (file)
@@ -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.