Allow non datamedia devices to wipe encryption
With 5.0 L, we decrypt automatically if the default_password is used. Non datamedia devices do not get the format data button so they cannot wipe encryption off the device. This patch add a wipe encryption button where the format data button would normally be located on the Wipe page. This patch also attempts to remove / delete the dm-crypt block device before formatting. Change-Id: I100d5d154d6c49254fd48e23279df973db5f23ae
This commit is contained in:
@@ -725,7 +725,7 @@ errout:
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int delete_crypto_blk_dev(char *name)
|
||||
int delete_crypto_blk_dev(char *name)
|
||||
{
|
||||
int fd;
|
||||
char buffer[DM_CRYPT_BUF_SIZE];
|
||||
|
||||
@@ -213,6 +213,7 @@ extern "C" {
|
||||
int cryptfs_check_passwd(char *pw);
|
||||
int cryptfs_verify_passwd(char *newpw);
|
||||
int cryptfs_get_password_type(void);
|
||||
int delete_crypto_blk_dev(char *name);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1057,10 +1057,7 @@
|
||||
</object>
|
||||
|
||||
<object type="button">
|
||||
<conditions>
|
||||
<condition var1="tw_has_internal" var2="1" />
|
||||
<condition var1="tw_has_data_media" var2="1" />
|
||||
</conditions>
|
||||
<condition var1="tw_has_data_media" var2="1" />
|
||||
<highlight color="%highlight_color%" />
|
||||
<placement x="%col3_x%" y="%wipe_button_y%" />
|
||||
<font resource="font" color="%button_text_color%" />
|
||||
@@ -1071,6 +1068,30 @@
|
||||
</actions>
|
||||
</object>
|
||||
|
||||
<object type="button">
|
||||
<conditions>
|
||||
<condition var1="tw_is_encrypted" var2="1" />
|
||||
<condition var1="tw_has_data_media" var2="0" />
|
||||
</conditions>
|
||||
<highlight color="%highlight_color%" />
|
||||
<placement x="%col3_x%" y="%wipe_button_y%" />
|
||||
<font resource="font" color="%button_text_color%" />
|
||||
<text>Wipe Encryption</text>
|
||||
<image resource="main_button" />
|
||||
<actions>
|
||||
<action function="set">tw_back=wipe</action>
|
||||
<action function="set">tw_action=wipe</action>
|
||||
<action function="set">tw_action_param=DATAMEDIA</action>
|
||||
<action function="set">tw_has_action2=0</action>
|
||||
<action function="set">tw_text1=Wipe Encryption from Data?</action>
|
||||
<action function="set">tw_text2=</action>
|
||||
<action function="set">tw_action_text1=Formatting Data...</action>
|
||||
<action function="set">tw_complete_text1=Data Format Complete</action>
|
||||
<action function="set">tw_slider_text=Swipe to Format Data</action>
|
||||
<action function="page">confirm_action</action>
|
||||
</actions>
|
||||
</object>
|
||||
|
||||
<object type="text" color="%text_color%">
|
||||
<font resource="font" />
|
||||
<placement x="%center_x%" y="%row12_text_y%" placement="5" />
|
||||
|
||||
@@ -769,10 +769,7 @@
|
||||
</object>
|
||||
|
||||
<object type="button">
|
||||
<conditions>
|
||||
<condition var1="tw_has_internal" var2="1" />
|
||||
<condition var1="tw_has_data_media" var2="1" />
|
||||
</conditions>
|
||||
<condition var1="tw_has_data_media" var2="1" />
|
||||
<highlight color="%highlight_color%" />
|
||||
<placement x="%col2_x%" y="%wipe_button_y%" />
|
||||
<font resource="font" color="%button_text_color%" />
|
||||
@@ -783,6 +780,30 @@
|
||||
</actions>
|
||||
</object>
|
||||
|
||||
<object type="button">
|
||||
<conditions>
|
||||
<condition var1="tw_is_encrypted" var2="1" />
|
||||
<condition var1="tw_has_data_media" var2="0" />
|
||||
</conditions>
|
||||
<highlight color="%highlight_color%" />
|
||||
<placement x="%col2_x%" y="%wipe_button_y%" />
|
||||
<font resource="font" color="%button_text_color%" />
|
||||
<text>Wipe Encryption</text>
|
||||
<image resource="main_button" />
|
||||
<actions>
|
||||
<action function="set">tw_back=wipe</action>
|
||||
<action function="set">tw_action=wipe</action>
|
||||
<action function="set">tw_action_param=DATAMEDIA</action>
|
||||
<action function="set">tw_has_action2=0</action>
|
||||
<action function="set">tw_text1=Wipe Encryption from Data?</action>
|
||||
<action function="set">tw_text2=</action>
|
||||
<action function="set">tw_action_text1=Formatting Data...</action>
|
||||
<action function="set">tw_complete_text1=Data Format Complete</action>
|
||||
<action function="set">tw_slider_text=Swipe to Format Data</action>
|
||||
<action function="page">confirm_action</action>
|
||||
</actions>
|
||||
</object>
|
||||
|
||||
<object type="slider">
|
||||
<placement x="%slider_x%" y="%slider_y%" />
|
||||
<resource base="slider" used="slider-used" touch="slider-touch" />
|
||||
|
||||
@@ -712,10 +712,7 @@
|
||||
</object>
|
||||
|
||||
<object type="button">
|
||||
<conditions>
|
||||
<condition var1="tw_has_internal" var2="1" />
|
||||
<condition var1="tw_has_data_media" var2="1" />
|
||||
</conditions>
|
||||
<condition var1="tw_has_data_media" var2="1" />
|
||||
<highlight color="%highlight_color%" />
|
||||
<placement x="%col2_x%" y="%wipe_button_y%" />
|
||||
<font resource="font" color="%button_text_color%" />
|
||||
@@ -726,6 +723,30 @@
|
||||
</actions>
|
||||
</object>
|
||||
|
||||
<object type="button">
|
||||
<conditions>
|
||||
<condition var1="tw_is_encrypted" var2="1" />
|
||||
<condition var1="tw_has_data_media" var2="0" />
|
||||
</conditions>
|
||||
<highlight color="%highlight_color%" />
|
||||
<placement x="%col2_x%" y="%wipe_button_y%" />
|
||||
<font resource="font" color="%button_text_color%" />
|
||||
<text>Wipe Encryption</text>
|
||||
<image resource="main_button" />
|
||||
<actions>
|
||||
<action function="set">tw_back=wipe</action>
|
||||
<action function="set">tw_action=wipe</action>
|
||||
<action function="set">tw_action_param=DATAMEDIA</action>
|
||||
<action function="set">tw_has_action2=0</action>
|
||||
<action function="set">tw_text1=Wipe Encryption from Data?</action>
|
||||
<action function="set">tw_text2=</action>
|
||||
<action function="set">tw_action_text1=Formatting Data...</action>
|
||||
<action function="set">tw_complete_text1=Data Format Complete</action>
|
||||
<action function="set">tw_slider_text=Swipe to Format Data</action>
|
||||
<action function="page">confirm_action</action>
|
||||
</actions>
|
||||
</object>
|
||||
|
||||
<object type="slider">
|
||||
<placement x="%slider_x%" y="%slider_y%" />
|
||||
<resource base="slider" used="slider-used" touch="slider-touch" />
|
||||
|
||||
@@ -1371,6 +1371,15 @@ bool TWPartition::Wipe_Encryption() {
|
||||
|
||||
Has_Data_Media = false;
|
||||
Decrypted_Block_Device = "";
|
||||
#ifdef TW_INCLUDE_CRYPTO
|
||||
if (Is_Decrypted) {
|
||||
if (!UnMount(true))
|
||||
return false;
|
||||
if (delete_crypto_blk_dev("userdata") != 0) {
|
||||
LOGERR("Error deleting crypto block device, continuing anyway.\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Is_Decrypted = false;
|
||||
Is_Encrypted = false;
|
||||
Find_Actual_Block_Device();
|
||||
@@ -1381,6 +1390,7 @@ bool TWPartition::Wipe_Encryption() {
|
||||
if (Mount(false))
|
||||
PartitionManager.Add_MTP_Storage(MTP_Storage_ID);
|
||||
}
|
||||
DataManager::SetValue(TW_IS_ENCRYPTED, 0);
|
||||
#ifndef TW_OEM_BUILD
|
||||
gui_print("You may need to reboot recovery to be able to use /data again.\n");
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user