Commit graph

837 commits

Author SHA1 Message Date
David Anderson
2ffc31b090 fastbootd: Unmount /cache before flashing.
Bug: 150112538
Test: fastboot flash cache on non-A/B device
Change-Id: I8a86bc4d12e4b3be020bbe47e02262a5aaa913a7
2020-03-25 21:00:13 -07:00
Steve Muckle
b36934bf5f fastboot: add support for v3 boot header format
Support v3 header format when changing the command line with
fastboot boot or using flash:raw.

Bug: 151750405
Test: fastboot boot and flash:raw with updated cmdline and v3 header
Merged-In: Ibf396e2d18d8b22cad50db290f3fd4e46ff85d9b
Change-Id: Ibf396e2d18d8b22cad50db290f3fd4e46ff85d9b
2020-03-19 14:48:28 -07:00
Treehugger Robot
3ab681c9a8 Merge "fastboot: add support for v3 boot header format" 2020-03-19 05:47:48 +00:00
Steve Muckle
15303f2f67 fastboot: add support for v3 boot header format
Support v3 header format when changing the command line with
fastboot boot or using flash:raw.

Bug: 151750405
Test: fastboot boot and flash:raw with updated cmdline and v3 header
Change-Id: Ibf396e2d18d8b22cad50db290f3fd4e46ff85d9b
2020-03-18 15:00:47 -07:00
yongcheol.lee
019f731097 Restore fastboot delete-logical-partition command for VTS
1. delete-logical-partition was deleted
	- After merge "Don't require bootloader fastboot for VTS compliance." commit, delete-logical-partition sequence was deleted in LogicalPartitionCompliance test. "create-logical-partition failed" is occurred when run vts fastbootverification module. So restore this sequence.

Signed-off-by: Yongcheol LEE <yongcheol09.lee@lge.com>

Test: VTS
Test: run vts -m VtsFastbootVerification

Change-Id: I00366b281eafa5677b0941419a86f2702fb3484b
2020-03-11 13:05:07 +09:00
Hridya Valsaraju
6c889bb9cb fastbootd: use FastbootDevice::GetCurrentSlot to get current slot suffix
Using FastbootDevice::GetCurrentSlot to get the current slot suffix
instead of reading the same from the device's boot control HAL
is required to account for the prior set_active commands issued via
fastbootd in the same boot.

Test: fuzzy_fastboot
--gtest_filter=Conformance.Slots:Conformance.SetActive --gtest_repeat=10
Bug: 146589281

Change-Id: I2edb0f024d93c2483659623423ef5c69c717c7af
Merged-In: I2edb0f024d93c2483659623423ef5c69c717c7af
2020-03-03 17:38:19 +00:00
Hridya Valsaraju
45719a8f07 fastbootd: use FastbootDevice::GetCurrentSlot to get current slot suffix
Using FastbootDevice::GetCurrentSlot to get the current slot suffix
instead of reading the same from the device's boot control HAL
is required to account for the prior set_active commands issued via
fastbootd in the same boot.

Test: fuzzy_fastboot
--gtest_filter=Conformance.Slots:Conformance.SetActive --gtest_repeat=10
Bug: 146589281

Change-Id: I2edb0f024d93c2483659623423ef5c69c717c7af
2020-03-02 13:14:11 -08:00
David Anderson
ac892d7569 Merge "Don't require bootloader fastboot for VTS compliance." 2020-02-07 21:46:01 +00:00
David Anderson
7868246e30 Don't require bootloader fastboot for VTS compliance.
Bug: 144820025
Test: vts
Change-Id: Ib99ddbe611645fe0f89134a628ddb486b02df170
2020-02-06 13:13:56 -08:00
Bowgo Tsai
27d5fb344b Increases fastbootd response message size
Some output of `fastboot getvar` exceeds current message size.
Increases the message size to 256 to fix the issue.

Bug: 74445765
Bug: 144473561
Test: fastboot getvar system-fingerprint
Change-Id: Id5064be4bb500697ce87c473f662d86c7c344d65
2020-02-06 16:22:59 +08:00
Baligh Uddin
3d902d1637 Use SOONG_HOST_OUT_EXECUTABLES
Bug: 147699225
Test: m com.android.tzdata (apexer requires these executables)
Change-Id: I008d244e330d2113cb3f2dd4b6c770df3f2fac06
2020-01-23 14:09:01 +00:00
Bowgo Tsai
99f9a38a8b fastbootd: exporting more properties
Exporting more properties that can be useful for image compatibility
check, prior to run fastboot flash.

Bug: 74445765
Bug: 144473561
Test: fastboot getvar <new variable>
Change-Id: I2ddfa2c1e9e719e05a3a64b9ca1d608957aebf11
2020-01-22 23:29:07 +08:00
steven_fann
fde5e27602 Allow fuzzy_fastboot test devices over internet
Bug: 144667236
Test: fuzzy_fastboot --serial=192.168.1.104:5555 --gtest_filter=*Logical*

Change-Id: I02e62f706d0a3a19a9b7b56788abe05759d2d63d
2020-01-21 15:40:52 +00:00
Yifan Hong
38f3706ab3 Merge "fastboot: Mount /metadata before overlayfs teardown." 2020-01-15 01:31:59 +00:00
Dan Shi
754167b241 Add libc++ as static library
This is for the test to run without packaging libc++.so in vts-core
suite.

Bug: 147249791
Test: atest FastbootVerifyUserspaceTest
Change-Id: I0263d13a2dd08186502b30b2fad25d4f0f3a6be8
2020-01-09 14:24:23 -08:00
Dan Shi
44b29c643a Add fuzzy_fastboot to vts-core suite
The binary is required by FastbootVerifyUserspaceTest.
Disable test config generation as fuzzy_fasboot itself is not part of
vts-core suite.

Bug: 147249791
Test: atest FastbootVerifyUserspaceTest
Change-Id: Ief86f33b41990a354497b128e154da04fec58ae9
2020-01-06 15:52:10 -08:00
David Anderson
23243497fd fastboot: Mount /metadata before overlayfs teardown.
fs_mgr_overlayfs needs access to /metadata to tell whether or not the
scratch partition exists on /data.

Bug: 134949511
Test: adb remount, fastboot flash system
Change-Id: I3a09aae495d691e9c1a1e25a8fb3514e355ecd05
2019-12-30 13:42:57 -08:00
Yifan Hong
712c32b2b9 fastboot: Flashall does proper snapshot cancel
Fix typo.
Test: flashall

Change-Id: I54a51a489aef2e1de5e682f5e97b95b2278085ec
2019-12-10 18:12:55 -08:00
David Anderson
bf55a76fd9 Merge "fastbootd: Disallow certain operations during snapshot updates." 2019-11-19 00:49:44 +00:00
Bowgo Tsai
33da5c9493 fastbootd: exporting CPU ABI info
CPU ABI info, e.g., arm64-v8a, can be useful to determine image
compatibility, prior to flash. Adding this info in fastbootd.

