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

Commit 029ab21e authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11200327 from e3472113 to 24Q1-release

Change-Id: I93eae99749444ac9f5d3e229a6230c4fb802a5be
parents f9b90df9 e3472113
Loading
Loading
Loading
Loading
+29 −20
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ using namespace std::literals;

using android::base::ErrnoError;
using android::base::Error;
using android::base::GetIntProperty;
using android::base::GetProperty;
using android::base::ParseInt;
using android::base::ReadFileToString;
@@ -112,7 +113,7 @@ 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 API_LEVEL_CURRENT = 10000;
constexpr auto MAX_VENDOR_API_LEVEL = 1000000;

static bool persistent_properties_loaded = false;

@@ -1093,15 +1094,16 @@ static void property_initialize_ro_cpu_abilist() {
    }
}

static int read_api_level_props(const std::vector<std::string>& api_level_props) {
    int api_level = API_LEVEL_CURRENT;
    for (const auto& api_level_prop : api_level_props) {
        api_level = android::base::GetIntProperty(api_level_prop, API_LEVEL_CURRENT);
        if (api_level != API_LEVEL_CURRENT) {
            break;
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 api_level;
    return MAX_VENDOR_API_LEVEL;
}

static void property_initialize_ro_vendor_api_level() {
@@ -1109,20 +1111,27 @@ static void property_initialize_ro_vendor_api_level() {
    // required to support.
    constexpr auto VENDOR_API_LEVEL_PROP = "ro.vendor.api_level";

    // Api level properties of the board. The order of the properties must be kept.
    std::vector<std::string> BOARD_API_LEVEL_PROPS = {"ro.board.api_level",
                                                      "ro.board.first_api_level"};
    // Api level properties of the device. The order of the properties must be kept.
    std::vector<std::string> DEVICE_API_LEVEL_PROPS = {"ro.product.first_api_level",
                                                       "ro.build.version.sdk"};
    auto vendor_api_level = GetIntProperty("ro.board.first_api_level", MAX_VENDOR_API_LEVEL);
    if (vendor_api_level != MAX_VENDOR_API_LEVEL) {
        // 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);
    }

    auto product_first_api_level =
            GetIntProperty("ro.product.first_api_level", __ANDROID_API_FUTURE__);
    if (product_first_api_level == __ANDROID_API_FUTURE__) {
        // Fallback to "ro.build.version.sdk" if the "ro.product.first_api_level" is not defined.
        product_first_api_level = GetIntProperty("ro.build.version.sdk", __ANDROID_API_FUTURE__);
    }

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

    int api_level = std::min(read_api_level_props(BOARD_API_LEVEL_PROPS),
                             read_api_level_props(DEVICE_API_LEVEL_PROPS));
    std::string error;
    auto res = PropertySetNoSocket(VENDOR_API_LEVEL_PROP, std::to_string(api_level), &error);
    auto res = PropertySetNoSocket(VENDOR_API_LEVEL_PROP, std::to_string(vendor_api_level), &error);
    if (res != PROP_SUCCESS) {
        LOG(ERROR) << "Failed to set " << VENDOR_API_LEVEL_PROP << " with " << api_level << ": "
                   << error << "(" << res << ")";
        LOG(ERROR) << "Failed to set " << VENDOR_API_LEVEL_PROP << " with " << vendor_api_level
                   << ": " << error << "(" << res << ")";
    }
}

+7 −2
Original line number Diff line number Diff line
@@ -107,7 +107,11 @@ static unique_fd read_file(const char* file_name, off64_t* out_file_size) {
        return {};
    }

    assert(st.st_size >= 0);
    if (st.st_size == 0) {
        LOG(ERROR) << "Zero length file '" << file_name << "'";
        return {};
    }

    file_size = st.st_size;

    /* The dmabuf size needs to be a multiple of the page size */
@@ -123,7 +127,8 @@ static unique_fd read_file(const char* file_name, off64_t* out_file_size) {
    BufferAllocator alloc;
    unique_fd dmabuf_fd(alloc.Alloc(kDmabufSystemHeapName, file_page_size));
    if (!dmabuf_fd.ok()) {
        LOG(ERROR) << "Error creating dmabuf: " << dmabuf_fd.get();
        LOG(ERROR) << "Error creating dmabuf for " << file_page_size
                   << " bytes: " << dmabuf_fd.get();
        return dmabuf_fd;
    }