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
diff --git a/init/apex_init_util.cpp b/init/apex_init_util.cpp
index e5a7fbc..809c805 100644
--- a/init/apex_init_util.cpp
+++ b/init/apex_init_util.cpp
@@ -101,14 +101,21 @@
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 {};