Bug: 74445765
Test: fastboot getvar cpu-abi # arm64-v8a
Change-Id: Ied494b646c551320295956b7890c0102fdb88382
2019-11-13 17:22:22 +08:00
David Anderson
220ddb1f0f fastbootd: Disallow certain operations during snapshot updates.
When a snapshot is applied or is merging, requests to erase or flash
userdata, metadata, or misc must be protected. In addition, the
set_active command must be restricted when a merge is in progress.

In addition, introduce a "snapshot-update merge" command for assisting
with erase requests when a merge is in progress. As in recovery, this
will force a merge to complete.

Bug: 139154945
Test: apply update
      fastboot erase userdata
      fastboot erase metadata
      fastboot erase misc
      fastboot set_active

Change-Id: I152446464335c62c39ffb4cc6366be9de19eac30
2019-11-10 23:07:13 -08:00
David Anderson
c399ccb345 Merge "fastboot: Implement helper commands for Virtual A/B." 2019-10-31 01:11:49 +00:00
David Anderson
ab8f466107 fastboot: Implement helper commands for Virtual A/B.
This introduces two new commands to the fastboot protocol:

  - getvar snapshot-update-status - Return "none", "snapshotted", or
    "merging" depending on the current status set by the boot control
    HAL.
  - snapshot-update [cancel] - Cancel any pending snapshot-based updates
    via the boot control HAL. After this, the HAL should return
    MergeStatus::CANCELLED and "update-merge-status" should be "none".
    If no argument is specified, the snapshot-update-status is returned
    via an INFO response.

Bootloaders are expected to implement this in a manner consistent with
the boot control HAL.

Fastboot-based tooling should expect wipes of userdata to fail when
update-merge-status returns "merging". Thus, the force flag now cancel
any pending snapshots.

Bug: 139154945
Test: fastboot getvar snapshot-update-status
      fastboot snapshot-update cancel
      fastboot snapshot-update

Change-Id: Idc423fe7656b212e929e64eb0e6b85b453e0e8dc
2019-10-31 01:11:16 +00:00
David Anderson
376f04e047 Merge "avoid data overflow in low memory device" 2019-10-23 23:15:06 +00:00
JeiFeng Lee
ba117304ab avoid data overflow in low memory device
Bug: 142294642
Test: fastboot flash system system.img
Change-Id: Iec50817aaca5d31c194f0fdf409503829d14ca06
2019-10-23 13:20:41 +08:00
Chin-Ting Kuo
df6a780ee7 Allow --disable-verification when top-level vbmeta is in 'boot'
If top-level vbmeta struct is in 'boot' partition,
the "flags" element offset of top-level vbmeta header
from the beginning of boot partition is 123 plus
top-level vbmeta offset recorded in the boot image footer.

Bug: 139639521
Test: m fastboot
Test: fastboot --disable-verification flashall
Test: fastboot --disable-verification flash boot boot.img, checks the
      flag isn't changed if the device has vbmeta partition
Test: fastboot --disable-verification flash vbmeta vbmeta.img
Change-Id: Ibf73c9330639e971ee3873ac19f072cf7baed55b
2019-09-24 12:35:26 +08:00
Tom Cherry
fbb9535aae fastboot: don't use sparse_file_import_auto() in load_buf_fd()
load_buf_fd() attempts to find the size of the file that it is about
to load by first calling sparse_file_import_auto() then using
sparse_file_len() upon success or falling back to the file size on the
filesystem on failure.

This is problematic however as sparse_file_import_auto() creates a
sparse_file out of the normal file, but does not resparse it, so an
assertion fails during the sparse_file_len() call.

This is fixed by using sparse_file_import() instead.  This will fail
in the case that the file is not sparse and the call to
sparse_file_len() will be properly skipped.

Bug: 140538105
Test: flash blueline factory image with assertions enabled in
      libsparse/sparse.cpp

Change-Id: I0283be33563a3301ce5b09bde41105a20f91086c
2019-09-17 13:43:56 -07:00
Yifan Hong
0e13bbade3 fastbootd: skip COW group
Skip importing COW group because they are dynamically
created by OTA clients and will never show up in built
images.
Test: flash

Change-Id: I44e7693cfb4c15e64455b56212a02f9abde88d61
2019-09-11 18:32:57 -07:00
Steven Moreland
a4eaf64de8 Remove libhwbinder/libhidltransport deps
Since these were combined into libhidlbase.

Bug: 135686713
Test: build only (libhwbinder/libhidltransport are empty)
Change-Id: I0bdffced6af52695c0ef98c9dd659348e56f7aa6
2019-09-05 14:17:42 -07:00
Tom Cherry
390b48bad2 Merge "fastboot: preserve partition_type if wants_wipe=true" 2019-08-29 20:24:52 +00:00
qiwu chen
325ba6ffa8 fastboot: Initialize UploadInner dsize value to 0
We must initialize UploadInner dsize value to 0, in case
stuck in ReadBuffer when receive DATA packet which dsize
is 0 or non DATA type packet. This will lead to fastboot
hang up unless USB unplugged.

Change-Id: I1e9752585c3d1013b1b1da38ead9ba4c532c2d34
Signed-off-by: qiwu chen <qiwuchen55@gmail.com>
2019-08-29 14:56:19 +08:00
cfig
f60613b4e8
fastboot: preserve partition_type if wants_wipe=true
originally if wants_wipe=true, program will erase and format partitions,
but after fb->Erase(), partition type should be raw(all 0xFFs),
then following fb_perform_format() will miss its original partition_type
Now we call fb_perform_format() with original fs type to keep the
partition consistent after wiping.

Change-Id: Ic778850588d5dd6fee23169d20c26bcbaa510627
2019-08-29 13:19:29 +08:00
Treehugger Robot
2d5395fec1 Merge "fastboot: add vendor_boot to list of images" 2019-08-29 02:54:51 +00:00
David Anderson
ad970fc055 fastbootd: Cancel snapshots when modifying partitions.
When flashing or resizing partitions, remove the
LP_PARTITION_ATTR_UPDATED flag. This will cause first-stage init to skip
any snapshots for that partition, and the backing storage (if any)
will later be reclaimed.

Bug: 139155473
Test: manual test
Change-Id: I3b185f68dfecb5a93636af0b5ae289ead1363fd0
2019-08-27 14:03:44 -07:00
Steve Muckle
3611243e4d fastboot: add vendor_boot to list of images
The vendor_boot partition has been created, so add it to the list of
images which may be flashed.

