Commit graph

63 commits

Author SHA1 Message Date
Tianjie Xu
68fc81e860 Report uncrypt errors in details
Add the error codes for uncrypt and report the failure details in
uncrypt_status.

Test: uncrypt_error logs correctly in last_install
Bug: 31603820
Change-Id: I8e0de845ce1707b6f8f5ae84564c5e93fd5f5ef5
(cherry picked from commit 0c68675f5ae80cd669e0bf014a69689b6fe08eee)
2016-09-29 11:27:46 -07:00
Tianjie Xu
b0d0ee3c7d Merge "Report uncrypt errors in details" am: af8b9363c6 am: 7582609d61
am: fc887a8fba

Change-Id: I5e83be10f4443c8b107821975b3506381fcbdf0c
2016-09-27 21:25:26 +00:00
Tianjie Xu
da44cf18f3 Report uncrypt errors in details
Add the error codes for uncrypt and report the failure details in
uncrypt_status.

Test: uncrypt_error logs correctly in last_install
Bug: 31603820
Change-Id: I8e0de845ce1707b6f8f5ae84564c5e93fd5f5ef5
2016-09-26 22:48:45 -07:00
Tao Bao
badaac45fe Duplicate the last_install content into last_log.
Currently we save the OTA metrics in last_install, which keeps the data
for the _last_ install only. This CL logs the same content into last_log
so that we keep the metrics for every install.

Bug: 31607469
Test: Apply an update (via OTA and sideload) and check last_log and last_install.

Change-Id: Id8f174d79534fddc9f06d72a4e69b2b1d8ab186c
(cherry picked from commit f4885adc18)
2016-09-26 14:56:25 -07:00
Tao Bao
f4885adc18 Duplicate the last_install content into last_log.
Currently we save the OTA metrics in last_install, which keeps the data
for the _last_ install only. This CL logs the same content into last_log
so that we keep the metrics for every install.

Bug: 31607469
Test: Apply an update (via OTA and sideload) and check last_log and last_install.

Change-Id: Id8f174d79534fddc9f06d72a4e69b2b1d8ab186c
2016-09-26 14:46:12 -07:00
Matthew Bouyack
c8db481780 Fail gracefully when we fail to fork the update binary
This change was original made in cw-f-dev but caused failures in
nyc-mr1-dev-plus-aosp due to lack of support for 'LOGE'

This version of the change uses the new 'LOG(ERROR)' style logging
instead.

See bug b/31395655
Test: attempt a memory intensive incremental OTA on a low-memory device

Change-Id: Ia87d989a66b0ce3f48e862abf9b9d6943f70e554
2016-09-21 10:06:31 -07:00
Matthew Bouyack
54881abb52 Revert "DO NOT MERGE Fail gracefully when we fail to fork the update binary am: de1b53d067"
This reverts commit 78563fdf78.

Change-Id: I1ea4956a9843130aa41f2f7bc011c72e64fd7b62
2016-09-20 22:57:19 +00:00
Matthew Bouyack
78563fdf78 DO NOT MERGE Fail gracefully when we fail to fork the update binary
am: de1b53d067

Change-Id: Ic7a42220ed7e842dad1d5d2aacdd12253bd5ad84
2016-09-20 21:24:51 +00:00
Matthew Bouyack
de1b53d067 DO NOT MERGE Fail gracefully when we fail to fork the update binary
See bug b/31395655

Change-Id: Ic5a046bc80ea88d7eb52755838bdbf4e1e47da50
2016-09-20 11:32:17 -07:00
Tianjie Xu
8dd5b2a2cc Merge "Check corruption when reading uncrypt_status file" am: 3cf815a6a9 am: 40bae5e1c6
am: 1d55666106

Change-Id: I2081d6803377a7bf26175a55b3b5defb7c9d09d1
2016-09-13 22:31:33 +00:00
Tianjie Xu
41a3fd4e20 Check corruption when reading uncrypt_status file
Bug: 31383361
Change-Id: I0de920916da213528d73b742e4823b4a98c63ea1
(cherry picked from commit 1c1864f321)
2016-09-13 14:04:55 -07:00
Tianjie Xu
1c1864f321 Check corruption when reading uncrypt_status file
Bug: 31383361
Change-Id: I0de920916da213528d73b742e4823b4a98c63ea1
2016-09-13 13:56:00 -07:00
Tianjie Xu
707583a4ab save uncrypt status to last_install am: e16e799dfd
am: 4769f209dc

Change-Id: Ic9056d4af518df3747743ec6b2886fa437029395
2016-09-13 01:50:40 +00:00
Tianjie Xu
e16e799dfd save uncrypt status to last_install
Save the uncrypt time cost to /cache/recovery/uncrypt_status. Recovery
reads the file and saves its contents to last_install.

Bug: 31383361
Test: Tested on angler and uncrypt_time reports correctly.

(cherry picked from commit fe16b5ccaf)

Change-Id: Id69681a35c7eb2f0eb21b48e3616dcda82ce41b8
2016-09-12 16:59:48 -07:00
Tianjie Xu
fe16b5ccaf save uncrypt status to last_install
Save the uncrypt time cost to /cache/recovery/uncrypt_status. Recovery
reads the file and saves its contents to last_install.

Bug: 31383361
Test: Tested on angler and uncrypt_time reports correctly.

Change-Id: I5cd3f7b6ca069d69086d09acfea8fc4f1215c833
Merged-In: I5cd3f7b6ca069d69086d09acfea8fc4f1215c833
2016-09-12 22:55:36 +00:00
Tianjie Xu
073451ae21 Fix a typo of variable name in install.cpp
Change-Id: I42057bc2fb5096ce009fe6e4b787bc9082cd572f
2016-09-01 22:00:17 +00:00
Tianjie Xu
c21edd4654 Switch recovery to libbase logging
Clean up the recovery image and switch to libbase logging.

Bug: 28191554
Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35
(cherry picked from commit 747781433f)
2016-09-01 14:32:55 -07:00
Tianjie Xu
7b0ad9c638 Switch recovery to libbase logging
Clean up the recovery image and switch to libbase logging.

Bug: 28191554
Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35
Merged-In: Icd999c3cc832f0639f204b5c36cea8afe303ad35
2016-09-01 18:33:25 +00:00
Chih-Hung Hsieh
a50d7faff0 Merge "Fix clang-tidy warnings in bootable/recovery." am: 89bf2bdc85 am: 9968866e86
am: d987fe1d57

Change-Id: Idd53009ad61bb4a0b573febdbedc5dc0eee8265f
2016-08-26 23:47:34 +00:00
Chih-Hung Hsieh
8b23811d2a Fix clang-tidy warnings in bootable/recovery.
* Use const reference type for read-only parameters.
Bug: 30407689
* Use faster overloaded string find function.
Bug: 30411878
* Add parentheses around macro parameters.
Bug: 28705665

Test: build with WITH_TIDY=1
Change-Id: I4e8e5748bfa4ae89871f1fb5fa4624d372530d75
2016-08-26 14:54:29 -07:00
Tao Bao
b3ddc0a4bf Merge "Free mmaped area if keys fail to load"
am: f599414aec

Change-Id: Id96153c211ca1fcc1cd78d6e662b0b48795c0d76
2016-08-18 06:14:46 +00:00
WiZarD
edafac6c7b Free mmaped area if keys fail to load
Keys for package verification is loaded after the update
package is mmaped into memory. This mmaped area needs
to be freed when exiting the function.

Another approach would be to mmap after loading the keys.

Change-Id: Ib77711a8acd5c363b5517da12dc311fb8f9f4605
Signed-off-by: WiZarD <WiZarD.Devel@gmail.com>
2016-08-18 05:20:40 +00:00
Alex Deymo
4e29ce0b88 Add inttypes.h for PRIu64.
This missing header is needed to use PRIu64 macros.

Bug: 27178350
TEST=`mma bootable/recovery` on the failing branch.

Change-Id: I165701e8019256426d3f6a4168db52c6a0197c4d
2016-08-12 21:20:45 +00:00
Alex Deymo
53c107f068 Add inttypes.h for PRIu64.
This missing header is needed to use PRIu64 macros.

Bug: 27178350
TEST=`mma bootable/recovery` on the failing branch.

Change-Id: I165701e8019256426d3f6a4168db52c6a0197c4d
2016-08-12 13:46:17 -07:00
Alex Deymo
9eaffca358 resolve merge conflicts of 66940b9 to nyc-mr1-dev-plus-aosp
Change-Id: Icd879395a88ff1de0fcf0c754c0633d8fb6cf208
2016-08-12 11:21:43 -07:00
Alex Deymo
4344d636d4 Call update_engine_sideload from recovery.
This patch enables sideloading an OTA on A/B devices while running from
recovery. Recovery accepts the same OTA package format as recent
versions of GMS, which consists of .zip file with the payload in it.

Bug: 27178350
TEST=`adb sideload` successfully a full OTA (*)
TEST=Failed to take several invalid payloads (wrong product,
fingerprint, update type, serial, etc).

<small>(*) with no postinstall script.</small>

Change-Id: I951869340100feb5a37e41fac0ee59c10095659e
2016-08-11 18:55:11 -07:00
Yabin Cui
bf049bffe2 resolve merge conflicts of ed4c49c to nyc-mr1-dev-plus-aosp
Change-Id: I8788cc80473dc77bfa0cd2682f3acb6e17ac36df
2016-06-21 11:09:38 -07:00
Yabin Cui
6faf0265c9 Verify wipe package when wiping A/B device in recovery.
To increase the security of wiping A/B devices, let uncrypt write
wipe package in misc partition. Then recovery verifies the wipe
package before wiping the device.

Bug: 29159185

Change-Id: I186691bab1928d3dc036bc5542abd64a81bc2168
2016-06-20 18:18:02 -07:00
Elliott Hughes
274d17dc0f resolve merge conflicts of 179c0d8 to stage-aosp-master
Change-Id: Iba5aec266444cabf83f600f2bdb45a3c027e5995
2016-06-15 15:22:17 -07:00
Elliott Hughes
63a319201f Remove obsolete MTD support.
Bug: http://b/29250988
Change-Id: Ia97ba9082a165c37f74d6e1c3f71a367adc59945
2016-06-10 13:45:35 -07:00
Tianjie Xu
9d2657fbb7 Log source/target build version to last_install
am: b0ddae55e5

Change-Id: Ifd9e006588de8bea233a4e90a5c80ed6b894054a
2016-06-10 17:21:40 +00:00
Tianjie Xu
b0ddae55e5 Log source/target build version to last_install
Parse the build.version.incremental from the metadata of the update
package; and log it to last_install.
Example:
In metadata we read:
post-build-incremental=2951741
pre-build-incremental=2943039

In last install we log:
source_build: 2943039
target_build: 2951741

Bug: 28658632
Change-Id: I0a9cc2d01644846e18bda31f4193ff40e8924486
2016-06-09 17:29:04 -07:00
Tianjie Xu
64f46fb16c resolve merge conflicts of 7ce287d to nyc-dev-plus-aosp
Change-Id: I2194d1170281f58eb508f2ef63b39c8729125f76
2016-06-03 15:44:52 -07:00
Tianjie Xu
7ce287d432 Call ioctl before each write on retry
If the update is a retry, ioctl(BLKDISCARD) the destination blocks before
writing to these blocks.

Bug: 28990135
Change-Id: I1e703808e68ebb1292cd66afd76be8fd6946ee59
2016-06-03 12:12:50 -07:00
Tianjie Xu
84478e8823 resolve merge conflicts of 50f6417 to nyc-dev-plus-aosp
Change-Id: I42c127f7946e678acf6596f6352f090abc0ca019
2016-05-23 12:24:28 -07:00
Tianjie Xu
162558382b Allow recovery to return error codes
Write error code, cause code, and retry count into last_install. So we
can have more information about the reason of a failed OTA.

Example of new last_install:
@/cache/recovery/block.map     package name
0                              install result
retry: 1                       retry count (new)
error: 30                      error code (new)
cause: 12                      error cause (new)

Details in:
go/android-ota-errorcode

Bug: 28471955
Change-Id: I00e7153c821e7355c1be81a86c7f228108f3dc37
2016-05-20 13:56:53 -07:00
Tianjie Xu
142b864ba1 Add time and I/O info to last_install
am: dd874b1c87

* commit 'dd874b1c87eb04f28db0db2629df0adde568a74c':
  Add time and I/O info to last_install

Change-Id: I02aa858d5ce488d3acbf5400811e2565cf7d9c75
2016-05-18 18:44:31 +00:00
Tianjie Xu
dd874b1c87 Add time and I/O info to last_install
One example of last_install is:

