Commit graph

18 commits

Author SHA1 Message Date
Tianjie Xu
8f397309b4 Move librecovery_ui to a sub-directory
This helps to expose librecovery_ui for device specific RecoveryUi.

Bug: 76436783
Test: mma, unit tests pass
Change-Id: Ic6c3d301d5833e4a592e6ea9d9d059bc4e4919be
(cherry picked from commit b5108c372c)
2019-03-21 10:46:11 -07:00
Tao Bao
6fcd208db4 Use android::base::Pipe.
Also clean up the comments regarding updater/recovery protocol.

Test: Sideload a package on taimen. Check that /tmp/recovery.log
      contains the log from update_engine_sideload.
Test: Factory reset on taimen. Check that log file has the info from
      mke2fs.
Change-Id: If560269ce7007769fc85a63bd228813bdd75bebd
2019-02-28 15:53:28 -08:00
David Anderson
983e2d5718 Add a logo to the fastbootd screen.
fastbootd looks too much like recovery, even if you're carefully reading
the menu. It's not obvious the device is in a flashing mode, and it's
too tempting to reboot or unplug the device in this state.

As a first step, this patch adds a big red "fastbootd" logo so it's less
obviously in recovery mode.

Bug: 120429730
Test: manual test
Change-Id: I73359f1fdfdc0b1694993f760fe7f35c5713b24e
2019-02-11 19:22:03 -08:00
Treehugger Robot
b22bd959e5 Merge "logical -> dynamic partitions." 2018-11-16 23:35:28 +00:00
Yifan Hong
d17174c3e5 logical -> dynamic partitions.
Reflect a name change.
Test: boots
Test: boot into recovery
Bug: 119286600

Change-Id: I7c323f27574ce033b8fc1750aab00f7300c5cc84
2018-11-16 12:56:44 -08:00
David Anderson
2b2f423ef6 recovery: Fix mounting /system with dynamic partitions.
When using dynamic partitions, the blk_device field in fstab_rec must be
translated to a /dev/block/dm-N node with
fs_mgr_update_logical_partition. However, init will not have created
these nodes to begin with since CreateLogicalPartitions is not called in
recovery. This patch addresses both issues.

Note that flashing system through fastbootd will not work while /system is
mounted.

Bug: 118634720
Test: manual test
Change-Id: I06c83309d09eab6b65245b1ed10c51d05398f23e
2018-10-30 13:47:59 -07:00
Treehugger Robot
c2e6f0410c Merge "Enter into userspace fastboot only if the device supports it" 2018-09-24 19:41:22 +00:00
Hridya Valsaraju
7f41a2cc4d Enter into userspace fastboot only if the device supports it
Test: For devices not supporting logical partitions, 'adb reboot
fastboot' command reboots into  Android.
Bug: 78793464

Change-Id: Ie6c6ccdebfee9302a9996ac5bc66069dbd817987
2018-09-19 21:35:47 -07:00
Hridya Valsaraju
daa301e3bd Show 'Enter Fastboot' menu item only if device supports fastbootd
Bug: 112664456
Test: Manual, 'Enter Fastboot' option not visible.
Change-Id: I2642391a69a11cd0496c1287130b3b0291c93232
2018-09-18 14:53:31 -07:00
Hridya Valsaraju
e4ef453914 Fix sideload for user devices by adding a new sideload config
Bug: 113563995
Test: Tested the 'adb sideload' command on marlin user/userdebug builds
and walleye user/userdebug builds

Change-Id: I00d565547b85f2db87012e4a08316609e03395ac
2018-09-07 15:02:43 -07:00
David Anderson
eee4e260f9 recovery: Add "boot-fastboot" command to BCB.
This change adds a new "boot-fastboot" command in order to boot into fastboot
without overwriting recovery tasks. This also allows bootloaders to boot
directly into userspace fastboot from the bootloader menu, or via
bootloader fastboot.

Bug: 112277594
Test: adb reboot fastboot
Change-Id: Ia0c9a0961a76c6cbe19486590179abaa50d93f58
2018-08-21 16:04:57 -07:00
Hridya Valsaraju
20c81b308d Add fastboot mode to recovery
Add a fastboot mode to recovery that can be
entered with command line args or with the ui.

Add usb property triggers to switch between
fastboot and adb configurations.

