Have vold grab a partial wakelock when encrypting
The Progress bar UI grabs a full wakelock when encrypting, but we've seen a case where it looks like the progress bar UI crashes, and the wakelock is lost, and then all hell breaks loose. The enablecrypto command has a lot of work to do, and it will take some time, so it should grab a wakelock to ensure it can finish without being interrupted and put to sleep. It grabs a partial wake lock, as it doesn't need the screen to be on to do its work. If the UI wants to keep it on, it should also grab a full wakelock, which it does. If the UI crashes, the screen may turn off, but the encryption will keep going, and vold will reboot the device when it's done. Change-Id: I51d3a72b8c77383044a3facb1604c1ee510733ae
This commit is contained in:
parent
3f476690ea
commit
5d4c68e407
2 changed files with 18 additions and 0 deletions
|
@ -33,6 +33,7 @@ common_shared_libraries := \
|
|||
libsysutils \
|
||||
libcutils \
|
||||
libdiskconfig \
|
||||
libhardware_legacy \
|
||||
libcrypto
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
|
17
cryptfs.c
17
cryptfs.c
|
@ -41,6 +41,7 @@
|
|||
#define LOG_TAG "Cryptfs"
|
||||
#include "cutils/log.h"
|
||||
#include "cutils/properties.h"
|
||||
#include "hardware_legacy/power.h"
|
||||
|
||||
#define DM_CRYPT_BUF_SIZE 4096
|
||||
#define DATA_MNT_POINT "/data"
|
||||
|
@ -897,6 +898,7 @@ int cryptfs_enable(char *howarg, char *passwd)
|
|||
struct crypt_mnt_ftr crypt_ftr;
|
||||
char tmpfs_options[80];
|
||||
char encrypted_state[32];
|
||||
char lockid[32] = { 0 };
|
||||
|
||||
property_get("ro.crypto.state", encrypted_state, "");
|
||||
if (strcmp(encrypted_state, "unencrypted")) {
|
||||
|
@ -936,6 +938,13 @@ int cryptfs_enable(char *howarg, char *passwd)
|
|||
}
|
||||
}
|
||||
|
||||
/* Get a wakelock as this may take a while, and we don't want the
|
||||
* device to sleep on us. We'll grab a partial wakelock, and if the UI
|
||||
* wants to keep the screen on, it can grab a full wakelock.
|
||||
*/
|
||||
snprintf(lockid, 32, "enablecrypto%d", (int) getpid());
|
||||
acquire_wake_lock(PARTIAL_WAKE_LOCK, lockid);
|
||||
|
||||
/* The init files are setup to stop the class main and late start when
|
||||
* vold sets trigger_shutdown_framework.
|
||||
*/
|
||||
|
@ -1020,6 +1029,7 @@ int cryptfs_enable(char *howarg, char *passwd)
|
|||
reboot(LINUX_REBOOT_CMD_RESTART);
|
||||
} else {
|
||||
property_set("vold.encrypt_progress", "error_partially_encrypted");
|
||||
release_wake_lock(lockid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1028,10 +1038,14 @@ int cryptfs_enable(char *howarg, char *passwd)
|
|||
* Set the property and return. Hope the framework can deal with it.
|
||||
*/
|
||||
property_set("vold.encrypt_progress", "error_reboot_failed");
|
||||
release_wake_lock(lockid);
|
||||
return rc;
|
||||
|
||||
error_unencrypted:
|
||||
property_set("vold.encrypt_progress", "error_not_encrypted");
|
||||
if (lockid[0]) {
|
||||
release_wake_lock(lockid);
|
||||
}
|
||||
return -1;
|
||||
|
||||
error_shutting_down:
|
||||
|
@ -1045,6 +1059,9 @@ error_shutting_down:
|
|||
|
||||
/* shouldn't get here */
|
||||
property_set("vold.encrypt_progress", "error_shutting_down");
|
||||
if (lockid[0]) {
|
||||
release_wake_lock(lockid);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue