Commit 38bd760b authored by Dees_Troy's avatar Dees_Troy

Add wipe functions, compiles in CM7, text shows in UI, zips install

Zip install works, had to move mincrypt code into TWRP to prevent
a crash when checking the zip signature.
Added wipe functions
Made it compile in CM7
Made text show up in console and logging
parent 32c8eb81
......@@ -38,7 +38,8 @@ LOCAL_SRC_FILES += \
mtdutils/mtdutils.c \
twinstall.cpp \
twmincrypt/twrsa.c \
twmincrypt/twsha.c
twmincrypt/twsha.c \
twrp-functions.cpp
ifeq ($(TARGET_RECOVERY_REBOOT_SRC),)
LOCAL_SRC_FILES += reboot.c
......
......@@ -50,8 +50,6 @@ extern "C"
void gui_notifyVarChange(const char *name, const char* value);
int get_battery_level(void);
int __system(const char *command);
}
......@@ -761,8 +759,36 @@ int DataManager::GetMagicValue(const string varName, string& value)
if (varName == "tw_battery")
{
char tmp[16];
static char charging = ' ';
static int lastVal = -1;
static time_t nextSecCheck = 0;
struct timeval curTime;
gettimeofday(&curTime, NULL);
if (curTime.tv_sec > nextSecCheck)
{
char cap_s[4];
FILE * cap = fopen("/sys/class/power_supply/battery/capacity","rt");
if (cap){
fgets(cap_s, 4, cap);
fclose(cap);
lastVal = atoi(cap_s);
if (lastVal > 100) lastVal = 101;
if (lastVal < 0) lastVal = 0;
}
cap = fopen("/sys/class/power_supply/battery/status","rt");
if (cap) {
fgets(cap_s, 2, cap);
fclose(cap);
if (cap_s[0] == 'C')
charging = '+';
else
charging = ' ';
}
nextSecCheck = curTime.tv_sec + 60;
}
sprintf(tmp, "%i%%", get_battery_level());
sprintf(tmp, "%i%%%c", lastVal, charging);
value = tmp;
return 0;
}
......
......@@ -339,102 +339,6 @@ int usb_storage_disable(void)
return 0;
}
void wipe_dalvik_cache()
{
//ui_set_background(BACKGROUND_ICON_WIPE);
ensure_path_mounted("/data");
ensure_path_mounted("/cache");
ui_print("\n-- Wiping Dalvik Cache Directories...\n");
__system("rm -rf /data/dalvik-cache");
ui_print("Cleaned: /data/dalvik-cache...\n");
__system("rm -rf /cache/dalvik-cache");
ui_print("Cleaned: /cache/dalvik-cache...\n");
__system("rm -rf /cache/dc");
ui_print("Cleaned: /cache/dc\n");
struct stat st;
LOGE("TODO: Re-implement wipe dalvik into Partition Manager!\n");
if (1) //if (0 != stat(sde.blk, &st))
{
ui_print("/sd-ext not present, skipping\n");
} else {
__system("mount /sd-ext");
LOGI("Mounting /sd-ext\n");
if (stat("/sd-ext/dalvik-cache",&st) == 0)
{
__system("rm -rf /sd-ext/dalvik-cache");
ui_print("Cleaned: /sd-ext/dalvik-cache...\n");
}
}
ensure_path_unmounted("/data");
ui_print("-- Dalvik Cache Directories Wipe Complete!\n\n");
//ui_set_background(BACKGROUND_ICON_MAIN);
//if (!ui_text_visible()) return;
}
// BATTERY STATS
void wipe_battery_stats()
{
ensure_path_mounted("/data");
struct stat st;
if (0 != stat("/data/system/batterystats.bin", &st))
{
ui_print("No Battery Stats Found. No Need To Wipe.\n");
} else {
//ui_set_background(BACKGROUND_ICON_WIPE);
remove("/data/system/batterystats.bin");
ui_print("Cleared: Battery Stats...\n");
ensure_path_unmounted("/data");
}
}
// ROTATION SETTINGS
void wipe_rotate_data()
{
//ui_set_background(BACKGROUND_ICON_WIPE);
ensure_path_mounted("/data");
__system("rm -r /data/misc/akmd*");
__system("rm -r /data/misc/rild*");
ui_print("Cleared: Rotatation Data...\n");
ensure_path_unmounted("/data");
}
void fix_perms()
{
ensure_path_mounted("/data");
ensure_path_mounted("/system");
//ui_show_progress(1,30);
ui_print("\n-- Fixing Permissions\n");
ui_print("This may take a few minutes.\n");
__system("./sbin/fix_permissions.sh");
ui_print("-- Done.\n\n");
//ui_reset_progress();
}
int get_battery_level(void)
{
static int lastVal = -1;
static time_t nextSecCheck = 0;
struct timeval curTime;
gettimeofday(&curTime, NULL);
if (curTime.tv_sec > nextSecCheck)
{
char cap_s[4];
FILE * cap = fopen("/sys/class/power_supply/battery/capacity","rt");
if (cap)
{
fgets(cap_s, 4, cap);
fclose(cap);
lastVal = atoi(cap_s);
if (lastVal > 100) lastVal = 101;
if (lastVal < 0) lastVal = 0;
}
nextSecCheck = curTime.tv_sec + 60;
}
return lastVal;
}
void update_tz_environment_variables() {
setenv("TZ", DataManager_GetStrValue(TW_TIME_ZONE_VAR), 1);
tzset();
......@@ -478,56 +382,6 @@ void run_script(const char *str1, const char *str2, const char *str3, const char
//if (!ui_text_visible()) return;
}
void install_htc_dumlock(void)
{
struct statfs fs1, fs2;
int need_libs = 0;
ui_print("Installing HTC Dumlock to system...\n");
ensure_path_mounted("/system");
__system("cp /res/htcd/htcdumlocksys /system/bin/htcdumlock && chmod 755 /system/bin/htcdumlock");
if (statfs("/system/bin/flash_image", &fs1) != 0) {
ui_print("Installing flash_image...\n");
__system("cp /res/htcd/flash_imagesys /system/bin/flash_image && chmod 755 /system/bin/flash_image");
need_libs = 1;
} else
ui_print("flash_image is already installed, skipping...\n");
if (statfs("/system/bin/dump_image", &fs2) != 0) {
ui_print("Installing dump_image...\n");
__system("cp /res/htcd/dump_imagesys /system/bin/dump_image && chmod 755 /system/bin/dump_image");
need_libs = 1;
} else
ui_print("dump_image is already installed, skipping...\n");
if (need_libs) {
ui_print("Installing libs needed for flash_image and dump_image...\n");
__system("cp /res/htcd/libbmlutils.so /system/lib && chmod 755 /system/lib/libbmlutils.so");
__system("cp /res/htcd/libflashutils.so /system/lib && chmod 755 /system/lib/libflashutils.so");
__system("cp /res/htcd/libmmcutils.so /system/lib && chmod 755 /system/lib/libmmcutils.so");
__system("cp /res/htcd/libmtdutils.so /system/lib && chmod 755 /system/lib/libmtdutils.so");
}
ui_print("Installing HTC Dumlock app...\n");
ensure_path_mounted("/data");
mkdir("/data/app", 0777);
__system("rm /data/app/com.teamwin.htcdumlock*");
__system("cp /res/htcd/HTCDumlock.apk /data/app/com.teamwin.htcdumlock.apk");
sync();
ui_print("HTC Dumlock is installed.\n");
}
void htc_dumlock_restore_original_boot(void)
{
ui_print("Restoring original boot...\n");
__system("htcdumlock restore");
ui_print("Original boot restored.\n");
}
void htc_dumlock_reflash_recovery_to_boot(void)
{
ui_print("Reflashing recovery to boot...\n");
__system("htcdumlock recovery noreboot");
ui_print("Recovery is flashed to boot.\n");
}
void check_and_run_script(const char* script_file, const char* display_name)
{
// Check for and run startup script if script exists
......
......@@ -8,22 +8,12 @@ int __system(const char *command);
FILE * __popen(const char *program, const char *type);
int __pclose(FILE *iop);
void wipe_dalvik_cache();
void wipe_battery_stats();
void wipe_rotate_data();
static long tmplog_offset = 0;
void update_tz_environment_variables();
void fix_perms();
void run_script(const char *str1, const char *str2, const char *str3, const char *str4, const char *str5, const char *str6, const char *str7, int request_confirm);
void install_htc_dumlock(void);
void htc_dumlock_restore_original_boot(void);
void htc_dumlock_reflash_recovery_to_boot(void);
void check_and_run_script(const char* script_file, const char* display_name);
int check_backup_name(int show_error);
void twfinish_recovery(const char *send_intent);
......
......@@ -19,6 +19,7 @@
#include <string>
#include <sstream>
#include "../partitions.hpp"
#include "../twrp-functions.hpp"
extern "C" {
#include "../common.h"
......@@ -31,7 +32,6 @@ extern "C" {
#include "../twinstall.h"
int TWinstall_zip(const char* path, int* wipe_cache);
void fix_perms();
void wipe_dalvik_cache(void);
int check_backup_name(int show_error);
void wipe_battery_stats(void);
......@@ -667,62 +667,57 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
operation_start("Format");
DataManager::SetValue("tw_partition", arg);
int ret_val = 0;
int ret_val = false;
if (simulate) {
simulate_progress_bar();
} else {
if (arg == "data")
PartitionManager.Factory_Reset();
ret_val = PartitionManager.Factory_Reset();
else if (arg == "battery")
wipe_battery_stats();
ret_val = PartitionManager.Wipe_Battery_Stats();
else if (arg == "rotate")
wipe_rotate_data();
ret_val = PartitionManager.Wipe_Rotate_Data();
else if (arg == "dalvik")
wipe_dalvik_cache();
ret_val = PartitionManager.Wipe_Dalvik_Cache();
else if (arg == "DATAMEDIA") {
LOGE("TODO: Implement formatting of datamedia device!\n");
ret_val = 1; //format_data_media();
int has_datamedia, dual_storage;
DataManager::GetValue(TW_HAS_DATA_MEDIA, has_datamedia);
DataManager::GetValue(TW_HAS_DUAL_STORAGE, dual_storage);
if (has_datamedia && !dual_storage) {
system("umount /sdcard");
system("mount /data/media /sdcard");
}
ret_val = PartitionManager.Format_Data();
} else if (arg == "INTERNAL") {
int has_datamedia, dual_storage;
DataManager::GetValue(TW_HAS_DATA_MEDIA, has_datamedia);
if (has_datamedia) {
PartitionManager.Mount_By_Path("/data", 1);
__system("rm -rf /data/media");
__system("cd /data && mkdir media && chmod 775 media");
DataManager::GetValue(TW_HAS_DUAL_STORAGE, dual_storage);
if (!dual_storage) {
system("umount /sdcard");
system("mount /data/media /sdcard");
}
ret_val = PartitionManager.Wipe_Media_From_Data();
} else {
ret_val = 0;
LOGE("Wipe not implemented yet!\n");
ret_val = PartitionManager.Wipe_By_Path(DataManager::GetSettingsStoragePath());
}
} else if (arg == "EXTERNAL") {
ret_val = 0;
LOGE("Wipe not implemented yet!\n");
string External_Path;
DataManager::GetValue(TW_EXTERNAL_PATH, External_Path);
ret_val = PartitionManager.Wipe_By_Path(External_Path);
} else
PartitionManager.Wipe_By_Path(arg);
ret_val = PartitionManager.Wipe_By_Path(arg);
if (arg == "/sdcard") {
PartitionManager.Mount_By_Path("/sdcard", 1);
mkdir("/sdcard/TWRP", 0777);
DataManager::Flush();
if (arg == DataManager::GetSettingsStoragePath()) {
// If we wiped the settings storage path, recreate the TWRP folder and dump the settings
string Storage_Path = DataManager::GetSettingsStoragePath();
if (PartitionManager.Mount_By_Path(Storage_Path, true)) {
LOGI("Making TWRP folder and saving settings.\n");
Storage_Path += "/TWRP";
mkdir(Storage_Path.c_str(), 0777);
DataManager::Flush();
} else {
LOGE("Unable to recreate TWRP folder and save settings.\n");
}
}
}
PartitionManager.Update_System_Details();
if (ret_val != 0)
ret_val = 1;
if (ret_val)
ret_val = 0; // 0 is success
else
ret_val = 1; // 1 is failure
operation_end(ret_val, simulate);
return 0;
}
......@@ -770,7 +765,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (simulate) {
simulate_progress_bar();
} else
fix_perms();
PartitionManager.Fix_Permissions();
LOGI("fix permissions DONE!\n");
operation_end(0, simulate);
......@@ -870,7 +865,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (simulate) {
simulate_progress_bar();
} else
install_htc_dumlock();
TWFunc::install_htc_dumlock();
operation_end(0, simulate);
return 0;
......@@ -881,7 +876,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (simulate) {
simulate_progress_bar();
} else
htc_dumlock_restore_original_boot();
TWFunc::htc_dumlock_restore_original_boot();
operation_end(0, simulate);
return 0;
......@@ -892,7 +887,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (simulate) {
simulate_progress_bar();
} else
htc_dumlock_reflash_recovery_to_boot();
TWFunc::htc_dumlock_reflash_recovery_to_boot();
operation_end(0, simulate);
return 0;
......
This diff is collapsed.
......@@ -34,6 +34,12 @@
#include "common.h"
#include "partitions.hpp"
#include "data.hpp"
#include "twrp-functions.hpp"
extern "C" {
#include "extra-functions.h"
int __system(const char *command);
}
#ifdef TW_INCLUDE_CRYPTO
#ifdef TW_INCLUDE_JB_CRYPTO
......@@ -89,10 +95,7 @@ int TWPartitionManager::Write_Fstab(void) {
}
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
if ((*iter)->Can_Be_Mounted) {
if ((*iter)->Is_Decrypted)
Line = (*iter)->Decrypted_Block_Device + " " + (*iter)->Mount_Point + " " + (*iter)->Current_File_System + " rw\n";
else
Line = (*iter)->Block_Device + " " + (*iter)->Mount_Point + " " + (*iter)->Current_File_System + " rw\n";
Line = (*iter)->Actual_Block_Device + " " + (*iter)->Mount_Point + " " + (*iter)->Current_File_System + " rw\n";
fputs(Line.c_str(), fp);
// Handle subpartition tracking
if ((*iter)->Is_SubPartition) {
......@@ -112,7 +115,7 @@ int TWPartitionManager::Mount_By_Path(string Path, bool Display_Error) {
std::vector<TWPartition*>::iterator iter;
int ret = false;
bool found = false;
string Local_Path = Get_Root_Path(Path);
string Local_Path = TWFunc::Get_Root_Path(Path);
// Iterate through all partitions
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
......@@ -181,7 +184,7 @@ int TWPartitionManager::UnMount_By_Path(string Path, bool Display_Error) {
std::vector<TWPartition*>::iterator iter;
int ret = false;
bool found = false;
string Local_Path = Get_Root_Path(Path);
string Local_Path = TWFunc::Get_Root_Path(Path);
// Iterate through all partitions
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
......@@ -294,7 +297,7 @@ int TWPartitionManager::Mount_Settings_Storage(bool Display_Error) {
TWPartition* TWPartitionManager::Find_Partition_By_Path(string Path) {
std::vector<TWPartition*>::iterator iter;
string Local_Path = Get_Root_Path(Path);
string Local_Path = TWFunc::Get_Root_Path(Path);
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
if ((*iter)->Mount_Point == Local_Path || (!(*iter)->Symlink_Mount_Point.empty() && (*iter)->Symlink_Mount_Point == Local_Path))
......@@ -307,7 +310,7 @@ TWPartition* TWPartitionManager::Find_Partition_By_Block(string Block) {
std::vector<TWPartition*>::iterator iter;
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
if ((*iter)->Block_Device == Block || (*iter)->Alternate_Block_Device == Block || ((*iter)->Is_Decrypted && (*iter)->Decrypted_Block_Device == Block))
if ((*iter)->Primary_Block_Device == Block || (*iter)->Alternate_Block_Device == Block || ((*iter)->Is_Decrypted && (*iter)->Decrypted_Block_Device == Block))
return (*iter);
}
return NULL;
......@@ -331,7 +334,7 @@ int TWPartitionManager::Run_Backup(string Backup_Name) {
int TWPartitionManager::Run_Restore(string Restore_Name) {
int check;
TWPartition* Part;
LOGE("TO DO: Check MD5 of all partitions before restoring ANY partitions.\n");
DataManager::GetValue(TW_RESTORE_SYSTEM_VAR, check);
if (check > 0) {
Part = Find_Partition_By_Path("/system");
......@@ -389,7 +392,7 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
#ifdef SP1_NAME
DataManager::GetValue(TW_RESTORE_SP1_VAR, check);
if (check > 0) {
Part = Find_Partition_By_Path(Get_Root_Path(SP1_NAME));
Part = Find_Partition_By_Path(TWFunc::Get_Root_Path(SP1_NAME));
if (Part) {
if (!Part->Restore(Restore_Name))
return false;
......@@ -400,7 +403,7 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
#ifdef SP2_NAME
DataManager::GetValue(TW_RESTORE_SP2_VAR, check);
if (check > 0) {
Part = Find_Partition_By_Path(Get_Root_Path(SP2_NAME));
Part = Find_Partition_By_Path(TWFunc::Get_Root_Path(SP2_NAME));
if (Part) {
if (!Part->Restore(Restore_Name))
return false;
......@@ -411,7 +414,7 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
#ifdef SP3_NAME
DataManager::GetValue(TW_RESTORE_SP3_VAR, check);
if (check > 0) {
Part = Find_Partition_By_Path(Get_Root_Path(SP3_NAME));
Part = Find_Partition_By_Path(TWFunc::Get_Root_Path(SP3_NAME));
if (Part) {
if (!Part->Restore(Restore_Name))
return false;
......@@ -518,15 +521,15 @@ void TWPartitionManager::Set_Restore_Files(string Restore_Name) {
if (Part->Mount_Point == "/sd-ext")
tw_restore_sdext = 1;
#ifdef SP1_NAME
if (Part->Mount_Point == Get_Root_Path(SP1_Name))
if (Part->Mount_Point == TWFunc::Get_Root_Path(SP1_Name))
tw_restore_sp1 = 1;
#endif
#ifdef SP2_NAME
if (Part->Mount_Point == Get_Root_Path(SP2_Name))
if (Part->Mount_Point == TWFunc::Get_Root_Path(SP2_Name))
tw_restore_sp2 = 1;
#endif
#ifdef SP3_NAME
if (Part->Mount_Point == Get_Root_Path(SP3_Name))
if (Part->Mount_Point == TWFunc::Get_Root_Path(SP3_Name))
tw_restore_sp3 = 1;
#endif
}
......@@ -551,7 +554,7 @@ int TWPartitionManager::Wipe_By_Path(string Path) {
std::vector<TWPartition*>::iterator iter;
int ret = false;
bool found = false;
string Local_Path = Get_Root_Path(Path);
string Local_Path = TWFunc::Get_Root_Path(Path);
// Iterate through all partitions
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
......@@ -612,7 +615,7 @@ int TWPartitionManager::Factory_Reset(void) {
int ret = true;
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
if ((*iter)->Wipe_During_Factory_Reset) {
if ((*iter)->Wipe_During_Factory_Reset && (*iter)->Is_Present) {
if (!(*iter)->Wipe())
ret = false;
}
......@@ -620,6 +623,101 @@ int TWPartitionManager::Factory_Reset(void) {
return ret;
}
int TWPartitionManager::Wipe_Dalvik_Cache(void) {
struct stat st;
if (!Mount_By_Path("/data", true))
return false;
if (!Mount_By_Path("/cache", true))
return false;
ui_print("\nWiping Dalvik Cache Directories...\n");
__system("rm -rf /data/dalvik-cache");
ui_print("Cleaned: /data/dalvik-cache...\n");
__system("rm -rf /cache/dalvik-cache");
ui_print("Cleaned: /cache/dalvik-cache...\n");
__system("rm -rf /cache/dc");
ui_print("Cleaned: /cache/dc\n");
TWPartition* sdext = Find_Partition_By_Path("/sd-ext");
if (sdext != NULL) {
if (sdext->Is_Present && sdext->Mount(false)) {
if (stat("/sd-ext/dalvik-cache", &st) == 0) {
__system("rm -rf /sd-ext/dalvik-cache");
ui_print("Cleaned: /sd-ext/dalvik-cache...\n");
}
}
}
ui_print("-- Dalvik Cache Directories Wipe Complete!\n\n");
return true;
}
int TWPartitionManager::Wipe_Rotate_Data(void) {
if (!Mount_By_Path("/data", true))
return false;
__system("rm -r /data/misc/akmd*");
__system("rm -r /data/misc/rild*");
ui_print("Rotation data wiped.\n");
return true;
}
int TWPartitionManager::Wipe_Battery_Stats(void) {
struct stat st;
if (!Mount_By_Path("/data", true))
return false;
if (0 != stat("/data/system/batterystats.bin", &st)) {
ui_print("No Battery Stats Found. No Need To Wipe.\n");
} else {
remove("/data/system/batterystats.bin");
ui_print("Cleared battery stats.\n");
}
return true;
}
int TWPartitionManager::Format_Data(void) {
TWPartition* dat = Find_Partition_By_Path("/data");
if (dat != NULL) {
if (!dat->UnMount(true))
return false;
return dat->Wipe_Encryption();
} else {
LOGE("Unable to locate /data.\n");
return false;
}
return false;
}
int TWPartitionManager::Wipe_Media_From_Data(void) {
TWPartition* dat = Find_Partition_By_Path("/data");
if (dat != NULL) {
if (!dat->Has_Data_Media) {
LOGE("This device does not have /data/media\n");
return false;
}
if (!dat->Mount(true))
return false;
ui_print("Wiping internal storage -- /data/media...\n");
__system("rm -rf /data/media");
__system("cd /data && mkdir media && chmod 775 media");
if (dat->Has_Data_Media) {
dat->Recreate_Media_Folder();
}
return true;
} else {
LOGE("Unable to locate /data.\n");
return false;
}
return false;
}
void TWPartitionManager::Refresh_Sizes(void) {
Update_System_Details();
return;
......@@ -692,7 +790,7 @@ int TWPartitionManager::Decrypt_Device(string Password) {
} else {
TWPartition* dat = Find_Partition_By_Path("/data");
if (dat != NULL) {
DataManager::SetValue(TW_DATA_BLK_DEVICE, dat->Block_Device);
DataManager::SetValue(TW_DATA_BLK_DEVICE, dat->Primary_Block_Device);
DataManager::SetValue(TW_IS_DECRYPTED, 1);
dat->Is_Decrypted = true;
dat->Decrypted_Block_Device = crypto_blkdev;
......@@ -711,17 +809,15 @@ int TWPartitionManager::Decrypt_Device(string Password) {
return 1;
}
string TWPartitionManager::Get_Root_Path(string Path) {
string Local_Path = Path;
int TWPartitionManager::Fix_Permissions(void) {
if (!Mount_By_Path("/data", true))
return false;
// Make sure that we have a leading slash
if (Local_Path.substr(0, 1) != "/")
Local_Path = "/" + Local_Path;
if (!Mount_By_Path("/system", true))
return false;
// Trim the path to get the root path only
size_t position = Local_Path.find("/", 2);
if (position != string::npos) {
Local_Path.resize(position);
}
return Local_Path;
}
ui_print("Fixing Permissions\nThis may take a few minutes.\n");
__system("./sbin/fix_permissions.sh");
ui_print("Done.\n\n");
return true;
}
\ No newline at end of file
......@@ -57,9 +57,11 @@ public:
virtual bool Wipe_Encryption(); // Ignores wipe commands for /data/media devices and formats the original block device
virtual void Check_FS_Type(); // Checks the fs type using blkid, does not do anything on MTD / yaffs2 because this crashes on some devices
virtual bool Update_Size(bool Display_Error); // Updates size information
virtual void Recreate_Media_Folder(); // Recreates the /data/media folder
protected:
bool Process_Fstab_Line(string Line, bool Display_Error); // Processes a fstab line
void Find_Actual_Block_Device(); // Determines the correct block device and stores it in Actual_Block_Device
protected:
bool Can_Be_Mounted; // Indicates that the partition can be mounted
......@@ -72,8 +74,10 @@ protected:
string Symlink_Path; // Symlink path (e.g. /data/media)
string Symlink_Mount_Point; // /sdcard could be the symlink mount point for /data/media
string Mount_Point; // Mount point for this partition (e.g. /system or /data)
string Block_Device; // Block device (e.g. /dev/block/mmcblk1p1)
string Actual_Block_Device; // Actual block device (one of primary, alternate, or decrypted)
string Primary_Block_Device; // Block device (e.g. /dev/block/mmcblk1p1)
string Alternate_Block_Device; // Alternate block device (e.g. /dev/block/mmcblk1)
string Decrypted_Block_Device; // Decrypted block device available after decryption
bool Removable; // Indicates if this partition is removable -- affects how often we check overall size, if present, etc.
bool Is_Present; // Indicates if the partition is currently present as a block device
int Length; // Used by make_ext4fs to leave free space at the end of the partition block for things like a crypto footer
......@@ -84,10 +88,10 @@ protected:
bool Can_Be_Encrypted; // This partition might be encrypted, affects error handling, can only be true if crypto support is compiled in
bool Is_Encrypted; // This partition is thought to be encrypted -- it wouldn't mount for some reason, only avialble with crypto support
bool Is_Decrypted; // This partition has successfully been decrypted
string Decrypted_Block_Device; // Decrypted block device available after decryption
string Display_Name; // Display name for the GUI
string Backup_Name; // Backup name -- used for backup filenames
string Backup_FileName; // Actual backup filename
string MTD_Name; // Name of the partition for MTD devices
Backup_Method_enum Backup_Method; // Method used for backup
bool Has_Data_Media; // Indicates presence of /data/media, may affect wiping and backup methods
bool Is_Storage; // Indicates if this partition is used for storage for backup, restore, and installing zips
......@@ -110,7 +114,7 @@ private:
bool Wipe_EXT23(); // Formats as ext3 or ext2
bool Wipe_EXT4(); // Formats using ext4, uses make_ext4fs when present
bool Wipe_FAT(); // Formats as FAT except that mkdosfs from busybox usually fails so oftentimes this is actually a rm -rf wipe
bool Wipe_YAFFS2(); // Formats as yaffs2 for MTD memory types
bool Wipe_MTD(); // Formats as yaffs2 for MTD memory types
bool Wipe_RMRF(); // Uses rm -rf to wipe
bool Wipe_Data_Without_Wiping_Media(); // Uses rm -rf to wipe but does not wipe /data/media
bool Backup_Tar(string backup_folder); // Backs up using tar for file systems
......@@ -123,6 +127,7 @@ private:
bool Get_Size_Via_df(bool Display_Error); // Get Partition size, used, and free space using df command
unsigned long long Get_Folder_Size(string Path, bool Display_Error); // Gets the size of the files in a folder and all of its subfolders
bool Make_Dir(string Path, bool Display_Error); // Creates a directory if it doesn't already exist
bool Find_MTD_Block_Device(string MTD_Name); // Finds the mtd block device based on the name from the fstab
friend class TWPartitionManager;
};
......@@ -157,10 +162,15 @@ public:
virtual int Wipe_By_Block(string Block); // Wipes a partition based on block device
virtual int Wipe_By_Name(string Name); // Wipes a partition based on display name
virtual int Factory_Reset(); // Performs a factory reset
virtual int Wipe_Dalvik_Cache(); // Wipes dalvik cache
virtual int Wipe_Rotate_Data(); // Wipes rotation data --
virtual int Wipe_Battery_Stats(); // Wipe battery stats -- /data/system/batterystats.bin
virtual int Format_Data(); // Really formats data on /data/media devices -- also removes encryption
virtual int Wipe_Media_From_Data(); // Removes and recreates the media folder on /data/media devices
virtual void Refresh_Sizes(); // Refreshes size data of partitions
virtual void Update_System_Details(); // Updates fstab, file systems, sizes, etc.
virtual int Decrypt_Device(string Password); // Attempt to decrypt any encrypted partitions
virtual string Get_Root_Path(string Path); // Trims any trailing folders or filenames from the path, also adds a leading / if not present
virtual int Fix_Permissions(); // Fixes permissions in /system and /data
private:
std::vector<TWPartition*> Partitions; // Vector list of all partitions
......
......@@ -53,6 +53,9 @@ endif
ifeq ($(TW_INCLUDE_JB_CRYPTO), true)
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcrypto.so
endif
ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/make_ext4fs
endif
TWRP_AUTOGEN := $(intermediates)/teamwin
......
......@@ -42,8 +42,6 @@ int tw_reboot(RebootCommand command)
// Always force a sync before we reboot
sync();
ensure_path_unmounted("/sdcard");
switch (command)
{