Commit graph

7329 commits

Author SHA1 Message Date
Tianjie Xu
c3a161e2b8 Add unit tests for simulator
Make sure the simulator succeeds executing common non-A/B update
functions.

Bug: 131911365
Test: run unit tests
Change-Id: I520ce6a8827539b88a9e36f9e67eec30d8b586d4
2019-06-27 16:17:05 -07:00
Treehugger Robot
db0a68e6b7 Merge "Implement updater runtime for dynamic partitions" 2019-06-24 20:24:49 +00:00
Tianjie Xu
d118833f3e Implement updater runtime for dynamic partitions
The simulator skips executing the operations for dynamic partitions, and
will use the logical images under target_files/IMAGES directly. (Similar
to the targets without DAP enabled)

Bug: 131911365
Test: run update on cuttlefish, run simulator
Change-Id: Id318d97ece4560df9f20dc5cabeb8b2e261bdf9c
2019-06-24 12:46:28 -07:00
Treehugger Robot
b87520077b Merge "updater_sample: Build SystemUpdaterSample as non-privileged app by default." 2019-06-24 15:41:27 +00:00
Tao Bao
061267eee9 updater_sample: Build SystemUpdaterSample as non-privileged app by default.
Prior to the change, SystemUpdaterSample was built as privileged app.
It must be installed along with the matching privapp-permissions
whitelist change (as noted in updater_sample/README.md), otherwise would
block device booting if installed unintentionally (e.g. with `mm` or
`mmma`).

This CL avoids putting the device in a bad state due to a sample app.

Fixes: 135703777
Test: `lunch aosp_taimen-userdebug && m -j installclean &&
          mmma -j bootable/recovery && m -j`
      Flash on device and boot successfully.
Test: Run the tests per instructions in updater_sample/README.md.
Change-Id: Ib8b587c77570f05f7db748fad84744fa45016aab
2019-06-21 12:10:36 -07:00
Tianjie Xu
090b62832f Merge "Support starting fuse from a block map" 2019-06-21 17:14:10 +00:00
Tianjie Xu
9b76970e9a Merge "Implement the TargetFile and BuildInfo" 2019-06-20 22:39:42 +00:00
Tianjie Xu
f6158eb918 Support starting fuse from a block map
Factor out a new function from ApplyFromSdcard that installs a package
from a local path. Inside this function, we start the fuse and choose the
type of data provider depending on the path string. And similar to the
existing logic, we treat the package as a block map if the path starts
with a '@'.

This is part of the effort to install larger than 2GiB packages on ILP32
devices.

Bug: 127071893
Test: Build a 32 bit sailfish and create a 3GiB OTA package. Sideload
the package, uncrypt and install the package from sdcard.

Change-Id: I328ea34fa530731acbce7554bfc3059313ad6ece
2019-06-20 13:53:40 -07:00
Tianjie Xu
87e2275970 Merge "InstallPackage now takes a package as parameter" 2019-06-14 00:24:49 +00:00
Tianjie Xu
980f92ec00 InstallPackage now takes a package as parameter
Therefore InstallPackage() doesn't need to worry about the details of a
given Package.

Bug: 127071893
Test: run update from /bin/recovery --update_package=@path, sideload a package
Change-Id: I0caa36785b43924f884ee398e7ea640d7472a92e
2019-06-13 13:36:56 -07:00
Elliott Hughes
053ea111a7 Merge "Use the new ziparchive Next std::string_view overload." 2019-06-13 19:59:18 +00:00
Treehugger Robot
eb33356544 Merge "Avoid key_queue_mutex deadlock in waitkey()" 2019-06-13 00:01:49 +00:00
Elliott Hughes
39ac1c013c Use the new ziparchive Next std::string_view overload.
Bug: http://b/129068177
Test: treehugger
Change-Id: Ieec83126e36b330da33092a172e365376cd04dfe
2019-06-12 12:20:37 -07:00
Zhang, GaofengX
852d9fec6d Avoid key_queue_mutex deadlock in waitkey()
Waitkey() is designed to obtain lock "key_queue_mutex" in
the very beginning of function.

  int RecoveryUI::WaitKey() {
    std::unique_lock<std::mutex> lk(key_queue_mutex);
    ...
  }

