From 59bf0da22fc4082438b997483e843b28048fc88b Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 15 Jun 2016 15:14:04 -0700 Subject: Remove an abused global so we can actually see logging. Change-Id: Ib97440bc0542003b84c45cb05f194ba20104dad6 --- adb_install.cpp | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'adb_install.cpp') diff --git a/adb_install.cpp b/adb_install.cpp index 4cfcb2ab8..60616ca33 100644 --- a/adb_install.cpp +++ b/adb_install.cpp @@ -33,10 +33,7 @@ #include "minadbd/fuse_adb_provider.h" #include "fuse_sideload.h" -static RecoveryUI* ui = NULL; - -static void -set_usb_driver(bool enabled) { +static void set_usb_driver(RecoveryUI* ui, bool enabled) { int fd = open("/sys/class/android_usb/android0/enable", O_WRONLY); if (fd < 0) { ui->Print("failed to open driver control: %s\n", strerror(errno)); @@ -50,18 +47,16 @@ set_usb_driver(bool enabled) { } } -static void -stop_adbd() { +static void stop_adbd(RecoveryUI* ui) { + ui->Print("Stopping adbd...\n"); property_set("ctl.stop", "adbd"); - set_usb_driver(false); + set_usb_driver(ui, false); } - -static void -maybe_restart_adbd() { +static void maybe_restart_adbd(RecoveryUI* ui) { if (is_ro_debuggable()) { ui->Print("Restarting adbd...\n"); - set_usb_driver(true); + set_usb_driver(ui, true); property_set("ctl.start", "adbd"); } } @@ -70,14 +65,11 @@ maybe_restart_adbd() { // package, before timing out. #define ADB_INSTALL_TIMEOUT 300 -int -apply_from_adb(RecoveryUI* ui_, bool* wipe_cache, const char* install_file) { +int apply_from_adb(RecoveryUI* ui, bool* wipe_cache, const char* install_file) { modified_flash = true; - ui = ui_; - - stop_adbd(); - set_usb_driver(true); + stop_adbd(ui); + set_usb_driver(ui, true); ui->Print("\n\nNow send the package you want to apply\n" "to the device with \"adb sideload \"...\n"); @@ -137,8 +129,8 @@ apply_from_adb(RecoveryUI* ui_, bool* wipe_cache, const char* install_file) { } } - set_usb_driver(false); - maybe_restart_adbd(); + set_usb_driver(ui, false); + maybe_restart_adbd(ui); return result; } -- cgit v1.2.3 From cb22040c6303144a42a90f424f29a267e43bef74 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 23 Sep 2016 15:30:55 -0700 Subject: Switch to . Bug: http://b/23102347 Test: boot into recovery. Change-Id: Ib2ca560f1312961c21fbaa294bb068de19cb883e Merged-In: Ib2ca560f1312961c21fbaa294bb068de19cb883e --- adb_install.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'adb_install.cpp') diff --git a/adb_install.cpp b/adb_install.cpp index b05fda13a..fab72f8a4 100644 --- a/adb_install.cpp +++ b/adb_install.cpp @@ -26,13 +26,14 @@ #include #include "ui.h" -#include "cutils/properties.h" #include "install.h" #include "common.h" #include "adb_install.h" #include "minadbd/fuse_adb_provider.h" #include "fuse_sideload.h" +#include + static void set_usb_driver(RecoveryUI* ui, bool enabled) { int fd = open("/sys/class/android_usb/android0/enable", O_WRONLY); if (fd < 0) { @@ -49,7 +50,7 @@ static void set_usb_driver(RecoveryUI* ui, bool enabled) { static void stop_adbd(RecoveryUI* ui) { ui->Print("Stopping adbd...\n"); - property_set("ctl.stop", "adbd"); + android::base::SetProperty("ctl.stop", "adbd"); set_usb_driver(ui, false); } @@ -57,7 +58,7 @@ static void maybe_restart_adbd(RecoveryUI* ui) { if (is_ro_debuggable()) { ui->Print("Restarting adbd...\n"); set_usb_driver(ui, true); - property_set("ctl.start", "adbd"); + android::base::SetProperty("ctl.start", "adbd"); } } -- cgit v1.2.3 From 3da880156b4a56a6af5065ac10dfd6833cdcb1d4 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 3 Feb 2017 13:09:23 -0800 Subject: Replace _exit(-1) with _exit(EXIT_FAILURE). -1 is not a valid exit status. Also replace a few exit(1) with exit(EXIT_FAILURE). Test: mmma bootable/recovery Change-Id: I4596c8328b770bf95acccc06a4401bd5cabd4bfd --- adb_install.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'adb_install.cpp') diff --git a/adb_install.cpp b/adb_install.cpp index fab72f8a4..79b8df91b 100644 --- a/adb_install.cpp +++ b/adb_install.cpp @@ -78,7 +78,7 @@ int apply_from_adb(RecoveryUI* ui, bool* wipe_cache, const char* install_file) { pid_t child; if ((child = fork()) == 0) { execl("/sbin/recovery", "recovery", "--adbd", NULL); - _exit(-1); + _exit(EXIT_FAILURE); } // FUSE_SIDELOAD_HOST_PATHNAME will start to exist once the host -- cgit v1.2.3