Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc645a1c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Use libvendorsupport for vendor api level calculation" into main

parents 44a7cadb 6bc1bfe1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -196,6 +196,7 @@ libinit_cc_defaults {
        "libselinux",
        "libunwindstack",
        "libutils",
        "libvendorsupport",
    ],
    header_libs: ["bionic_libc_platform_headers"],
    bootstrap: true,
+9 −15
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@
#include <selinux/android.h>
#include <selinux/label.h>
#include <selinux/selinux.h>
#include <vendorsupport/api_level.h>

#include "debug_ramdisk.h"
#include "epoll.h"
@@ -113,7 +114,6 @@ constexpr auto ID_PROP = "ro.build.id";
constexpr auto LEGACY_ID_PROP = "ro.build.legacy.id";
constexpr auto VBMETA_DIGEST_PROP = "ro.boot.vbmeta.digest";
constexpr auto DIGEST_SIZE_USED = 8;
constexpr auto MAX_VENDOR_API_LEVEL = 1000000;

static bool persistent_properties_loaded = false;

@@ -1085,25 +1085,13 @@ static void property_initialize_ro_cpu_abilist() {
    }
}

static int vendor_api_level_of(int sdk_api_level) {
    if (sdk_api_level < __ANDROID_API_V__) {
        return sdk_api_level;
    }
    // In Android V, vendor API level started with version 202404.
    // The calculation assumes that the SDK api level bumps once a year.
    if (sdk_api_level < __ANDROID_API_FUTURE__) {
        return 202404 + ((sdk_api_level - __ANDROID_API_V__) * 100);
    }
    return MAX_VENDOR_API_LEVEL;
}

static void property_initialize_ro_vendor_api_level() {
    // ro.vendor.api_level shows the api_level that the vendor images (vendor, odm, ...) are
    // required to support.
    constexpr auto VENDOR_API_LEVEL_PROP = "ro.vendor.api_level";

    auto vendor_api_level = GetIntProperty("ro.board.first_api_level", MAX_VENDOR_API_LEVEL);
    if (vendor_api_level != MAX_VENDOR_API_LEVEL) {
    auto vendor_api_level = GetIntProperty("ro.board.first_api_level", __ANDROID_VENDOR_API_MAX__);
    if (vendor_api_level != __ANDROID_VENDOR_API_MAX__) {
        // Update the vendor_api_level with "ro.board.api_level" only if both "ro.board.api_level"
        // and "ro.board.first_api_level" are defined.
        vendor_api_level = GetIntProperty("ro.board.api_level", vendor_api_level);
@@ -1118,6 +1106,12 @@ static void property_initialize_ro_vendor_api_level() {

    vendor_api_level = std::min(vendor_api_level_of(product_first_api_level), vendor_api_level);

    if (vendor_api_level < 0) {
        LOG(ERROR) << "Unexpected vendor api level for " << VENDOR_API_LEVEL_PROP << ". Check "
                   << "ro.product.first_api_level and ro.build.version.sdk.";
        vendor_api_level = __ANDROID_VENDOR_API_MAX__;
    }

    std::string error;
    auto res = PropertySetNoSocket(VENDOR_API_LEVEL_PROP, std::to_string(vendor_api_level), &error);
    if (res != PROP_SUCCESS) {
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package {
cc_library {
    name: "libvendorsupport",
    native_bridge_supported: true,
    recovery_available: true,
    llndk: {
        symbol_file: "libvendorsupport.map.txt",
    },