aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2016-06-15 18:16:14 -0500
committerandroid-build-merger2016-06-15 18:16:14 -0500
commit4692e5d8c8000600bc4c59c5f2b5fb5177dd0758 (patch)
treed1320c0b8da3257168cf2c753204fdc501ac7e0f /adb_install.cpp
parentc58d7dda8c12d179b2e702da52370b8db3fe4e6c (diff)
parent37450d7f427345aee463b1ff730d0b2ff18ff57b (diff)
downloadplatform-bootable-recovery-4692e5d8c8000600bc4c59c5f2b5fb5177dd0758.tar.gz
platform-bootable-recovery-4692e5d8c8000600bc4c59c5f2b5fb5177dd0758.tar.xz
platform-bootable-recovery-4692e5d8c8000600bc4c59c5f2b5fb5177dd0758.zip
Merge \"Remove an abused global so we can actually see logging.\"
am: 37450d7f42 Change-Id: Id9c78be08f2822ec92d54ba11693d3e5adb7b5aa
Diffstat (limited to 'adb_install.cpp')
-rw-r--r--adb_install.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/adb_install.cpp b/adb_install.cpp
index 4aed9d4b..b05fda13 100644
--- a/adb_install.cpp
+++ b/adb_install.cpp
@@ -33,10 +33,7 @@
33#include "minadbd/fuse_adb_provider.h" 33#include "minadbd/fuse_adb_provider.h"
34#include "fuse_sideload.h" 34#include "fuse_sideload.h"
35 35
36static RecoveryUI* ui = NULL; 36static void set_usb_driver(RecoveryUI* ui, bool enabled) {
37
38static void
39set_usb_driver(bool enabled) {
40 int fd = open("/sys/class/android_usb/android0/enable", O_WRONLY); 37 int fd = open("/sys/class/android_usb/android0/enable", O_WRONLY);
41 if (fd < 0) { 38 if (fd < 0) {
42 ui->Print("failed to open driver control: %s\n", strerror(errno)); 39 ui->Print("failed to open driver control: %s\n", strerror(errno));
@@ -50,18 +47,16 @@ set_usb_driver(bool enabled) {
50 } 47 }
51} 48}
52 49
53static void 50static void stop_adbd(RecoveryUI* ui) {
54stop_adbd() { 51 ui->Print("Stopping adbd...\n");
55 property_set("ctl.stop", "adbd"); 52 property_set("ctl.stop", "adbd");
56 set_usb_driver(false); 53 set_usb_driver(ui, false);
57} 54}
58 55
59 56static void maybe_restart_adbd(RecoveryUI* ui) {
60static void
61maybe_restart_adbd() {
62 if (is_ro_debuggable()) { 57 if (is_ro_debuggable()) {
63 ui->Print("Restarting adbd...\n"); 58 ui->Print("Restarting adbd...\n");
64 set_usb_driver(true); 59 set_usb_driver(ui, true);
65 property_set("ctl.start", "adbd"); 60 property_set("ctl.start", "adbd");
66 } 61 }
67} 62}
@@ -70,14 +65,11 @@ maybe_restart_adbd() {
70// package, before timing out. 65// package, before timing out.
71#define ADB_INSTALL_TIMEOUT 300 66#define ADB_INSTALL_TIMEOUT 300
72 67
73int 68int apply_from_adb(RecoveryUI* ui, bool* wipe_cache, const char* install_file) {
74apply_from_adb(RecoveryUI* ui_, bool* wipe_cache, const char* install_file) {
75 modified_flash = true; 69 modified_flash = true;
76 70
77 ui = ui_; 71 stop_adbd(ui);
78 72 set_usb_driver(ui, true);
79 stop_adbd();
80 set_usb_driver(true);
81 73
82 ui->Print("\n\nNow send the package you want to apply\n" 74 ui->Print("\n\nNow send the package you want to apply\n"
83 "to the device with \"adb sideload <filename>\"...\n"); 75 "to the device with \"adb sideload <filename>\"...\n");
@@ -137,8 +129,8 @@ apply_from_adb(RecoveryUI* ui_, bool* wipe_cache, const char* install_file) {
137 } 129 }
138 } 130 }
139 131
140 set_usb_driver(false); 132 set_usb_driver(ui, false);
141 maybe_restart_adbd(); 133 maybe_restart_adbd(ui);
142 134
143 return result; 135 return result;
144} 136}