init: filter .##rc with preview SDK version

On a preview device (where codename is not "REL"), filtering .##rc files
will choose the highest versions reglardless of ro.build.version.sdk.

Bug: n/a
Test: add .36rc to an apex and see if init reads it.
Change-Id: Icd63cf70e45cc14504f839ce9492e1766147a40e
This commit is contained in:
Jooyung Han 2024-10-15 14:41:49 +09:00
parent b3c9db481f
commit a6af9bced3

View file

@ -101,14 +101,21 @@ std::set<std::string> GetApexListFrom(const std::string& apex_dir) {
return apex_list;
}
static int GetCurrentSdk() {
bool is_preview = base::GetProperty("ro.build.version.codename", "") != "REL";
if (is_preview) {
return __ANDROID_API_FUTURE__;
}
return android::base::GetIntProperty("ro.build.version.sdk", __ANDROID_API_FUTURE__);
}
static Result<void> ParseRcScripts(const std::vector<std::string>& files) {
if (files.empty()) {
return {};
}
// APEXes can have versioned RC files. These should be filtered based on
// SDK version.
int sdk = android::base::GetIntProperty("ro.build.version.sdk", INT_MAX);
if (sdk < 35) sdk = 35; // aosp/main merges only into sdk=35+ (ie. __ANDROID_API_V__+)
static int sdk = GetCurrentSdk();
auto filtered = FilterVersionedConfigs(files, sdk);
if (filtered.empty()) {
return {};