#pragma once #include #include #include #include #include #include #include #define PROP_STARTS_WITH(prop, prefix) \ (android::base::GetProperty(prop, "").rfind(prefix, 0) == 0) #define FP_STARTS_WITH(prefix) \ PROP_STARTS_WITH("ro.vendor.build.fingerprint", prefix) using namespace std; template void fork_execl(Args... args) { int pid, status; if ((pid = fork()) == 0) { execl(args..., nullptr); } else { waitpid(pid, &status, 0); } } class DeviceQuirk { public: DeviceQuirk(); virtual bool ShouldRun() = 0; virtual void Run() {} virtual void RunPostData() {} virtual ~DeviceQuirk(); }; #define LOAD_QUIRK(NAME) \ static NAME _ignored; namespace Quirks { void Add(DeviceQuirk* quirk); void Run(); void RunPostData(); int OverrideWithBindMount(filesystem::path src, filesystem::path dst); void OverrideFileWith(filesystem::path p, function proc); void OverrideFileReplaceSubstr(filesystem::path p, string pattern, string replacement); void OverrideFolderWith(filesystem::path p, function proc); void CopyFileKeepPerms(filesystem::path src, filesystem::path dst); }