diff --git a/services/ptable_parse/ptable.cpp b/services/ptable_parse/ptable.cpp index d91e4b2a99127ea5264891a1292e820274569aba..c379f813d4d692e9c738f9c721d7a7fc5c344488 100644 --- a/services/ptable_parse/ptable.cpp +++ b/services/ptable_parse/ptable.cpp @@ -48,11 +48,33 @@ bool Ptable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, const s return false; } +std::vector Ptable::GetABPartitionList() const +{ + return abPartitionList_; +} + uint32_t Ptable::GetPtablePartitionNum() const { return partitionInfo_.size(); } +bool Ptable::LoadABPtnInfo() +{ + if (abPartitionList_.empty()) { + LOG(ERROR) << "gei partiotion failed! abPartitionList_ is empty"; + return false; + } + for ( auto &partition : partitionInfo_) { + if (partition.partType == Ptable::PartType::A_TYPE) { + std::string partitionName = partition.dispName.substr( + 0, partition.dispName.size() - Ptable::PARTITION_AB_SUFFIX_SIZE); + LOG(INFO) << "get AB partition. name = " << partitionName; + abPartitionList_.push_back(partitionName); + } + } + return true; +} + bool Ptable::LoadPtnInfo(const std::vector &ptnInfo) { if (ptnInfo.empty()) { diff --git a/services/ptable_parse/ptable.h b/services/ptable_parse/ptable.h index 7bab2056afe6e629435f0dd0ca544765e02e6932..b54a6881ffce7f49aca801f16cf6f53012e05489 100644 --- a/services/ptable_parse/ptable.h +++ b/services/ptable_parse/ptable.h @@ -72,6 +72,7 @@ public: uint64_t devDensity; }; std::vector GetPtablePartitionInfo() const; + std::vector GetABPartitionList() const; uint32_t GetPtablePartitionNum() const; void SetReservedSize(uint64_t reservedSize); bool InitPtable(); @@ -81,6 +82,7 @@ public: bool GetPartionInfoByName(const std::string &partitionName, PtnInfo &ptnInfo, int32_t &index); std::vector& GetPtablePartitionInfoInstance(); bool LoadPtnInfo(const std::vector& ptnInfo); + bool LoadABPtnInfo(); bool WritePartitionBufToFile(uint8_t *ptbImgBuffer, const uint32_t imgBufSize); bool ReadPartitionFileToBuffer(uint8_t *ptbImgBuffer, uint32_t &imgBufSize); void DeletePartitionTmpFile(); @@ -212,6 +214,7 @@ public: }; std::vector partitionInfo_; + std::vector abPartitionList_; PtableData ptableData_; uint64_t reservedSize_ {0};