aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Zongker2012-01-09 17:16:13 -0600
committerDoug Zongker2012-01-10 12:18:17 -0600
commit9270a20a801403c9f60d6a701b39eae70d380403 (patch)
tree5bdb058af5b05a65112297a504018ee356e0ddbb /recovery.cpp
parent210f887382e0fd7e51ec6ce071972374a76f0722 (diff)
downloadplatform-bootable-recovery-9270a20a801403c9f60d6a701b39eae70d380403.tar.gz
platform-bootable-recovery-9270a20a801403c9f60d6a701b39eae70d380403.tar.xz
platform-bootable-recovery-9270a20a801403c9f60d6a701b39eae70d380403.zip
support "sideload over ADB" mode
Rather than depending on the existence of some place to store a file that is accessible to users on an an unbootable device (eg, a physical sdcard, external USB drive, etc.), add support for sideloading packages sent to the device with adb. This change adds a "minimal adbd" which supports nothing but receiving a package over adb (with the "adb sideload" command) and storing it to a fixed filename in the /tmp ramdisk, from where it can be verified and sideloaded in the usual way. This should be leave available even on locked user-build devices. The user can select "apply package from ADB" from the recovery menu, which starts minimal-adb mode (shutting down any real adbd that may be running). Once minimal-adb has received a package it exits (restarting real adbd if appropriate) and then verification and installation of the received package proceeds. Change-Id: I6fe13161ca064a98d06fa32104e1f432826582f5
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/recovery.cpp b/recovery.cpp
index da9334aa..726442b8 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -40,6 +40,10 @@
40#include "ui.h" 40#include "ui.h"
41#include "screen_ui.h" 41#include "screen_ui.h"
42#include "device.h" 42#include "device.h"
43#include "adb_install.h"
44extern "C" {
45#include "minadbd/adb.h"
46}
43 47
44static const struct option OPTIONS[] = { 48static const struct option OPTIONS[] = {
45 { "send_intent", required_argument, NULL, 's' }, 49 { "send_intent", required_argument, NULL, 's' },
@@ -725,6 +729,21 @@ prompt_and_wait(Device* device) {
725 } 729 }
726 } 730 }
727 break; 731 break;
732
733 case Device::APPLY_ADB_SIDELOAD:
734 ensure_path_mounted(CACHE_ROOT);
735 status = apply_from_adb(ui, &wipe_cache, TEMPORARY_INSTALL_FILE);
736 if (status >= 0) {
737 if (status != INSTALL_SUCCESS) {
738 ui->SetBackground(RecoveryUI::ERROR);
739 ui->Print("Installation aborted.\n");
740 } else if (!ui->IsTextVisible()) {
741 return; // reboot if logs aren't visible
742 } else {
743 ui->Print("\nInstall from ADB complete.\n");
744 }
745 }
746 break;
728 } 747 }
729 } 748 }
730} 749}
@@ -741,6 +760,19 @@ main(int argc, char **argv) {
741 // If these fail, there's not really anywhere to complain... 760 // If these fail, there's not really anywhere to complain...
742 freopen(TEMPORARY_LOG_FILE, "a", stdout); setbuf(stdout, NULL); 761 freopen(TEMPORARY_LOG_FILE, "a", stdout); setbuf(stdout, NULL);
743 freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL); 762 freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL);
763
764 // If this binary is started with the single argument "--adbd",
765 // instead of being the normal recovery binary, it turns into kind
766 // of a stripped-down version of adbd that only supports the
767 // 'sideload' command. Note this must be a real argument, not
768 // anything in the command file or bootloader control block; the
769 // only way recovery should be run with this argument is when it
770 // starts a copy of itself from the apply_from_adb() function.
771 if (argc == 2 && strcmp(argv[1], "--adbd") == 0) {
772 adb_main();
773 return 0;
774 }
775
744 printf("Starting recovery on %s", ctime(&start)); 776 printf("Starting recovery on %s", ctime(&start));
745 777
746 Device* device = make_device(); 778 Device* device = make_device();