summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adb_install.cpp18
-rw-r--r--gui/action.cpp19
-rw-r--r--minadbd/adb.c9
-rw-r--r--minadbd/adb.h5
-rw-r--r--recovery.cpp4
5 files changed, 23 insertions, 32 deletions
diff --git a/adb_install.cpp b/adb_install.cpp
index f5ba89c3f..3b64606d9 100644
--- a/adb_install.cpp
+++ b/adb_install.cpp
@@ -84,7 +84,7 @@ apply_from_adb(RecoveryUI* ui_, int* wipe_cache, const char* install_file) {
pid_t child;
if ((child = fork()) == 0) {
- execl("/sbin/recovery", "recovery", "--adbd", NULL);
+ execl("/sbin/recovery", "recovery", "--adbd", install_file, NULL);
_exit(-1);
}
DataManager_SetIntValue("tw_child_pid", child);
@@ -102,7 +102,7 @@ apply_from_adb(RecoveryUI* ui_, int* wipe_cache, const char* install_file) {
maybe_restart_adbd();
struct stat st;
- if (stat(ADB_SIDELOAD_FILENAME, &st) != 0) {
+ if (stat(install_file, &st) != 0) {
if (errno == ENOENT) {
ui->Print("No package received.\n");
} else {
@@ -110,17 +110,5 @@ apply_from_adb(RecoveryUI* ui_, int* wipe_cache, const char* install_file) {
}
return INSTALL_ERROR;
}
- char zip_file[255];
- if (strncmp(ADB_SIDELOAD_FILENAME, "/tmp", 4) == 0) {
- char command[255];
- sprintf(zip_file, "%s/%s", DataManager_GetCurrentStoragePath(), "sideload.zip");
- ui->Print("Copying zip to '%s'\n", zip_file);
- sprintf(command, "cp %s %s", ADB_SIDELOAD_FILENAME, zip_file);
- system(command);
- sprintf(command, "rm %s", ADB_SIDELOAD_FILENAME);
- system(command);
- } else {
- strcpy(zip_file, ADB_SIDELOAD_FILENAME);
- }
- return TWinstall_zip(zip_file, wipe_cache);
+ return TWinstall_zip(install_file, wipe_cache);
}
diff --git a/gui/action.cpp b/gui/action.cpp
index 4114bf0aa..15180ca06 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -1057,22 +1057,19 @@ LOGE("TODO: Implement ORS support\n");
simulate_progress_bar();
} else {
int wipe_cache = 0;
- string Command;
+ string Command, Sideload_File;
if (!PartitionManager.Mount_Current_Storage(true)) {
operation_end(1, simulate);
return 0;
}
- if (TWFunc::Path_Exists(ADB_SIDELOAD_FILENAME)) {
- Command = "rm ";
- Command += ADB_SIDELOAD_FILENAME;
+ Sideload_File = DataManager::GetCurrentStoragePath() + "/sideload.zip";
+ if (TWFunc::Path_Exists(Sideload_File)) {
+ Command = "rm " + Sideload_File;
system(Command.c_str());
}
- Command = "touch ";
- Command += ADB_SIDELOAD_FILENAME;
- system(Command.c_str());
ui_print("Starting ADB sideload feature...\n");
- ret = apply_from_adb(ui, &wipe_cache, "/tmp/install_log");
+ ret = apply_from_adb(ui, &wipe_cache, Sideload_File.c_str());
if (ret != 0)
ret = 1; // failure
else if (wipe_cache)
@@ -1084,9 +1081,9 @@ LOGE("TODO: Implement ORS support\n");
if (function == "adbsideloadcancel")
{
int child_pid;
- string Command;
- Command = "rm ";
- Command += ADB_SIDELOAD_FILENAME;
+ string Command, Sideload_File;
+ Sideload_File = DataManager::GetCurrentStoragePath() + "/sideload.zip";
+ Command = "rm " + Sideload_File;
system(Command.c_str());
DataManager::GetValue("tw_child_pid", child_pid);
ui_print("Cancelling ADB sideload...\n");
diff --git a/minadbd/adb.c b/minadbd/adb.c
index 0e8fd2a7e..54adba050 100644
--- a/minadbd/adb.c
+++ b/minadbd/adb.c
@@ -40,6 +40,8 @@ int HOST = 0;
static const char *adb_device_banner = "sideload";
+char ADB_SIDELOAD_FILENAME[255];
+
void fatal(const char *fmt, ...)
{
va_list ap;
@@ -378,8 +380,9 @@ static void adb_cleanup(void)
usb_cleanup();
}
-int adb_main()
+int adb_main(const char* path)
{
+ strcpy(ADB_SIDELOAD_FILENAME, path);
atexit(adb_cleanup);
#if defined(HAVE_FORKEXEC)
// No SIGCHLD. Let the service subproc handle its children.
@@ -394,6 +397,7 @@ int adb_main()
usb_init();
}
+/* Remove this so that perms work properly
if (setgid(AID_SHELL) != 0) {
fprintf(stderr, "failed to setgid to shell\n");
exit(1);
@@ -402,8 +406,9 @@ int adb_main()
fprintf(stderr, "failed to setuid to shell\n");
exit(1);
}
- fprintf(stderr, "userid is %d\n", getuid());
+ fprintf(stderr, "userid is %d\n", getuid());
+*/
D("Event loop starting\n");
fdevent_loop();
diff --git a/minadbd/adb.h b/minadbd/adb.h
index 98fa5972e..19c22e8ea 100644
--- a/minadbd/adb.h
+++ b/minadbd/adb.h
@@ -217,7 +217,7 @@ void send_packet(apacket *p, atransport *t);
void get_my_path(char *s, size_t maxLen);
int launch_server(int server_port);
-int adb_main();
+int adb_main(const char* path);
/* transports are ref-counted
@@ -413,6 +413,7 @@ extern int SHELL_EXIT_NOTIFY_FD;
int sendfailmsg(int fd, const char *reason);
int handle_host_request(char *service, transport_type ttype, char* serial, int reply_fd, asocket *s);
-#define ADB_SIDELOAD_FILENAME "/tmp/update.zip"
+//#define ADB_SIDELOAD_FILENAME "/tmp/update.zip"
+extern char ADB_SIDELOAD_FILENAME[255];
#endif
diff --git a/recovery.cpp b/recovery.cpp
index b8bb09920..2d89014c1 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -790,8 +790,8 @@ main(int argc, char **argv) {
// anything in the command file or bootloader control block; the
// only way recovery should be run with this argument is when it
// starts a copy of itself from the apply_from_adb() function.
- if (argc == 2 && strcmp(argv[1], "--adbd") == 0) {
- adb_main();
+ if (argc == 3 && strcmp(argv[1], "--adbd") == 0) {
+ adb_main(argv[2]);
return 0;
}