Skip to content

Commit

Permalink
porsche: libinit: Set model based on ro.boot.prjname
Browse files Browse the repository at this point in the history
Change-Id: I06f9acda3fe77f57a1bc24ee5a802db0ab3b8d60
  • Loading branch information
danielml3 authored and resist15 committed Aug 5, 2023
1 parent 5f86056 commit bdcceb2
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
3 changes: 3 additions & 0 deletions BoardConfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ BOARD_INCLUDE_RECOVERY_DTBO := true
# GPS
LOC_HIDL_VERSION = 4.0

# Init
TARGET_INIT_VENDOR_LIB := //$(DEVICE_PATH):libinit_porsche

# Kernel
BOARD_KERNEL_BASE := 0x00000000
BOARD_KERNEL_CMDLINE := \
Expand Down
20 changes: 20 additions & 0 deletions libinit/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2023 Paranoid Android
//
// 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_porsche",
recovery_available: true,
shared_libs: ["libbase"],
srcs: ["init_porsche.cpp"],
}
61 changes: 61 additions & 0 deletions libinit/init_porsche.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (C) 2023 Paranoid Android
* SPDX-License-Identifier: Apache-2.0
*/

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

#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>

using android::base::GetProperty;

/*
* SetProperty does not allow updating read only properties and as a result
* does not work for our use case. Write "OverrideProperty" to do practically
* the same thing as "SetProperty" without this restriction.
*/
void OverrideProperty(const char* name, const char* value) {
size_t valuelen = strlen(value);

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

/*
* Only for read-only properties. Properties that can be wrote to more
* than once should be set in a typical init script (e.g. init.oplus.hw.rc)
* after the original property has been set.
*/
void vendor_load_properties() {
auto prjname = std::stoi(GetProperty("ro.boot.prjname", "0"));
char* build_desc;
char* build_fingerprint;
char* product_model;
char* product_name;

switch (prjname) {
case 136882:
product_name = "RMX3312";
product_model = "RMX3312";
build_desc = "qssi-user 13 TP1A.220905.001 1673407054945 release-keys";
build_fingerprint = "realme/RMX3312/RE58B2L1:13/TP1A.220905.001/S.d7a144-1-3cc75:user/release-keys";
break;
default:
product_name = "RMX3311EEA";
product_model = "RMX3311";
build_desc = "qssi-user 13 TP1A.220905.001 1682070307948 release-keys";
build_fingerprint = "realme/RMX3311EEA/RE58B2L1:13/TP1A.220905.001/S.fe5caa-da01-3c05a:user/release-keys";
break;
}

OverrideProperty("ro.product.model", product_model);
OverrideProperty("ro.product.name", product_name);
OverrideProperty("ro.build.fingerprint", build_fingerprint);
OverrideProperty("ro.build.description", build_desc);
}

0 comments on commit bdcceb2

Please sign in to comment.