summaryrefslogtreecommitdiffstats
path: root/twinstall.cpp
diff options
context:
space:
mode:
authorthat <github@that.at>2014-03-06 07:57:43 +0100
committerthat <github@that.at>2014-03-09 23:17:15 +0100
commit7e303cfeb85373323eeeb2ebe83ba3184c9d7bfa (patch)
tree9c9f6d74f486f40532607f5f80a42c90e4dae9e4 /twinstall.cpp
parentFix error handling in createList (diff)
downloadandroid_bootable_recovery-7e303cfeb85373323eeeb2ebe83ba3184c9d7bfa.tar
android_bootable_recovery-7e303cfeb85373323eeeb2ebe83ba3184c9d7bfa.tar.gz
android_bootable_recovery-7e303cfeb85373323eeeb2ebe83ba3184c9d7bfa.tar.bz2
android_bootable_recovery-7e303cfeb85373323eeeb2ebe83ba3184c9d7bfa.tar.lz
android_bootable_recovery-7e303cfeb85373323eeeb2ebe83ba3184c9d7bfa.tar.xz
android_bootable_recovery-7e303cfeb85373323eeeb2ebe83ba3184c9d7bfa.tar.zst
android_bootable_recovery-7e303cfeb85373323eeeb2ebe83ba3184c9d7bfa.zip
Diffstat (limited to '')
-rw-r--r--twinstall.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/twinstall.cpp b/twinstall.cpp
index af12ce36f..b3b9b774b 100644
--- a/twinstall.cpp
+++ b/twinstall.cpp
@@ -48,6 +48,34 @@
#include "twrp-functions.hpp"
extern "C" {
#include "gui/gui.h"
+ #include "legacy_property_service.h"
+}
+
+static const char* properties_path = "/dev/__properties__";
+static const char* properties_path_renamed = "/dev/__properties_kk__";
+
+static void switch_to_legacy_properties()
+{
+ char tmp[32];
+ int propfd, propsz;
+ legacy_properties_init();
+ legacy_get_property_workspace(&propfd, &propsz);
+ sprintf(tmp, "%d,%d", dup(propfd), propsz);
+ setenv("ANDROID_PROPERTY_WORKSPACE", tmp, 1);
+
+ if (TWFunc::Path_Exists(properties_path)) {
+ // hide real properties so that the updater uses the envvar to find the legacy format properties
+ if (rename(properties_path, properties_path_renamed) != 0)
+ LOGERR("Renaming properties failed: %s (assertions in old installers may fail)\n", strerror(errno));
+ }
+}
+
+static void switch_to_new_properties()
+{
+ if (TWFunc::Path_Exists(properties_path_renamed)) {
+ if (rename(properties_path_renamed, properties_path) != 0)
+ LOGERR("Restoring properties failed: %s\n", strerror(errno));
+ }
}
static int Run_Update_Binary(const char *path, ZipArchive *Zip, int* wipe_cache) {
@@ -127,8 +155,9 @@ static int Run_Update_Binary(const char *path, ZipArchive *Zip, int* wipe_cache)
pid_t pid = fork();
if (pid == 0) {
+ switch_to_legacy_properties();
close(pipe_fd[0]);
- execv(Temp_Binary.c_str(), (char* const*)args);
+ execve(Temp_Binary.c_str(), (char* const*)args, environ);
printf("E:Can't execute '%s'\n", Temp_Binary.c_str());
_exit(-1);
}
@@ -175,6 +204,7 @@ static int Run_Update_Binary(const char *path, ZipArchive *Zip, int* wipe_cache)
fclose(child_data);
waitpid(pid, &status, 0);
+ switch_to_new_properties();
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
LOGERR("Error executing updater binary in zip '%s'\n", path);
return INSTALL_ERROR;