vold: Use the new method of rebooting by asking init to do it
Change-Id: I7fd5f1048c3cf43fa14597f079c929690cac367c
diff --git a/cryptfs.c b/cryptfs.c
index 1bf7049..2f8381c 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -35,15 +35,14 @@
#include <openssl/evp.h>
#include <openssl/sha.h>
#include <errno.h>
-#include <cutils/android_reboot.h>
#include <ext4.h>
#include <linux/kdev_t.h>
#include <fs_mgr.h>
#include "cryptfs.h"
#define LOG_TAG "Cryptfs"
-#include "cutils/android_reboot.h"
#include "cutils/log.h"
#include "cutils/properties.h"
+#include "cutils/android_reboot.h"
#include "hardware_legacy/power.h"
#include "VolumeManager.h"
@@ -70,6 +69,19 @@
extern struct fstab *fstab;
+static void cryptfs_reboot(int recovery)
+{
+ if (recovery) {
+ property_set(ANDROID_RB_PROPERTY, "reboot,recovery");
+ } else {
+ property_set(ANDROID_RB_PROPERTY, "reboot");
+ }
+ sleep(20);
+
+ /* Shouldn't get here, reboot should happen before sleep times out */
+ return;
+}
+
static void ioctl_init(struct dm_ioctl *io, size_t dataSize, const char *name, unsigned flags)
{
memset(io, 0, dataSize);
@@ -1697,7 +1709,7 @@
put_crypt_ftr_and_key(&crypt_ftr);
sleep(2); /* Give the UI a chance to show 100% progress */
- android_reboot(ANDROID_RB_RESTART, 0, 0);
+ cryptfs_reboot(0);
} else {
char value[PROPERTY_VALUE_MAX];
@@ -1713,7 +1725,7 @@
} else {
SLOGE("could not open /cache/recovery/command\n");
}
- android_reboot(ANDROID_RB_RESTART2, 0, "recovery");
+ cryptfs_reboot(1);
} else {
/* set property to trigger dialog */
property_set("vold.encrypt_progress", "error_partially_encrypted");
@@ -1744,7 +1756,7 @@
* vold to restart the system.
*/
SLOGE("Error enabling encryption after framework is shutdown, no data changed, restarting system");
- android_reboot(ANDROID_RB_RESTART, 0, 0);
+ cryptfs_reboot(0);
/* shouldn't get here */
property_set("vold.encrypt_progress", "error_shutting_down");