From 1a8eee6d2a1d79412902331b74283eec77414c6b Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Sat, 19 Feb 2022 08:20:25 -0500 Subject: [PATCH 1/2] Add new mechanism to fake vendor props on a per-process basis This reads debug.phh.props.. If its value is "vendor", then ro.product.device/ro.product.manufacturer is read from vendor --- libc/system_properties/system_properties.cpp | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/libc/system_properties/system_properties.cpp b/libc/system_properties/system_properties.cpp index 1cb15c3df..d6e7e3e68 100644 --- a/libc/system_properties/system_properties.cpp +++ b/libc/system_properties/system_properties.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -50,6 +51,32 @@ #define SERIAL_DIRTY(serial) ((serial)&1) #define SERIAL_VALUE_LEN(serial) ((serial) >> 24) +static char comm[128]; +static bool self_ok = false; +static char comm_override[PROP_VALUE_MAX]; + +static void read_self() { + //NB: Not atomic, but should be good enough, there is no possible corruption from concurrency + if(self_ok) return; + self_ok = true; + + int fd = open("/proc/self/comm", O_RDONLY); + if(fd<0) return; + read(fd, comm, sizeof(comm)-1); + for(unsigned i=0; i0) return r; + } + if(strcmp(name, "ro.product.manufacturer") == 0) { + int r = Get("ro.product.vendor.manufacturer", value); + if(r>0) return r; + } + } const prop_info* pi = Find(name); if (pi != nullptr) { -- 2.34.1