summaryrefslogtreecommitdiffstats
path: root/updater/install.cpp (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Add add_slot_suffix function.Yifan Hong2020-05-081-0/+16
| | | | | | | | | This function appends androidboot.slot_suffix to the value of the argument. Test: apply update Bug: 153581609 Change-Id: I28a4047b5f2051acc039084f65a71deb492d9dcb
* Consolidate the wait in recovery's rebootTianjie Xu2020-03-181-1/+0
| | | | | | | | | | After a reboot function call, we should always wait for it to finish without executing other instructions. Bug: 151110322 Test: build Change-Id: I1dda291a0835ff96df7eaf42eba1a38267a3beeb (cherry picked from commit 00c4aba9bf428717fc00e26a03e97401eca76ee8)
* Move mounts.cpp from libotautil into libupdater.Tao Bao2019-10-011-1/+0
| | | | | | | | | All the active users of mounts.h now live in updater/. Test: mmma bootable/recovery Test: Run recovery_unit_test on taimen. Test: Code search shows no reference to otautil/mounts.h in device dirs. Change-Id: I6c35d2e403e92a0111102d00aa4773f4f524650e
* applypatch: Add backup_source parameter to PatchPartition.Tao Bao2019-09-231-1/+1
| | | | | | | | | | | | | | | | | | | And set it to false when installing recovery image via applypatch. We only need to back up the source partition when doing in-place update (e.g. when updating a given partition under recovery). When installing recovery image via applypatch, we won't touch the source partition (i.e. /boot). Removing the backup step also allows dropping the dac_override_allowed permission. Previously it was needed due to the access to /cache. Because applypatch runs as root:root, while /cache is owned by system:cache with 0770. Bug: 68319577 Test: Invoke the code that installs recovery image; check that recovery is installed successfully without denials. Test: recovery_unit_test passes on taimen. Change-Id: I549a770b511762189d6672a2835b6e403d695919
* Simulator: add the argument to keep the updated imagesTianjie Xu2019-07-311-1/+8
| | | | | | | | | | | | | | Add the command line option to select the work directory and save the updated image files. Because some people might have interested in getting updated images from an ota file. Also, fix a minor issue that the destination of package_extract_file needs to be updated if it's a block device. Otherwise, an unintended file may be extracted in the callers' directory. Test: run simulation, run unit tests Change-Id: Ic6a7db0580bc1748d6e080102e4654da4e41fd8c
* Some clean ups to the updaterTianjie Xu2019-05-221-1/+4
| | | | | | | | | Remove some unnecessary includes or forward declarations. And include the correct headers to build host executables. Bug: 131911365 Test: unit tests pass Change-Id: I62e75f60678159fe24619a4bd386b1416f1a5b5d
* Add UpdaterRuntime classTianjie Xu2019-05-211-102/+65
| | | | | | | | | | | This class adds a wrapper to the runtime dependent functions. Therefore, the behavior of update on device stays the same, while simulators can have their own implementations. Also change the caller side of the registered updater functions to call these runtime wrappers. Bug: 131911365 Test: unit tests pass, sideload an update on cuttlefish Change-Id: Ib3ab67132991d67fc132f27120e4152439d16ac5
* Add Updater class and remove UpdaterInfoTianjie Xu2019-05-091-47/+21
| | | | | | | | | | | The UpdaterInfo class is merely a collection of pointers and POD types. We can replace it with a Updater class that has the ownership of the resources. This also makes this class extensible as we plan to add more functionality in the host simulator. Bug: 131911365 Test: unit tests pass, run an update on cuttlefish and check last_install Change-Id: I07ca5963bbee8ae3cb85ccc184464910aa73d4e4
* Track libziparchive API change.Elliott Hughes2019-05-061-4/+2
| | | | | | Bug: http://b/129068177 Test: treehugger Change-Id: Ie5b2b0cff087f2e9e65a4e77c187e3173357f3ad
* Consolidate the codes that handle reboot/shutdown.Tao Bao2019-04-291-1/+1
| | | | | | | Test: Choose `Reboot system now`, `Power off`, `Reboot to bootloader` from recovery UI respectively. Test: `adb reboot recovery` while under sideload mode. Change-Id: I0f3d55b80b472178ea4f6970b29cd9df0778b639
* Use dynamically linked f2fs executables.Tao Bao2018-12-201-4/+5
| | | | | | | | | | It also reduces the space cost for devices using f2fs (e.g. crosshatch). /sbin/mkfs.f2fs 722560 => /system/bin/make_f2fs 49568 /sbin/sload.f2fs 1182456 => /system/bin/sload_f2fs 150032 Test: Build and boot recovery on crosshatch. Factory reset. Test: Install a non-A/B OTA package that formats a f2fs partition. Change-Id: Ibe70c8d91a1d07e1c78ff9eac19b1f7955800161
* Clean up the arg setup for exec(3).Tao Bao2018-12-201-54/+34
| | | | | | Test: Build and boot into recovery on marlin. Factory reset. Test: Build and install a non-A/B OTA that calls format. Change-Id: I72416e775e237fc15ca5eff1036175a9eef43b76
* make_f2fs: use -g android by defaultJaegeuk Kim2018-11-211-5/+1
| | | | | | Bug: 119875846 Change-Id: Ibff18ea6f92620852222fff4073379ec8afd0e10 Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
* applypatch: Refactor applypatch().Tao Bao2018-08-311-69/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | applypatch() was initially designed for file-based OTA, operating on individual files. It was later extended to allow patching eMMC targets as a whole, in favor of block-based updates. As we have deprecated file-based OTA since Oreo, part of the code in applypatch() has become obsolete. This CL refactors the related functions, by removing the obsolete logic and focusing on eMMC targets. Since this CL substantially changes applypatch APIs, it adds new functions to avoid unintentionally mixing them together. In particular, it removes `applypatch()`, `applypatch_check()`, `applypatch_flash()`, and adds `PatchPartition()`, `PatchPartitionCheck()`, `FlashPartition()` and `CheckPartition()`. It also replaces the old Edify functions `apply_patch()` and `apply_patch_check()` with `patch_partition()` and `patch_partition_check()` respectively. This CL requires matching changes to OTA generation script (in the same topic). Bug: 110106408 Test: Run recovery_unit_test and recovery_component_test on marlin. Test: `m dist` with non-A/B target. Verify /system/bin/install-recovery.sh on device. Test: `m dist` with non-A/B target using BOARD_USES_FULL_RECOVERY_IMAGE. Verify /system/bin/install-recovery.sh on device. Test: Install an incremental OTA with the new updater and scripts. Change-Id: Ia34a90114bb227f4216eb478c22dc98c8194cb7f
* Remove otafaultTianjie Xu2018-08-281-30/+15
| | | | | | | | | | Now it's less beneficial to inject I/O faults since we don't see many of them. Remove the library that mocks I/O failures. And switch to android::base I/O when possible. Bug: 113032079 Test: unit tests pass Change-Id: I9f2a92b7ba80f4da6ff9e2abc27f2680138f942c
* Merge "applypatch: Consolidate CacheSizeCheck() and MakeFreeSpaceOnCache()."Tao Bao2018-07-131-1/+1
|\ | | | | | | | | | | am: 624b6b6cd5 Change-Id: I16278b00abcdcc532928b534462ff0762c64c1a2
| * applypatch: Consolidate CacheSizeCheck() and MakeFreeSpaceOnCache().Tao Bao2018-07-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | They are doing exactly the same thing, except for the slightly different error return value (1 vs -1). int CacheSizeCheck(size_t bytes); int MakeFreeSpaceOnCache(size_t bytes_needed); This CL consolidates the two functions and uses bool as its return type. // Checks whether /cache partition has at least 'bytes'-byte free space. Returns true immediately // if so. Otherwise, it will try to free some space by removing older logs, checks again and // returns the checking result. bool CheckAndFreeSpaceOnCache(size_t bytes); Test: Run recovery_unit_test and recovery_component_test on marlin. Change-Id: I94a96934d2b18713f8f39ad5aa96a02c98d87963
* | Merge "updater: Let read_file() return Value::Type::STRING."Tao Bao2018-07-101-5/+5
|\| | | | | | | | | | | am: ac234b4493 Change-Id: Ia5cc991c7b1d8800aa211349eeb3f8676a056191
| * updater: Let read_file() return Value::Type::STRING.Tao Bao2018-07-101-5/+5
| | | | | | | | | | | | | | | | | | | | It used to return a Value blob to be consumed by sha1_check() (which has been deprecated). Currently there's no other generic updater function that works with BLOB Values. This CL changes read_file() to return a string Value to make it more useful (e.g. allowing equality check). Test: Run recovery_component_test and recovery_unit_test on marlin. Change-Id: Iba986ba649030112babefe898f26aa9ffe69eeb7
* | Merge "edify: Remove VAL_INVALID and move ValueType into Value class."Tao Bao2018-07-101-11/+11
|\| | | | | | | | | | | am: 503ff38043 Change-Id: I0a99b445b643892f147cde48ae312e87674ba96d
| * edify: Remove VAL_INVALID and move ValueType into Value class.Tao Bao2018-07-101-11/+11
| | | | | | | | | | | | Test: mmma -j bootable/recovery Test: Run recovery_component_test and recovery_unit_test on marlin. Change-Id: I4b240e3e771c387b9694be9c0f2f74e0265ab4cb
* | Merge "updater: Remove the support for sha1_check()."Tao Bao2018-07-101-49/+1
|\| | | | | | | | | | | am: fbc0f6062c Change-Id: I487b1f9bd35335f39c1dd3ab7a4e5dfe722b1863
| * updater: Remove the support for sha1_check().Tao Bao2018-07-091-49/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The matching edify function has been removed from EdifyGenerator [1]. In theory device-specific releasetools script may still use this function, but it no longer looks useful. Because a) we should use range_sha1() when asserting the SHA-1 hash of a block device; b) we should look into the contents when asserting a text file. [1] https://android-review.googlesource.com/c/platform/build/+/714104 Test: Run recovery_component_test on marlin. Test: Code search shows no active user. Change-Id: Id39439101534fb89cf8c5cea80a4b758c8a1a60d
* | Merge "applypatch: {Load,Save}FileContents and ParseSha1 take std::string."Tao Bao2018-06-251-1/+1
|\| | | | | | | | | | | am: b4181566f9 Change-Id: I9fb25b58eaa23443d24c3d6ed75d52ac96c7788f
| * Merge "applypatch: {Load,Save}FileContents and ParseSha1 take std::string."Tao Bao2018-06-251-1/+1
| |\
| | * applypatch: {Load,Save}FileContents and ParseSha1 take std::string.Tao Bao2018-06-201-1/+1
| | | | | | | | | | | | | | | | | | Test: mmma -j bootable/recovery Test: Run recovery_component_test on marlin. Change-Id: Ifcf244346a88dac833d91b169a4c2aee1fe677f1
* | | Merge "e2fsdroid and mke2fs are dynamic executable in recovery partition"Jiyong Park2018-06-211-4/+4
|\| | | | | | | | | | | | | | | | | am: 9b5d4ea20f Change-Id: I017a76c320f29baff3183b0156c1fdf2deed66bf
| * | e2fsdroid and mke2fs are dynamic executable in recovery partitionJiyong Park2018-06-201-4/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | The two utilities are now converted to dynamic executables as shared libraries are supported in recovery mode. As part of the conversion, their location has moved from /sbin to /system/bin. Reflect the change in the program 'recovery' Bug: 79146551 Test: adb reboot recovery, and select 'Wipe data/factory reset'. The data partition is formatted and there is no selinux denial. Change-Id: Ie7cfc4c50ab1e6767e4a5170533ccf826ec7d7f3
* | Merge changes I1cc5d702,I32ab9854 am: 420f7f8df4android-build-prod (mdb)2018-05-041-7/+3
|\| | | | | | | | | | | am: c4ba6b738f Change-Id: I7696fb68e13e214ee830b9de1bf66dc6f1cac691
| * Move reboot() from common.h into otautil/sysutil.h.Tao Bao2018-05-041-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | This breaks the dependency on common.h (which belongs to recovery/librecovery) from librecovery_ui. reboot() is now owned by libotautil, which is expected to be a leaf node to be depended on. With the change, recovery and updater also share the same reboot() code now. Test: mmma -j bootable/recovery Change-Id: I1cc5d702cfe49302048db33d31c9c87ddc97ac71
| * otautil: Rename dir/sys/thermal utils.Tao Bao2018-05-041-1/+1
| | | | | | | | | | Test: mmma -j bootable/recovery Change-Id: I32ab98549e91f993364306e4a88dc654221b3869
* | Merge "Merge libmounts into libotautil." am: 686353215fandroid-build-prod (mdb)2018-04-281-1/+1
|\| | | | | | | | | | | am: cddf5dbf67 Change-Id: I57bcd1195084d2e60861aa5b410e2eb50c41c3c3
| * Merge libmounts into libotautil.Tao Bao2018-04-281-1/+1
| | | | | | | | | | | | | | | | | | Export its header (mounts.h) from there, and drop the dot dot dependency from libupdater / updater. Test: mmma bootable/recovery Test: recovery_component_test Change-Id: Ic26a6b9b78a34dbe1f178b138f3abaafffbec44c
| * install: mkfs.f2fs: specify sector size for target image sizeJaegeuk Kim2018-04-051-0/+2
| | | | | | | | | | | | | | | | | | The total sectors that we want to format is used in different meanings from various users. This notifies its size based on 512 bytes explicitly. Bug: 76407663 Change-Id: I20687b40a1733d3b459a45f8b64a338c37a7bc95 Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
* | recovery: enable fsverity feature bitJaegeuk Kim2018-04-061-6/+4
| | | | | | | | | | | | | | Bug: 74604441 Bug 67380979 Change-Id: Iab1cc9aef356f0ddf6e2491578a2bd53009182ce Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
* | install: mkfs.f2fs: specify sector size for target image sizeJaegeuk Kim2018-04-051-0/+2
|/ | | | | | | | | The total sectors that we want to format is used in different meanings from various users. This notifies its size based on 512 bytes explicitly. Bug: 76407663 Change-Id: I20687b40a1733d3b459a45f8b64a338c37a7bc95 Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
* Reorder the functions in updater/install.cppTianjie Xu2018-02-121-239/+244
| | | | | | | | There is no logical change to the file; merely the function definition reorder and some comestic change to make the future review easier. Test: mma Change-Id: I7ffe952f8c78e840f10aa6bfad0c4b5a58e29896
* Avoid overwrite of the error message in AbortFnTianjie Xu2018-01-291-6/+6
| | | | | | | | | | | | | The AbortFn() used to overwrite the error message, hiding the real failure reported in ErrorAbort(). And we will miss the failure in the script patterns like 'blockimageupdate() || abort()' We will ensure there's one line break at the end of ErrorAbort's error message; and append to the existing error message when calling abort(). Test: Message from ErrorAbort shows up in the log Change-Id: I3aebd06629c5129330250c7fe5e8cdead2ae85bc
* add sload.f2fs for recovery formatJaegeuk Kim2017-12-051-0/+9
| | | | | Change-Id: Iddfe54b2b36f2d531925cbe61c98dbfb4903c0d1 Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
* Detect interrupted update due to power offTianjie Xu2017-12-011-1/+5
| | | | | | | | | | | An interrupted update may stash extra blocks in /cache, leading to a failure when checking the cache size. We can save the incremented retry_count in the BCB before installing the update; and distinguish a fresh update from an interrupted one this way. Bug: 68679601 Test: An interrupted update reapplies successfully. Change-Id: Ic1403e1fd25a937c91ef34c14b92a0f6c8f1c0f4
* recovery: format f2fs with encrypt/quotaJaegeuk Kim2017-11-131-4/+10
| | | | | Change-Id: Ia393b7b78b45f09964449ec0e255aa26bb3b8ddf Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
* recovery: remove make_ext4fs from updaterJin Qian2017-11-031-9/+2
| | | | | Bug: 64395169 Change-Id: I6f6a4f82b225435c6ad5c828e110fa135e6f7579
* Move rangeset.h and print_sha1.h into otautil.Tao Bao2017-10-111-2/+2
| | | | | | | | | Also drop the "bootable/recovery" path in LOCAL_C_INCLUDES from applypatch modules. Test: lunch aosp_{angler,bullhead,fugu,dragon,sailfish}-userdebug; mmma bootable/recovery Change-Id: Idd602a796894f971ee4f8fa3eafe36c42d9de986
* Revert "Revert "Move error_code.h into otautil.""Tao Bao2017-10-091-1/+1
| | | | | | | | | | | | | | | | This reverts commit 26436d6d6010d5323349af7e119ff8f34f85c40c to re-land "Move error_code.h into otautil.". This way it stops requiring relative path ".." in LOCAL_C_INCLUDES (uncrypt and edify). Soong doesn't accept non-local ".." in "local_include_dirs". This CL needs to land with device-specific module changes (e.g. adding the dependency on libotautil). Test: lunch aosp_{angler,bullhead,dragon,fugu,sailfish}-userdebug; mmma bootable/recovery Change-Id: If193241801af2dae73eccd31ce57cd2b81c9fd96
* Revert "Move error_code.h into otautil."Tao Bao2017-10-051-1/+1
| | | | | | | | This reverts commit 623fe7e701d5d0fb17082d1ced14498af1b44e5b. Reason for revert: Need to address device-specific modules. Change-Id: Ib7a4191e7f193dfff49b02d3de76dda856800251
* Move error_code.h into otautil.Tao Bao2017-10-041-1/+1
| | | | | | | | | This way it stops requiring relative path ".." in LOCAL_C_INCLUDES (uncrypt and edify). Soong doesn't accept non-local ".." in "local_include_dirs". Test: mmma bootable/recovery Change-Id: Ia4649789cef2aaeb2785483660e9ea5a8b389c62
* otafault: Move headers under otafault/.Tao Bao2017-09-291-1/+1
| | | | | Test: mmma bootable/recovery Change-Id: I3ceb72f703c7c2857d656c137d71baa1fccd8238
* updater: Remove dead make_parents().Tao Bao2017-07-251-28/+0
| | | | | | | | Its former callers in RenameFn() and SymlinkFn() have been removed in commit 63d786cf22cb44fe32e8b9c1f18b32da3c9d2e1b. Test: mmma -j bootable/recovery Change-Id: I26ed126202554fc5840811ec7ae162da70593213
* Remove the obsolete reference to /file_contexts.Tao Bao2017-07-231-2/+1
| | | | | | | | | | | | | | | | This file no longer exists: - /file_contexts has been split into plat_file_contexts and nonplat_file_contexts since commit b236eb6ca204cefcb926e19bd5682f9dcad4021d (system/sepolicy). - It was named /file_contexts.bin prior to the split. '-S file_contexts' is also no longer required by e2fsdroid, since commit 2fff6fb036cbbb6dedd7da3d208b312a9038a5ce (external/e2fsprogs). It will load the file contexts via libselinux. Test: Trigger the path by performing a data wipe for converting to FBE. Change-Id: I179939da409e5c0415ae0ea0bf5ddb23f9e6331e (cherry picked from commit 7af933b6a6fd687bd17710ef6fda0ad5483e4d6d)
* recovery: replace make_ext4 with e2fsprogsJin Qian2017-07-201-2/+25
| | | | | | | | | | Execute mke2fs to create empty ext4 filesystem. Execute e2fsdroid to add files to filesystem. Test: enter recovery mode and wipe data Bug: 35219933 Change-Id: I10a9f4c1f4754ad864b2df45b1f879180ab33876 (cherry picked from commit ac31808cd37cfb98755e5821dbb2efb5fe5cb12a)
* kill package_extract_dirTianjie Xu2017-05-241-32/+0
| | | | | | | It's only used by file-based OTA which has been deprecated for O. Test: mma Change-Id: I439c93155ca94554d827142c99aa6c0845cc7561
* updater: Update the mkfs.f2fs argument to match f2fs-tools 1.8.0.Tao Bao2017-05-121-3/+5
| | | | | | | | | | | | | | Commit adeb41a8c0da3122a2907acb4aafd7ff9bce26af has switched the argument for recovery. This CL handles the case for updater. Note that there's a chance the updater may run against the old recovery (and f2fs 1.4.1 binary). Not sending a 0-sector argument to f2fs 1.4.1 also works. Bug: 37758867 Test: Make an OTA package that calls format f2fs, with mkfs.f2fs 1.8.0 and 1.4.1 binaries respectively. Change-Id: I4d4bbe8c57544d1c514b7aa37fbf22a0aab14e2c
* Adding support for quiescent reboot to recoveryDmitri Plotnikov2017-04-191-1/+4
| | | | | | Bug: 37401320 Test: build and push OTA and hit adb reboot recovery,quiescent. The screen should remain off throughout the upgrade process. Change-Id: Ibed3795c09e26c4fa73684d40b94e40c78394d3f
* updater: Don't append newline when calling uiPrint().Tao Bao2017-03-301-8/+8
| | | | | | | | LOG(INFO) already appends a newline. Don't print redundant newline. Test: No extra blank lines when calling ui_print(). And on-screen UI shows the same. Change-Id: I74e9a8504a7146a6cb3dae02fe2406d0dd54069b
* updater: Fix the broken case for apply_patch_check().Tao Bao2017-03-231-1/+1
| | | | | | | | | | | It's valid to provide only 1 argument to apply_patch_check(). We shouldn't fail the argument parsing. Bug: 36541737 Test: recovery_component_test passes. Test: recovery_component_test captures the failure without the fix. Test: The previously failed update applies successfully. Change-Id: Iee4c54ed33b877fc4885945b085341ec5c64f663
* Remove malloc in edify functionsTianjie Xu2017-03-221-111/+131
| | | | | | | | And switch them to std::vector & std::unique_ptr Bug: 32117870 Test: recovery tests passed on sailfish Change-Id: I5a45951c4bdf895be311d6d760e52e7a1b0798c3
* updater: Remove some obsoleted functions for file-based OTA.Tao Bao2017-03-131-362/+0
| | | | | | | | | | | | | | This CL removes the updater support for delete(), symlink(), rename(), set_metadata() and set_metadata_recursive(). Such functions have been removed from the generation script in commit f388104eaacd05cfa075d6478369e1d0df5ddbf3 (platform/build). Note: This CL also removes delete_recursive() which seems to have never been supported in generation script. Bug: 35853185 Test: recovery_component_test passes. Change-Id: I51e1ec946fa73761118fa1eaa082423df6d588e9
* Replace _exit(-1) with _exit(EXIT_FAILURE).Tao Bao2017-02-031-2/+2
| | | | | | | | | -1 is not a valid exit status. Also replace a few exit(1) with exit(EXIT_FAILURE). Test: mmma bootable/recovery Change-Id: I4596c8328b770bf95acccc06a4401bd5cabd4bfd
* Print with newline for ui_print.Tao Bao2017-01-221-1/+0
| | | | | | | | | | | | | | | | | | | 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
* updater: Update the header name for bootloader.h.Tao Bao2016-12-291-2/+2
| | | | | | | We should include "bootloader_message/bootloader_message.h" now. Test: m updater Change-Id: I65b22a8a0bcc5976ff1ba827bd30b46ee9d59c53
* updater: Switch to libbase logging.Tao Bao2016-12-011-742/+742
| | | | | Test: Build an updater into a package and apply it on device. Change-Id: I289b5768e9b1e44ef78e0479c64dbaa36fb1a685
* Remove ota_close(int) and ota_fclose(FILE*).Tao Bao2016-11-281-73/+69
| | | | | | | | | | | 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
* updater: Refactor set_stage() and get_stage() functions.Tao Bao2016-11-181-68/+67
| | | | | | | | | | | 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
* updater: Add testcase for package_extract_dir().Tao Bao2016-11-181-17/+21
| | | | | Test: recovery_component_test passes. Change-Id: I3af4707bc42c7331ca961be8b967a53de82ea25b
* updater: Add "write_value()" function.Tao Bao2016-11-171-3/+31
| | | | | | | | | | | | | 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
* updater: Fix the wrong return value for package_extract_file().Tao Bao2016-11-151-76/+69
| | | | | | | | | | | | | | | '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
* updater: Add more testcase for symlink().Tao Bao2016-11-091-20/+17
| | | | | | | | 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
* Make make_parent() to take const argumentTianjie Xu2016-11-081-19/+27
| | | | | | | | Switch to use const std::string; and add corresponding tests. Bug: 32649858 Test: Component tests pass Change-Id: I640f3ec81f1481fa91aa310f8d4d96dac9649cb9
* updater: Add a testcase for RenameFn().Tao Bao2016-11-041-1/+4
| | | | | | Test: recovery_component_test passes. Change-Id: Iba5a0fdf6c79e2bed6b30b8fc19a306c1ab29d8a
* updater: Fix a bug in DeleteFn().Tao Bao2016-11-041-9/+13
| | | | | | | Also add a testcase for delete() function. Test: recovery_component_test passes. Change-Id: I064d1ad4693c3ed339d0a69eabadd08a61a2ea86
* updater: Fix an off-by-1 bug in file_getprop().Tao Bao2016-11-031-6/+9
| | | | | | | | Also add a testcase for file_getprop(). Test: recovery_component_test passes. Change-Id: I8eb2f9a5702b43997ac9f4b29665eea087b1c146
* Cleanup ReadArgs & ReadValueArgs usageTianjie Xu2016-11-011-467/+387
| | | | | | | | ReadArgs will switch to using std::string and std::unique_ptr. Also cleanup the callers. Test: mma & component test passed. Change-Id: I4724406ae6c0c134a27bbd1cdd24ad5d343b2a3b
* applypatch: Switch the parameter of Value** to std::vector.Tao Bao2016-10-291-3/+1
| | | | | | Test: Unit tests and install-recovery.sh pass on angler and dragon. Change-Id: I328e6554edca667cf850f5584ebf1ac211e3d4d1
* Replace minzip with libziparchiveTianjie Xu2016-10-181-15/+23
| | | | | | | | | | | 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
* Change StringValue to use std::stringTianjie Xu2016-10-151-110/+81
| | | | | | | | | | | 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
* updater: Kill the duplicate PrintSha1() in install.cpp.Tao Bao2016-10-111-36/+19
| | | | | | | | Also add a testcase for sha1_check(). Test: mmma bootable/recovery; recovery_component_test passes. Change-Id: I4d06d551a771aec84e460148544f68b247a7e721
* Refactor libupdater into a seperate module.Tao Bao2016-10-111-26/+26
| | | | | | | | | 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
* Update the header path for ext4_utils.Tao Bao2016-10-091-3/+2
| | | | | Test: `mmma bootable/recovery` Change-Id: I70ccddb3ddf46bb012fdc5f632afc46ebdd5473e
* Switch to <android-base/properties.h>.Elliott Hughes2016-09-261-12/+7
| | | | | | | Bug: http://b/23102347 Test: boot into recovery. Change-Id: Ib2ca560f1312961c21fbaa294bb068de19cb883e Merged-In: Ib2ca560f1312961c21fbaa294bb068de19cb883e
* Merge \"Fix install.h\'s use of attribute printf.\"Elliott Hughes2016-06-301-2/+1
|\ | | | | | | | | | | am: a82ee456bb Change-Id: Ibcfabbb0e044d503f889f1afea271cf73ad93f45
| * Fix install.h's use of attribute printf.Elliott Hughes2016-06-301-2/+1
| | | | | | | | | | | | And move off the bionic __nonnull macro, which I'm removing. Change-Id: I40b4424f4fd7bd8076e0eee3ec35de36c3ded8de
* | resolve merge conflicts of 179c0d8 to stage-aosp-masterElliott Hughes2016-06-161-157/+11
|\| | | | | | | Change-Id: Iba5aec266444cabf83f600f2bdb45a3c027e5995
| * Merge "Remove obsolete MTD support."Elliott Hughes2016-06-151-157/+11
| |\
| | * Remove obsolete MTD support.Elliott Hughes2016-06-101-157/+11
| | | | | | | | | | | | | | | Bug: http://b/29250988 Change-Id: Ia97ba9082a165c37f74d6e1c3f71a367adc59945
* | | Merge \\"updater: Fix the broken ReadFileFn.\\" am: 4ddd5edf31Tao Bao2016-06-111-1/+1
|\| | | | | | | | | | | | | | | | | am: 89dfe730d4 Change-Id: Ia465c92d341da4681d3490151a20e1e117271e52
| * | updater: Fix the broken ReadFileFn.Tao Bao2016-06-111-1/+1
| |/ | | | | | | | | | | | | | | Was accidentally broken by the CL in [1]. [1]: commit d6c93afcc28cc65217ba65eeb646009c4f15a2ad Change-Id: I851e13ccea6f5be6fcd47f712cc95867245f9934
* | resolve merge conflicts of 50f6417Tianjie Xu2016-05-231-1/+0
| | | | | | | | | | | | Fix a typo for ota_fclose(). Change-Id: Ia93e911aa5391afc604874fc3a09c5a45c094c80
* | resolve merge conflicts of 50f6417 to nyc-dev-plus-aospTianjie Xu2016-05-231-59/+70
|\ \ | |/ |/| | | Change-Id: I42c127f7946e678acf6596f6352f090abc0ca019
| * Allow recovery to return error codesTianjie Xu2016-05-201-59/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Control fault injection with config files instead of build flagsJed Estep2016-03-191-1/+1
| | | | | | | | | | Bug: 27724259 Change-Id: I65bdefed10b3fb85fcb9e1147eaf0687d7d438f4
| * Revert "DO NOT MERGE Control fault injection with config files instead of build flags"Tao Bao2016-03-171-1/+1
| | | | | | | | | | | | | | This reverts commit f73abf36bcfd433a3fdd1664a77e8e531346c1b1. Bug: 27724259 Change-Id: I1301fdad15650837d0b1febd0c3239134e2b94fb
| * DO NOT MERGE Control fault injection with config files instead of build flagsJed Estep2016-03-161-1/+1
| | | | | | | | | | Bug: 26570379 Change-Id: I76109d09276d6e3ed3a32b6fedafb2582f545c0c
| * applypatch: use vector to store data in FileContents.Yabin Cui2016-03-111-10/+11
| | | | | | | | | | | | | | | | | | Cherry pick this patch because it fixes the problem that a newed Value is released by free(). Bug: 26906416 Change-Id: Ib53b445cd415a1ed5e95733fbc4073f9ef4dbc43 (cherry picked from commit d6c93afcc28cc65217ba65eeb646009c4f15a2ad)
| * Merge "updater: fix memory leak based on static analysis." am: e50d447692Yabin Cui2016-02-051-44/+39
| |\ | | | | | | | | | | | | | | | | | | am: 66b02c4ce5 * commit '66b02c4ce5b175451e723c463e6e9d19ab7872fa': updater: fix memory leak based on static analysis.
| * \ resolve merge conflicts of 7b6027dde4 to master.Tao Bao2016-02-041-7/+7
| |\ \ | | | | | | | | | | | | Change-Id: I1d5232f61744bb18ca5de3a16a340bc3afd110bb
| * | | IO fault injection for OTA packagesJed Estep2016-01-061-12/+13
| | | | | | | | | | | | | | | | | | | | Bug: 25951086 Change-Id: I31c74c735eb7a975b7f41fe2b2eff042e5699c0c
* | | | updater, minzip: Remove unnecessary O_SYNC flags.Alistair Strachan2016-05-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove O_SYNC from mzExtractRecursive() and PackageExtractFileFn(). These functions deal with extracting whole files from the update package onto a filesystem. If run on ext4 on a rotating disk, for example, the O_SYNC flag will cause serious performance problems and the extraction proecss can take over 30 minutes, with no obvious benefits. This API function already calls fsync(fd) after each file is extracted to ensure data and metadata is written to the underlying block device, so the O_SYNC calls should be superfluous and safely removable. This change does not affect the OTA patch paths or any modification of the bootloader partition or writes to other 'emmc' partitions. Signed-off-by: Alistair Strachan <alistair.strachan@imgtec.com> Change-Id: I9cbb98a98e6278bf5c0d7efaae340773d1fbfcd2
* | | | Fix google-runtime-int warnings.Chih-Hung Hsieh2016-04-181-5/+6
| | | | | | | | | | | | | | | | | | | | Bug: 28220065 Change-Id: Ida199c66692a1638be6990d583d2ed42583fb592
* | | | Move selinux dependencies out of header files.Elliott Hughes2016-04-021-1/+2
| | | | | | | | | | | | | | | | | | | | Bug: http://b/27764900 Change-Id: Ib62a59edcb13054f40f514c404d32b87b14ed5f1
* | | | Control fault injection with config files instead of build flagsJed Estep2016-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Bug: 26570379 Change-Id: I76109d09276d6e3ed3a32b6fedafb2582f545c0c (cherry picked from commit d940887dde23597dc358b16d96ca48dd7480fee6)
* | | | applypatch: use vector to store data in FileContents.Yabin Cui2016-02-121-10/+11
| | | | | | | | | | | | | | | | | | | | Bug: 26906416 Change-Id: Ib53b445cd415a1ed5e95733fbc4073f9ef4dbc43
* | | | IO fault injection for OTA packagesJed Estep2016-02-101-21/+22
| |_|/ |/| | | | | | | | | | | | | | Bug: 25951086 Change-Id: I31c74c735eb7a975b7f41fe2b2eff042e5699c0c (cherry-picked from commit f1fc48c6e62cfee42d25ad12f443e22d50c15d0b)
* | | updater: fix memory leak based on static analysis.Yabin Cui2016-02-041-44/+39
| |/ |/| | | | | | | Bug: 26907377 Change-Id: I384c0131322b2d12f0ef489735e70e86819846a4
* | Switch from mincrypt to BoringSSL in applypatch and updater.Sen Jiang2016-02-041-7/+7
|/ | | | | Bug: 18790686 Change-Id: I7d2136fb39b2266f5ae5be24819c617b08a6c21e
* updater: Use O_SYNC and fsync() for package_extract_file().Tao Bao2015-12-151-6/+13
| | | | | | | | We are already using O_SYNC and fsync() for the recursive case (package_extract_dir()). Make it consistent for the single-file case. Bug: 20625549 Change-Id: I487736fe5a0647dd4a2428845e76bf642e0f0dff
* Track rename from base/ to android-base/.Elliott Hughes2015-12-051-3/+3
| | | | Change-Id: I354a8c424d340a9abe21fd716a4ee0d3b177d86f
* updater: Use android::base::ParseInt() to parse integers.Tao Bao2015-09-241-12/+12
| | | | Change-Id: Ic769eafc8d9535b1d517d3dcbd398c3fd65cddd9
* Suppress some compiler warnings due to signedness.Tao Bao2015-09-241-1/+1
| | | | Change-Id: I63f28b3b4ba4185c23b972fc8f93517295b1672a
* updater: Fix the line breaks in ui_print commands.Tao Bao2015-09-101-26/+32
| | | | | | | | | When processing ui_print commands in the updater, it misses a line break when printing to the recovery log. Also clean up uiPrintf() and UIPrintFn() with std::string's. Change-Id: Ie5dbbfbc40b024929887d3c3ccd3a334249a8c9d
* recovery: Switch applypatch/ and updater/ to cpp.Tao Bao2015-07-141-0/+1622
Mostly trivial changes to make cpp compiler happy. Change-Id: I69bd1d96fcccf506007f6144faf37e11cfba1270