Fixes for multi-user in 4.2

Also fixed inability to delete backups with a space in the name.

Change-Id: I2f6639d33caa3c4542960f76adbd59b25ab64f5d
This commit is contained in:
Dees_Troy
2012-11-14 22:27:31 +00:00
parent 3e14652310
commit 16b74353d9
56 changed files with 3681 additions and 45 deletions
+19 -24
View File
@@ -446,6 +446,18 @@ void DataManager::update_tz_environment_variables(void) {
tzset();
}
void DataManager::SetBackupFolder()
{
string str = GetCurrentStoragePath();
str += "/TWRP/BACKUPS/";
string dev_id;
GetValue("device_id", dev_id);
str += dev_id;
SetValue(TW_BACKUPS_FOLDER_VAR, str, 0);
}
void DataManager::SetDefaultValues()
{
string str, path;
@@ -475,7 +487,7 @@ void DataManager::SetDefaultValues()
LOGI("Internal path defined: '%s'\n", EXPAND(TW_INTERNAL_STORAGE_PATH));
mValues.insert(make_pair(TW_USE_EXTERNAL_STORAGE, make_pair("0", 1)));
mConstValues.insert(make_pair(TW_HAS_INTERNAL, "1"));
mConstValues.insert(make_pair(TW_INTERNAL_PATH, EXPAND(TW_INTERNAL_STORAGE_PATH)));
mValues.insert(make_pair(TW_INTERNAL_PATH, make_pair(EXPAND(TW_INTERNAL_STORAGE_PATH), 0)));
mConstValues.insert(make_pair(TW_INTERNAL_LABEL, EXPAND(TW_INTERNAL_STORAGE_MOUNT_POINT)));
path.clear();
path = "/";
@@ -530,7 +542,7 @@ void DataManager::SetDefaultValues()
// Device has /data/media
mConstValues.insert(make_pair(TW_USE_EXTERNAL_STORAGE, "0"));
mConstValues.insert(make_pair(TW_HAS_INTERNAL, "1"));
mConstValues.insert(make_pair(TW_INTERNAL_PATH, "/data/media"));
mValues.insert(make_pair(TW_INTERNAL_PATH, make_pair("/data/media", 0)));
mConstValues.insert(make_pair(TW_INTERNAL_MOUNT, "/data"));
mConstValues.insert(make_pair(TW_INTERNAL_LABEL, "data"));
#ifdef TW_EXTERNAL_STORAGE_PATH
@@ -547,7 +559,7 @@ void DataManager::SetDefaultValues()
// Device has no internal storage
mConstValues.insert(make_pair(TW_USE_EXTERNAL_STORAGE, "1"));
mConstValues.insert(make_pair(TW_HAS_INTERNAL, "0"));
mConstValues.insert(make_pair(TW_INTERNAL_PATH, "0"));
mValues.insert(make_pair(TW_INTERNAL_PATH, make_pair("0", 0)));
mConstValues.insert(make_pair(TW_INTERNAL_MOUNT, "0"));
mConstValues.insert(make_pair(TW_INTERNAL_LABEL, "0"));
#endif
@@ -580,6 +592,10 @@ void DataManager::SetDefaultValues()
LOGI("Defaulting to external storage.\n");
#endif
#ifdef RECOVERY_SDCARD_ON_DATA
if (PartitionManager.Mount_By_Path("/data", false) && TWFunc::Path_Exists("/data/media/0"))
SetValue(TW_INTERNAL_PATH, "/data/media/0");
#endif
str = GetCurrentStoragePath();
#ifdef RECOVERY_SDCARD_ON_DATA
#ifndef TW_EXTERNAL_STORAGE_PATH
@@ -889,27 +905,6 @@ void DataManager::ReadSettingsFile(void)
} else {
PartitionManager.Mount_Current_Storage(true);
}
if (has_data_media == 1) {
if (has_dual == 0) {
LOGI("Mounting /data/media to /sdcard\n");
system("umount /sdcard");
system("mount /data/media /sdcard");
} else {
string ext_path;
GetValue(TW_EXTERNAL_PATH, ext_path);
if (ext_path == "/sdcard") {
LOGI("Mounting /data/media to /emmc\n");
system("cd / && mkdir emmc");
system("umount /emmc");
system("mount /data/media /emmc");
} else {
LOGI("Mounting /data/media to /sdcard\n");
system("umount /sdcard");
system("mount /data/media /sdcard");
}
}
}
if (has_ext) {
string ext_path;
+1
View File
@@ -48,6 +48,7 @@ public:
static void DumpValues();
static void update_tz_environment_variables();
static void SetBackupFolder();
static void SetDefaultValues();
static void Output_Version(void); // Outputs the version to a file in the TWRP folder
static void ReadSettingsFile(void);
+1 -1
View File
@@ -2198,7 +2198,7 @@
<actions>
<action function="set">tw_back=restore</action>
<action function="set">tw_action=cmd</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf %tw_restore_name%</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf &quot;%tw_restore_name%&quot;</action>
<action function="set">tw_text1=Delete Backup? %tw_restore_name%</action>
<action function="set">tw_text2=This cannot be undone!</action>
<action function="set">tw_action_text1=Deleting Backup...</action>
+1 -1
View File
@@ -2198,7 +2198,7 @@
<actions>
<action function="set">tw_back=restore</action>
<action function="set">tw_action=cmd</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf %tw_restore_name%</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf &quot;%tw_restore_name%&quot;</action>
<action function="set">tw_text1=Delete Backup? %tw_restore_name%</action>
<action function="set">tw_text2=This cannot be undone!</action>
<action function="set">tw_action_text1=Deleting Backup...</action>
+1 -1
View File
@@ -2198,7 +2198,7 @@
<actions>
<action function="set">tw_back=restore</action>
<action function="set">tw_action=cmd</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf %tw_restore_name%</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf &quot;%tw_restore_name%&quot;</action>
<action function="set">tw_text1=Delete Backup? %tw_restore_name%</action>
<action function="set">tw_text2=This cannot be undone!</action>
<action function="set">tw_action_text1=Deleting Backup...</action>
+1 -1
View File
@@ -2198,7 +2198,7 @@
<actions>
<action function="set">tw_back=restore</action>
<action function="set">tw_action=cmd</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf %tw_restore_name%</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf &quot;%tw_restore_name%&quot;</action>
<action function="set">tw_text1=Delete Backup? %tw_restore_name%</action>
<action function="set">tw_text2=This cannot be undone!</action>
<action function="set">tw_action_text1=Deleting Backup...</action>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1680,7 +1680,7 @@
<actions>
<action function="set">tw_back=restore</action>
<action function="set">tw_action=cmd</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf %tw_restore_name%</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf &quot;%tw_restore_name%&quot;</action>
<action function="set">tw_text1=Delete Backup? %tw_restore_name%</action>
<action function="set">tw_text2=This cannot be undone!</action>
<action function="set">tw_action_text1=Deleting Backup...</action>
+1 -1
View File
@@ -1679,7 +1679,7 @@
<actions>
<action function="set">tw_back=restore</action>
<action function="set">tw_action=cmd</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf %tw_restore_name%</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf &quot;%tw_restore_name%&quot;</action>
<action function="set">tw_text1=Delete Backup? %tw_restore_name%</action>
<action function="set">tw_text2=This cannot be undone!</action>
<action function="set">tw_action_text1=Deleting Backup...</action>
+1 -1
View File
@@ -1678,7 +1678,7 @@
<actions>
<action function="set">tw_back=restore</action>
<action function="set">tw_action=cmd</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf %tw_restore_name%</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf &quot;%tw_restore_name%&quot;</action>
<action function="set">tw_text1=Delete Backup? %tw_restore_name%</action>
<action function="set">tw_text2=This cannot be undone!</action>
<action function="set">tw_action_text1=Deleting Backup...</action>
+1 -1
View File
@@ -1679,7 +1679,7 @@
<actions>
<action function="set">tw_back=restore</action>
<action function="set">tw_action=cmd</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf %tw_restore_name%</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf &quot;%tw_restore_name%&quot;</action>
<action function="set">tw_text1=Delete Backup? %tw_restore_name%</action>
<action function="set">tw_text2=This cannot be undone!</action>
<action function="set">tw_action_text1=Deleting Backup...</action>
+1 -1
View File
@@ -1684,7 +1684,7 @@
<actions>
<action function="set">tw_back=restore</action>
<action function="set">tw_action=cmd</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf %tw_restore_name%</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf &quot;%tw_restore_name%&quot;</action>
<action function="set">tw_text1=Delete Backup? %tw_restore_name%</action>
<action function="set">tw_text2=This cannot be undone!</action>
<action function="set">tw_action_text1=Deleting Backup...</action>
+1 -1
View File
@@ -1680,7 +1680,7 @@
<actions>
<action function="set">tw_back=restore</action>
<action function="set">tw_action=cmd</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf %tw_restore_name%</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf &quot;%tw_restore_name%&quot;</action>
<action function="set">tw_text1=Delete Backup? %tw_restore_name%</action>
<action function="set">tw_text2=This cannot be undone!</action>
<action function="set">tw_action_text1=Deleting Backup...</action>
+1 -1
View File
@@ -2198,7 +2198,7 @@
<actions>
<action function="set">tw_back=restore</action>
<action function="set">tw_action=cmd</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf %tw_restore_name%</action>
<action function="set">tw_action_param=cd %tw_backups_folder% && rm -rf &quot;%tw_restore_name%&quot;</action>
<action function="set">tw_text1=Delete Backup? %tw_restore_name%</action>
<action function="set">tw_text2=This cannot be undone!</action>
<action function="set">tw_action_text1=Deleting Backup...</action>
+17 -9
View File
@@ -183,15 +183,20 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
Has_Data_Media = true;
Is_Storage = true;
Storage_Path = "/data/media";
Symlink_Path = Storage_Path;
if (strcmp(EXPAND(TW_EXTERNAL_STORAGE_PATH), "/sdcard") == 0) {
Make_Dir("/emmc", Display_Error);
Symlink_Path = "/data/media";
Symlink_Mount_Point = "/emmc";
} else {
Make_Dir("/sdcard", Display_Error);
Symlink_Path = "/data/media";
Symlink_Mount_Point = "/sdcard";
}
if (Mount(false) && TWFunc::Path_Exists("/data/media/0")) {
Storage_Path = "/data/media/0";
Symlink_Path = Storage_Path;
DataManager::SetValue(TW_INTERNAL_PATH, "/data/media/0");
UnMount(true);
}
#endif
#ifdef TW_INCLUDE_CRYPTO
Can_Be_Encrypted = true;
@@ -1054,24 +1059,27 @@ bool TWPartition::Wipe_Data_Without_Wiping_Media() {
return false;
ui_print("Wiping data without wiping /data/media ...\n");
system("rm -f /data/*");
system("rm -f /data/.*");
DIR* d;
d = opendir("/data");
if (d != NULL)
{
if (d != NULL) {
struct dirent* de;
while ((de = readdir(d)) != NULL) {
if (strcmp(de->d_name, "media") == 0) continue;
if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue;
// The media folder is the "internal sdcard"
// The .layout_version file is responsible for determining whether 4.2 decides up upgrade
// the media folder for multi-user.
if (strcmp(de->d_name, "media") == 0 || strcmp(de->d_name, ".layout_version") == 0) continue;
sprintf(cmd, "rm -fr /data/%s", de->d_name);
system(cmd);
}
closedir(d);
ui_print("Done.\n");
return true;
}
ui_print("Done.\n");
return true;
ui_print("Dirent failed to open /data, error!\n");
return false;
}
bool TWPartition::Backup_Tar(string backup_folder) {
+9
View File
@@ -1582,6 +1582,15 @@ int TWPartitionManager::Decrypt_Device(string Password) {
ui_print("Data successfully decrypted, new block device: '%s'\n", crypto_blkdev);
// Sleep for a bit so that the device will be ready
sleep(1);
#ifdef RECOVERY_SDCARD_ON_DATA
if (dat->Mount(false) && TWFunc::Path_Exists("/data/media/0")) {
dat->Storage_Path = "/data/media/0";
dat->Symlink_Path = dat->Storage_Path;
DataManager::SetValue(TW_INTERNAL_PATH, "/data/media/0");
dat->UnMount(false);
DataManager::SetBackupFolder();
}
#endif
Update_System_Details();
UnMount_Main_Partitions();
} else
+1 -1
View File
@@ -17,7 +17,7 @@
#ifndef _VARIABLES_HEADER_
#define _VARIABLES_HEADER_
#define TW_VERSION_STR "2.3.1.3"
#define TW_VERSION_STR "2.3.2.0"
#define TW_USE_COMPRESSION_VAR "tw_use_compression"
#define TW_IGNORE_IMAGE_SIZE "tw_ignore_image_size"