Commit Graph

280 Commits

Author SHA1 Message Date
Tao Bao aaeafe73e9 Merge "Remove ota_close(int) and ota_fclose(FILE*)." am: 7b59b45b08 am: 1f934beedd am: 8762a560fc
am: 6478f3804d

Change-Id: I655dafe50fcb19f60270c37206409ca52655499a
2016-11-29 18:14:13 +00:00
Tao Bao 358c2ec1dc Remove ota_close(int) and ota_fclose(FILE*).
We should always use unique_fd or unique_file to hold the FD or FILE*
pointer when opening via ota_(f)open functions.

This CL avoids accidentally closing raw FDs or FILE* pointers that are
managed by unique_fd/unique_file.

Test: recovery_component_test passes.
Change-Id: If58eb8b5c5da507563f85efd5d56276472a1c957
2016-11-28 12:09:39 -08:00
Tao Bao 509269924c Merge "updater: Refactor set_stage() and get_stage() functions." am: c627cd6486 am: 146f92ab3e am: 062a2cffb3
am: 953851cb97

Change-Id: Id7348d0011cd4f9112948a421c8d62843e436433
2016-11-20 05:22:49 +00:00
Tao Bao bedf5fc11c updater: Refactor set_stage() and get_stage() functions.
Add read_bootloader_message_from() and write_bootloader_message_to() to
allow specifying the BCB device (/misc).

Also add testcases for set_stage() and get_stage().

Test: recovery_component_test passes.
Test: Build a recovery image and apply a two-step OTA package.
Change-Id: If5ab06a1aaaea168d2a9e5dd63c07c0a3190e4ae
2016-11-18 12:04:48 -08:00
Tao Bao 9a7618e1d1 Merge "updater: Add testcase for package_extract_dir()." am: 23e785935e am: d109c788ad am: 9b1a791e3c
am: 1ae9f22d6e

Change-Id: Icbc8520976841c1fcfcebd20fb05e2031370983c
2016-11-18 17:55:30 +00:00
Tao Bao 1036d36542 updater: Add testcase for package_extract_dir().
Test: recovery_component_test passes.
Change-Id: I3af4707bc42c7331ca961be8b967a53de82ea25b
2016-11-17 23:02:13 -08:00
Tao Bao 4f0685b93c Merge "updater: Add "write_value()" function." am: d00046b691 am: 100dba35f9 am: 29dc892c07
am: 1906efab60

Change-Id: I4773541c2ba82ce2080ead5bca1e8d88057bc60d
2016-11-18 01:18:19 +00:00
Tao Bao d0f3088aa9 updater: Add "write_value()" function.
write_value(value, filename) writes 'value' to 'filename'. It can be
used to tune device settings when applying an OTA package. For example,
write_value("960000", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq").

Bug: 32463933
Test: recovery_component_test passes.
Test: Apply an OTA package that contains a call to write_value(), and
      check the result.

Change-Id: Ib009ecb8a45a94353f10c59e2383fe1f49796e35
2016-11-16 15:51:53 -08:00
Tao Bao 9abee8d22d updater: Fix the wrong return value for package_extract_file(). am: 2274e57f67
am: 7e3d156b86

Change-Id: Id550cd00fd2fa60f8882c45d0e830f514718c71f
2016-11-16 05:34:57 +00:00
Tao Bao 2274e57f67 updater: Fix the wrong return value for package_extract_file().
'bool success = ExtractEntryToFile()' gives opposite result. Fix the
issue and add testcases.

Change the one-argument version of package_extract_file() to explicitly
abort for non-existent zip entry. Note that this is NOT changing the
behavior. Prior to this CL, it aborts from Evaluate() function, by
giving a general cause code. Now it returns kPackageExtractFileFailure.

BUg: 32903624
Test: recovery_component_test works.

Change-Id: I7a273e9c0d9aaaf8c472b2c778f7b8d90362c24f
(cherry picked from commit ef0eb3b01b)
2016-11-15 16:55:37 -08:00
Tao Bao ef0eb3b01b updater: Fix the wrong return value for package_extract_file().
'bool success = ExtractEntryToFile()' gives opposite result. Fix the
issue and add testcases.

Change the one-argument version of package_extract_file() to explicitly
abort for non-existent zip entry. Note that this is NOT changing the
behavior. Prior to this CL, it aborts from Evaluate() function, by
giving a general cause code. Now it returns kPackageExtractFileFailure.

BUg: 32903624
Test: recovery_component_test works.

Change-Id: I7a273e9c0d9aaaf8c472b2c778f7b8d90362c24f
2016-11-15 13:17:52 -08:00
Tao Bao 7fbc9d39f3 Merge "updater: Add more testcase for symlink()." am: 1b74e8cea8 am: 2c175c302c am: 7da0c7e439
am: 7e62f22d78

Change-Id: Ic5668c046cc51f0a16e98cdb12f3e264d9d8bc39
2016-11-09 19:31:18 +00:00
Tao Bao 8992902aab updater: Add more testcase for symlink().
Clean up SymlinkFn() a bit. Also clean up the temp files created when
running the tests; otherwise non-empty TemporaryDir won't be removed.

Test: recovery_component_test passes.
Change-Id: Id3844abebd168c40125c4dcec54e6ef680a83c3a
2016-11-08 21:29:16 -08:00
Tianjie Xu b66b94c56c Merge "Make make_parent() to take const argument" am: 52e2a97aa7 am: 1fd9f0aff7 am: 260573b3c2
am: cd3513c8dd

Change-Id: I3244b7ff4f67a04b34c3531caae49bb50dc4917f
2016-11-08 21:13:54 +00:00
Tianjie Xu d75003d24c Make make_parent() to take const argument
Switch to use const std::string; and add corresponding tests.

Bug: 32649858
Test: Component tests pass
Change-Id: I640f3ec81f1481fa91aa310f8d4d96dac9649cb9
2016-11-08 10:11:03 -08:00
Tao Bao 88ee9f61bf Merge "updater: Add a testcase for RenameFn()." am: d0daf7f7df am: 05a801ca8e am: 8269eb0d1f
am: 63ae92ded4

Change-Id: Ia4558618507770ff9324883c917b8cc8d09792dd
2016-11-04 21:15:12 +00:00
Tao Bao af03617d81 Merge "updater: Fix a bug in DeleteFn()." am: 529032f4a0 am: 4f91ca78b9 am: 786b083b8e
am: afd1d3af5a

Change-Id: I91d664cdbe14b4b7d70090ba5aebab5a46b57c1c
2016-11-04 16:19:24 +00:00
Tao Bao a659d79b92 updater: Add a testcase for RenameFn().
Test: recovery_component_test passes.

Change-Id: Iba5a0fdf6c79e2bed6b30b8fc19a306c1ab29d8a
2016-11-03 23:35:42 -07:00
Tao Bao 0831d0b592 updater: Fix a bug in DeleteFn().
Also add a testcase for delete() function.

Test: recovery_component_test passes.
Change-Id: I064d1ad4693c3ed339d0a69eabadd08a61a2ea86
2016-11-03 23:28:36 -07:00
Tao Bao 3e8666172b Merge "updater: Fix an off-by-1 bug in file_getprop()." am: da2b34b5d0 am: 917be35f0f am: 4098285e8c
am: 00c7b6112a

Change-Id: Id05ce102be21b9a045a3dac5fa9967914a7e6377
2016-11-04 04:47:15 +00:00
Tao Bao 51d516e913 updater: Fix an off-by-1 bug in file_getprop().
Also add a testcase for file_getprop().

Test: recovery_component_test passes.

Change-Id: I8eb2f9a5702b43997ac9f4b29665eea087b1c146
2016-11-03 14:58:54 -07:00
Tianjie Xu b059c4b554 Merge "Cleanup ReadArgs & ReadValueArgs usage" am: a9b252887c am: 88fc75ee54 am: 0b6085a341
am: c81ef65828

Change-Id: I245bea4f9fd484e7e22422835139b040efa33519
2016-11-02 00:09:35 +00:00
Tianjie Xu 5fe280ac96 Cleanup ReadArgs & ReadValueArgs usage
ReadArgs will switch to using std::string and std::unique_ptr. Also
cleanup the callers.

Test: mma & component test passed.
Change-Id: I4724406ae6c0c134a27bbd1cdd24ad5d343b2a3b
2016-11-01 15:03:06 -07:00
Tao Bao 2f9b98c99f Merge "applypatch: Switch the parameter of Value** to std::vector." am: 3f4030e0ef am: bc48de6bf0 am: edf2928edf
am: 492bd8ca71

Change-Id: Icc5e01085004386771175bda66a9eba9ed76d703
2016-11-01 21:37:21 +00:00
Tao Bao fada91ccf2 applypatch: Switch the parameter of Value** to std::vector.
Test: Unit tests and install-recovery.sh pass on angler and dragon.

Change-Id: I328e6554edca667cf850f5584ebf1ac211e3d4d1
2016-10-28 16:46:12 -07:00
Tianjie Xu 81e54eddd4 resolve merge conflicts of 434697f to master
Change-Id: I0fea3d33b97065a3bf50f8e3669c2b50166a14ed
2016-10-18 15:33:23 -07: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
Tianjie Xu c012c3ce01 Merge "Change StringValue to use std::string" am: 2b17b24ae5 am: 430b7ae469
am: 13d8ee8c72

Change-Id: Ib8730f1656dfea01cb8dcb5a3ee50a40d13179ac
2016-10-18 00:28:30 +00:00
Tianjie Xu aced5d9e4e Change StringValue to use std::string
Changing the field of 'Value' in edify to std::string from char*.
Meanwhile cleaning up the users of 'Value' and switching them to
cpp style.

Test: compontent tests passed.
Bug: 31713288

Change-Id: Iec5a7d601b1e4ca40935bf1c70d325dafecec235
2016-10-15 01:18:23 +00:00
Tao Bao 5f3982056d Merge "edify: Some clean-ups to libedify." am: c5b4b71913 am: 039e9dc5ca am: bd16939bbf
am: 1b1a4edb4b

Change-Id: Idc74e9e549fe61c8b3bb566579821660ecf459c4
2016-10-13 18:02:46 +00:00
Tao Bao 39119ad8ec edify: Some clean-ups to libedify.
- Remove dead declarations in expr.h: SetError(), GetError(),
  ClearError().
- Remove the declaration of Build() out of expr.h.
- Use std::unordered_map to implement RegisterFunction() and
  FindFunction(); kill FinishRegistration().
- Add a testcase for calling unknown functions.

Test: mmma bootable/recovery; recovery_component_test passes.
Change-Id: I9af6825ae677f92b22d716a4a5682f58522af03b
2016-10-12 23:29:59 -07:00
Tao Bao f3d3dca01d Merge "updater: Kill the duplicate PrintSha1() in install.cpp." am: 19bb05dfc7 am: 3ac1995cfd am: aa9f017ceb
am: 998c6debca

Change-Id: Ifb2e1a950c685816a70e4edfb2514319a4b03cc1
2016-10-12 19:48:56 +00:00
Tao Bao df6da4adad Refactor libupdater into a seperate module. am: 0c7839ac14 am: cf1dbfa854 am: 8ff7cd20ba
am: 3a01338332

Change-Id: I1d03d8107d354122edbb88a817b76c490e35210c
2016-10-11 04:00:31 +00:00
Tao Bao 361342cbd2 updater: Kill the duplicate PrintSha1() in install.cpp.
Also add a testcase for sha1_check().

Test: mmma bootable/recovery; recovery_component_test passes.

Change-Id: I4d06d551a771aec84e460148544f68b247a7e721
2016-10-10 20:36:17 -07:00
Tao Bao 0c7839ac14 Refactor libupdater into a seperate module.
So that we can write native tests for updater functions. This CL adds a
testcase for getprop() function.

Test: mmma bootable/recovery; Run recovery_component_test on device.

Change-Id: Iff4c1ff63c5c71aded2f9686fed6b71cc298c228
2016-10-10 16:49:50 -07:00
Tao Bao de40ba59c8 Update the header path for ext4_utils.
Test: `mmma bootable/recovery`
Change-Id: I70ccddb3ddf46bb012fdc5f632afc46ebdd5473e
2016-10-09 14:02:10 -07:00
Tao Bao df0d2a2ae0 Update the header path for ext4_utils.
Test: `mmma bootable/recovery`
Change-Id: I70ccddb3ddf46bb012fdc5f632afc46ebdd5473e
(cherry picked from commit 3cbe1d20978dc488272e2b1ba10890a006fdfab9)
2016-10-07 14:33:34 -07:00
Tao Bao 876b9391c0 edify: Move State.script and State.errmsg to std::string.
This way we kill a few strdup() and free() calls.

Test: 1. recovery_component_test still passes;
2. Applying an update with the new updater works;
3. The error code in a script with abort("E310: xyz") is recorded into
last_install correctly.

Change-Id: Ibda4da5937346e058a0d7cc81764d6f02920010a
(cherry picked from commit 59dcb9cbea)
2016-10-04 15:33:22 -07:00
Tao Bao 59dcb9cbea edify: Move State.script and State.errmsg to std::string.
This way we kill a few strdup() and free() calls.

Test: 1. recovery_component_test still passes;
2. Applying an update with the new updater works;
3. The error code in a script with abort("E310: xyz") is recorded into
last_install correctly.

Change-Id: Ibda4da5937346e058a0d7cc81764d6f02920010a
2016-10-04 14:24:32 -07:00
Tianjie Xu 10e223c181 Turn on -Werror for recovery
am: 17e316cce0

Change-Id: Ia0e1948491edf7cca8b64d7e7f0cac91314c2025
2016-09-30 20:34:23 +00:00
Tianjie Xu 17e316cce0 Turn on -Werror for recovery
Also remove the 0xff comparison when validating the bootloader
message fields. As the fields won't be erased to 0xff after we
remove the MTD support.

Bug: 28202046
Test: The recovery folder compiles for aosp_x86-eng
Change-Id: Ibb30ea1b2b28676fb08c7e92a1e5f7b6ef3247ab
(cherry picked from commit 7aa88748f6)
2016-09-30 11:18:01 -07:00
Tianjie Xu 7aa88748f6 Turn on -Werror for recovery
Also remove the 0xff comparison when validating the bootloader
message fields. As the fields won't be erased to 0xff after we
remove the MTD support.

Bug: 28202046
Test: The recovery folder compiles for aosp_x86-eng
Change-Id: Ibb30ea1b2b28676fb08c7e92a1e5f7b6ef3247ab
2016-09-29 19:21:24 -07:00
Elliott Hughes cb22040c63 Switch to <android-base/properties.h>.
Bug: http://b/23102347
Test: boot into recovery.
Change-Id: Ib2ca560f1312961c21fbaa294bb068de19cb883e
Merged-In: Ib2ca560f1312961c21fbaa294bb068de19cb883e
2016-09-26 09:51:37 -07:00
Elliott Hughes 91e3aee9bd Switch to <android-base/properties.h>.
Bug: http://b/23102347
Test: boot into recovery.
Change-Id: Ib2ca560f1312961c21fbaa294bb068de19cb883e
2016-09-23 18:16:35 -07:00
Tianjie Xu 61590bbf0d Merge "Switch recovery to libbase logging" 2016-09-01 23:04:37 +00: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
Tianjie Xu e22805ef11 Merge "Check an edge case when read(2) returns 0" am: 3202b8faf4 am: 852ae8d0fb am: 0ae9d80082
am: 28f6c43db5

Change-Id: I8fb1470e0f7e675c205bffe95c4fb9d0f202e4ed
2016-09-01 18:07:40 +00:00
Tianjie Xu 747781433f Switch recovery to libbase logging
Clean up the recovery image and switch to libbase logging.

Bug: 28191554
Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35
2016-09-01 17:43:14 +00:00
Tianjie Xu 71e182bc38 Check an edge case when read(2) returns 0
We might end up in an infinite loop if read(2) reached EOF unexpectedly.
The problematic code in uncrypt mentioned in the bug has been fixed
by switching to libbase ReadFully(). So I grepped through the recovery
code and fixed some other occurences of the issue.

Bug: 31073201
Change-Id: Ib867029158ba23363b8f85d61c25058a635c5a6b
2016-08-31 19:11:41 -07:00
Josh Gao 2d7ff437ae Merge "Fix references to libcrypto_utils_static." am: b97da5e0f0 am: dc97404346 am: e6a4195bf7
am: 66571856a1

Change-Id: Ibae209f6fba7adb549cdf2fd9e0323c42240df19
2016-08-08 18:41:47 +00:00