Skip to content

Commit 71dd706

Browse files
Tom CherryYifan Hong
Tom Cherry
authored and
Yifan Hong
committed
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
1 parent f2d359c commit 71dd706

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

init/ueventd.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "ueventd.h"
1818

19+
#include <android/api-level.h>
1920
#include <ctype.h>
2021
#include <dirent.h>
2122
#include <fcntl.h>
@@ -266,6 +267,17 @@ void ColdBoot::Run() {
266267
LOG(INFO) << "Coldboot took " << cold_boot_timer.duration().count() / 1000.0f << " seconds";
267268
}
268269

270+
static UeventdConfiguration GetConfiguration() {
271+
// TODO: Remove these legacy paths once Android S is no longer supported.
272+
if (android::base::GetIntProperty("ro.product.first_api_level", 10000) <= __ANDROID_API_S__) {
273+
auto hardware = android::base::GetProperty("ro.hardware", "");
274+
return ParseConfig({"/system/etc/ueventd.rc", "/vendor/ueventd.rc", "/odm/ueventd.rc",
275+
"/ueventd." + hardware + ".rc"});
276+
}
277+
278+
return ParseConfig({"/system/etc/ueventd.rc"});
279+
}
280+
269281
int ueventd_main(int argc, char** argv) {
270282
/*
271283
* init sets the umask to 077 for forked processes. We need to
@@ -283,7 +295,7 @@ int ueventd_main(int argc, char** argv) {
283295

284296
std::vector<std::unique_ptr<UeventHandler>> uevent_handlers;
285297

286-
auto ueventd_configuration = ParseConfig("/system/etc/ueventd.rc");
298+
auto ueventd_configuration = GetConfiguration();
287299

288300
uevent_handlers.emplace_back(std::make_unique<DeviceHandler>(
289301
std::move(ueventd_configuration.dev_permissions),

init/ueventd_parser.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Result<void> SubsystemParser::EndSection() {
230230
return {};
231231
}
232232

233-
UeventdConfiguration ParseConfig(const std::string& config) {
233+
UeventdConfiguration ParseConfig(const std::vector<std::string>& configs) {
234234
Parser parser;
235235
UeventdConfiguration ueventd_configuration;
236236

@@ -260,7 +260,9 @@ UeventdConfiguration ParseConfig(const std::string& config) {
260260
std::bind(ParseEnabledDisabledLine, _1,
261261
&ueventd_configuration.enable_parallel_restorecon));
262262

263-
parser.ParseConfig(config);
263+
for (const auto& config : configs) {
264+
parser.ParseConfig(config);
265+
}
264266

265267
return ueventd_configuration;
266268
}

init/ueventd_parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct UeventdConfiguration {
3636
bool enable_parallel_restorecon = false;
3737
};
3838

39-
UeventdConfiguration ParseConfig(const std::string& config);
39+
UeventdConfiguration ParseConfig(const std::vector<std::string>& configs);
4040

4141
} // namespace init
4242
} // namespace android

rootdir/ueventd.rc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import /vendor/ueventd.rc
2-
import /odm/ueventd.rc
3-
import /ueventd.${ro.hardware}.rc
1+
import /vendor/etc/ueventd.rc
2+
import /odm/etc/ueventd.rc
43

54
firmware_directories /etc/firmware/ /odm/firmware/ /vendor/firmware/ /firmware/image/
65
uevent_socket_rcvbuf_size 16M

0 commit comments

Comments
 (0)