1 #pragma once 2 3 #include <inttypes.h> 4 #include <stdlib.h> 5 6 #include <string> 7 #include <vector> 8 9 #include <android-base/unique_fd.h> 10 #include <bootimg.h> 11 #include <liblp/liblp.h> 12 #include <sparse/sparse.h> 13 14 using SparsePtr = std::unique_ptr<sparse_file, decltype(&sparse_file_destroy)>; 15 16 /* util stuff */ 17 double now(); 18 void set_verbose(); 19 20 // These printf-like functions are implemented in terms of vsnprintf, so they 21 // use the same attribute for compile-time format string checking. 22 void die(const char* fmt, ...) __attribute__((__noreturn__)) 23 __attribute__((__format__(__printf__, 1, 2))); 24 25 void verbose(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2))); 26 27 void die(const std::string& str) __attribute__((__noreturn__)); 28 29 bool should_flash_in_userspace(const android::fs_mgr::LpMetadata& metadata, 30 const std::string& partition_name); 31 bool is_sparse_file(android::base::borrowed_fd fd); 32 int64_t get_file_size(android::base::borrowed_fd fd); 33 std::string fb_fix_numeric_var(std::string var); 34 35 class ImageSource { 36 public: ~ImageSource()37 virtual ~ImageSource(){}; 38 virtual bool ReadFile(const std::string& name, std::vector<char>* out) const = 0; 39 virtual android::base::unique_fd OpenFile(const std::string& name) const = 0; 40 }; 41