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

Commit 44eae39c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use AVendorSupport_getVendorApiLevel instead of ro.board.api_level" into main

parents f43e21a8 f50484fe
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -227,3 +227,13 @@ flag {
       purpose: PURPOSE_BUGFIX
     }
}

flag {
     namespace: "camera_platform"
     name: "use_system_api_for_vndk_version"
     description: "ro.board.api_level isn't reliable. Use system api to replace ro.vndk.version"
     bug: "312315580"
     metadata {
       purpose: PURPOSE_BUGFIX
     }
}
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ cc_defaults {
        "libsensorprivacy",
        "libstagefright",
        "libstagefright_foundation",
        "libvendorsupport",
        "libxml2",
        "libyuv",
        "android.companion.virtual.virtualdevice_aidl-cpp",
+24 −4
Original line number Diff line number Diff line
@@ -21,18 +21,20 @@
#include <com_android_internal_camera_flags.h>
#include <utils/Errors.h>
#include <utils/Log.h>
#include <vendorsupport/api_level.h>

namespace android {

namespace flags = com::android::internal::camera::flags;

namespace {
constexpr const char* LEGACY_VNDK_VERSION_PROP = "ro.vndk.version";
constexpr const char* BOARD_API_LEVEL_PROP = "ro.board.api_level";
constexpr int MAX_VENDOR_API_LEVEL = 1000000;
constexpr int FIRST_VNDK_VERSION = 202404;

int getVNDKVersionFromProp(int defaultVersion) {
    if (!com_android_internal_camera_flags_use_ro_board_api_level_for_vndk_version()) {
int legacyGetVNDKVersionFromProp(int defaultVersion) {
    if (!flags::use_ro_board_api_level_for_vndk_version()) {
        return base::GetIntProperty(LEGACY_VNDK_VERSION_PROP, defaultVersion);
    }

@@ -54,6 +56,24 @@ int getVNDKVersionFromProp(int defaultVersion) {
    vndkVersion = (vndkVersion - FIRST_VNDK_VERSION) / 100;
    return __ANDROID_API_V__ + vndkVersion;
}
}  // anonymous namespace

int getVNDKVersionFromProp(int defaultVersion) {
    if (!flags::use_system_api_for_vndk_version()) {
        return legacyGetVNDKVersionFromProp(defaultVersion);
    }

    int vendorApiLevel = AVendorSupport_getVendorApiLevel();
    if (vendorApiLevel == 0) {
        // Couldn't find vendor API level, return default
        return defaultVersion;
    }

    // Vendor API level for Android V and above are of the format YYYYMM starting with 202404.
    // AVendorSupport_getSdkApiLevelOf maps them back to SDK API levels while leaving older
    // values unchanged.
    return AVendorSupport_getSdkApiLevelOf(vendorApiLevel);
}

RunThreadWithRealtimePriority::RunThreadWithRealtimePriority(int tid)
    : mTid(tid), mPreviousPolicy(sched_getscheduler(tid)) {