summaryrefslogtreecommitdiff
path: root/boot_control_android_unittest.cc
Commit message (Collapse)AuthorAgeFilesLines
* Proper split of BootControl and DynamicPartitionControl.Yifan Hong2019-11-131-250/+0
| | | | | | | | | | | | | | | | | | | | | 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
* DynamicPartitionControl: only create snapshot when snapshot_enabledYifan Hong2019-10-171-0/+3
| | | | | | | | | | | | 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
* [REFACTOR] Pass DeltaArchiveManifest to DynamicPartitionControlYifan Hong2019-09-231-11/+11
| | | | | | | | | | | | | | 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
* DynamicPartitionsControl: Add Virtual A/B feature flag.Yifan Hong2019-08-291-0/+2
| | | | | | Test: unittest Bug: 138816109 Change-Id: I7ae65ba0bf36a6ca5085bc4ec2c46245288b4703
* [REFACTOR] DynamicPartitionControl: Add GetSuperPartitionNameYifan Hong2019-07-311-0/+7
| | | | | | | | | | | | | 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
* [REFACTOR] Move and refactor tests.Yifan Hong2019-07-311-629/+9
| | | | | | | | | | | | | | | | | 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
* [REFACTOR] DynamicPartitionControl: combine DAP feature flag APIsYifan Hong2019-07-311-4/+2
| | | | | | | | | | 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
* [REFACTOR] DynamicPartitionControl: minimize APIYifan Hong2019-07-311-3/+3
| | | | | | | | | | | | | | | - 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
* Fix build for API change to DestroyLogicalPartition().David Anderson2019-07-131-4/+4
| | | | | | | | This method no longer uses a timeout parameter. Bug: 135771280 Test: update_engine and update_engine_unittests build Change-Id: If4764bf2d60c6b3aac1e8052c7fbb013c7b3349d
* Rename product_services to system_extJustin Yun2019-07-011-8/+6
| | | | | | Bug: 134359158 Test: run tests for update_engine_unittests Change-Id: I5d5b7f33f2b106f23152049f07e4b44c0cdcdc7e
* Fix resuming updates on DAP launch devices.Yifan Hong2019-04-011-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Call InitPartitionMetadata when resuming an update.Tao Bao2019-01-041-25/+87
| | | | | | | | | | | | | 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
* Don't inherit from std::string.Dan Albert2018-12-201-36/+27
| | | | | | | | | | | | 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
* Improve the logic for mapping target dynamic partitions.Yifan Hong2018-12-141-58/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* BootControlAndroid unittests: fix testsYifan Hong2018-11-201-10/+14
| | | | | | | | | 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
* Retrofit devices do not do allocatable space / 2.Yifan Hong2018-11-201-0/+2
| | | | | | | | | Retrofit devices have two supers, so the allocatable space does not need to be halved. Test: manual OTA Bug: 118506262 Change-Id: I31c77b9318e7c0b6bc6d1a8ae6efa70a3383b05f
* DynamicPartitionControl: support retrofit devicesYifan Hong2018-11-151-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add force_writable to MapPartitionOnDeviceMapperYifan Hong2018-10-301-6/+7
| | | | | | | | | | In sideloading we will map source partitions with force_writable = false. Test: manual sideloading Bug: 117101719 Change-Id: I7629b8ecce07a9bd2c9e24ac6b64617386067ca5
* Support updateable groups.Yifan Hong2018-10-261-162/+409
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix false negative NeedResizeYifan Hong2018-10-261-104/+0
| | | | | | | | | | | | | | | | | | | | | | 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
* boot_control_android_unittest: ExpectStoreMetadataYifan Hong2018-10-261-63/+36
| | | | | | | Factor out common code. Test: update_engine_unittests Change-Id: I1faba28197e2a5731c0243730f4b1bfca0d7f046
* Don't hardcode the super partition name.David Anderson2018-10-041-1/+2
| | | | | | Bug: 116608795 Test: update_engine_unittests --gtest_filter=*BootControlAndroid* Change-Id: Ibf5b0596278d280c7c47b110e7ba96bc04b28472
* Don't pass a guid to MetadataBuilder::AddPartition.David Anderson2018-10-031-2/+1
| | | | | | | | | 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
* update_engine resize dynamic partitions during OTA.Yifan Hong2018-09-281-0/+670
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