device_xiaomi_miatoll/libinit/libinit_variant.cpp
Alexander Winkowski e5f08782f3
sm6250-common: Update copyright headers in modified files
Change-Id: I256eb65e4e2df3bb4cca174145976bd46016aed1
2022-09-04 09:45:28 +00:00

43 lines
1.3 KiB
C++

/*
* Copyright (C) 2021-2022 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <android-base/properties.h>
#include <libinit_utils.h>
#include <libinit_variant.h>
using android::base::GetProperty;
#define HWC_PROP "ro.boot.hwc"
#define HWNAME_PROP "ro.boot.hwname"
#define SKU_PROP "ro.boot.product.hardware.sku"
void search_variant(const std::vector<variant_info_t> variants) {
std::string hwc_value = GetProperty(HWC_PROP, "");
std::string hwname_value = GetProperty(HWNAME_PROP, "");
for (const auto& variant : variants) {
if ((variant.hwc_value == "" || variant.hwc_value == hwc_value) && (variant.device == hwname_value)) {
set_variant_props(variant);
break;
}
}
}
void set_variant_props(const variant_info_t variant) {
set_ro_build_prop("brand", variant.brand, true);
set_ro_build_prop("device", variant.device, true);
set_ro_build_prop("model", variant.model, true);
set_ro_build_prop("fingerprint", variant.build_fingerprint);
property_override("ro.bootimage.build.fingerprint", variant.build_fingerprint);
property_override("ro.build.description", fingerprint_to_description(variant.build_fingerprint));
if (variant.nfc)
property_override(SKU_PROP, "nfc");
}