From 3c89fae5d3bb6b9a9f3b341f93d109b82cade080 Mon Sep 17 00:00:00 2001 From: Keertesh Date: Mon, 22 Jun 2020 10:43:52 +0530 Subject: [PATCH] sdm660-common: whyred: init: Add custom init to set proper variants (#55) * Revert "sdm660: whyred: libinit: Set product model dynamically" This reverts commit 92bf64ca5b27324f40d02a64ff770d29426e6eb4. * sdm660-common: whyred: init: Add custom init to set proper variants Change-Id: I30c57fb24cea89af879d102e4749f95ec1aa9985 --- init/init_sdm660.cpp | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/init/init_sdm660.cpp b/init/init_sdm660.cpp index a6b5c2c6..62911407 100644 --- a/init/init_sdm660.cpp +++ b/init/init_sdm660.cpp @@ -116,22 +116,25 @@ void vendor_load_persist_properties() } } - - if (product.find("whyred") != std::string::npos) { - - std::ifstream fin; - std::string buf; - - fin.open("/proc/cmdline"); - while (std::getline(fin, buf, ' ')) - if (buf.find("androidboot.hwc") != std::string::npos) - break; - fin.close(); - - if (buf.find("CN") != std::string::npos || buf.find("Global") != std::string::npos) { - property_override_dual("ro.product.model", "ro.vendor.product.model", "Redmi Note 5"); - } else { - property_override_dual("ro.product.model", "ro.vendor.product.model", "Redmi Note 5 Pro"); - } - } +} +void vendor_load_properties() +{ + std::string product = GetProperty("ro.product.vendor.device", ""); + if (product.find("whyred") != std::string::npos) + { + std::string region = GetProperty("ro.boot.hwc", ""); + + if (region.find("CN") != std::string::npos || region.find("Global") != std::string::npos || region.find("GLOBAL") != std::string::npos) + { + property_override_dual("ro.product.model", "ro.vendor.product.model", "Redmi Note 5"); + property_override_dual("ro.product.odm.model", "ro.product.system.model", "Redmi Note 5"); + property_override_dual("ro.product.vendor.model", "persist.vendor.camera.exif.model", "Redmi Note 5"); + } + else + { + property_override_dual("ro.product.model", "ro.vendor.product.model", "Redmi Note 5 Pro"); + property_override_dual("ro.product.odm.model", "ro.product.system.model", "Redmi Note 5 Pro"); + property_override_dual("ro.product.vendor.model", "persist.vendor.camera.exif.model", "Redmi Note 5 Pro"); + } + } }