Bug: 137297791
Change-Id: I27eaa16656a83dbcb8289680844bf58dd1fccf24
2019-08-21 11:17:55 -07:00
David Anderson
15aa9540df liblp: CreateLogicalPartition with a given mapped name
Introduce a parameter struct to eliminate parameter explosion, and refactor
existing callers to use the new helper.

Test: manual test
Bug: 135752105
Change-Id: I0c5ebe4e084ad7503c2ac6c65886a71505d50d00
2019-08-13 13:41:36 -07:00
David Anderson
470fe2b5f0 fs_mgr: Remove the timeout parameter to DestroyLogicalPartition.
This is no longer needed as CreateLogicalPartition() ensures the
obtained path will not race with device deletion.

Bug: 135771280
Test: device builds, flashes
Change-Id: I821290aa08fede99d5c51cd68681c351a1ea97bc
2019-07-11 15:39:53 -07:00
Justin Yun
5d0ac62995 Rename product_services to system_ext
Update adb, fastboot and mount point

Bug: 134359158
Test: build and check if system_ext.img can be flashed
Change-Id: I6219f72242c5fe42a508008c0b1fd218d74da5b6
2019-07-09 08:56:53 +00:00
David Anderson
7c84b9fea2 fastboot: add a wipe-super command.
Usage: fastboot wipe-super [super_empty.img]

This command will read the given super_empty.img (using the default one
in ANDROID_PRODUCT_OUT if not specified), and flash by generating a
temporary super.img with no partition data. This command will even work
on retrofit devices.

This command is intended to be used either during device bringup or with
scripts that will manually flash individual dynamic partitions, in place
of using "fastboot flashall".

Bug: 136282057
Test: fastboot wipe-super on retrofit and non-retrofit device
Change-Id: Icab368a63ff36fcce9ac9304eb3966dd38bd78c4
2019-06-28 21:09:03 +00:00
David Anderson
2747532f96 fastbootd: Don't include all of the fs_mgr namespace in commands.cpp.
Bug: N/A
Test: m fastbootd
Change-Id: Iea67a27a2d3637df5dfd55982bda1465b7ef7de8
2019-06-11 14:05:02 -07:00
David Anderson
196d2ba7b9 liblp: Add helpers for finding partitions and partition sizes.
These tend to get manually, so let's promote to actual helpers.

Bug: 134536978
Test: liblp_test gtest
Change-Id: Ifb79c8d6f247cc3f9635bf6adfd1c99907340002
2019-06-07 11:09:28 -07:00
Greg Kaiser
8acf8c2da7 fastboot: windows: Minor printf format fixes
We recently changed 'xfer' to a size_t, so update the DBG format
accordingly.  We also fix a long standing issue with format for
the unsigned 'read'.

Test: TreeHugger
Change-Id: I3dc5f26a033fea64119016802bc9cdb54bbb7b52
2019-06-03 14:12:42 -07:00
Fernando Lugo
b7eac2d084 fastboot: windows: fix Read function
Read function exits before reading all requested bytes. Fix that by
looping until the len requested is completed.

This will fix the issue execting get_staged command for a staged image
bigger than 1MB

Test: fastboot get_staged file.txt
Change-Id: Ic70ab48f3a8c8d78c225db638892501d4dc20b13
Signed-off-by: Fernando Lugo <flugo@google.com>
2019-05-30 17:47:49 -07:00
chihhao.chen
8c544b6fd8 Fix non-aio USB read issue for fastbootd
non-aio USB read function was stuck in a loop waiting for more data
because data length parameter is always set 64 for fastbootd commands.
It should be a normal case to get less data than expected
since lengths of these commands are usually less than 64.
Add logic to check this and one more parameter to distinguish
fastbootd from general adbd case.

Bug: 133189029
Test: try various fastbootd commands
Change-Id: I6690324840d78f3f1e04235040301520329976db
Merged-In: I6690324840d78f3f1e04235040301520329976db
2019-05-29 23:10:50 +00:00
Treehugger Robot
9ab0471734 Merge "fastbootd: reduce USB buffer size to 16K" 2019-05-22 03:45:18 +00:00
Hridya Valsaraju
d747dba9c0 fastbootd: reduce USB buffer size to 16K
Some USB controllers can only support transfers upto 16K.

Bug: 133208811
Test: fastboot flashall
Change-Id: Ic025bdd8e7a6cf2634fc24524fd189e0cc9efbb5
2019-05-21 13:08:52 -07:00
Treehugger Robot
b545055f6d Merge "Get max-download-size from device during fastbootd for flashall/update" 2019-05-20 22:50:10 +00:00
Hridya Valsaraju
83d856e4c5 Get max-download-size from device during fastbootd for flashall/update
Currently, during a 'fastboot flashall/fastboot update', the 'getvar
max-download-size' command is issued once to the device when it is in
bootloader mode and the same value is used even after the device boots
into fastbootd. If the max-download-size returned by bootloader is
greater than the max-download-size in fastbootd, this could break flash
as large images are broken down into chunks before downloading by using
the max-download-size variable. This will cause fastbootd to return
an error since it checks whether the buffer being downloaded has a size
greater than the max-download-size limit.

Test: fastboot flashall
Bug: 536870912

Change-Id: Ife7c1ec0583d80d4a31ecf01f1fc14a8365afe0d
2019-05-20 09:37:22 -07:00
Treehugger Robot
3afe5f22b3 Merge "Allow CreateResizeDeleteLP test case to run on non-A/B devices" 2019-05-15 03:53:37 +00:00
Hridya Valsaraju
f81bd17179 Allow CreateResizeDeleteLP test case to run on non-A/B devices
Test: fuzzy_fastboot --gtest_filter=*Logical*
Bug: 117220134

Change-Id: Ic7c2b246b7c5646d3589f8f57eceb9ba5feeef2b
2019-05-14 16:37:10 -07:00
Treehugger Robot
9426110d37 Merge "fastboot: demote OS X USB error." 2019-05-10 21:23:42 +00:00
Josh Gao
16f992e228 fastboot: demote OS X USB error.
We can't create interface iterators for all devices (e.g. the keyboard,
touchbar, etc.), so we get multiple instances of this log spam on every
command.

Demote it to a warning that only shows up on debug builds.

Test: none
Change-Id: I20581b9134c05360d5723b09ffe8de8c4cfd6a3f
2019-05-10 11:29:13 -07:00
Elliott Hughes
b17bf521d5 libziparchive: report errors on over-long names.
Switch FindEntry and the ZipString constructor to std::string_view. This
lets us accept an over-long name so that we can reject it as too long.

Also fastboot changes to track the API change.

