Load Zygisk modules

This commit is contained in:
topjohnwu
2021-10-13 04:52:02 -07:00
parent 27814e3015
commit c8ac6c07b0
10 changed files with 366 additions and 120 deletions

View File

@@ -107,16 +107,15 @@ void exec_common_scripts(const char *stage) {
PFS_DONE()
}
// Return if a > b
static bool timespec_larger(timespec *a, timespec *b) {
if (a->tv_sec != b->tv_sec)
return a->tv_sec > b->tv_sec;
return a->tv_nsec > b->tv_nsec;
static bool operator>(const timespec &a, const timespec &b) {
if (a.tv_sec != b.tv_sec)
return a.tv_sec > b.tv_sec;
return a.tv_nsec > b.tv_nsec;
}
void exec_module_scripts(const char *stage, const vector<string> &module_list) {
void exec_module_scripts(const char *stage, const vector<string_view> &modules) {
LOGI("* Running module %s scripts\n", stage);
if (module_list.empty())
if (modules.empty())
return;
bool pfs = stage == "post-fs-data"sv;
@@ -124,15 +123,15 @@ void exec_module_scripts(const char *stage, const vector<string> &module_list) {
timespec now{};
clock_gettime(CLOCK_MONOTONIC, &now);
// If we had already timed out, treat it as service mode
if (timespec_larger(&now, &pfs_timeout))
if (now > pfs_timeout)
pfs = false;
}
int timer_pid = -1;
PFS_SETUP()
char path[4096];
for (auto &m : module_list) {
const char* module = m.data();
for (auto &m : modules) {
const char *module = m.data();
sprintf(path, MODULEROOT "/%s/%s.sh", module, stage);
if (access(path, F_OK) == -1)
continue;