diff options
author | Ken Sumrall <ksumrall@android.com> | 2011-01-30 19:06:03 -0800 |
---|---|---|
committer | Ken Sumrall <ksumrall@android.com> | 2011-01-30 19:10:07 -0800 |
commit | 5d4c68e40700424b65a4331be75620706a0dd49c (patch) | |
tree | f19cf38b6b8b1e3588501ae424f9726f99f54e8a | |
parent | 3f476690eaef3b824255813ed335284ef9a90e91 (diff) | |
download | system_vold-5d4c68e40700424b65a4331be75620706a0dd49c.tar.gz system_vold-5d4c68e40700424b65a4331be75620706a0dd49c.tar.bz2 system_vold-5d4c68e40700424b65a4331be75620706a0dd49c.zip |
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
-rw-r--r-- | Android.mk | 1 | ||||
-rw-r--r-- | cryptfs.c | 17 |
2 files changed, 18 insertions, 0 deletions
@@ -33,6 +33,7 @@ common_shared_libraries := \ libsysutils \ libcutils \ libdiskconfig \ + libhardware_legacy \ libcrypto include $(CLEAR_VARS) @@ -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; } |