Merge "Switch RebootType to an enum class."

gugelfrei
Treehugger Robot 7 years ago committed by Gerrit Code Review
commit db725d3348

@ -193,19 +193,19 @@ static const int password_max_age_seconds = 60;
extern struct fstab *fstab; extern struct fstab *fstab;
enum RebootType {reboot, recovery, shutdown}; enum class RebootType {reboot, recovery, shutdown};
static void cryptfs_reboot(enum RebootType rt) static void cryptfs_reboot(RebootType rt)
{ {
switch(rt) { switch (rt) {
case reboot: case RebootType::reboot:
property_set(ANDROID_RB_PROPERTY, "reboot"); property_set(ANDROID_RB_PROPERTY, "reboot");
break; break;
case recovery: case RebootType::recovery:
property_set(ANDROID_RB_PROPERTY, "reboot,recovery"); property_set(ANDROID_RB_PROPERTY, "reboot,recovery");
break; break;
case shutdown: case RebootType::shutdown:
property_set(ANDROID_RB_PROPERTY, "shutdown"); property_set(ANDROID_RB_PROPERTY, "shutdown");
break; break;
} }
@ -1455,7 +1455,7 @@ static int cryptfs_restart_internal(int restart_main)
} else { } else {
/* Let's hope that a reboot clears away whatever is keeping /* Let's hope that a reboot clears away whatever is keeping
the mount busy */ the mount busy */
cryptfs_reboot(reboot); cryptfs_reboot(RebootType::reboot);
} }
} else { } else {
SLOGE("Failed to mount decrypted data"); SLOGE("Failed to mount decrypted data");
@ -2656,7 +2656,7 @@ static int cryptfs_enable_all_volumes(struct crypt_mnt_ftr *crypt_ftr, int how,
if (rc == ENABLE_INPLACE_ERR_DEV) { if (rc == ENABLE_INPLACE_ERR_DEV) {
/* Hack for b/17898962 */ /* Hack for b/17898962 */
SLOGE("cryptfs_enable: crypto block dev failure. Must reboot...\n"); SLOGE("cryptfs_enable: crypto block dev failure. Must reboot...\n");
cryptfs_reboot(reboot); cryptfs_reboot(RebootType::reboot);
} }
if (!rc) { if (!rc) {
@ -2891,7 +2891,7 @@ int cryptfs_enable_internal(char *howarg, int crypt_type, const char *passwd,
if (onlyCreateHeader) { if (onlyCreateHeader) {
sleep(2); sleep(2);
cryptfs_reboot(reboot); cryptfs_reboot(RebootType::reboot);
} }
if (how == CRYPTO_ENABLE_INPLACE && (!no_ui || rebootEncryption)) { if (how == CRYPTO_ENABLE_INPLACE && (!no_ui || rebootEncryption)) {
@ -2978,11 +2978,11 @@ int cryptfs_enable_internal(char *howarg, int crypt_type, const char *passwd,
return 0; return 0;
} else { } else {
sleep(2); /* Give the UI a chance to show 100% progress */ sleep(2); /* Give the UI a chance to show 100% progress */
cryptfs_reboot(reboot); cryptfs_reboot(RebootType::reboot);
} }
} else { } else {
sleep(2); /* Partially encrypted, ensure writes flushed to ssd */ sleep(2); /* Partially encrypted, ensure writes flushed to ssd */
cryptfs_reboot(shutdown); cryptfs_reboot(RebootType::shutdown);
} }
} else { } else {
char value[PROPERTY_VALUE_MAX]; char value[PROPERTY_VALUE_MAX];
@ -2998,7 +2998,7 @@ int cryptfs_enable_internal(char *howarg, int crypt_type, const char *passwd,
if (!write_bootloader_message(options, &err)) { if (!write_bootloader_message(options, &err)) {
SLOGE("could not write bootloader message: %s", err.c_str()); SLOGE("could not write bootloader message: %s", err.c_str());
} }
cryptfs_reboot(recovery); cryptfs_reboot(RebootType::recovery);
} else { } else {
/* set property to trigger dialog */ /* set property to trigger dialog */
property_set("vold.encrypt_progress", "error_partially_encrypted"); property_set("vold.encrypt_progress", "error_partially_encrypted");
@ -3028,7 +3028,7 @@ error_shutting_down:
* vold to restart the system. * vold to restart the system.
*/ */
SLOGE("Error enabling encryption after framework is shutdown, no data changed, restarting system"); SLOGE("Error enabling encryption after framework is shutdown, no data changed, restarting system");
cryptfs_reboot(reboot); cryptfs_reboot(RebootType::reboot);
/* shouldn't get here */ /* shouldn't get here */
property_set("vold.encrypt_progress", "error_shutting_down"); property_set("vold.encrypt_progress", "error_shutting_down");

Loading…
Cancel
Save