Skip to content

Commit

Permalink
init: unified r5x
Browse files Browse the repository at this point in the history
Signed-off-by: MD Raza <raza231198@gmail.com>
  • Loading branch information
MD Raza committed May 9, 2021
1 parent 4484e91 commit 66feade
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 4 deletions.
4 changes: 4 additions & 0 deletions BoardConfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_VENDORIMAGE_PARTITION_SIZE := 1452277760
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4

# Init
TARGET_INIT_VENDOR_LIB := libinit_r5x
TARGET_RECOVERY_DEVICE_MODULES := libinit_r5x

# System as root
BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
BOARD_ROOT_EXTRA_FOLDERS := bluetooth dsp firmware persist
Expand Down
26 changes: 26 additions & 0 deletions init/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright (C) 2020 The LineageOS Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

cc_library_static {
name: "libinit_r5x",
srcs: ["r5x.cpp"],
whole_static_libs: ["libbase"],
include_dirs: [
"system/core/base/include",
"system/core/init"
],
shared_libs: ["libbase"],
}
104 changes: 104 additions & 0 deletions init/r5x.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
Copyright (c) 2015, The Linux Foundation. All rights reserved.
Copyright (C) 2016 The CyanogenMod Project.
Copyright (C) 2019-2020 The LineageOS Project.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of The Linux Foundation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <cstdlib>
#include <unistd.h>
#include <fcntl.h>
#include <android-base/logging.h>
#include <android-base/properties.h>

#include "property_service.h"
#include "log.h"
#include <string>
#include <fstream>

namespace android {
namespace init {

void load_RMX1911() {
property_set("ro.product.model", "Realme 5");
property_set("ro.build.product", "RMX1911");
property_set("ro.product.device", "RMX1911");

}

void load_RMX1925() {
property_set("ro.product.model", "Realme 5s");
property_set("ro.build.product", "RMX1925");
property_set("ro.product.device", "RMX1925");

}

void load_RMX1927() {
property_set("ro.product.model", "Realme 5 NFC");
property_set("ro.build.product", "RMX1927");
property_set("ro.product.device", "RMX1927");

}

void load_RMX2030() {
property_set("ro.product.model", "Realme 5i");
property_set("ro.build.product", "RMX2030");
property_set("ro.product.device", "RMX2030");

}

void vendor_load_properties()
{
std::ifstream infile("/proc/oppoVersion/prjVersion");
std::string prjVersion;
getline(infile, prjVersion);

std::ifstream fin;
std::string buf;
fin.open("/proc/cmdline");
while (std::getline(fin, buf, ' '))
if (buf.find("board_id") != std::string::npos)
break;
fin.close();

if (prjVersion == "19743")
{
load_RMX2030();
}
else if (prjVersion == "19632")
{
load_RMX1927();
}
else
{
if (buf.find("S86125AA1") != std::string::npos) {
load_RMX1925();
} else {
load_RMX1911();
}
}
}
} // namespace init
} // namespace android
8 changes: 4 additions & 4 deletions omni_r5x.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PRODUCT_PROPERTY_OVERRIDES += \
ro.vendor.build.security_patch=2099-12-31 \
ro.separate.soft="19631"

# PRODUCT_SYSTEM_PROPERTY_BLACKLIST += \
# ro.product.device \
# ro.product.name \
# ro.build.product
PRODUCT_SYSTEM_PROPERTY_BLACKLIST += \
ro.product.model \
ro.build.product \
ro.product.device

0 comments on commit 66feade

Please sign in to comment.