Loading libvendorsupport/Android.bp +2 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ cc_library { llndk: { symbol_file: "libvendorsupport.map.txt", }, srcs: ["version_props.c"], srcs: ["version_props.cpp"], cflags: [ "-Wall", "-Werror", Loading @@ -32,6 +32,7 @@ cc_library { export_include_dirs: ["include"], shared_libs: [ "liblog", "libbase", ], } Loading libvendorsupport/include/vendorsupport/api_level.h +18 −0 Original line number Diff line number Diff line Loading @@ -44,4 +44,22 @@ int AVendorSupport_getVendorApiLevelOf(int sdkApiLevel); */ int AVendorSupport_getSdkApiLevelOf(int vendorApiLevel); #if !defined(__ANDROID_VENDOR__) /** * @brief Provide vendor API level to system modules. * * @details * Before deprecating VNDK, system modules read ro.vndk.version to find the * API level that vendor image had implemented. With the VNDK deprecation, this * must be replaced with ro.board.api_level. However, there still are devices * keeping old vendor partitions with the new system upgraded. In this case, the * VNDK version can be used as before. * This API is for platform only. * * @return ro.vndk.version if exist. Otherwise fallback to ro.board.api_level. * 0 if none of these properties are found. This is unexpected, though. */ int AVendorSupport_getVendorApiLevel(); #endif // __ANDROID_VENDOR__ __END_DECLS libvendorsupport/version_props.c→libvendorsupport/version_props.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ #include <log/log.h> #if !defined(__ANDROID_VENDOR__) #include <android-base/properties.h> #endif int AVendorSupport_getVendorApiLevelOf(int sdkApiLevel) { if (sdkApiLevel < __ANDROID_API_V__) { return sdkApiLevel; Loading @@ -39,3 +43,13 @@ int AVendorSupport_getSdkApiLevelOf(int vendorApiLevel) { ALOGE("Unexpected vendor api level: %d", vendorApiLevel); return __INVALID_API_LEVEL; } #if !defined(__ANDROID_VENDOR__) int AVendorSupport_getVendorApiLevel() { int vendorApiLevel = android::base::GetIntProperty("ro.vndk.version", 0); if (vendorApiLevel) { return vendorApiLevel; } return android::base::GetIntProperty("ro.board.api_level", 0); } #endif // __ANDROID_VENDOR__ Loading
libvendorsupport/Android.bp +2 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ cc_library { llndk: { symbol_file: "libvendorsupport.map.txt", }, srcs: ["version_props.c"], srcs: ["version_props.cpp"], cflags: [ "-Wall", "-Werror", Loading @@ -32,6 +32,7 @@ cc_library { export_include_dirs: ["include"], shared_libs: [ "liblog", "libbase", ], } Loading
libvendorsupport/include/vendorsupport/api_level.h +18 −0 Original line number Diff line number Diff line Loading @@ -44,4 +44,22 @@ int AVendorSupport_getVendorApiLevelOf(int sdkApiLevel); */ int AVendorSupport_getSdkApiLevelOf(int vendorApiLevel); #if !defined(__ANDROID_VENDOR__) /** * @brief Provide vendor API level to system modules. * * @details * Before deprecating VNDK, system modules read ro.vndk.version to find the * API level that vendor image had implemented. With the VNDK deprecation, this * must be replaced with ro.board.api_level. However, there still are devices * keeping old vendor partitions with the new system upgraded. In this case, the * VNDK version can be used as before. * This API is for platform only. * * @return ro.vndk.version if exist. Otherwise fallback to ro.board.api_level. * 0 if none of these properties are found. This is unexpected, though. */ int AVendorSupport_getVendorApiLevel(); #endif // __ANDROID_VENDOR__ __END_DECLS
libvendorsupport/version_props.c→libvendorsupport/version_props.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ #include <log/log.h> #if !defined(__ANDROID_VENDOR__) #include <android-base/properties.h> #endif int AVendorSupport_getVendorApiLevelOf(int sdkApiLevel) { if (sdkApiLevel < __ANDROID_API_V__) { return sdkApiLevel; Loading @@ -39,3 +43,13 @@ int AVendorSupport_getSdkApiLevelOf(int vendorApiLevel) { ALOGE("Unexpected vendor api level: %d", vendorApiLevel); return __INVALID_API_LEVEL; } #if !defined(__ANDROID_VENDOR__) int AVendorSupport_getVendorApiLevel() { int vendorApiLevel = android::base::GetIntProperty("ro.vndk.version", 0); if (vendorApiLevel) { return vendorApiLevel; } return android::base::GetIntProperty("ro.board.api_level", 0); } #endif // __ANDROID_VENDOR__