However, there's case "key_queue_mutex" being applied again in
waitkey(), thus cause deadlock. There are two reproduce
scenario:
1.Executing "fastboot reboot recovery" in userspace
  fastboot
2.Executing "adb reboot fastboot" in recovery os

When entering userspace fastboot/recovery, waitkey()
will wait there for user action. fastboot/adb commands
will trigger ui->interruptkey() to notify the thread
waitkey() in. In the next, waitkey() will move on and call
SetScreenSaveState(), which do LOG(ERROR) in fail case of
brightness set. LOG(ERROR) is designed to print log on
UI. Unfortunately, UI->print() applies lock "key_queue_mutex"
too, so deadlock happen.

Note:
Here is details how lock "key_queue_mutex" applied in
UI->print():
Function Print() call
   Function PrintV() call
      Function update_screen_locked() call
         Function draw_screen_locked() call
            Function draw_menu_and_test_buffer_locked() call
               Function IsLongPress()

  bool RecoveryUI::IsLongPress() {
    std::lock_guard<std::mutex> lg(key_queue_mutex);
    bool result = key_long_press;
    return result;
  }

Bug: 135078366
Test: no errors when running "fastboot reboot recovery" in userspace
      fastboot & "adb reboot fastboot" in recovery os

Change-Id: Ida6b3c4ba9896a70021373f02a94954f0a60cf31
Signed-off-by: Zhang, GaofengX <gaofengx.zhang@intel.com>
Signed-off-by: Xihua Chen <xihua.chen@intel.com>
2019-06-12 14:48:37 +08:00
Tao Bao
cb930939a4 Merge "minadbd: adb rescue getprop returns newline-terminated result." 2019-06-10 23:43:09 +00:00
Tao Bao
57a27890ce minadbd: adb rescue getprop returns newline-terminated result.
This change addresses the comment in [1], which makes the results of
`adb shell getprop foo` and `adb rescue getprop foo` more consistent.
That is, both will return newline-terminated results now.

[1] https://r.android.com/c/platform/bootable/recovery/+/976340/3/minadbd/minadbd_services.cpp#188

Test: Run the following commands on taimen (under rescue mode):
    `adb rescue getprop ro.build.fingerprint`
    `adb rescue getprop ro.nonexistent`
    `adb rescue getprop`
Change-Id: I5af47f8ea4d569b8507e259daef87749c0945f47
2019-06-10 13:08:03 -07:00
Tao Bao
533a12c71e Merge "minadbd: Support adb rescue getprop." 2019-06-05 20:43:55 +00:00
Tao Bao
d8db81a014 minadbd: Support adb rescue getprop.
It dumps all the allowed properties, similar to `adb shell getprop`.

Bug: 134027350
Test: Run the command under rescue mode.
Change-Id: Ic0864ca0fb51505ec1e4f38af2464591aa576201
2019-06-04 15:09:41 -07:00
Tao Bao
1ef7f92871 Merge "minadbd: More allowed properties." 2019-06-04 22:01:36 +00:00
Paul Duffin
14bc5e1feb Merge "Use icu4j instead of its deprecated legacy alias icu4j-host" 2019-06-04 09:24:01 +00:00
Tao Bao
3b9ef341be minadbd: More allowed properties.
Most of these properties are already part of the fingerprint. This CL
allows querying them directly, instead of encouraging users to decode
from fingerprints.

Bug: 134027350
Test: Boot into rescue mode on taimen. Run `adb rescue getprop` with new
      props.
Change-Id: Id4667fcaf0e908c391085b22e22c957acd01d9c4
2019-06-03 12:14:18 -07:00
Paul Duffin
eb586b7baf Use icu4j instead of its deprecated legacy alias icu4j-host
Bug: 134379140
Test: m droid
Change-Id: I71c2ac392361b3c6dfa693194c05116422335e55
2019-06-03 16:14:35 +01:00
Tianjie Xu
74b0f7cce0 Implement the TargetFile and BuildInfo
The TargetFile class parses a target-file and provides functions to read
its contents. And the BuildInfo tries to simulate the device with files
on host. Some work it does includes parsing the build properties,
and extracting the image files for partitions specified in the fstab.

