summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2014-02-15 23:43:23 +0100
committerEthan Yonker <dees_troy@teamw.in>2014-02-15 23:43:26 +0100
commitd7adf29ba154ac5efc35be9f0e311ff402e81b8e (patch)
treecbe7a1e3837554d4d504f930a0031b0200061297
parentConditional -> GUIObject and make all gui objects children of GUIObject (diff)
downloadandroid_bootable_recovery-d7adf29ba154ac5efc35be9f0e311ff402e81b8e.tar
android_bootable_recovery-d7adf29ba154ac5efc35be9f0e311ff402e81b8e.tar.gz
android_bootable_recovery-d7adf29ba154ac5efc35be9f0e311ff402e81b8e.tar.bz2
android_bootable_recovery-d7adf29ba154ac5efc35be9f0e311ff402e81b8e.tar.lz
android_bootable_recovery-d7adf29ba154ac5efc35be9f0e311ff402e81b8e.tar.xz
android_bootable_recovery-d7adf29ba154ac5efc35be9f0e311ff402e81b8e.tar.zst
android_bootable_recovery-d7adf29ba154ac5efc35be9f0e311ff402e81b8e.zip
Diffstat (limited to '')
-rw-r--r--openrecoveryscript.cpp75
1 files changed, 29 insertions, 46 deletions
diff --git a/openrecoveryscript.cpp b/openrecoveryscript.cpp
index 4479ec919..014702741 100644
--- a/openrecoveryscript.cpp
+++ b/openrecoveryscript.cpp
@@ -184,24 +184,21 @@ int OpenRecoveryScript::run_script_file(void) {
if (folder_path[0] != '/') {
char backup_folder[512];
string folder_var;
- DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, folder_var);
- sprintf(backup_folder, "%s/%s", folder_var.c_str(), folder_path);
- LOGINFO("Restoring relative path: '%s'\n", backup_folder);
- if (!TWFunc::Path_Exists(backup_folder)) {
- if (DataManager::GetIntValue(TW_HAS_DUAL_STORAGE)) {
- if (DataManager::GetIntValue(TW_USE_EXTERNAL_STORAGE)) {
- LOGINFO("Backup folder '%s' not found on external storage, trying internal...\n", folder_path);
- DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 0);
- } else {
- LOGINFO("Backup folder '%s' not found on internal storage, trying external...\n", folder_path);
- DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 1);
- }
+ std::vector<PartitionList> Storage_List;
+
+ PartitionManager.Get_Partition_List("storage", &Storage_List);
+ int listSize = Storage_List.size();
+ for (int i = 0; i < listSize; i++) {
+ if (PartitionManager.Is_Mounted_By_Path(Storage_List.at(i).Mount_Point)) {
+ DataManager::SetValue("tw_storage_path", Storage_List.at(i).Mount_Point);
DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, folder_var);
sprintf(backup_folder, "%s/%s", folder_var.c_str(), folder_path);
- LOGINFO("2Restoring relative path: '%s'\n", backup_folder);
+ if (TWFunc::Path_Exists(backup_folder)) {
+ strcpy(folder_path, backup_folder);
+ break;
+ }
}
}
- strcpy(folder_path, backup_folder);
} else {
if (folder_path[strlen(folder_path) - 1] == '/')
strcat(folder_path, ".");
@@ -398,42 +395,26 @@ int OpenRecoveryScript::Install_Command(string Zip) {
// Install zip
string ret_string;
int ret_val = 0, wipe_cache = 0;
+ std::vector<PartitionList> Storage_List;
+ string Full_Path;
PartitionManager.Mount_All_Storage();
- if (Zip.substr(0, 1) != "/") {
- // Relative path given
- string Full_Path;
-
- Full_Path = DataManager::GetCurrentStoragePath();
- Full_Path += "/" + Zip;
- LOGINFO("Full zip path: '%s'\n", Full_Path.c_str());
- if (!TWFunc::Path_Exists(Full_Path)) {
- ret_string = Locate_Zip_File(Full_Path, DataManager::GetCurrentStoragePath());
- if (!ret_string.empty()) {
- Full_Path = ret_string;
- } else if (DataManager::GetIntValue(TW_HAS_DUAL_STORAGE)) {
- if (DataManager::GetIntValue(TW_USE_EXTERNAL_STORAGE)) {
- LOGINFO("Zip file not found on external storage, trying internal...\n");
- DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 0);
- } else {
- LOGINFO("Zip file not found on internal storage, trying external...\n");
- DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 1);
- }
- Full_Path = DataManager::GetCurrentStoragePath();
- Full_Path += "/" + Zip;
- LOGINFO("Full zip path: '%s'\n", Full_Path.c_str());
- ret_string = Locate_Zip_File(Full_Path, DataManager::GetCurrentStoragePath());
- if (!ret_string.empty())
- Full_Path = ret_string;
+ PartitionManager.Get_Partition_List("storage", &Storage_List);
+ int listSize = Storage_List.size();
+ for (int i = 0; i < listSize; i++) {
+ if (PartitionManager.Is_Mounted_By_Path(Storage_List.at(i).Mount_Point)) {
+ Full_Path = Storage_List.at(i).Mount_Point + "/" + Zip;
+ if (TWFunc::Path_Exists(Full_Path)) {
+ Zip = Full_Path;
+ break;
}
- }
- Zip = Full_Path;
- } else {
- // Full path given
- if (!TWFunc::Path_Exists(Zip)) {
- ret_string = Locate_Zip_File(Zip, DataManager::GetCurrentStoragePath());
- if (!ret_string.empty())
+ Full_Path = Zip;
+ LOGINFO("Trying to find zip '%s' on '%s'...\n", Full_Path.c_str(), Storage_List.at(i).Mount_Point.c_str());
+ ret_string = Locate_Zip_File(Full_Path, Storage_List.at(i).Mount_Point);
+ if (!ret_string.empty()) {
Zip = ret_string;
+ break;
+ }
}
}
@@ -465,9 +446,11 @@ string OpenRecoveryScript::Locate_Zip_File(string Zip, string Storage_Root) {
{
pathCpy = Path.substr(pos, Path.size() - pos);
wholePath = pathCpy + "/" + File;
+ LOGINFO("Looking for zip at '%s'\n", wholePath.c_str());
if (TWFunc::Path_Exists(wholePath))
return wholePath;
wholePath = Storage_Root + "/" + wholePath;
+ LOGINFO("Looking for zip at '%s'\n", wholePath.c_str());
if (TWFunc::Path_Exists(wholePath))
return wholePath;