Bug: http://b/129068177
Test: treehugger
Change-Id: I7df7acd1fe2c46380b789c25f8909e0553e2d55e
2019-05-04 08:41:12 -07:00
Treehugger Robot
6e28863442 Merge "Handle failed usb/reads and writes correctly" 2019-04-16 23:03:17 +00:00
Hridya Valsaraju
8efadf70e1 Handle failed usb/reads and writes correctly
Currently if the device is unplugged from host,
there is a lot of log spamming since fastbootd
does not not recognize that the device has been
disconnected and keeps trying to read/write to the
device.

2856 printk messages dropped ** [  169.941904] c7    579 fastbootd: aio: got error event on
read total bufs 1: No such devie
** 2960 printk messages dropped ** [  169.953328] c7    579 fastbootd: Fastboot command:
** 2074 printk messages dropped ** [  169.961355] c7    579 fastbootd: aio: got error event
on read total bufs 1: No such devie

Bug: 121333158
Test: unplug device and check for log spam multiple times

Change-Id: I1d4c6f48f34e313c5ebce23d62a4fe6a6373f94f
2019-04-15 10:36:42 -07:00
Treehugger Robot
1a17b09174 Merge "Allow fuzzy_fastboot number to run for a specific device serial number" 2019-04-11 22:33:22 +00:00
Hridya Valsaraju
b9051a3e65 Allow fuzzy_fastboot number to run for a specific device serial number
Test: ./fuzzy_fastboot --serial=826X003L --gtest_filter=*Logical*
Bug: 117181762
Change-Id: I9dec510aa604b7994f25ce26edb87d7f6ec3e875
2019-04-11 09:52:09 -07:00
Hridya Valsaraju
61a5bc6cf4 Test is-logical command for vendor and boot partitions.
Vendor must be a logical partition and boot must not be a logical
partition.

Test: fuzzy_fastboot --gtest_filter=*Logical*
Bug: 117220134
Change-Id: Ifc6f2f715ca92cd1fe779e8fce2d6a10a1f140b9
2019-04-05 11:30:21 -07:00
Treehugger Robot
744677aaf5 Merge "Open image files in binary mode" 2019-04-04 04:38:26 +00:00
Hridya Valsaraju
1a6f6feff4 Open image files in binary mode
This is required for read() to function correctly
in Windows since it behaves differently in text mode and
binary mode and may cause unpredictable behavior depending
on the contents of the image file.

Bug: 129281908
Test: fastboot.exe flashall
Change-Id: I64370af44a050bafea60ff1b0b2be18cc531480a
2019-04-03 18:14:14 -07:00
Greg Kaiser
b49d9e19dc fastboot: Avoid extra std::string copies
The function do_for_partitions() takes a const std::string
reference, so it's inefficient to pass a std::string::c_str().

Test: TreeHugger
Change-Id: Ia84ed9ec691ee2f524c61dd25a81b2995bb0bb33
2019-03-26 12:04:05 -07:00
Hridya Valsaraju
d5b690993b Merge "Fuzzy_fastboot must set back the original slot after test" 2019-03-22 21:09:08 +00:00
Hridya Valsaraju
405431fd50 Add more tests for dynamic partitions
Test: ./fuzzy_fastboot --gtest_filter=LogicalPartitionCompliance*
Bug: 117220134
Change-Id: Ica489b0f9b252b2981cd44676bb892ded977de22
2019-03-19 21:36:07 +00:00
Hridya Valsaraju
68e639ecf6 Add a test for logical partitions.
Test: ./fuzzy_fastboot --gtest_filter=LogicalPartitionCompliance*
Bug: 117220134

Change-Id: Ib68f98ec5c8c402f9a80139134a0118ab65f8cd3
2019-03-19 14:33:54 -07:00
Hridya Valsaraju
bcab240cbc Fuzzy_fastboot must set back the original slot after test
Test: ./fuzzy_fastboot --gtest_filter=Conformance.SetActive
Bug: 117220134

Change-Id: I1fb6975dda52ace3e6d2a81a50cba5ff55310818
2019-03-18 15:39:32 -07:00
Dima Zavin
6d46a4975e fastboot: reset timeout if INFO is received during long commands
As part of a refactor, commit db511207ed
added a timeout for receving responses for commands. Unfortunately,
the timeout is optimistic as to how quickly target devices can complete
such operations. Flash and erase commands can be quite slow on devices
with traditional flash chips. The fastboot protocol is already adept
at handling such cases because it allows for sending INFO packets during
these periods. We may receive one or more INFO packets during tehse long
operations. Every time we receive an INFO packet, it proves the remote
end is alive, but busy, which should reset our timeout timer.

Change-Id: Ia3bba21c497b22639b626d89711ecd4eb02504ed
Signed-off-by: Dima Zavin <dmitriyz@waymo.com>
2019-02-28 14:55:49 -08:00
Dima Zavin
a5b85a431e fastboot: switch the timeout clock source to steady_clock
Previously, system_clock was used for remote command timeouts
which can get disturbed by NTP adjustments (jumps).

Change-Id: I0ffc159bf34d12e8d3713044524114d60a6a45ca
Signed-off-by: Dima Zavin <dmitriyz@waymo.com>
2019-02-28 14:55:48 -08:00
David Anderson
3d782d57cc fastboot: Fix "fastboot gsi".
This command erroneously reports that no GSI is installed, because
/metadata is not mounted in recovery. To address this, temporarily mount
/metadata when the gsi command is invoked.

Bug: 122556707
Test: fastboot gsi disable
      fastboot gsi wipe

Change-Id: Ib21971b49b46fd580b902ff75f01cfb96192afc0
2019-01-29 13:20:36 -08:00
Tom Cherry
b688d917cd Remove the rest of users of the old style fstab
And deprecate one more old style function that is not used after this
change.

Test: boot, disable and enable verity
Change-Id: Id509f479850120352b4ea4dc3b6c40f6e8e2e53e
2019-01-28 12:34:33 -08:00
Hridya Valsaraju
6c8fca6d59 Make 'fastboot boot' command support boot header version 2
New arguments 'dtb' and 'dtb-offset' have been added to
support boot image header version 2 for the 'fastboot boot'
and 'fastboot flash:raw boot' commands.

Test: fastboot boot Image.lz4 --dtb <dtb_path> --header-version 2
Test: fastboot flash:raw boot Image.lz4 --dtb <dtb_path>
--header-version 2
Bug: 111136242

Change-Id: Idf5c2eb138609dc7e915e80c4db64677c89f24b6
2019-01-25 12:52:27 -08:00
David Anderson
1d504e3342 fastbootd: Add command to remove GSI installs
Note: this only removes the bootable marker, since we're unable to
remove the userdata files within recovery.

Bug: 121210348
Test: fastboot gsi wipe
      fastboot gsi disable
