init: use macro to handle prefix matching

This commit is contained in:
Peter Cai 2021-10-17 21:41:49 -04:00
parent 6870114c33
commit 4deb916a32
2 changed files with 6 additions and 2 deletions

View file

@ -8,6 +8,11 @@
#include <sys/wait.h>
#include <unistd.h>
#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<typename... Args>

View file

@ -9,8 +9,7 @@ using namespace std;
class UnihertzKeylayoutQuirk : DeviceQuirk {
public:
bool ShouldRun() {
return android::base::GetProperty("ro.vendor.build.fingerprint", "")
.rfind("Unihertz/", 0) == 0;
return FP_STARTS_WITH("Unihertz/");
}
void Run() {