Bug: 131911365
Test: unit tests pass, run simulator with cuttlefish, wear devices and from extracted TF.
Change-Id: Iefe4a96d619d2e4b3d038e31480f11a0f9a70afa
2019-05-31 17:55:36 -07:00
Treehugger Robot
f3dd821f76 Merge "Disable building simulator for mac" 2019-05-30 20:45:28 +00:00
Tianjie Xu
76e165d143 Disable building simulator for mac
Disable building the simulator and its support libraries to resolve the breakage
on mac host targets. Because the simulator is not intended to use on mac anyway.

Bug: 134047992
Test: mma
Change-Id: I488ab50cab1282f03250010b5334f1895d44f98b
2019-05-30 10:49:18 -07:00
Tianjie Xu
65d7d5b8cf Merge "Implement an update simulator to verify BB OTA packages on host" 2019-05-29 17:20:36 +00:00
Tianjie Xu
c1a5e26fd9 Implement an update simulator to verify BB OTA packages on host
Implement the simulator runtime and build the updater simulator as a host
executable. The code to parse the target-files and mocks the block devices
will be submitted in the follow-up.

Bug: 131911365
Test: unit tests pass

Change-Id: Ib1ba939aec8333ca68a45139514d772ad7a27ad8
2019-05-28 15:18:25 -07:00
Treehugger Robot
c0a51a01ce Merge "recovery: report compliant reboot reason (Part Deux)" 2019-05-28 15:57:24 +00:00
Tianjie Xu
52e61f6995 Merge "Some clean ups to the updater" 2019-05-24 04:45:43 +00:00
Mark Salyzyn
488cc05c96 recovery: report compliant reboot reason (Part Deux)
shutdown and reboot should have a corresponding sub-reason.

