From 0050bef9e1ca300e17c9dca18f6861b526f3ee14 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 2 Jun 2021 18:21:07 -0700 Subject: [PATCH] Warn loudly if using deprecated ueventd paths. Bug: 189268918 Test: treehugger Change-Id: Ib4cfa4f3a1f4626afcd37278d93390ad34b0216b --- init/ueventd.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/init/ueventd.cpp b/init/ueventd.cpp index 331255b1e..f9ee9e307 100644 --- a/init/ueventd.cpp +++ b/init/ueventd.cpp @@ -268,14 +268,27 @@ void ColdBoot::Run() { } static UeventdConfiguration GetConfiguration() { - // TODO: Remove these legacy paths once Android S is no longer supported. + auto hardware = android::base::GetProperty("ro.hardware", ""); + std::vector legacy_paths{"/vendor/ueventd.rc", "/odm/ueventd.rc", + "/ueventd." + hardware + ".rc"}; + + std::vector canonical{"/system/etc/ueventd.rc"}; + if (android::base::GetIntProperty("ro.product.first_api_level", 10000) <= __ANDROID_API_S__) { - auto hardware = android::base::GetProperty("ro.hardware", ""); - return ParseConfig({"/system/etc/ueventd.rc", "/vendor/ueventd.rc", "/odm/ueventd.rc", - "/ueventd." + hardware + ".rc"}); + // TODO: Remove these legacy paths once Android S is no longer supported. + canonical.insert(canonical.end(), legacy_paths.begin(), legacy_paths.end()); + } else { + // Warn if newer device is using legacy paths. + for (const auto& path : legacy_paths) { + if (access(path.c_str(), F_OK) == 0) { + LOG(FATAL_WITHOUT_ABORT) + << "Legacy ueventd configuration file detected and will not be parsed: " + << path; + } + } } - return ParseConfig({"/system/etc/ueventd.rc"}); + return ParseConfig(canonical); } int ueventd_main(int argc, char** argv) {