Skip to content
Snippets Groups Projects
Commit 23d937a3 authored by Dhina17's avatar Dhina17
Browse files

onclite: Set device model based on hwversion

* Redmi 7 and Redmi Y3 are nearly same device except Front camera and Gyroscope sensor.
* Redmi Y3 has 32MP selfie camera that is an AUX camera which is a cursed part in custom roms.
  And Gyroscope sensor works well in Y3 since we are including permission config which won't affect Redmi 7 as well
* Hence, Redmi Y3 is an another variant of Redmi 7.
  Lets set the correct device name based on hwversion in init.

Change-Id: Ie04a22815731b90450907a10091eb7859386b34e
parent 5dd9dda2
No related branches found
No related tags found
Loading
......@@ -137,6 +137,10 @@ DEVICE_MANIFEST_FILE := $(DEVICE_PATH)/manifest.xml
DEVICE_MATRIX_FILE := $(DEVICE_PATH)/compatibility_matrix.xml
DEVICE_FRAMEWORK_MANIFEST_FILE := $(DEVICE_PATH)/framework_manifest.xml
# Init
TARGET_INIT_VENDOR_LIB := //$(DEVICE_PATH):libinit_onclite
TARGET_RECOVERY_DEVICE_MODULES := libinit_onclite
# Partitions
BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
BOARD_BOOTIMAGE_PARTITION_SIZE := 67108864
......
//
// Copyright (C) 2023 The LineageOS Project
//
// SPDX-License-Identifier: Apache-2.0
//
cc_library_static {
name: "libinit_onclite",
recovery_available: true,
srcs: ["init_onclite.cpp"],
whole_static_libs: ["libbase"],
include_dirs: ["system/core/init"]
}
/*
* Copyright (C) 2023 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <android-base/properties.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
#include "vendor_init.h"
// Define variants
#define VARIANT_ONE "Redmi 7"
#define VARIANT_TWO "Redmi Y3"
using android::base::GetProperty;
static const std::string ro_props_sources[] = {
"",
"odm.",
"product.",
"system.",
"system_ext.",
"vendor.",
"vendor_dlkm."
};
void property_override(const std::string& name, const std::string& value, bool add = true) {
auto pi = const_cast<prop_info*>(__system_property_find(name.c_str()));
if (pi != nullptr) {
__system_property_update(pi, value.c_str(), value.size());
} else if (add) {
__system_property_add(name.c_str(), name.size(), value.c_str(), value.size());
}
}
void set_model_props(const std::string &model) {
// Set device model
for (const std::string &source : ro_props_sources) {
std::string prop = "ro.product." + source + "model";
property_override(prop, model);
}
}
void set_device_model() {
// Get the hwversion prop
const std::string hwversion = GetProperty("ro.boot.hwversion", "");
// Only Redmi Y3 has hwversion 1.19.0.
// So set the device model based on it.
if (hwversion == "1.19.0") {
set_model_props(VARIANT_TWO);
} else {
set_model_props(VARIANT_ONE);
}
}
void vendor_load_properties() {
set_device_model();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment