ueventd: deprecate paths without /etc/
ueventd.rc scripts belong in the /etc/ directory of their given
partition, not the root of the partition. This can cause problems,
especially since Android.bp cannot write to the root directly, forcing
vendors to use Android.mk for these files. Note that
/system/etc/ueventd.rc moved long ago.
Test: Tree-hugger
Change-Id: I2dcaafc3c3f687f76ab6bc38af979c8b43346db0
diff --git a/init/ueventd.cpp b/init/ueventd.cpp
index 923d769..331255b 100644
--- a/init/ueventd.cpp
+++ b/init/ueventd.cpp
@@ -16,6 +16,7 @@
#include "ueventd.h"
+#include <android/api-level.h>
#include <ctype.h>
#include <dirent.h>
#include <fcntl.h>
@@ -266,6 +267,17 @@
LOG(INFO) << "Coldboot took " << cold_boot_timer.duration().count() / 1000.0f << " seconds";
}
+static UeventdConfiguration GetConfiguration() {
+ // TODO: Remove these legacy paths once Android S is no longer supported.
+ 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"});
+ }
+
+ return ParseConfig({"/system/etc/ueventd.rc"});
+}
+
int ueventd_main(int argc, char** argv) {
/*
* init sets the umask to 077 for forked processes. We need to
@@ -283,7 +295,7 @@
std::vector<std::unique_ptr<UeventHandler>> uevent_handlers;
- auto ueventd_configuration = ParseConfig("/system/etc/ueventd.rc");
+ auto ueventd_configuration = GetConfiguration();
uevent_handlers.emplace_back(std::make_unique<DeviceHandler>(
std::move(ueventd_configuration.dev_permissions),