Adding:
    "reboot,userrequested,fastboot"
    "reboot,userrequested,recovery"
    "reboot,userrequested,recovery,ui"
    "shutdown,userrequested,fastboot"
    "shutdown,userrequested,recovery"
    "reboot,unknown#" (Can't happen, debug)

Test: manual, multiple targets, enter recovery, be able to exit recovery
Bug: 133326470
Change-Id: Ibfcb2a23158e8e99922e8053edd815fb592150f2
2019-05-23 13:58:53 -07:00
Elliott Hughes
7b67d28518 Merge "Move off the Next ZipString overload." 2019-05-23 17:55:27 +00:00
Elliott Hughes
88d8001e75 Move off the Next ZipString overload.
Bug: http://b/129068177
Test: treehugger
Change-Id: I3c8f70b0d8cc5dc6b3b4439dbe0b9a5bd85003c4
2019-05-22 18:52:29 -07:00
Tianjie Xu
27556d089f Some clean ups to the updater
Remove some unnecessary includes or forward declarations. And include
the correct headers to build host executables.

Bug: 131911365
Test: unit tests pass
Change-Id: I62e75f60678159fe24619a4bd386b1416f1a5b5d
2019-05-22 14:58:28 -07:00
Treehugger Robot
44f6b182dd Merge "Revert "recovery: report compliant reboot reason"" 2019-05-22 21:55:38 +00:00
Tao Bao
feefbf2f56 Revert "recovery: report compliant reboot reason"
This reverts commit 6f4e4db4f9.

Reason for revert: Booting out of recovery (choose `Reboot system now`)
on taimen is broken. Device keeps booting back into recovery.

Bug: 133326470
Test: Choose `Reboot system now` from recovery menu. Deivce attempts
      normal boot.
Change-Id: I6e85fc248e18953a6fb94513c3abc7e7e0fb0477
2019-05-22 11:06:26 -07:00
Mark Salyzyn
d31fb2e7fc Merge "recovery: report compliant reboot reason" 2019-05-21 17:44:14 +00:00
Tianjie Xu
e7b3c5698e Merge "Add UpdaterRuntime class" 2019-05-21 17:07:30 +00:00
Tao Bao
962f7e0c0c Merge "Add misc_writer." 2019-05-21 13:41:07 +00:00
Tianjie Xu
1536db887f Add UpdaterRuntime class
This class adds a wrapper to the runtime dependent functions. Therefore,
the behavior of update on device stays the same, while simulators can
have their own implementations. Also change the caller side of the
registered updater functions to call these runtime wrappers.

Bug: 131911365
Test: unit tests pass, sideload an update on cuttlefish
Change-Id: Ib3ab67132991d67fc132f27120e4152439d16ac5
2019-05-20 18:03:27 -07:00
Tao Bao
7ae0169842 Add misc_writer.
bootloader_message.h currently divides /misc into four segments. The
space between 2K and 16K is reserved for vendor use (e.g. bootloader
persists flags). This CL adds a vendor tool "misc_writer", to allow
writing data to the vendor space in /misc, before getting a dedicated
HAL for accessing /misc partition (b/131775112).

Targets need to explicitly include the module, then invoke the
executable to write data. For example, the following command will write
3-byte data ("0xABCDEF") to offset 4 in vendor space (i.e. 2048 + 4 in
/misc).
$ /vendor/bin/misc_writer --vendor-space-offset 4 --hex-string 0xABCDEF

Bug: 132906936
Test: Run recovery_unit_test on crosshatch.
Test: Call the command via init.hardware.rc on crosshatch. Check that
      the call finishes successfully. Then check the contents written to
      /misc (`dd bs=1 skip=2048 if=/dev/block/sda2 count=32 | xxd`).
Change-Id: I79548fc63fc79b705a0320868690569c3106949f
2019-05-20 15:51:26 -07:00
Mark Salyzyn
6f4e4db4f9 recovery: report compliant reboot reason
shutdown and reboot should have a corresponding sub-reason.

Adding:
    "reboot,fastboot_menu"
    "reboot,recovery_menu"
    "reboot,recovery_ui"
    "shutdown,fastboot"
    "shutdown,recovery"
    "reboot,unknown#"

Test: none
Change-Id: Icf1ab0d462ec2de2272914a36994a095998d6186
2019-05-20 13:52:10 -07:00
Xin Li
e7a0262c14 DO NOT MERGE - Skip pi-platform-release (PPRL.190505.001) in stage-aosp-master
Bug: 132622481
Change-Id: Ic07faa9aa968d11ae8f6b44d548d724fd194e047
2019-05-13 15:56:57 -07:00
Tao Bao
c53856dca7 Merge "roots: Remove get_system_root and logical_partitions_mapped."
am: ba8f38d741

Change-Id: I7bc0a5ff9e7709f91fe28f4c9b8d20f5c8d20cf8
2019-05-10 17:40:31 -07:00
Tao Bao
ba8f38d741 Merge "roots: Remove get_system_root and logical_partitions_mapped." 2019-05-10 23:58:32 +00:00
Tao Bao
f90d9a102f roots: Remove get_system_root and logical_partitions_mapped.
Test: TreeHugger
Test: Boot into recovery on blueline. Choose "Mount system partition".
Change-Id: Iac475d18ce2415de09dc0bf009ad4cf0383ffede
2019-05-10 10:42:56 -07:00
Xin Li
8e7be1faeb [automerger skipped] Merge "DO NOT MERGE - Merge Pie Bonito/Sargo into master."
am: 343a7dcdd2 -s ours
am skip reason: subject contains skip directive

Change-Id: Iea7679752ae74ce0d026fe3e58d3d3df88b21739
2019-05-09 15:48:46 -07:00
Xin Li
343a7dcdd2 Merge "DO NOT MERGE - Merge Pie Bonito/Sargo into master." 2019-05-09 22:05:46 +00:00
Elliott Hughes
46fa74623a Merge "Track libziparchive API change."
am: 6da27adb0b

Change-Id: Ib261d224fe4b57ead972987466dc30411505aa30
2019-05-09 14:46:26 -07:00
Tianjie Xu
e945763a5d Merge "Skip hashtree computation during block image verify"
am: c046a61d97

Change-Id: If5934f92768248c79029c3e7e0934b7a2a37c88d
2019-05-09 14:43:49 -07:00
Elliott Hughes
6da27adb0b Merge "Track libziparchive API change." 2019-05-09 21:32:52 +00:00