gsi: reconcile system fingerprint / device model with vendor
This commit is contained in:
parent
732c135b4d
commit
aaba77ede8
5
BoardConfigCommon.mk
Normal file
5
BoardConfigCommon.mk
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
DEVICE_PATH := device/peter/gsi
|
||||||
|
|
||||||
|
# Sepolicy
|
||||||
|
SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS += $(DEVICE_PATH)/sepolicy/private
|
||||||
|
SELINUX_IGNORE_NEVERALLOWS := true
|
|
@ -29,3 +29,8 @@ PRODUCT_PROPERTY_OVERRIDES += \
|
||||||
# Resetprop
|
# Resetprop
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
resetprop_sys
|
resetprop_sys
|
||||||
|
|
||||||
|
# Init
|
||||||
|
PRODUCT_PACKAGES += \
|
||||||
|
init_gsi
|
||||||
|
|
||||||
|
|
7
init/Android.bp
Normal file
7
init/Android.bp
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
cc_binary {
|
||||||
|
name: "init_gsi",
|
||||||
|
system_ext_specific: true,
|
||||||
|
srcs: ["init_gsi.cpp"],
|
||||||
|
shared_libs: ["libbase", "libdl", "libutils"],
|
||||||
|
init_rc: ["init_gsi.rc"],
|
||||||
|
}
|
61
init/init_gsi.cpp
Normal file
61
init/init_gsi.cpp
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#include <android-base/logging.h>
|
||||||
|
#include <android-base/properties.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
using namespace android;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
void fork_execl(Args... args) {
|
||||||
|
int pid, status;
|
||||||
|
if ((pid = fork()) == 0) {
|
||||||
|
execl(args..., nullptr);
|
||||||
|
} else {
|
||||||
|
waitpid(pid, &status, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void override_ro_prop(string prefix, string source, string postfix, string value) {
|
||||||
|
if (value.length() == 0) return;
|
||||||
|
|
||||||
|
std::string prop = prefix;
|
||||||
|
|
||||||
|
if (source.length() > 0) {
|
||||||
|
prop += ".";
|
||||||
|
prop += source;
|
||||||
|
}
|
||||||
|
|
||||||
|
prop += "." + postfix;
|
||||||
|
std::cout << prop << std::endl;
|
||||||
|
std::cout << value << std::endl;
|
||||||
|
|
||||||
|
fork_execl("/system/system_ext/bin/resetprop_sys", "resetprop_sys", prop.c_str(), value.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string RO_PROP_SOURCES[] = {
|
||||||
|
"", "product", "odm", "vendor", "system_ext", "system", "bootimage",
|
||||||
|
};
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
string device = base::GetProperty("ro.product.vendor.device", "");
|
||||||
|
string model = base::GetProperty("ro.product.vendor.model", "");
|
||||||
|
string name = base::GetProperty("ro.product.vendor.name", "");
|
||||||
|
string brand = base::GetProperty("ro.product.vendor.brand", "");
|
||||||
|
string manufacturer = base::GetProperty("ro.product.vendor.manufacturer", "");
|
||||||
|
string fingerprint = base::GetProperty("ro.vendor.build.fingerprint", "");
|
||||||
|
|
||||||
|
for (const auto& source : RO_PROP_SOURCES) {
|
||||||
|
override_ro_prop("ro.product", source, "device", device);
|
||||||
|
override_ro_prop("ro.product", source, "model", model);
|
||||||
|
override_ro_prop("ro.product", source, "name", name);
|
||||||
|
override_ro_prop("ro.product", source, "brand", brand);
|
||||||
|
override_ro_prop("ro.product", source, "manufacturer", manufacturer);
|
||||||
|
override_ro_prop("ro", source, "build.fingerprint", fingerprint);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
5
init/init_gsi.rc
Normal file
5
init/init_gsi.rc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
service init_gsi /system/system_ext/bin/init_gsi
|
||||||
|
class core
|
||||||
|
user root
|
||||||
|
group root
|
||||||
|
seclabel u:r:init:s0
|
|
@ -1 +1,2 @@
|
||||||
include build/make/target/board/generic_arm64/BoardConfig.mk
|
include build/make/target/board/generic_arm64/BoardConfig.mk
|
||||||
|
include device/peter/gsi/BoardConfigCommon.mk
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
cc_binary {
|
cc_binary {
|
||||||
name: "resetprop_sys",
|
name: "resetprop_sys",
|
||||||
|
system_ext_specific: true,
|
||||||
srcs: [
|
srcs: [
|
||||||
//nanopb
|
//nanopb
|
||||||
"Magisk/native/jni/external/nanopb/pb_common.c",
|
"Magisk/native/jni/external/nanopb/pb_common.c",
|
||||||
|
|
1
sepolicy/private/init.te
Normal file
1
sepolicy/private/init.te
Normal file
|
@ -0,0 +1 @@
|
||||||
|
allow init system_file:file execute_no_trans;
|
Loading…
Reference in a new issue