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

Commit f0dd1207 authored by Yifan Hong's avatar Yifan Hong
Browse files

MetadataBuilder::IsABDevice: make static / use std::optional

Align with hat sRetrofitDap does.

Test: liblp_test_static
Change-Id: Ifc4c45404369a4eb18c02fc6a0ede938da5809b8
parent 9d0e6cdf
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -30,8 +30,7 @@
namespace android {
namespace fs_mgr {

bool MetadataBuilder::sABOverrideSet;
bool MetadataBuilder::sABOverrideValue;
std::optional<bool> MetadataBuilder::sABOverride;
std::optional<bool> MetadataBuilder::sRetrofitDap;

static const std::string kDefaultGroup = "default";
@@ -212,8 +211,7 @@ std::unique_ptr<MetadataBuilder> MetadataBuilder::NewForUpdate(const IPartitionO
}

void MetadataBuilder::OverrideABForTesting(bool ab_device) {
    sABOverrideSet = true;
    sABOverrideValue = ab_device;
    sABOverride = ab_device;
}

void MetadataBuilder::OverrideRetrofitDynamicParititonsForTesting(bool retrofit) {
@@ -1051,9 +1049,9 @@ void MetadataBuilder::SetAutoSlotSuffixing() {
    auto_slot_suffixing_ = true;
}

bool MetadataBuilder::IsABDevice() const {
    if (sABOverrideSet) {
        return sABOverrideValue;
bool MetadataBuilder::IsABDevice() {
    if (sABOverride.has_value()) {
        return *sABOverride;
    }
    return !android::base::GetProperty("ro.boot.slot_suffix", "").empty();
}
+4 −3
Original line number Diff line number Diff line
@@ -309,7 +309,9 @@ class MetadataBuilder {
    void ImportExtents(Partition* dest, const LpMetadata& metadata,
                       const LpMetadataPartition& source);
    bool ImportPartition(const LpMetadata& metadata, const LpMetadataPartition& source);
    bool IsABDevice() const;

    // Return true if the device is an AB device.
    static bool IsABDevice();

    // Return true if the device is retrofitting dynamic partitions.
    static bool IsRetrofitDynamicPartitionsDevice();
@@ -345,8 +347,7 @@ class MetadataBuilder {
                                                    const std::vector<Interval>& free_list,
                                                    uint64_t sectors_needed) const;

    static bool sABOverrideValue;
    static bool sABOverrideSet;
    static std::optional<bool> sABOverride;
    static std::optional<bool> sRetrofitDap;

    LpMetadataGeometry geometry_;