From a6af9bced3f7d7c25d62db36b404cf21b5fbf51d Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Tue, 15 Oct 2024 14:41:49 +0900 Subject: [PATCH] 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 --- init/apex_init_util.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/init/apex_init_util.cpp b/init/apex_init_util.cpp index e5a7fbcc0..809c805c4 100644 --- a/init/apex_init_util.cpp +++ b/init/apex_init_util.cpp @@ -101,14 +101,21 @@ std::set 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 ParseRcScripts(const std::vector& 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 {};