Commit graph

94 commits

Author SHA1 Message Date
Tao Bao
43bd2c8414 Merge "verify_file: Add constness to a few addresses."
am: 5b2bf90e13

Change-Id: I6e04bf2bc3dc8c978edafafcbb41401189865233
2017-03-21 19:09:37 +00:00
Tao Bao
76fdb2419b verify_file: Add constness to a few addresses.
We should not touch any data while verifying packages (or parsing the
in-memory ASN.1 structures).

Test: mmma bootable/recovery
Test: recovery_component_test passes.
Test: recovery_unit_test passes.
Change-Id: Ie990662c6451ec066a1807b3081c9296afbdb0bf
2017-03-20 22:13:56 -07:00
Tao Bao
553c7bd307 resolve merge conflicts of 90d3f20c to stage-aosp-master
Test: I solemnly swear I tested this conflict resolution.
Change-Id: I9c1806eceb56712c4b3d1c67d54f4b21bd3fe50a
2017-03-18 07:33:26 -07:00
Tao Bao
5e535014dd Drop the dependency on 'ui' in verify_file().
verify_file() has a dependency on the global variable of 'ui' for
posting the verification progress, which requires the users of
libverifier to provide a UI instance.

This CL adds an optional argument to verify_file() so that it can
post the progress through the provided callback function. As a result,
we can drop the MockUI class in verifier_test.cpp.

Test: recovery_component_test passes.
Test: verify_file() posts progress update when installing an OTA.
Change-Id: I8b87d0f0d99777ea755d33d6dbbe2b6d44243bf1
2017-03-17 14:07:12 -07:00
Tao Bao
b8af1beed0 Merge "Replace _exit(-1) with _exit(EXIT_FAILURE)." am: 95bcbfdd4e
am: 80176c68b2

Change-Id: I6338fc4f929b0887563a0194719c887131538fec
2017-02-03 23:48:27 +00:00
Tianjie Xu
15ab95bb63 Merge "Avoid to call UI functions in child process" am: 0f275ae56e
am: 5fa2e576f9

Change-Id: I83d52f51ab6c788cc67a75ca6f7a46cd2f8289cd
2017-02-03 22:14:20 +00:00
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
14be4eb8ce Merge "Print with newline for ui_print." am: 90deaf9ab7
am: 1313a9636d

Change-Id: I1cc5523b0ae213f5091caa6793c549e08dc148dc
2017-01-24 05:00:27 +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
81bffbda89 Merge "recovery: Move property_get() to android::base::GetProperty()." am: ebb4e96a71
am: 421d92707d

Change-Id: I4f87ad321fba45f98f7adfd12937bf484025873e
2017-01-14 15:43:10 +00: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
af53db6ba0 Merge "recovery: Clean up try_update_binary() in install.cpp." am: 095675a3eb
am: 1bbd9c68af

Change-Id: Ia502cd3e40fb02ed01e3e91fd0892f952083b1fa
2017-01-06 19:17:37 +00: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
1871a2feeb Merge "Remove the obsolete comments for firmware update." am: 833ecb03f2
am: 527f08ed0b

Change-Id: I93716c3c455f118b0bac88d18c7c0e157031834b
2016-12-14 18:48:07 +00: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
b9c3411de7 Merge "Revert "Revert "Some cleanups to recovery.""" am: a7a8262944
am: cb3cbaffac

Change-Id: I2536156317b0bcb4a272ce13db251af791bd67be
2016-11-04 16:11:56 +00: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
3456ee19f9 Merge "Revert "Some cleanups to recovery."" am: 9514eb1934
am: 0c571e5923

Change-Id: I1a5b89905f24c2f20250a288345b6dbdea486cc1
2016-10-27 04:58:20 +00: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
05c68a8775 Merge "Some cleanups to recovery." am: 46fb0a6a6f
am: 00f893fe23

Change-Id: Iea4884c8ea12f8edfdd7e39e8ec6e4cfff26f3a5
2016-10-26 23:37:01 +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
434697f06b resolve merge conflicts of 6fba98c to stage-aosp-master
am: 8176cf232e

Change-Id: I01b34cb31604ea5caffe96ad69ab4d4d21bfe28e
2016-10-18 22:05:21 +00: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
1709d22b4e 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
(cherry picked from commit ee9b95544a)
(cherry picked from commit e30a5b3a44)
2016-10-14 18:07:47 +00: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