summaryrefslogtreecommitdiffstats
path: root/adb_install.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'adb_install.cpp')
-rw-r--r--adb_install.cpp35
1 files changed, 14 insertions, 21 deletions
diff --git a/adb_install.cpp b/adb_install.cpp
index 4aed9d4b1..fab72f8a4 100644
--- a/adb_install.cpp
+++ b/adb_install.cpp
@@ -26,17 +26,15 @@
#include <fcntl.h>
#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"
-static RecoveryUI* ui = NULL;
+#include <android-base/properties.h>
-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,19 +48,17 @@ set_usb_driver(bool enabled) {
}
}
-static void
-stop_adbd() {
- property_set("ctl.stop", "adbd");
- set_usb_driver(false);
+static void stop_adbd(RecoveryUI* ui) {
+ ui->Print("Stopping adbd...\n");
+ android::base::SetProperty("ctl.stop", "adbd");
+ 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);
- property_set("ctl.start", "adbd");
+ set_usb_driver(ui, true);
+ android::base::SetProperty("ctl.start", "adbd");
}
}
@@ -70,14 +66,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 <filename>\"...\n");
@@ -137,8 +130,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;
}