Skip to content

Commit

Permalink
satsuki: read model from lta-label
Browse files Browse the repository at this point in the history
  • Loading branch information
luk1337 authored and joel16 committed Oct 5, 2021
1 parent 0995c15 commit 69bcdf1
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions init_satsuki/init_satsuki.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
#include <android-base/logging.h>

#include <fcntl.h>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <unistd.h>
#include <sys/stat.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
Expand All @@ -34,17 +36,18 @@
#include "util.h"

using android::init::import_kernel_cmdline;
using android::init::property_set;

void property_override(char const prop[], char const value[])
constexpr auto LTALABEL_PATH = "/dev/block/platform/soc.0/f9824900.sdhci/by-name/LTALabel";

void property_override(char const prop[], char const value[], bool add = true)
{
prop_info *pi;
auto pi = (prop_info *) __system_property_find(prop);

pi = (prop_info*) __system_property_find(prop);
if (pi)
if (pi != nullptr) {
__system_property_update(pi, value, strlen(value));
else
} else if (add) {
__system_property_add(prop, strlen(prop), value, strlen(value));
}
}

void property_override_dual(char const system_prop[], char const vendor_prop[], char const value[])
Expand All @@ -65,25 +68,31 @@ static void import_kernel_nv(const std::string& key,
{
if (key.empty()) return;

if (std::ifstream file = std::ifstream(LTALABEL_PATH, std::ios::binary)) {
std::string str((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
size_t offset = str.find("Model: ");

if (offset != std::string::npos) {
std::string model = str.substr(offset + strlen("Model: "), 5);
property_override("ro.semc.product.model", model.c_str());
property_override_triple("ro.product.model", "ro.product.system.model", "ro.product.vendor.model", model.c_str());
property_override_triple("ro.product.name", "ro.product.system.name", "ro.product.vendor.name", model.c_str());
}
}

if (key == "oemandroidboot.phoneid") {
// Dual Sim variant contains two IMEIs separated by comma.
if ((count(value.begin(), value.end(),',')) > 0) {
property_set("persist.multisim.config", "dsds");
property_set("persist.radio.multisim.config", "dsds");
property_set("ro.telephony.default_network", "9,1");
property_set("ro.semc.product.model", "E6883");
property_set("ro.semc.product.name", "Xperia Z5 Premium Dual");
property_override_triple("ro.product.model", "ro.product.system.model", "ro.product.vendor.model", "E6883");
property_override_dual("ro.product.name", "ro.vendor.product.name", "satsuki_dsds");
property_override("persist.multisim.config", "dsds");
property_override("persist.radio.multisim.config", "dsds");
property_override("ro.telephony.default_network", "9,1");
property_override("ro.semc.product.name", "Xperia Z5 Premium Dual");
property_override_triple("ro.product.device", "ro.product.system.device", "ro.product.vendor.device", "satsuki_dsds");
property_override("ro.build.description", "E6883-user 7.1.1 32.4.A.1.54 3761073091 release-keys");
property_override_triple("ro.build.fingerprint", "ro.system.build.fingerprint", "ro.vendor.build.fingerprint", "Sony/E6883/E6883:7.1.1/32.4.A.1.54/3761073091:user/release-keys");
} else {
property_set("ro.telephony.default_network", "9");
property_set("ro.semc.product.model", "E6853");
property_set("ro.semc.product.name", "Xperia Z5 Premium");
property_override_triple("ro.product.model", "ro.product.system.model", "ro.product.vendor.model", "E6853");
property_override_dual("ro.product.name", "ro.vendor.product.name", "satsuki");
property_override("ro.telephony.default_network", "9");
property_override("ro.semc.product.name", "Xperia Z5 Premium");
property_override_triple("ro.product.device", "ro.product.system.device", "ro.product.vendor.device", "satsuki");
property_override("ro.build.description", "E6853-user 7.1.1 32.4.A.1.54 3761073091 release-keys");
property_override_triple("ro.build.fingerprint", "ro.system.build.fingerprint", "ro.vendor.build.fingerprint", "Sony/E6853/E6853:7.1.1/32.4.A.1.54/3761073091:user/release-keys");
Expand Down

0 comments on commit 69bcdf1

Please sign in to comment.