/sideload/package.zip
1
time_total: 101
bytes_written_system: 14574000
bytes_stashed_system: 100
bytes_written_vendor: 5107400
bytes_stashed_vendor: 0

Bug: 28658632
Change-Id: I4bf79ea71a609068d38fbce6b41bcb892524aa7a
2016-05-16 14:54:37 -07:00
Elliott Hughes
6e08bff22b resolve merge conflicts of 8febafa to nyc-dev-plus-aosp
Change-Id: I423937b4b20a2079714aa38ab7f8b199782df689
2016-04-14 09:39:47 -07:00
Elliott Hughes
8febafa67e Use BoringSSL instead of mincrypt to speed up package verification.
This changes the verification code in bootable/recovery to use
BoringSSL instead of mincrypt.

Cherry-pick of 452df6d99c, with
merge conflict resolution, extra logging in verifier.cpp, and
an increase in the hash chunk size from 4KiB to 1MiB.

Bug: http://b/28135231
Change-Id: I1ed7efd52223dd6f6a4629cad187cbc383d5aa84
2016-04-13 16:39:56 -07:00
Mattias Nissler
452df6d99c Convert recovery to use BoringSSL instead of mincrypt.
This changes the verification code in bootable/recovery to use
BoringSSL instead of mincrypt.

Change-Id: I37b37d84b22e81c32ac180cd1240c02150ddf3a7
2016-04-06 15:54:17 +02:00
Tianjie Xu
fa12b9737d Reboot and retry on I/O errors
When I/O error happens, reboot and retry installation two times
before we abort this OTA update.

Bug: 25633753
Change-Id: Iba6d4203a343a725aa625a41d237606980d62f69
(cherry picked from commit 3c62b67faf)
2016-03-10 11:50:28 -08:00
Tianjie Xu
3c62b67faf Reboot and retry on I/O errors
When I/O error happens, reboot and retry installation two times
before we abort this OTA update.

Bug: 25633753
Change-Id: Iba6d4203a343a725aa625a41d237606980d62f69
2016-03-02 17:31:05 -08:00
Yabin Cui
4425c1d960 Fix some memory leaks.
Bug: 26906328
Change-Id: Iebaf03db0cb3054f91715f8c849be6087d01b27b
2016-02-10 15:32:19 -08:00
Tao Bao
71e3e09ec2 recovery: Refactor verifier and verifier_test.
Move to using std::vector and std::unique_ptr to manage key
certificates to stop memory leaks.

Bug: 26908001
Change-Id: Ia5f799bc8dcc036a0ffae5eaa8d9f6e09abd031c
2016-02-02 21:51:32 -08:00
Tao Bao
b6918c7c43 Log update outputs in order
Although stdout and stderr are both redirected to log file with no
buffering, we are seeing some outputs are mixed in random order.
This is because ui_print commands from the updater are passed to the
recovery binary via a pipe, which may interleave with other outputs
that go to stderr directly.

In recovery, adding ui::PrintOnScreenOnly() function to handle
ui_print command, which skips printing to stdout. Meanwhile, updater
prints the contents to stderr in addition to piping them to recovery.

Change-Id: Idda93ea940d2e23a0276bb8ead4aa70a3cb97700
2015-06-02 22:15:40 -07:00
Tao Bao
b07e1f3a3a Update the comments for package installer commands
These commands are for the communication between the installer and the
update binary (edify interpreter). Update the comments in sync with the
codes.

Change-Id: I7390f022b1447049a974b0b45697ef1d2e71d4e0
2015-04-10 16:18:32 -07:00
Tao Bao
682c34bbc3 Rotate logs only when there are actual operations
Currently it rotates the log files every time it boots into the recovery
mode. We lose useful logs after ten times. This CL changes the rotation
condition so that it will rotate only if it performs some actual
operations that modify the flash (installs, wipes, sideloads and etc).

Bug: 19695622
Change-Id: Ie708ad955ef31aa500b6590c65faa72391705940
2015-04-07 22:02:27 -07:00
Tao Bao
145d861460 Factor out option variables from int to bool types
Change-Id: Ia897aa43e44d115bde6de91789b35723826ace22
2015-03-25 15:56:15 -07:00
Elliott Hughes
26dbad2b98 Add missing includes.
Change-Id: I0737456e0221ebe9cc854d65c95a7d37d0869d56
2015-01-28 12:09:05 -08:00