platform_device_motorola_sm.../libinit/init_sm6225.cpp
dianlujitao 799d86bb52 sm6225-common: Add init extension to override ro.carrier
Change-Id: I82ec6b0d2293dc13524660fd0e2539f08ced2f9f
2023-07-26 23:32:33 +05:30

30 lines
854 B
C++

/*
* Copyright (C) 2022 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"
using android::base::GetProperty;
namespace {
void PropertyOverride(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());
}
}
}; // anonymous namespace
void vendor_load_properties() {
std::string value = GetProperty("ro.boot.carrier", "");
if (!value.empty()) PropertyOverride("ro.carrier", value);
}