Change-Id: I64fe848c787d426ae9d18a1557a9d6b340bfc2cf
2019-01-17 18:33:14 +00:00
David Anderson
a48f86b88e fastbootd: Better error message when boot_devices is missing.
Bug: 121333158
Test: N/A
Change-Id: Ifac7ae382d9e57864f6a3915987300eb91355293
2018-12-20 16:56:06 -08:00
Treehugger Robot
8fd4435d53 Merge "fastbootd: Only flash slots listed by the boot control HAL." 2018-12-18 03:56:48 +00:00
David Anderson
4d307b0975 fastbootd: Only flash slots listed by the boot control HAL.
Bug: N/A
Test: flash when metadata slot count is >2
Change-Id: I67481be0de162cab5da8d32c2e318489427f1932
Merged-In: I67481be0de162cab5da8d32c2e318489427f1932
(cherry picked from commit 8568dcb057)
2018-12-18 02:12:22 +00:00
Chih-Hung Hsieh
1b7b7979af Fix performance-for-range-copy warnings
Bug: 30413223
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,performance*
Change-Id: I3ad102f2b0f971266d57488a3bd57d312f7ee3e6
2018-12-11 10:51:13 -08:00
David Anderson
b81bc9ec00 Merge "fastboot: Wait for reboot-fastboot to complete before signaling success." 2018-12-08 06:19:52 +00:00
David Anderson
11d6d278cd fastboot: Wait for reboot-fastboot to complete before signaling success.
Bug: N/A
Test: manual test
Change-Id: I07495c1befcf63607c9996d6da6b4df05c060641
2018-12-07 16:39:55 -08:00
David Anderson
0047580398 fastboot: Check if super_empty.img exists before reading it.
On non-DAP devices, fastboot flash <partition> will spam error messages
about not being able to read super_empty.img. We should check that
super_empty.img exists before trying to read it.

Bug: 120429424
Test: fastboot flash system on non-DAP device
Change-Id: I6c4eec19cb3ef8d24595a75e072e1d75baaa8cdd
2018-12-04 17:12:58 -08:00
Treehugger Robot
a7f54b1592 Merge "C++17 is the default now." 2018-12-04 07:53:24 +00:00
Elliott Hughes
3c59cb8420 C++17 is the default now.
Test: builds
Change-Id: I6814455e9ad2cdcf99ad66de38a3ad0bfb440d80
2018-12-03 09:02:18 -08:00
Mark Salyzyn
307a41fe9f fastboot: call fs_mgr_overlayfs_teardown() in UpdateSuper
When the update-super command is issued, we want overlayfs overrides
to disappear without a doubt, which includes non-A/B utilizing
/cache/overlay/ tree.  Call fs_mgr_overlayfs_teardown() on successful
return.

Test: adb-remount-test.sh
Bug: 120034852
Change-Id: Ia5cdb797f7e8350b5591a51fc8ae5f323901aee4
2018-12-03 07:33:38 -08:00
David Anderson
0c73234fe0 fastboot: Delete logical "other" partitions on retrofit devices.
On retrofit devices, if both slots contain dynamic partition builds,
then "flashall" will attempt to write secondary images to dynamic
partitions in the other slot. At worst, this can fail with an error. At
best, it will result in the "other" partition not being mounted on first
boot.

This patch therefore deletes logical partitions for secondary images, on
retrofit devices only. On a Pixel device on the "b" slot, this means
"system_a" and "vendor_a" will be deleted before flashing, and therefore
system_other and vendor_other will be flashed to physical partitions
instead.

Bug: 120034852
Test: fastboot set_active a
      fastboot flashall
      fastboot set_active b
      fastboot flashall

Change-Id: I6affe9a6c639b0495bffc77fcf20f329b86ad159
2018-11-28 17:47:21 -08:00
Treehugger Robot
4055587ddd Merge changes Ic4e1a1de,Icfceaa46
* changes:
  fastboot: propagate error for format command
  fs_mgr: overlayfs: resize scratch should it be too small
2018-11-28 23:34:29 +00:00
David Anderson
e0e693c32f fastboot: do not die if ANDROID_PRODUCT_OUT undefined
When checking for existence of "super_empty.img" to determine if
flash image product set is meant for logical partitions, we die if
ANDROID_PRODUCT_OUT environment is unset or empty.  This check
is done before we look at the flash image name to determine if it
is a candidate to look at the logical metadata.

Instead, allow this check to conservatively fail for now.

Test: export ANDROID_PRODUCT_OUT=
      fastboot flash bootloader
Bug: 120041144
Change-Id: I43f124015f9d26c79a0feb9123522432fe937343
Merged-In: I43f124015f9d26c79a0feb9123522432fe937343
2018-11-28 18:54:28 +00:00
Jaegeuk Kim
9c4ae20f0e Merge "make_f2fs: use -g android by default" 2018-11-28 00:57:25 +00:00
Mark Salyzyn
a30b6964d6 fastboot: propagate error for format command
If fastboot format command fails, return error.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: Ic4e1a1dea8861028f19ac7f9c834d26e8adba56c
2018-11-27 13:51:42 -08:00
Treehugger Robot
ee9d6382d1 Merge "Switch from dist-for-goals to dist in Android.bp" 2018-11-27 00:59:19 +00:00
Jaegeuk Kim
46542f9ecc make_f2fs: use -g android by default
Bug: 119875846
Change-Id: I0c6d642d474df5cc678ced9ec4c04027ee51c6d1
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-11-22 03:42:07 -08:00
David Anderson
66a6d8877c Merge "fastbootd: Support two super partitions for retrofit devices." 2018-11-21 17:40:43 +00:00
David Anderson
d25f1c3775 fastbootd: Support two super partitions for retrofit devices.
Retrofit devices will have two super partitions, spanning the A and B
slots separately. By design an OTA will never cause "A" or "B"
partitions to be assigned to the wrong super. However, the same is not
true of fastbootd, where it is possible to flash the inactive slot. We
do not want, for example, logical "system_a" flashing to super_b.

When interacting with partitions, fastbootd now extracts the slot suffix
from a GetSuperSlotSuffix() helper. On retrofit devices, if the partition
name has a slot, that slot will override FastbootDevice::GetCurrentSlot.
This forces partitions in the inactive slot to be assigned to the correct
super.

There are two consequences of this. First, partitions with no slot
suffix will default to the current slot. That means it is possible to
wind up with two "scratch" partitions, if "adb remount" is used on both
the "A" and "B" slots. However, only the active slot's "scratch" will be
visible to the user (either through adb or fastboot).

Second, if one slot does not have dynamic partitions, flashing will
default to fixed partitions. For example, if the A slot is logical and B
is not, flashing "system_a" will be logical and "system_b" will be
fixed. This works no matter which slot is active. We do not try to
upgrade the inactive slot to dynamic partitions.

