bigbiff | 32cbabe | 2020-04-12 19:16:19 -0400 | [diff] [blame] | 1 | |
| 2 | #ifndef TWRPAPEX_HPP |
| 3 | #define TWRPAPEX_HPP |
| 4 | |
| 5 | #include <string> |
| 6 | #include <vector> |
| 7 | #include <filesystem> |
bigbiff | b5a20a8 | 2021-10-17 20:02:17 -0400 | [diff] [blame] | 8 | #include <regex> |
bigbiff | 7992430 | 2021-05-02 20:06:09 -0400 | [diff] [blame] | 9 | #include <sstream> |
bigbiff | 32cbabe | 2020-04-12 19:16:19 -0400 | [diff] [blame] | 10 | |
| 11 | #include <sys/types.h> |
| 12 | #include <sys/stat.h> |
| 13 | #include <sys/ioctl.h> |
| 14 | #include <linux/loop.h> |
| 15 | #include <sys/mount.h> |
| 16 | #include <sys/sysmacros.h> |
| 17 | #include <fcntl.h> |
| 18 | #include <unistd.h> |
bigbiff | ab03661 | 2021-06-24 21:31:40 -0400 | [diff] [blame] | 19 | #include <android-base/properties.h> |
bigbiff | 32cbabe | 2020-04-12 19:16:19 -0400 | [diff] [blame] | 20 | |
| 21 | #include <ziparchive/zip_archive.h> |
| 22 | #include "twcommon.h" |
| 23 | |
bigbiff | 32cbabe | 2020-04-12 19:16:19 -0400 | [diff] [blame] | 24 | #define APEX_DIR "/system_root/system/apex" |
| 25 | #define APEX_PAYLOAD "apex_payload.img" |
| 26 | #define LOOP_BLOCK_DEVICE_DIR "/dev/block/" |
bigbiff | ad58e1b | 2020-07-06 20:24:34 -0400 | [diff] [blame] | 27 | #define APEX_BASE "/apex/" |
bigbiff | 0e97f7e | 2021-02-25 10:16:59 -0500 | [diff] [blame] | 28 | #define LOOP_CONTROL "/dev/loop-control" |
bigbiff | 32cbabe | 2020-04-12 19:16:19 -0400 | [diff] [blame] | 29 | |
| 30 | class twrpApex { |
| 31 | public: |
| 32 | bool loadApexImages(); |
bigbiff | cfa875c | 2021-06-20 16:20:27 -0400 | [diff] [blame] | 33 | bool Unmount(); |
bigbiff | 32cbabe | 2020-04-12 19:16:19 -0400 | [diff] [blame] | 34 | |
| 35 | private: |
| 36 | std::string unzipImage(std::string file); |
bigbiff | 0e97f7e | 2021-02-25 10:16:59 -0500 | [diff] [blame] | 37 | bool mountApexOnLoopbackDevices(std::vector<std::string> apexFiles); |
bigbiff | 32cbabe | 2020-04-12 19:16:19 -0400 | [diff] [blame] | 38 | bool loadApexImage(std::string fileToMount, size_t loop_device_number); |
| 39 | }; |
| 40 | #endif |