1 #ifndef COM_ANDROID_APEX_H 2 #define COM_ANDROID_APEX_H 3 4 #include <array> 5 #include <map> 6 #include <optional> 7 #include <string> 8 #include <vector> 9 #include <sstream> 10 #include <iostream> 11 12 #if __has_include(<libxml/parser.h>) 13 #include <libxml/parser.h> 14 #include <libxml/xinclude.h> 15 #else 16 #error Require libxml2 library. Please add libxml2 to shared_libs or static_libs 17 #endif 18 19 #include "com_android_apex_enums.h" 20 21 namespace com { 22 namespace android { 23 namespace apex { 24 class ApexInfoList; 25 class ApexInfo; 26 std::optional<ApexInfoList> readApexInfoList(const char* configFile); 27 28 std::optional<ApexInfoList> parseApexInfoList(const char* xml); 29 30 void write(std::ostream& _out, const ApexInfoList& apexInfoList); 31 32 class ApexInfoList { 33 private: 34 const std::vector<ApexInfo> apexInfo_; 35 public: 36 explicit ApexInfoList(std::vector<ApexInfo> apexInfo); 37 const std::vector<ApexInfo>& getApexInfo() const; 38 bool hasApexInfo() const; 39 const ApexInfo* getFirstApexInfo() const; 40 static ApexInfoList read(xmlNode *root); 41 void write(std::ostream& _out, const std::string& _name) const; 42 }; 43 44 class ApexInfo { 45 private: 46 const std::string moduleName_; 47 const std::string modulePath_; 48 const std::optional<std::string> preinstalledModulePath_; 49 const int64_t versionCode_; 50 const std::string versionName_; 51 const bool isFactory_; 52 const bool isActive_; 53 const std::optional<int64_t> lastUpdateMillis_; 54 const bool provideSharedApexLibs_; 55 const std::string partition_; 56 public: 57 ApexInfo(std::string moduleName, std::string modulePath, std::optional<std::string> preinstalledModulePath, int64_t versionCode, std::string versionName, bool isFactory, bool isActive, std::optional<int64_t> lastUpdateMillis, bool provideSharedApexLibs, std::string partition); 58 const std::string& getModuleName() const; 59 bool hasModuleName() const; 60 const std::string& getModulePath() const; 61 bool hasModulePath() const; 62 const std::string& getPreinstalledModulePath() const; 63 bool hasPreinstalledModulePath() const; 64 const int64_t& getVersionCode() const; 65 bool hasVersionCode() const; 66 const std::string& getVersionName() const; 67 bool hasVersionName() const; 68 const bool& getIsFactory() const; 69 bool hasIsFactory() const; 70 const bool& getIsActive() const; 71 bool hasIsActive() const; 72 const int64_t& getLastUpdateMillis() const; 73 bool hasLastUpdateMillis() const; 74 const bool& getProvideSharedApexLibs() const; 75 bool hasProvideSharedApexLibs() const; 76 const std::string& getPartition() const; 77 bool hasPartition() const; 78 static ApexInfo read(xmlNode *root); 79 void write(std::ostream& _out, const std::string& _name) const; 80 }; 81 82 } // apex 83 } // android 84 } // com 85 #endif // COM_ANDROID_APEX_H 86