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

Commit 0dc944ff authored by Mark Salyzyn's avatar Mark Salyzyn Committed by Automerger Merge Worker
Browse files

Merge "init: support wait timeout with more precision" into rvc-dev am: 7a6a01a0

Change-Id: I832fd1d6183ba91e79d2407c2f08cbaf24be7df1
parents 099e5c9d 7a6a01a0
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -644,7 +644,8 @@ provides the `aidl_lazy_test_1` interface.
`wait <path> [ <timeout> ]`
> Poll for the existence of the given file and return when found,
  or the timeout has been reached. If timeout is not specified it
  currently defaults to five seconds.
  currently defaults to five seconds. The timeout value can be
  fractional seconds, specified in floating point notation.

`wait_for_prop <name> <value>`
> Wait for system property _name_ to be _value_. Properties are expanded
+5 −3
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@
#include <android-base/chrono_utils.h>
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/parsedouble.h>
#include <android-base/parseint.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
@@ -1065,11 +1066,12 @@ static Result<void> do_load_system_props(const BuiltinArguments& args) {
static Result<void> do_wait(const BuiltinArguments& args) {
    auto timeout = kCommandRetryTimeout;
    if (args.size() == 3) {
        int timeout_int;
        if (!android::base::ParseInt(args[2], &timeout_int)) {
        double timeout_double;
        if (!android::base::ParseDouble(args[2], &timeout_double, 0)) {
            return Error() << "failed to parse timeout";
        }
        timeout = std::chrono::seconds(timeout_int);
        timeout = std::chrono::duration_cast<std::chrono::nanoseconds>(
                std::chrono::duration<double>(timeout_double));
    }

    if (wait_for_file(args[1].c_str(), timeout) != 0) {
+3 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <sys/time.h>

#include <android-base/logging.h>
#include <android-base/parsedouble.h>
#include <android-base/parseint.h>
#include <android-base/strings.h>

@@ -205,8 +206,8 @@ Result<void> check_sysclktz(const BuiltinArguments& args) {

Result<void> check_wait(const BuiltinArguments& args) {
    if (args.size() == 3 && !args[2].empty()) {
        int timeout_int;
        if (!android::base::ParseInt(args[2], &timeout_int)) {
        double timeout_double;
        if (!android::base::ParseDouble(args[2], &timeout_double, 0)) {
            return Error() << "failed to parse timeout";
        }
    }