Bug: 116802789
Test: fastboot set_active a
      fastboot flashall # dynamic partitions
      fastboot getvar is-logical:system_a # true
      fastboot getvar is-logical:system_b # false
      fastboot set_active b
      fastboot flashall --skip-secondary
      fastboot getvar is-logical:system_a # true
      fastboot getvar is-logical:system_b # true
      Booting both slots works.

Change-Id: Ib3c91944aaee1a96b2f5ad69c90e215bd6c5a2e8
2018-11-20 13:47:01 -08:00
David Anderson
8956964ee2 fastboot: Warn when flashing dynamic partitions in the bootloader.
On retrofit devices, it is easy to accidentally overwrite
system/vendor/product by flashing system in the bootloader. The reason
is that GPT system_a is really the super partition, and the bootloader
doesn't know it.

Addressing this in bootloaders would require two separate commands: one
that rejects flashing system/vendor/product, and another for
expert/factory use that would allow direct flashing.

This patch introduces protection into the host fastboot tool instead.
It's not mutually exclusive with bootloader changes; having protection
in the host tool affords us better and consistent UI. However it does
rely on users having newer builds.

With this change, the following will not work in the bootloader:

    fastboot flash system       # or vendor, product, etc

The message is the same whether or not the device is a retrofit. To
continue anyway, you can do:

    fastboot flash --force system

If we decide on bootloader protection as well, the --force flag can be
re-used.

Bug: 119689480
Test: fastboot flash system # disallowed in bootloader, allowed in fastbootd
      fastboot flash --force system # allowed in bootloader
Change-Id: I0861e3f28a15be925886d5c30c7ebd4b20c477cf
2018-11-20 12:10:16 -08:00
Dan Willemsen
3f439a7a88 Switch from dist-for-goals to dist in Android.bp
Removes a few more Android.mk files.

Test: check for adb, mkbootfs, and fastboot in the build artifacts
Change-Id: Ie4e50a363a734d0b9207f0d0098c54719f038e76
2018-11-19 23:06:12 -08:00
Mark Salyzyn
9f1cf25332 switch to using android-base/file.h instead of android-base/test_utils.h
Test: compile
Bug: 119313545
Change-Id: I4f7ad84743e974b4b4d1d7256088f6c8b749a237
2018-11-14 09:35:34 -08:00
Eran Messeri
be0ab0a6e0 fastboot: pin USB interface versions on darwin.
Similar to the change to adb in Id26760bc62c89a1f7ef67511b21f9d9252ab69f3,
pin the interface version to IOUSBFamily 5.0.0.

Bug: 119264733
Test: Manual
Change-Id: Ied9164532c0ba6f20415dafecb0c774578aa5c57
2018-11-11 18:14:58 -08:00
David Anderson
90fe0a43ab fastboot: Query the name of the super partition.
This patch adds a new variable, "super-partition-name", to query the
name of the super partition (with a slot suffix if it has one). The
fastboot flashing tool has been updated to query this variable.

Since the super partition name can no longer be determined without
fastbootd, the presence of super_empty.img is used to test for
dynamic partition support rather than the presence of a super partition.

Bug: 116802789
Test: fastboot flashall on retrofit device
Change-Id: If830768eba6de7f31ac3183c64167fae973c77a4
2018-11-06 11:43:04 -08:00
David Anderson
96a9fd4063 fastboot: Fix flashing both slots with dynamic partitions.
When updating the super partition, attempt to preserve partitions from
the other slot. If any partition can't be preserved, fail and require a
wipe (-w) to proceed. This allows two bootable builds to be flashed to
both slots.

The preserve operation can fail if the metadata is not compatible with
the old partition layout. For example, if the partition references a
group that no longer exists, or a group changed its capacity, or the
metadata's block device list or list contents changed.

Bug: N/A
Test: liblp_test gtest
      fastboot flashall --skip-secondary

Change-Id: I53fdd29bc1f0ef132005a93d3cf1cdcd7f2fc05f
2018-11-06 11:43:03 -08:00
David Anderson
63ffb447a7 fastbootd: Partition commands should update all metadata slots.
Without this, it is much more difficult to ensure that the "a" and "b"
slots are both bootable during development. We already update all
metadata slots for update-super, so we should here as well.

Bug: N/A
Test: fastboot flashall
      fastboot set_active other
      fastboot flashall
Change-Id: Ib661e35fa89171a68a0b1da195dc5ba0375d72e4
2018-11-01 17:43:45 -07:00
Treehugger Robot
787de64fad Merge "fastboot: wipe overlayfs for partition" 2018-10-27 00:18:24 +00:00
David Anderson
43cb5db90a Merge "fastbootd: Remove metadata merging code." 2018-10-26 23:23:34 +00:00
Yuchao Zhou
55d31ecd86 Merge "More Mac build fixes." 2018-10-26 22:47:40 +00:00
Mark Salyzyn
044f04baed fastboot: wipe overlayfs for partition
Arrange to delete the overlayfs backing when a specified partition
has been flashed.

Test: manual
Bug: 109821005
Bug: 117605276
Change-Id: I1c6a0341c6cd2ecfbb7c71bec5679a74d579aadd
2018-10-26 20:57:14 +00:00
David Anderson
b6134a6d4e fastbootd: Remove metadata merging code.
The purpose of this code was to support preserving partitions across a
flashall operation. Since we are not supporting persistent read-write
partitions, this merging code is effectively useless - it is preserving
only partitions that will be deleted.

Additionally, this code does not merge partition group changes, since
doing so accurately is difficult. Partition size changes aren't sent
until after update-super resolves, so a valid re-grouping could be
rejected during update-super if the existing partitions are too big.

This patch removes the update-super merging code until a use case comes
along and we can properly evaluate how it should work.

Bug: N/A
Test: fastboot flashall
Change-Id: I1d622b23dabdf031897be9de49f59fc8cf3caf3b
2018-10-26 13:34:40 -07:00
David Anderson
3eb5ba753c Merge "fastboot: Resize logical partitions when using the flash command." 2018-10-26 18:26:42 +00:00
Elliott Hughes
a56a729c14 More Mac build fixes.
The libziparchive public headers that refer to `off64_t` also need the
Mac workaround.

In fastboot, there's a stray `lseek64` but since it's only for offset 0,
any kind of seek is fine.

Bug: N/A
Test: builds
Change-Id: I68b4f95202623ebf07ffe6c3e0e21437e7922c5b
2018-10-26 10:53:24 -07:00
Treehugger Robot
dd85c74655 Merge "fastboot: Check that reboot to userspace succeeded." 2018-10-25 23:06:51 +00:00
David Anderson
629e51c109 fastboot: Resize logical partitions when using the flash command.
If an image size changes slightly in between "flashall" and some change
in the build, it's inconvenient to have to reflash the whole device again.
This patch resizes partitions when using a normal flash command, to
improve the developer workflow.

