From 8ce23dc44ea588329961bd1cd760f8d5380f2988 Mon Sep 17 00:00:00 2001 From: Justin Yun Date: Thu, 15 Feb 2024 15:46:59 +0900 Subject: [PATCH] Rename functions in libvendorsupport Follow platform naming conventions for an LLNDK library. Bug: 325093550 Test: atest libvendorsupport-tests Change-Id: Id93f7e66a47ae9250191f9827a76ce819e8f6f88 --- init/property_service.cpp | 3 ++- .../include/vendorsupport/api_level.h | 22 +++++++---------- libvendorsupport/libvendorsupport.map.txt | 4 ++-- libvendorsupport/tests/version_props_test.cpp | 18 +++++++------- libvendorsupport/version_props.c | 24 +++++++++---------- 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index 30ad80036..bc4ef424b 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -1104,7 +1104,8 @@ static void property_initialize_ro_vendor_api_level() { 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); + vendor_api_level = + std::min(AVendorSupport_getVendorApiLevelOf(product_first_api_level), vendor_api_level); if (vendor_api_level < 0) { LOG(ERROR) << "Unexpected vendor api level for " << VENDOR_API_LEVEL_PROP << ". Check " diff --git a/libvendorsupport/include/vendorsupport/api_level.h b/libvendorsupport/include/vendorsupport/api_level.h index ba1a6b887..d365075e0 100644 --- a/libvendorsupport/include/vendorsupport/api_level.h +++ b/libvendorsupport/include/vendorsupport/api_level.h @@ -14,38 +14,34 @@ #pragma once -#include +#include + +__BEGIN_DECLS #define __ANDROID_VENDOR_API_MAX__ 1000000 #define __INVALID_API_LEVEL -1 -#ifdef __cplusplus -extern "C" { -#endif - /** * @brief Find corresponding vendor API level from an SDK API version. * * @details * SDK API versions and vendor API levels are not compatible and not - * convertible. However, this function can be used to compare the two versions + * exchangeable. However, this function can be used to compare the two versions * to know which one is newer than the other. * - * @param sdk_api_level The SDK version int. This must be less than 10000. + * @param sdkApiLevel The SDK version int. This must be less than 10000. * @return The corresponding vendor API level of the SDK version. -1 if the SDK * version is invalid or 10000. */ -int vendor_api_level_of(int sdk_api_level); +int AVendorSupport_getVendorApiLevelOf(int sdkApiLevel); /** * @brief Find corresponding SDK API version from a vendor API level. * - * @param vendor_api_level The vendor API level int. + * @param vendorApiLevel The vendor API level int. * @return The corresponding SDK API version of the vendor API level. -1 if the * vendor API level is invalid. */ -int sdk_api_level_of(int vendor_api_level); +int AVendorSupport_getSdkApiLevelOf(int vendorApiLevel); -#ifdef __cplusplus -} -#endif +__END_DECLS diff --git a/libvendorsupport/libvendorsupport.map.txt b/libvendorsupport/libvendorsupport.map.txt index 9a23b940f..d99c834e9 100644 --- a/libvendorsupport/libvendorsupport.map.txt +++ b/libvendorsupport/libvendorsupport.map.txt @@ -1,7 +1,7 @@ LIBVENDORSUPPORT { global: - vendor_api_level_of; # llndk systemapi - sdk_api_level_of; # llndk systemapi + AVendorSupport_getVendorApiLevelOf; # llndk systemapi + AVendorSupport_getSdkApiLevelOf; # llndk systemapi local: *; }; diff --git a/libvendorsupport/tests/version_props_test.cpp b/libvendorsupport/tests/version_props_test.cpp index 538a2e26b..ad54c8895 100644 --- a/libvendorsupport/tests/version_props_test.cpp +++ b/libvendorsupport/tests/version_props_test.cpp @@ -21,17 +21,17 @@ using namespace std; namespace { -TEST(vendorsupport, get_corresponding_vendor_api_level) { - ASSERT_EQ(__ANDROID_API_U__, vendor_api_level_of(__ANDROID_API_U__)); - ASSERT_EQ(202404, vendor_api_level_of(__ANDROID_API_V__)); - ASSERT_EQ(__INVALID_API_LEVEL, vendor_api_level_of(__ANDROID_API_FUTURE__)); +TEST(VendorSupport, GetCorrespondingVendorApiLevel) { + ASSERT_EQ(__ANDROID_API_U__, AVendorSupport_getVendorApiLevelOf(__ANDROID_API_U__)); + ASSERT_EQ(202404, AVendorSupport_getVendorApiLevelOf(__ANDROID_API_V__)); + ASSERT_EQ(__INVALID_API_LEVEL, AVendorSupport_getVendorApiLevelOf(__ANDROID_API_FUTURE__)); } -TEST(vendorsupport, get_corresponding_sdk_api_level) { - ASSERT_EQ(__ANDROID_API_U__, sdk_api_level_of(__ANDROID_API_U__)); - ASSERT_EQ(__ANDROID_API_V__, sdk_api_level_of(202404)); - ASSERT_EQ(__INVALID_API_LEVEL, sdk_api_level_of(__ANDROID_VENDOR_API_MAX__)); - ASSERT_EQ(__INVALID_API_LEVEL, sdk_api_level_of(35)); +TEST(VendorSupport, GetCorrespondingSdkApiLevel) { + ASSERT_EQ(__ANDROID_API_U__, AVendorSupport_getSdkApiLevelOf(__ANDROID_API_U__)); + ASSERT_EQ(__ANDROID_API_V__, AVendorSupport_getSdkApiLevelOf(202404)); + ASSERT_EQ(__INVALID_API_LEVEL, AVendorSupport_getSdkApiLevelOf(__ANDROID_VENDOR_API_MAX__)); + ASSERT_EQ(__INVALID_API_LEVEL, AVendorSupport_getSdkApiLevelOf(35)); } } // namespace \ No newline at end of file diff --git a/libvendorsupport/version_props.c b/libvendorsupport/version_props.c index 4d0e45ecf..835828c0a 100644 --- a/libvendorsupport/version_props.c +++ b/libvendorsupport/version_props.c @@ -16,26 +16,26 @@ #include -int vendor_api_level_of(int sdk_api_level) { - if (sdk_api_level < __ANDROID_API_V__) { - return sdk_api_level; +int AVendorSupport_getVendorApiLevelOf(int sdkApiLevel) { + if (sdkApiLevel < __ANDROID_API_V__) { + return sdkApiLevel; } // 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); + if (sdkApiLevel < __ANDROID_API_FUTURE__) { + return 202404 + ((sdkApiLevel - __ANDROID_API_V__) * 100); } - ALOGE("The SDK version must be less than 10000: %d", sdk_api_level); + ALOGE("The SDK version must be less than 10000: %d", sdkApiLevel); return __INVALID_API_LEVEL; } -int sdk_api_level_of(int vendor_api_level) { - if (vendor_api_level < __ANDROID_API_V__) { - return vendor_api_level; +int AVendorSupport_getSdkApiLevelOf(int vendorApiLevel) { + if (vendorApiLevel < __ANDROID_API_V__) { + return vendorApiLevel; } - if (vendor_api_level >= 202404 && vendor_api_level < __ANDROID_VENDOR_API_MAX__) { - return (vendor_api_level - 202404) / 100 + __ANDROID_API_V__; + if (vendorApiLevel >= 202404 && vendorApiLevel < __ANDROID_VENDOR_API_MAX__) { + return (vendorApiLevel - 202404) / 100 + __ANDROID_API_V__; } - ALOGE("Unexpected vendor api level: %d", vendor_api_level); + ALOGE("Unexpected vendor api level: %d", vendorApiLevel); return __INVALID_API_LEVEL; }