summaryrefslogtreecommitdiff
path: root/boot_control_android_unittest.cc
AgeCommit message (Collapse)Author
2019-11-13Proper split of BootControl and DynamicPartitionControl.Yifan Hong
All dynamic/static partitions stuff are moved to DynamicPartitionControlAndroid. After this patch: (1) BootControl remains a simple shim over the boot control HAL. (BootControl still have two calls that is a delegate to DynamicPartitionControl, which will be cleaned up in follow up CLs.) (2) DynamicPartitionControlInterface API is minimized. All libdm and other Android specific details are hidden from the API surface now. Also move tests from boot_control_unittest to dynamic_partition_control_unittest because functionalities are moved. Test: update_engine_unittests Change-Id: I6ed902197569f9f0ef40e02703634e9078a4b060
2019-10-17DynamicPartitionControl: only create snapshot when snapshot_enabledYifan Hong
Do not create snapshot when applying downgrade to non-Virtual-A/B packages and secondary OTAs. Test: apply downgrade OTA on Virtual A/B devices Bug: 138733621 (secondary OTA) Fixes: 138258570 (downgrades) Change-Id: I13318f57613d6bd60a5b7e81ebb3e35b3c225a0c
2019-09-23[REFACTOR] Pass DeltaArchiveManifest to DynamicPartitionControlYifan Hong
DynamicPartitionControl need the list of operations to calculate COW sizes. - Remove BootControlInterface::PartitionMetadata. Replace all references with DeltaArchiveManifest. DeltaArchiveManifest has all information that PartitionMetadata has. - Rename all InitPartitionMetadata to PreparePartitionsForUpdate - Change all PreparePartitionsForUpdate to use new signature Bug: 138816109 Test: update_enigne_unittests --gtest_filter=*BootControl*:*Dynamic* Change-Id: I4389ba2b1801addf8c3bc8395e2ea6a9a3ed27a0
2019-08-29DynamicPartitionsControl: Add Virtual A/B feature flag.Yifan Hong
Test: unittest Bug: 138816109 Change-Id: I7ae65ba0bf36a6ca5085bc4ec2c46245288b4703
2019-07-31[REFACTOR] DynamicPartitionControl: Add GetSuperPartitionNameYifan Hong
fs_mgr_get_super_partition_name() should be mocked because it is an external dependency to libfs_mgr. In tests, deliberately make GetSuperDevice() to return "fake_super" instead of "super" to make sure it is mocked properly. Test: run unittests Test: manually apply OTA Change-Id: I0f05d99bf168b6e658052b4bd67dc1e82ab36471
2019-07-31[REFACTOR] Move and refactor tests.Yifan Hong
Some tests from boot_control_android_unittest only test logic of UpdatePartitionMetadata. Move them to dynamic_partition_control_android_unittest. After moving the test, boot_control_android_unittest can depend on the MockDynamicPartitionControl (which is a mocked DynamicPartitionControlInterface) directly again. It no longer depends on internal implementation of DynamicPartitionControlAndroid. Test: unittest Fixes: 138333673 Change-Id: Idc5f11be98754b8f6d38fcb8604af497e5d86376
2019-07-31[REFACTOR] DynamicPartitionControl: combine DAP feature flag APIsYifan Hong
Combine IsDynamicPartitionsEnabled/Retrofit into one API that returns a FeatureFlag struct instead. This allows us to add new feature flags more easily. Test: unittest Change-Id: I32f0f0c4d5c636d2eac3bf99d6f92fcc6b71c7a9
2019-07-31[REFACTOR] DynamicPartitionControl: minimize APIYifan Hong
- Move UpdatePartitionMetadata in boot_control_android.cc to DynamicPartitionControlAndroid::PreparePartitionsForUpdate to reflect code ownership better. - Minimize the API by removing unused functions now that we have PreparePartitionsForUpdate - Fix tests: replace MockDynamicPartitionControl to MockDynamicPartitionControlAndroid because it tests DynamicPartitionControlAndroid. Test: unit test Test: manually apply full OTA Change-Id: I2959270bd89c4f8ddaa45cf45ba93acdec850f67
2019-07-13Fix build for API change to DestroyLogicalPartition().David Anderson
This method no longer uses a timeout parameter. Bug: 135771280 Test: update_engine and update_engine_unittests build Change-Id: If4764bf2d60c6b3aac1e8052c7fbb013c7b3349d
2019-07-01Rename product_services to system_extJustin Yun
Bug: 134359158 Test: run tests for update_engine_unittests Change-Id: I5d5b7f33f2b106f23152049f07e4b44c0cdcdc7e
2019-04-01Fix resuming updates on DAP launch devices.Yifan Hong
On devices that launch with dynamic partitions, the following sequence may occur: - update started (assume current_slot = A) - super partition metadata slot B initialized - device rebooted - init maps system_b from extents in metadata slot A - update is resumed, but system_b has wrong extents now InitPartitionMetadata is not called when update is resumed, hence system_b is not unmapped before GetDynamicPartitionDevice is called. The new logic for GetDynamicPartitionDevice is as follows: if (slot == current_slot && partition is mapped) { return GetDmDevicePathByName } return MapPartitionOnDeviceMapper The new logic for MapPartitionOnDeviceMapper is as follows: if (not mapped) return CreateLogicalPartition; if (mapped) { if (mapped by update_engine) { return GetDmDevicePathByName; } DestroyLogicalPartition; return CreateLogicalPartition; } Test: start OTA, see partition metadata initialized, reboot and resume OTA Test: update_engine_unittests Fixes: 129292271 Change-Id: If0b541e9aa42a7f462c1061c67750cf360e42732
2019-01-04Call InitPartitionMetadata when resuming an update.Tao Bao
BootControlAndroid::InitPartitionMetadata() should always be called when starting / resuming an update that uses dynamic partitions. This allows updating the metadata for the target slot, as well as setting up the internal state for accessing the dynamic partitions in the target slot. Bug: 122097567 Test: Run update_engine_unittests on taimen and blueline. Test: Apply a payload that uses dynamic partitions. Reboot before it finishes, then resume the update. Change-Id: I1353f7460a61c0183654b6349689beaa9bf12129
2018-12-20Don't inherit from std::string.Dan Albert
std::string should not be inherited from. This code does not compile with the libc++ update because copy constructors cannot be inherited (not sure why Clang allows this prior to the update). Test: mm Bug: None Change-Id: I9b83a918386016de892bba1a3ff144ab44741b7c
2018-12-14Improve the logic for mapping target dynamic partitions.Yifan Hong
While applying a retrofit update on a dynamic-partitions-enabled build, it should always use static target partitions. Otherwise reading them from the updated partition metadata would end up using mismatching info. This CL improves the logic in detecting and handling such a case. - It identifies a retrofit or regular update based on the absence of DynamicPartitionMetadata field. - Upon seeing that, it skips updating partition metadata for the target slot, and looks up target partitions as static partitions. - Source partitions will always be loaded according to the actual state. This CL also removes the re-mapping of the target partitions from InitPartitionMetadata(). It only needs to unmap those partitions, since they may become inconsistent with the updated metadata. However, it's unnecessary to re-map them, which will be done later as part of GetDynamicPartitionDevice(). Also updated tests to reflect this. Bug: 120775936 Test: update_engine_unittests Test: Apply an update with dynamic partitions; abort and resume. Test: Apply a retrofit update; abort and resume the update. Change-Id: Ic07bd98847e91a003101266e426c4d23666810f2
2018-11-20BootControlAndroid unittests: fix testsYifan Hong
Tests are broken when fs_mgr_get_super_partition_name requires a 'slot' argument, and it defaults to zero. Test: update_engine_unittests --gtest_filter=*BootControlAndroid* Bug: 118506262 Change-Id: Ibd36e8d8e714e87525079b38e1ce78fc940c958b
2018-11-20Retrofit devices do not do allocatable space / 2.Yifan Hong
Retrofit devices have two supers, so the allocatable space does not need to be halved. Test: manual OTA Bug: 118506262 Change-Id: I31c77b9318e7c0b6bc6d1a8ae6efa70a3383b05f
2018-11-15DynamicPartitionControl: support retrofit devicesYifan Hong
On retrofit devices: * The retrofit update includes block devices at source slot (for example, system_a, vendor_a, product_a). This is done automatically because the retrofit update does not look different from regular updates in OTA client's perspective. * The first update after the retrofit update includes the rest of the block devices (in the above example, system_b, vendor_b and product_b). In order to do the second, * use NewForUpdate() API from liblp to automatically include block devices at the target slot when the metadata is loaded. * Use FlashPartitionTable() API to flash metadata to system_b directly without reading existing metadata from it. Test: manual OTA on retrofit devices Bug: 118506262 Change-Id: Ib2c15b8a1a04271320bfef408813723a5b2a7bd7
2018-10-30Add force_writable to MapPartitionOnDeviceMapperYifan Hong
In sideloading we will map source partitions with force_writable = false. Test: manual sideloading Bug: 117101719 Change-Id: I7629b8ecce07a9bd2c9e24ac6b64617386067ca5
2018-10-26Support updateable groups.Yifan Hong
Adds updateable group support to OTA. * DeltaPerformer combines partition sizes with dynamic_partition_metadata to BootControlInterface::PartitionMetadata. * BootControlAndroid::InitPartitionMetadata: * Copy all groups / partitions from source metadata slot * Remove all groups / partitions mentioned in the manifest (of the target slot) * Re-add all groups / partitions mentioned in the manifest. * BootControlAndroid::InitPartitionMetadata can check the incoming PartitionMetadata to see if a partition is dynamic or not. The guessing logic is completely removed. * Because a partition is removed then re-added, there is no need for preserving the entry with size 0 to indicate that a partition is removed. When update_engine sees a partition in a group "foo" on the device, but manifest contains group "foo" without the partition, it removes the partition. * Hence, Removing a partition does NOT require keeping the entry (i.e. RemovePartition is used instead of ShrinkPartition(0) ). This makes retrofitting dynamic partitions on older devices easier. The following is now allowed: - Adding / removing / resizing partitions - Adding / resizing groups It is not allowed to remove a group, but a group can always be resized to zero to deprecate it. Test: update_engine_unittests Bug: 117182932 Change-Id: I39d77f1d1d1fc52fc245f3de699635e6a429015e
2018-10-26Fix false negative NeedResizeYifan Hong
BootControlAndroid did not call ResizePartitions when the sizes were all correct to avoid storing metadata more than once (after resuming from an update), and potentially writing to incorrect extents. But, when the update starts, the target metadata slot may contain metadata that happen to exactly matches the size requirements, but have extents that maps to currently running devices. To do this correctly, DeltaPerformer uses PrefsInterface to avoid calling into InitPartitionMetadata again when it is initialized. Hence, BootControlAndroid::InitPartitionMetadata ALWAYS write metadata to the target slot. Also removed tests to reflect this. Test: manual OTA Test: update_engine_unittests Bug: 117182932 Change-Id: I488ab369e42d582c94974791fdb988d12e695bc2
2018-10-26boot_control_android_unittest: ExpectStoreMetadataYifan Hong
Factor out common code. Test: update_engine_unittests Change-Id: I1faba28197e2a5731c0243730f4b1bfca0d7f046
2018-10-04Don't hardcode the super partition name.David Anderson
Bug: 116608795 Test: update_engine_unittests --gtest_filter=*BootControlAndroid* Change-Id: Ibf5b0596278d280c7c47b110e7ba96bc04b28472
2018-10-03Don't pass a guid to MetadataBuilder::AddPartition.David Anderson
GUIDs are being removed from the super partition, so remove update_engine code that uses them. Bug: 117229984 Test: update_engine_unittests --gtest_filter=*BootControlAndroid* Change-Id: Ia91e7bed8e5d25535e568fa2aa9cb8854479156a
2018-09-28update_engine resize dynamic partitions during OTA.Yifan Hong
update_engine uses device mapper to resize dynamic partitions before opening the devices to apply the update. * DeltaPerformer calls BootControlInterface::InitPartitionMetadata when parsing the update manifest. The implementation for BootControlAndroid::InitPartitionMetadata does the following if sizes for dynamic partitions are incorrect (assuming updating from slot A to B): * Load metadata from metadata slot A * Delete all extents of partitions at slot B (with _b suffix) * Add extents for partitions at slot B * Write metadata to metadata slot B * Re-map all partitions at slot B using metadata slot B with force_writable = true * BootControlAndroid::GetPartitionDevice() checks device-mapper before returning static partitions. * PostinstallRunnerAction::Cleanup calls BootControlInterface::Cleanup which unmaps all partitions at slot B. A partition "foo" is considered dynamic if foo_a exists as a dynamic partition OR foo_b does NOT exist as a static partition. Bug: 110717529 Test: manual ota Test: update_engine_unittests --gtest_filter=*BootControlAndroid* Change-Id: I50f410b486a874242663624801c3694151bdda18