Finalization bugfixes.

Keep isAtLeast* functions compatible with older release configs.

Fixes: 329312253
Test: local run + presubmit
Ignore-AOSP-First: release configs present in internal repo only
Change-Id: I776dd808e2e01e8a1c7a6f9b6171fd84f49cdcdf
This commit is contained in:
Alex Buynytskyy
2024-03-13 18:29:25 +00:00
parent 4fb99d85e6
commit f05c249d2a

View File

@@ -34,7 +34,8 @@ function finalize_modules_utils() {
echo " /** Checks if the device is running on a release version of Android $FINAL_PLATFORM_CODENAME or newer */ echo " /** Checks if the device is running on a release version of Android $FINAL_PLATFORM_CODENAME or newer */
@ChecksSdkIntAtLeast(api = $FINAL_PLATFORM_SDK_VERSION /* BUILD_VERSION_CODES.$FINAL_PLATFORM_CODENAME */) @ChecksSdkIntAtLeast(api = $FINAL_PLATFORM_SDK_VERSION /* BUILD_VERSION_CODES.$FINAL_PLATFORM_CODENAME */)
public static boolean isAtLeast${FINAL_PLATFORM_CODENAME:0:1}() { public static boolean isAtLeast${FINAL_PLATFORM_CODENAME:0:1}() {
return SDK_INT >= $FINAL_PLATFORM_SDK_VERSION; return SDK_INT >= $FINAL_PLATFORM_SDK_VERSION ||
(SDK_INT == $(($FINAL_PLATFORM_SDK_VERSION - 1)) && isAtLeastPreReleaseCodename(\"$FINAL_PLATFORM_CODENAME\"));
}" > "$tmpfile" }" > "$tmpfile"
local javaFuncRegex='\/\*\*[^{]*isAtLeast'"${shortCodename}"'() {[^{}]*}' local javaFuncRegex='\/\*\*[^{]*isAtLeast'"${shortCodename}"'() {[^{}]*}'
@@ -48,7 +49,11 @@ function finalize_modules_utils() {
d}' $javaSdkLevel d}' $javaSdkLevel
echo "// Checks if the device is running on release version of Android ${FINAL_PLATFORM_CODENAME:0:1} or newer. echo "// Checks if the device is running on release version of Android ${FINAL_PLATFORM_CODENAME:0:1} or newer.
inline bool IsAtLeast${FINAL_PLATFORM_CODENAME:0:1}() { return android_get_device_api_level() >= $FINAL_PLATFORM_SDK_VERSION; }" > "$tmpfile" inline bool IsAtLeast${FINAL_PLATFORM_CODENAME:0:1}() {
return android_get_device_api_level() >= $FINAL_PLATFORM_SDK_VERSION ||
(android_get_device_api_level() == $(($FINAL_PLATFORM_SDK_VERSION - 1)) &&
detail::IsAtLeastPreReleaseCodename(\"$FINAL_PLATFORM_CODENAME\"));
}" > "$tmpfile"
local cppFuncRegex='\/\/[^{]*IsAtLeast'"${shortCodename}"'() {[^{}]*}' local cppFuncRegex='\/\/[^{]*IsAtLeast'"${shortCodename}"'() {[^{}]*}'
local cppFuncReplace="N;N;N;N;N;N; s/$cppFuncRegex/$methodPlaceholder/; /$cppFuncRegex/!{P;D};" local cppFuncReplace="N;N;N;N;N;N; s/$cppFuncRegex/$methodPlaceholder/; /$cppFuncRegex/!{P;D};"