diff options
author | Tom Cherry <tomcherry@google.com> | 2019-08-19 15:21:25 -0700 |
---|---|---|
committer | Tom Cherry <tomcherry@google.com> | 2019-12-04 15:43:21 -0800 |
commit | c88d8f93cfaa8cbf368a0fa94e8bc84bc55c3ece (patch) | |
tree | 3caaa75251230d98f2b21dadd9b8892c2442c976 /init/util.cpp | |
parent | f7a6c4587f06bc7e79748acd97dc4dd5b741f328 (diff) |
init: Replace property_set() with android::base::SetProperty()
Init is no longer a special case and talks to property service just
like every other client, therefore move it away from property_set()
and to android::base::SetProperty().
In doing so, this change moves the initial property set up from the
kernel command line and property files directly into PropertyInit().
This makes the responsibilities between init and property services
more clear.
Test: boot, unit test cases
Change-Id: I36b8c83e845d887f1b203355c2391ec123c3d05f
Diffstat (limited to 'init/util.cpp')
-rw-r--r-- | init/util.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/init/util.cpp b/init/util.cpp index e5254dddf..0ca0da5d0 100644 --- a/init/util.cpp +++ b/init/util.cpp @@ -234,15 +234,14 @@ int wait_for_file(const char* filename, std::chrono::nanoseconds timeout) { return -1; } -void import_kernel_cmdline(bool in_qemu, - const std::function<void(const std::string&, const std::string&, bool)>& fn) { +void ImportKernelCmdline(const std::function<void(const std::string&, const std::string&)>& fn) { std::string cmdline; android::base::ReadFileToString("/proc/cmdline", &cmdline); for (const auto& entry : android::base::Split(android::base::Trim(cmdline), " ")) { std::vector<std::string> pieces = android::base::Split(entry, "="); if (pieces.size() == 2) { - fn(pieces[0], pieces[1], in_qemu); + fn(pieces[0], pieces[1]); } } } @@ -359,12 +358,11 @@ static std::string init_android_dt_dir() { // Use the standard procfs-based path by default std::string android_dt_dir = kDefaultAndroidDtDir; // The platform may specify a custom Android DT path in kernel cmdline - import_kernel_cmdline(false, - [&](const std::string& key, const std::string& value, bool in_qemu) { - if (key == "androidboot.android_dt_dir") { - android_dt_dir = value; - } - }); + ImportKernelCmdline([&](const std::string& key, const std::string& value) { + if (key == "androidboot.android_dt_dir") { + android_dt_dir = value; + } + }); LOG(INFO) << "Using Android DT directory " << android_dt_dir; return android_dt_dir; } |