summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDees_Troy <dees_troy@teamw.in>2012-09-27 21:44:01 +0200
committerDees_Troy <dees_troy@teamw.in>2012-09-27 21:44:01 +0200
commit3477d7163e781bc88836fe5c36160d8eb60ea4ac (patch)
treed11921fd6388cb4843f003407a2d2f0488185aac
parentCreate symlinks at compile time for busybox (diff)
downloadandroid_bootable_recovery-3477d7163e781bc88836fe5c36160d8eb60ea4ac.tar
android_bootable_recovery-3477d7163e781bc88836fe5c36160d8eb60ea4ac.tar.gz
android_bootable_recovery-3477d7163e781bc88836fe5c36160d8eb60ea4ac.tar.bz2
android_bootable_recovery-3477d7163e781bc88836fe5c36160d8eb60ea4ac.tar.lz
android_bootable_recovery-3477d7163e781bc88836fe5c36160d8eb60ea4ac.tar.xz
android_bootable_recovery-3477d7163e781bc88836fe5c36160d8eb60ea4ac.tar.zst
android_bootable_recovery-3477d7163e781bc88836fe5c36160d8eb60ea4ac.zip
Diffstat (limited to '')
-rw-r--r--gui/action.cpp1
-rw-r--r--recovery.cpp6
-rw-r--r--twrp-functions.cpp26
-rw-r--r--twrp-functions.hpp7
4 files changed, 32 insertions, 8 deletions
diff --git a/gui/action.cpp b/gui/action.cpp
index afa52d1f8..771c5e74e 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -981,6 +981,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
DataManager::SetValue(TW_IS_ENCRYPTED, 0);
DataManager::ReadSettingsFile();
+ TWFunc::Output_Version();
if (OpenRecoveryScript::check_for_script_file()) {
ui_print("Processing OpenRecoveryScript file...\n");
if (OpenRecoveryScript::run_script_file() == 0) {
diff --git a/recovery.cpp b/recovery.cpp
index 3c4447274..41bd080ce 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -809,11 +809,6 @@ main(int argc, char **argv) {
DataManager_LoadDefaults();
printf("Starting the UI...");
gui_init();
- //printf("=> Installing busybox into /sbin\n");
- //system("/sbin/bbinstall.sh"); // Let's install busybox
- printf("Symlinking gzip to pigz\n");
- system("ln -sf /sbin/pigz /sbin/gzip");
- system("ln -sf /sbin/unpigz /sbin/gunzip");
printf("=> Linking mtab\n");
system("ln -s /proc/mounts /etc/mtab"); // And link mtab for mke2fs
printf("=> Processing recovery.fstab\n");
@@ -931,6 +926,7 @@ main(int argc, char **argv) {
finish_recovery(NULL);
DataManager_ReadSettingsFile();
if (DataManager_GetIntValue(TW_IS_ENCRYPTED) == 0 && OpenRecoveryScript::check_for_script_file()) {
+ TWFunc::Output_Version();
gui_console_only();
OpenRecoveryScript::run_script_file();
if (1 || OpenRecoveryScript::run_script_file() != 0) {
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 28d0ba58e..320001723 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -15,6 +15,7 @@
#include "common.h"
#include "data.hpp"
#include "bootloader.h"
+#include "variables.h"
/* Checks md5 for a path
Return values:
@@ -385,4 +386,29 @@ void TWFunc::check_and_run_script(const char* script_file, const char* display_n
system(script_file);
ui_print("\nFinished running %s script.\n", display_name);
}
+}
+
+void TWFunc::Output_Version(void) {
+ string Path, Command;
+ char version[255];
+
+ Path = DataManager::GetSettingsStoragePath();
+ if (!PartitionManager.Mount_By_Path(Path, false)) {
+ LOGI("Unable to mount '%s' to write version number.\n");
+ return;
+ }
+ Path += "/TWRP/.version";
+ if (Path_Exists(Path)) {
+ Command = "rm -f " + Path;
+ system(Command.c_str());
+ }
+ FILE *fp = fopen(Path.c_str(), "w");
+ if (fp == NULL) {
+ LOGE("Unable to open '%s'.\n", Path.c_str());
+ return;
+ }
+ strcpy(version, TW_VERSION_STR);
+ fwrite(version, sizeof(version[0]), strlen(version) / sizeof(version[0]), fp);
+ fclose(fp);
+ sync();
} \ No newline at end of file
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index 7bda28725..da17e3cd1 100644
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -33,9 +33,10 @@ public:
static void GUI_Operation_Text(string Read_Value, string Default_Text); // Updates text for display in the GUI, e.g. Backing up %partition name%
static void GUI_Operation_Text(string Read_Value, string Partition_Name, string Default_Text); // Same as above but includes partition name
static unsigned long Get_File_Size(string Path); // Returns the size of a file
- static void twfinish_recovery(const char *send_intent);
- static int tw_reboot(RebootCommand command);
- static void check_and_run_script(const char* script_file, const char* display_name);
+ static void twfinish_recovery(const char *send_intent); // Writes the log to last_log
+ static int tw_reboot(RebootCommand command); // Prepares the device for rebooting
+ static void check_and_run_script(const char* script_file, const char* display_name); // checks for the existence of a script, chmods it to 755, then runs it
+ static void Output_Version(void); // Outputs the version to a file in the TWRP folder
private:
static void check_and_fclose(FILE *fp, const char *name);