Use __ANDROID_VENDOR_API__ for vendor API surface

Build system defines __ANDROID_VENDOR_API__ for non-system modules.
Use this flag to provide vendor API surface for vendor or product
variant modules.

Bug: 368559337
Test: atest AImageReaderWindowTest
Change-Id: I7da3d4ca9f92255a426af8d66b4391f3c1426759
This commit is contained in:
Justin Yun 2024-10-06 13:43:59 +09:00
parent 7cc50a8c29
commit 3a7cb4c637

View file

@ -25,15 +25,15 @@
__attribute__((annotate("introduced_in_llndk=" #vendor_api_level)))
#endif
#if defined(__ANDROID_VNDK__)
#if defined(__ANDROID_VENDOR_API__)
// __ANDROID_VENDOR_API__ is defined only for vendor or product variant modules.
// Use this macro as an `if` statement to call an API that are available to both NDK and LLNDK.
// This returns true for the vendor modules if the vendor_api_level is less than or equal to the
// ro.board.api_level.
// This returns true for vendor or product modules if the vendor_api_level is less than or equal to
// the ro.board.api_level.
#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) \
constexpr(__ANDROID_VENDOR_API__ >= vendor_api_level)
#else // __ANDROID_VNDK__
#else // __ANDROID_VENDOR_API__
// For non-vendor modules, API_LEVEL_AT_LEAST is replaced with __builtin_available(sdk_api_level) to
// guard the API for __INTRODUCED_IN.
@ -42,4 +42,4 @@
(__builtin_available(android sdk_api_level, *))
#endif
#endif // __ANDROID_VNDK__
#endif // __ANDROID_VENDOR_API__