Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4383e14 authored by Yifan Hong's avatar Yifan Hong Committed by Gerrit Code Review
Browse files

Merge "liblp: MetadataBuilder::NewForUpdate takes always_keep_source_slot arg"

parents 2fd9d735 6bc5b47a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -171,7 +171,8 @@ std::unique_ptr<MetadataBuilder> MetadataBuilder::New(const LpMetadata& metadata
std::unique_ptr<MetadataBuilder> MetadataBuilder::NewForUpdate(const IPartitionOpener& opener,
                                                               const std::string& source_partition,
                                                               uint32_t source_slot_number,
                                                               uint32_t target_slot_number) {
                                                               uint32_t target_slot_number,
                                                               bool always_keep_source_slot) {
    auto metadata = ReadMetadata(opener, source_partition, source_slot_number);
    if (!metadata) {
        return nullptr;
@@ -189,7 +190,8 @@ std::unique_ptr<MetadataBuilder> MetadataBuilder::NewForUpdate(const IPartitionO
        }
    }

    if (IPropertyFetcher::GetInstance()->GetBoolProperty("ro.virtual_ab.enabled", false)) {
    if (IPropertyFetcher::GetInstance()->GetBoolProperty("ro.virtual_ab.enabled", false) &&
        !always_keep_source_slot) {
        if (!UpdateMetadataForInPlaceSnapshot(metadata.get(), source_slot_number,
                                              target_slot_number)) {
            return nullptr;
+4 −1
Original line number Diff line number Diff line
@@ -209,10 +209,13 @@ class MetadataBuilder {
    // metadata may not have the target slot's devices listed yet, in which
    // case, it is automatically upgraded to include all available block
    // devices.
    // If |always_keep_source_slot| is set, on a Virtual A/B device, source slot
    // partitions are kept. This is useful when applying a downgrade package.
    static std::unique_ptr<MetadataBuilder> NewForUpdate(const IPartitionOpener& opener,
                                                         const std::string& source_partition,
                                                         uint32_t source_slot_number,
                                                         uint32_t target_slot_number);
                                                         uint32_t target_slot_number,
                                                         bool always_keep_source_slot = false);

    // Import an existing table for modification. If the table is not valid, for
    // example it contains duplicate partition names, then nullptr is returned.