Allow switching between fastboot and adb through
usb commands by opening a unix socket. adbd/fastbootd
writes to this socket, which interrupts the ui and
switches to the new mode.

Test: Use fastboot mode
Bug: 78793464
Change-Id: I7891bb84427ec734a21a872036629b95ab3fb13c
2018-08-13 21:18:18 -07:00
Tao Bao
42c45e2b66 Dynamically load device-specific recovery UI lib.
We used to statically link the device-specific recovery UI extension
(`TARGET_RECOVERY_UI_LIB`) into `recovery`. Such a logic can't be easily
migrated to Soong, as modules specified by `TARGET_RECOVERY_UI_LIB` may
not be built with Soong.

Instead of porting all the device-specific codes over, this CL builds
and installs the UI lib as a shared library with Android.mk. `recovery`
dlopen(3)'s and dlsym(3)'s `make_device` to invoke the device-specific
UI lib on start.

Note that in order to make dlopen(3) actually working, we have to switch
`recovery` to be dynamically linked (we will make the move later
anyway).

Bug: 110380063
Test: Build and boot into marlin recovery image. Check that
      device-specific recovery UI is successfully loaded.
Change-Id: Ia9861c7559a95f3f50676534540c0cb87cae4574
2018-08-06 12:35:23 -07:00
Tao Bao
1700cc46b5 Fix the arguments passed to getopt_long(3).
The getopt_long(3) implementation in Android (upstream freebsd) expects
a null-terminated array while parsing long options with required args.

  if (long_options[match].has_arg == required_argument) {
    optarg = nargv[optind++];
  }
  ...
  if (long_options[match].has_arg == required_argument && optarg == NULL) {
    return (BADARG);
  }

This seems to make sense in practice, as getopt(3) takes the first two
arguments of argc and argv that are "as passed to the main() function on
program invocation", and both of C and C++ spec say "the value of
argv[argc] shall be 0".

Prior to the CL, we may run into undefined behavior on malformed input
command line (e.g. missing arg for an option that requires one). This CL
fixes the issue by always appending a nullptr to the argument list (but
without counting that into argc).

Test: Build and boot into recovery with commands.
Change-Id: Ic6c37548f4db2f30aeabd40f387ca916eeca5392
2018-07-17 12:16:53 -07:00
Jerry Zhang
49fd5d262c recovery: Reset optind to 1 after getopt
The getopt library exposes optind which is the
next index to be processed. When scanning is
restarted, optind has to be reset to 1.

Test: Recovery works
Bug: 78793464
Change-Id: I1efca3fb985ffbdfe91e43767469733cda6e7d5b
2018-05-17 19:56:42 +00:00
Jerry Zhang
f5e319ac96 recovery: Refactor common setup into main()
Move more common setup into the main function.
Main() handles all 1 time setup, such as ui,
logging, and secontext. Recovery_main()
takes in command line arguments, does any
necessary recovery work, and can be called
multiple times from main().

Test: Recovery works
Bug: 78793464
Change-Id: I2d2595fc342b4ddfa80f4e06b30e44263132acd9
Merged-In: I2d2595fc342b4ddfa80f4e06b30e44263132acd9
2018-05-16 19:32:06 +00:00
Jerry Zhang
152933a28e recovery: Refactor logging code into logging.cpp
Move common logging related functions to
rotate_logs.cpp, and rename that to logging.cpp.

Test: Recovery works
Bug: 78793464
Merged-In: I00f20a79a296680122b8437d54a87897c5cb2fc7
Change-Id: I00f20a79a296680122b8437d54a87897c5cb2fc7
2018-05-07 14:14:17 -07:00
Tao Bao
6d99d4b457 recovery: Split main() into recovery_main.cpp.
This prepares for moving more codes from recovery into librecovery, so
that they will become more easily testable. recovery_main.cpp will be
the source code for recovery module, with the rest moved into
librecovery. recovery_main.cpp mainly does the initializations, such as
setting up the logger.

Test: mmma -j bootable/recovery
Test: recovery_component_test
Test: Build and boot into recovery image on marlin.
Change-Id: I8e846524546b6f3f0e32ed869e851f62261eef23
Merged-In: I8e846524546b6f3f0e32ed869e851f62261eef23
2018-05-01 09:48:00 -07:00