Commit graph

79 commits

Author SHA1 Message Date
Tao Bao
3da880156b Replace _exit(-1) with _exit(EXIT_FAILURE).
-1 is not a valid exit status.

Also replace a few exit(1) with exit(EXIT_FAILURE).

Test: mmma bootable/recovery
Change-Id: I4596c8328b770bf95acccc06a4401bd5cabd4bfd
2017-02-03 14:11:11 -08:00
Tianjie Xu
ab1abae59c Avoid to call UI functions in child process
ui_print uses a mutex to protect the critical section. And a forked
child process may intialize the mutex inappropriatly, which leads to a
hanging child process. So we shall avoid to call the UI functions in
child process.

Bug: 34769056
Test: fake ota on fugu failed as expected due to updater format mismatch.
Change-Id: I81bc942a796878fac19cf712512092c2b0d807c9
2017-02-03 20:35:40 +00:00
Tao Bao
f013642477 Print with newline for ui_print.
Currently the ui_print command between the recovery and updater doesn't
append newline. Updater has to send an extra "ui_print" command without
any argument to get the line break. This looks unnecessary. And not all
the callers (including the ones in bootable/recovery) are following this
protocol when sending the ui_print command.

This CL simplifies the protocol to always print with a newline for
ui_print command. When updating from an old recovery with the new
updater, all the ui_print'd strings would appear in one line as a side
effect. But a) it would only affect the text-mode UI, which won't be
shown to users; b) log files won't be affected.

Bug: 32305035
Test: Apply an update with the new updater on top of an old and new
      recovery image respectively.
Change-Id: I305a0ffc6f180daf60919cf99d24d1495d68749b
2017-01-21 20:43:45 -08:00
Tao Bao
efc35594dd recovery: Move property_get() to android::base::GetProperty().
Test: Apply two A/B incremental OTAs with the new recovery image. The
      one with incorrect pre-build should be blocked, while the other
      works fine.

Change-Id: I94d97eb8798599da1630f66343fb603e87464187
2017-01-13 12:08:34 -08:00
Tao Bao
20c581e35d recovery: Clean up try_update_binary() in install.cpp.
Move functions over to android::base versions.
- strtok(3) => android::base::Split()
- strtol(3) => android::base::ParseInt()
- strtof(3) => android::base::ParseDouble()

Test: Build recovery image and apply a package that calls ui_print /
      progress / set_progress commands.
Change-Id: I953b4985e0bd9e277362ae53e233d755cf27d80c
2017-01-06 09:25:32 -08:00
Tao Bao
c0336399ae Remove the obsolete comments for firmware update.
The corresponding code was removed in commit
e08991e02a in 2010 (Froyo).

Test: N/A
Change-Id: I2b296e1b07d54232bade79fda7501387d65a4c37
2016-12-13 22:36:02 -08:00
Tao Bao
cb3cbaffac Merge "Revert "Revert "Some cleanups to recovery."""
am: a7a8262944

Change-Id: Iab6de4788c4dbecd33d076144f8324fde53b4024
2016-11-04 16:08:26 +00:00
Tao Bao
ac9d94d19c Revert "Revert "Some cleanups to recovery.""
This reverts commit 8584fcf677.

This CL re-lands commit c0319b60f5.
The "stage" and "reason" variables are now declared as global by
dropping the static qualifier, because they may be used by vendor
recovery libraries.

Test: lunch aosp_angler-userdebug; mmma bootable/recovery
Test: lunch aosp_dragon-userdebug; mmma bootable/recovery

Change-Id: I252c346f450079478cff22bbff01590b8ab2e2b3
2016-11-03 11:57:46 -07:00
Dan Albert
0c571e5923 Merge "Revert "Some cleanups to recovery.""
am: 9514eb1934

Change-Id: Id96135ffde5adaebd45811b9c3d319a99fe28ecd
2016-10-27 04:53:48 +00:00
Dan Albert
8584fcf677 Revert "Some cleanups to recovery."
This reverts commit c0319b60f5.

Reason for revert: Broke builds.

Change-Id: I82aa880b83de5ae6c36fd7567cb001920559a972
2016-10-27 03:08:08 +00:00
Tao Bao
00f893fe23 Merge "Some cleanups to recovery."
am: 46fb0a6a6f

Change-Id: Ic247a408b1bd3e2eab1db34eb4b14423d9fd16d6
2016-10-26 23:32:30 +00:00
Tao Bao
c0319b60f5 Some cleanups to recovery.
- Remove the duplicate gCurrentUI variable in recovery.cpp;
- Refactor the load/save of locale functions;
- Clean up ui_print() to get rid of 256-byte buffer limit;
- Declare ui in common.h;
- Move the typedef of Volume into roots.h.

Test: Build and boot into recovery image.

Change-Id: Ia28c116858ca754133127a5ff9c722af67ad55b7
2016-10-26 14:36:42 -07:00
Yabin Cui
fd99a318fe 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.

Based on the original cherrypick, this CL also has additional changes to
address the LOG statements and libziparchive changes.

Bug: 29159185
Test: Build and boot into recovery.

Change-Id: I186691bab1928d3dc036bc5542abd64a81bc2168
(cherry picked from commit 6faf0265c9)
2016-10-19 11:19:15 -07:00
Tianjie Xu
8176cf232e resolve merge conflicts of 6fba98c to stage-aosp-master
Change-Id: I2fa8b85109309ec88c1f8d8def593aa65ab885d7
2016-10-18 21:31:04 +00:00
Tianjie Xu
8cf5c8f60f Replace minzip with libziparchive
Clean up the duplicated codes that handle the zip files in
bootable/recovery; and rename the library of the remaining
utility functions to libotautil.

Test: Update package installed successfully on angler.
Bug: 19472796

Change-Id: Iea8962fcf3004473cb0322b6bb3a9ea3ca7f679e
2016-10-17 17:41:51 -07:00
Tao Bao
ee9b95544a Fix the prefix matching for uncrypt status.
Also change its logging statement from PLOG to LOG, since
android::base::StartsWith() doesn't set errno.

Test: Build and reboot into recovery image. Check last_log.

Change-Id: I55ac7eec24228db76a13580958b4a4330b06cf57
2016-10-13 16:07:15 -07:00
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