Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6af9bce authored by Jooyung Han's avatar Jooyung Han
Browse files

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
parent b3c9db48
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -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 {};