Bug: N/A
Test: fastboot flash system
Change-Id: I349364a4742a0c15748f545fcfda946107720d45
2018-10-25 20:10:20 +00:00
David Anderson
0444a8cbd9 fastboot: Check that reboot to userspace succeeded.
After rebooting to userspace fastboot, the first command issued is
"update-super". If we wound up in the bootloader by accident (as
happened to a few users with a busted vbmeta_system), the resulting
error message will be very misleading ("update-super" will be an
unrecognized command).

Instead, this patch explicitly errors if we did not successfully boot
into fastbootd.

Bug: N/A
Test: fastboot flashall
Change-Id: I7d5bd64db540978bd0bae884f40ce8c3df48f856
2018-10-25 12:31:49 -07:00
Elliott Hughes
32df7ee5c8 libbase: add O_CLOEXEC to <android-base/file.h>.
We already expose O_BINARY, and O_CLOEXEC seems equally legitimate.

Bug: N/A
Test: builds
Change-Id: I7f07e1bb2a5d6b5c5f293783c39ceab148fabefb
2018-10-24 14:06:45 -07:00
Elliott Hughes
e8f4b14301 Add a simple MappedFile to libbase and switch fastboot and libziparchive over.
This allows us to remove libziparchive's dependency on libutils.

Bug: http://b/79112958
Test: ran libbase and libziparchive tests, ran fastboot manually
Change-Id: I95c651976dad222863e5b8c37d4514b778f5dce7
2018-10-23 13:20:49 -07:00
Treehugger Robot
b59b20caac Merge "fastboot: use constants.h values" 2018-10-18 14:27:33 +00:00
Mark Salyzyn
8e7e9cb395 fastboot: use constants.h values
Cleanup to utilize all the manifest values in constants.h.

If the cli command _and_ the protocol name match, use a common
source of convenient truth.  This should set a pattern for future
additional commands.  When the command and the protocol differ,
we want to introduce resistance as it results in confusion and
maintenance issues.

Test: compile
Change-Id: Idad413c63cbbfcb6e851856105a5d5a9ef53ef29
2018-10-18 14:26:27 +00:00
David Anderson
166bfef4e6 Rename vbmeta_mainline to vbmeta_system.
Bug: 116859651
Test: fastboot flash vbmeta_system
Change-Id: Ice65b6f5141ec6da3e1c91d6a3aac58533dc2314
2018-10-15 14:48:00 -07:00
Treehugger Robot
a605668edd Merge "Do not calculate CRC for sparse images during fastboot flash" 2018-10-10 22:22:30 +00:00
Treehugger Robot
cd72cbb5d8 Merge "set_active command should update current slot information." 2018-10-10 22:13:15 +00:00
Hridya Valsaraju
aec0de5d96 Do not calculate CRC for sparse images during fastboot flash
Bug: 78793464
Test: fastboot flashall

Sparse images with CRC are not supported by the Android build
system and hence the calculated CRC is unused.

Change-Id: Ia48b2f7e29f2adea26d185c5a8f2337c4cbe6dcb
2018-10-10 13:18:35 -07:00
Hridya Valsaraju
20bdf899b2 set_active command should update current slot information.
Boot control HAL implementations will return the current boot
slot as the active slot. If a set_active command is issued on another
slot, it should be considered as the new active slot and subsequent
flashes should flash the same.

Test: fastboot set_active "b", fastboot getvar current-slot
Bug: 78793464
Change-Id: Ida3817670de8e74a7d7ae2a905e7ac1756c6bdf1
2018-10-10 12:25:11 -07:00
Treehugger Robot
9810709d91 Merge "Check validity of partition for getvar:partition-type" 2018-10-09 23:21:54 +00:00
Treehugger Robot
b2263b4a07 Merge "Return partition size in hex format." 2018-10-09 21:38:48 +00:00
Hridya Valsaraju
4165e00d67 Check validity of partition for getvar:partition-type
Test: fastboot getvar partition-type:product_services_a
Bug: 79480454

Change-Id: I4020b0c94daf8fb86c29104aecc1eb8f44f89999
2018-10-09 13:32:04 -07:00
Hridya Valsaraju
2a377da2f6 Return partition size in hex format.
This is required to pass fuzzy_fastboot conformance tests.
Also, allow for zero sized partitions in fuzzy_fastboot.

Test: ./fuzzy_fastboot --gtest_filter=Conformance.Slots
Bug: 117220134

Change-Id: Ifb12994a7796b081215084cb68b37674210aaa12
2018-10-09 12:16:50 -07:00
Treehugger Robot
f7d154e10f Merge "Check maximum allowed download size for download command." 2018-10-08 23:35:10 +00:00
Hridya Valsaraju
aae84e813c Check maximum allowed download size for download command.
Bug: 117272937
Test: fastboot flashall
Change-Id: Ied34a89129813a7f9fce6d4f48d8b65967558731
2018-10-08 14:07:56 -07:00
Treehugger Robot
32f5ff0dae Merge changes Id6c00c76,Ibc74a12f
* changes:
  Check return status of ReadFileToString() in GetDeviceLockStatus()
  Validate partition name when searching for physical partitions.
2018-10-08 20:33:46 +00:00
Hridya Valsaraju
bb12c5e45b Check return status of ReadFileToString() in GetDeviceLockStatus()
Return lock status of true if unable to read kernel command line.

Test: fastboot getvar unlocked
Bug: 117275849
Change-Id: Id6c00c769bcdcdf87fcc9e88902713a8eff3e320
2018-10-08 19:21:12 +00:00
Hridya Valsaraju
99f3772cb2 Validate partition name when searching for physical partitions.
Bug: 117274137
Test: fastboot getvar has-slot:../by-name/system
Change-Id: Ibc74a12f836a30bdf1fd7f6b2a1e941de2430c70
2018-10-08 11:59:07 -07:00
Treehugger Robot
e4046c7886 Merge "Allow erase, set_active and download commands only on unlocked devices." 2018-10-08 18:38:59 +00:00
Hridya Valsaraju
d1e623160c Allow erase, set_active and download commands only on unlocked devices.
Bug: 117276890
Bug: 117277405
Bug: 117278071
Test: make

Change-Id: Ic5e3a3ce9e2199578c2788b3b14aac7a8860a270
2018-10-08 10:27:48 -07:00
Treehugger Robot
4aa42b46c9 Merge "Allow Conformance tests to verify userspace fastboot." 2018-10-08 16:34:26 +00:00
Treehugger Robot
e06850afdb Merge "Support fastboot variable battery-soc-ok" 2018-10-07 17:53:45 +00:00
Hridya Valsaraju
a534a5a973 Support fastboot variable battery-soc-ok
Bug: 79480454
Test: fastboot getvar battery-soc-ok

