summaryrefslogtreecommitdiff
path: root/core/java/android/os/RecoverySystem.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/os/RecoverySystem.java')
-rw-r--r--core/java/android/os/RecoverySystem.java40
1 files changed, 34 insertions, 6 deletions
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java
index b692ffdea91c..f671ed955659 100644
--- a/core/java/android/os/RecoverySystem.java
+++ b/core/java/android/os/RecoverySystem.java
@@ -338,11 +338,11 @@ public class RecoverySystem {
}
/**
- * Reboots the device and wipes the user data partition. This is
- * sometimes called a "factory reset", which is something of a
- * misnomer because the system partition is not restored to its
- * factory state.
- * Requires the {@link android.Manifest.permission#REBOOT} permission.
+ * Reboots the device and wipes the user data and cache
+ * partitions. This is sometimes called a "factory reset", which
+ * is something of a misnomer because the system partition is not
+ * restored to its factory state. Requires the
+ * {@link android.Manifest.permission#REBOOT} permission.
*
* @param context the Context to use
*
@@ -350,6 +350,28 @@ public class RecoverySystem {
* fails, or if the reboot itself fails.
*/
public static void rebootWipeUserData(Context context) throws IOException {
+ rebootWipeUserData(context, false);
+ }
+
+ /**
+ * Reboots the device and wipes the user data and cache
+ * partitions. This is sometimes called a "factory reset", which
+ * is something of a misnomer because the system partition is not
+ * restored to its factory state. Requires the
+ * {@link android.Manifest.permission#REBOOT} permission.
+ *
+ * @param context the Context to use
+ * @param shutdown if true, the device will be powered down after
+ * the wipe completes, rather than being rebooted
+ * back to the regular system.
+ *
+ * @throws IOException if writing the recovery command file
+ * fails, or if the reboot itself fails.
+ *
+ * @hide
+ */
+ public static void rebootWipeUserData(Context context, boolean shutdown)
+ throws IOException {
final ConditionVariable condition = new ConditionVariable();
Intent intent = new Intent("android.intent.action.MASTER_CLEAR_NOTIFICATION");
@@ -365,7 +387,13 @@ public class RecoverySystem {
// Block until the ordered broadcast has completed.
condition.block();
- bootCommand(context, "--wipe_data\n--locale=" + Locale.getDefault().toString());
+ String shutdownArg = "";
+ if (shutdown) {
+ shutdownArg = "--shutdown_after\n";
+ }
+
+ bootCommand(context, shutdownArg + "--wipe_data\n--locale=" +
+ Locale.getDefault().toString());
}
/**