blob: d03df106ef6977433a1bfdd969c5c0ae6c6e48e8 [file] [log] [blame]
bigbiff32cbabe2020-04-12 19:16:19 -04001
2#ifndef TWRPAPEX_HPP
3#define TWRPAPEX_HPP
4
5#include <string>
6#include <vector>
7#include <filesystem>
bigbiff79924302021-05-02 20:06:09 -04008#include <sstream>
bigbiff32cbabe2020-04-12 19:16:19 -04009
10#include <sys/types.h>
11#include <sys/stat.h>
12#include <sys/ioctl.h>
13#include <linux/loop.h>
14#include <sys/mount.h>
15#include <sys/sysmacros.h>
16#include <fcntl.h>
17#include <unistd.h>
bigbiffab036612021-06-24 21:31:40 -040018#include <android-base/properties.h>
bigbiff32cbabe2020-04-12 19:16:19 -040019
20#include <ziparchive/zip_archive.h>
21#include "twcommon.h"
22
bigbiff32cbabe2020-04-12 19:16:19 -040023#define APEX_DIR "/system_root/system/apex"
24#define APEX_PAYLOAD "apex_payload.img"
25#define LOOP_BLOCK_DEVICE_DIR "/dev/block/"
bigbiffad58e1b2020-07-06 20:24:34 -040026#define APEX_BASE "/apex/"
bigbiff0e97f7e2021-02-25 10:16:59 -050027#define LOOP_CONTROL "/dev/loop-control"
bigbiff32cbabe2020-04-12 19:16:19 -040028
29class twrpApex {
30public:
31 bool loadApexImages();
bigbiffcfa875c2021-06-20 16:20:27 -040032 bool Unmount();
bigbiff32cbabe2020-04-12 19:16:19 -040033
34private:
35 std::string unzipImage(std::string file);
bigbiff0e97f7e2021-02-25 10:16:59 -050036 bool mountApexOnLoopbackDevices(std::vector<std::string> apexFiles);
bigbiff32cbabe2020-04-12 19:16:19 -040037 bool loadApexImage(std::string fileToMount, size_t loop_device_number);
38};
39#endif