diff options
Diffstat (limited to 'install.h')
-rw-r--r-- | install.h | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -19,6 +19,7 @@ #include <stddef.h> +#include <map> #include <string> #include <ziparchive/zip_archive.h> @@ -33,6 +34,12 @@ enum InstallResult { INSTALL_KEY_INTERRUPTED }; +enum class OtaType { + AB, + BLOCK, + BRICK, +}; + // Installs the given update package. If INSTALL_SUCCESS is returned and *wipe_cache is true on // exit, caller should wipe the cache partition. int install_package(const std::string& package, bool* wipe_cache, bool needs_mount, @@ -42,12 +49,17 @@ int install_package(const std::string& package, bool* wipe_cache, bool needs_mou // otherwise return false. bool verify_package(const unsigned char* package_data, size_t package_size); -// Read meta data file of the package, write its content in the string pointed by meta_data. -// Return true if succeed, otherwise return false. -bool read_metadata_from_package(ZipArchiveHandle zip, std::string* metadata); +// Reads meta data file of the package; parses each line in the format "key=value"; and writes the +// result to |metadata|. Return true if succeed, otherwise return false. +bool ReadMetadataFromPackage(ZipArchiveHandle zip, std::map<std::string, std::string>* metadata); // Verifies the compatibility info in a Treble-compatible package. Returns true directly if the // entry doesn't exist. bool verify_package_compatibility(ZipArchiveHandle package_zip); +// Checks if the the metadata in the OTA package has expected values. Returns 0 on success. +// Mandatory checks: ota-type, pre-device and serial number(if presents) +// AB OTA specific checks: pre-build version, fingerprint, timestamp. +int CheckPackageMetadata(const std::map<std::string, std::string>& metadata, OtaType ota_type); + #endif // RECOVERY_INSTALL_H_ |