Change-Id: Icfd70a71f1598e437316d4b8f895fd851516febb
Merged-In: Icfd70a71f1598e437316d4b8f895fd851516febb
(cherry picked from commit 9a1203b7ac)
2018-10-05 16:16:49 -07:00
Hridya Valsaraju
bdc1429454 Allow Conformance tests to verify userspace fastboot.
Bug: 117220134
Test: ./fuzzy_fastboot --gtest_filter=Conformance.*

Change-Id: Iab04fdff71e7e90a56d53d24cf14e94c81131009
2018-10-05 15:56:12 -07:00
Treehugger Robot
02678f32be Merge "Don't hardcode the super partition name." 2018-10-04 19:29:34 +00:00
David Anderson
e5f2f06b00 liblp: Remove the guid field from LpMetadataPartition.
Bug: 117229984
Test: liblp_test gtest
Change-Id: Ie42b3a8005b1cf711303966a2a117c255f0fb08c
2018-10-03 14:48:42 -07:00
Treehugger Robot
49ef2c5897 Merge "Remove tests for sparse images with CRC from fuzzy_fastboot" 2018-10-02 23:05:13 +00:00
Tom Cherry
e6fc328d16 Merge "fastboot: remove engine.cpp/engine.h" 2018-10-02 21:21:50 +00:00
Hridya Valsaraju
94d05063ba Remove tests for sparse images with CRC from fuzzy_fastboot
Sparse images with CRC are currently not supported by the
Android build system.

Test: ./fuzzy_fastboot --gtest_filter=Conformance.*
Change-Id: I6a73fb0dc5d4c77a3d1a0384c137789eb06fa956
2018-10-02 17:21:39 +00:00
David Anderson
5cbd2e43ee Don't hardcode the super partition name.
If a device has logical partitions but does not use a partition called
"super", we will need this to be configurable. Note that the "slot"
argument is currently unused, but will be necessary for update_engine if
there are A and B super partitions.

Bug: 116608795
Test: super partition works
Change-Id: Ieb548a158faeb423f3561230f26d582325efbc6b
2018-10-01 14:13:22 -07:00
Hridya Valsaraju
47658caae4 Interface with health HAL to read battery voltage
Bug: 78793464
Test: fastboot getvar battery-voltage
Change-Id: Ie0763e4f08327ec7649c5629066eb73e8142e0e6
2018-09-28 14:28:49 -07:00
Hridya Valsaraju
7c9bbe948b Add support to read fastboot variable 'off-mode-charge'
Bug: 78793464
Bug: 79480454

Test: fastboot getvar off-mode-charge
Change-Id: I4c40847be292e8e2e420340f81bb624b247bc11b
Merged-In: I4c40847be292e8e2e420340f81bb624b247bc11b
(cherry picked from commit b05d278696)
2018-09-28 14:16:47 -07:00
Hridya Valsaraju
4af80901a6 Support fastboot variable 'variant'.
Bug: 79480454
Bug: 78793464
Test: fastboot getvar variant
Change-Id: Iefef82c147d8405318c793ad0a73f00674bbb63d
Merged-In: Iefef82c147d8405318c793ad0a73f00674bbb63d
(cherry picked from commit 4785287a00)
2018-09-28 11:38:58 -07:00
Treehugger Robot
e4931c5bd4 Merge "Support 'fastboot getvar unlocked' command." 2018-09-26 16:21:28 +00:00
Treehugger Robot
c448000e42 Merge "Pass OEM commands to HAL" 2018-09-26 00:29:21 +00:00
Hridya Valsaraju
dca328d55c Support 'fastboot getvar unlocked' command.
Test: fastboot getvar unlocked.
Bug: 78793464

Change-Id: Ie59c6db90a503e9a6e9ac1c416e4ee5deac60479
2018-09-25 16:25:46 -07:00
Hridya Valsaraju
a15fe31507 Pass OEM commands to HAL
Bug: 78793464
Bug: 79480454
Test: fastboot oem command

Change-Id: Ibaabef6ea725857102f7531997fcff2a1dbdc1ca
Merged-In: Ibaabef6ea725857102f7531997fcff2a1dbdc1ca
(cherry picked from commit 993b4edb0f)
2018-09-25 22:55:47 +00:00
Tom Cherry
9027af0d40 fastboot: remove engine.cpp/engine.h
Replace the remnants of engine.cpp with better functionality in
FastBootDriver.  Particularly, add prolog() and epilog()
callbacks to FastBootDriver for printing actions and their result to
the console.  Then clean up the rest of fastboot.cpp to directly use
FastBootDriver.

Test: fastboot works
Change-Id: I0ff01d6a10f75e9dc1c82b46c6e9bb3bc4c68638
2018-09-25 14:32:56 -07:00
Tom Cherry
4aa60b382c fastboot: clean up CheckRequirements
CheckRequirements() had various issues that are cleaned up here,

1) Move from C string parsing to C++
2) Moved from C data structures to C++, including fixing memory leaks.
3) Removed the 'cur_product' global and the 'query_save' function that
   stores it
4) Actually writing tests for the parsing function for
android-info.txt
5) Check that a variable needs to be checked for a given product before
   trying to read it.  Previously, fastboot would fail if a variable
   isn't recognized on a device, even if the check should be ignored.

A lot of flexibility is allowed for the input strings, to keep
backwards compatibility with the previous parsers.

Test: fastboot works, unit tests

Change-Id: Idc3bba8b8fe829d8eefe5f6c495e63a9441c0b60
2018-09-21 12:50:39 -07:00
Tom Cherry
dfd85df11a Use vector<char> instead of char* and malloc() for images
And fix the associated memory leaks in the process.

Test: fastboot works
Change-Id: I6e41f351ca6cebf79282d30b1eca1506496e0c21
2018-09-20 16:48:36 -07:00
David Anderson
1109c92bea fastboot: Add vbmeta_mainline to the partition list.
Bug: 115939310
Test: fastboot flash vbmeta_mainline works
      fastboot flashall includes vbmeta_mainline

Change-Id: I081660cd8437ac66cab750b270f5019230050285
2018-09-17 17:34:22 -07:00
Treehugger Robot
e9997f8152 Merge "Integrate with fastboot HAL to get partition type" 2018-09-08 02:47:41 +00:00
Hridya Valsaraju
bf9f8d1a64 Integrate with fastboot HAL to get partition type
Bug: 79480454
Bug: 78793464

Test: fastboot getvar partition-type:userdata

Change-Id: Ib096ee8061568b8503f3a3f2dbb7e19a932162c4
2018-09-07 12:22:00 -07:00