diff options
author | Keun-young Park <keunyoung@google.com> | 2017-02-28 22:39:40 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-02-28 22:39:41 +0000 |
commit | ad37e2b37b725960cf0d11dcc6295577f0e55cde (patch) | |
tree | 20c147c146104345184907019d2c571c6c79210f | |
parent | ecfdacd86c300c3afb053eabb6f974df78fd8614 (diff) | |
parent | 8575745a91d33a21421f34471b3c631510583ded (diff) | |
download | libhidl-ad37e2b37b725960cf0d11dcc6295577f0e55cde.tar.gz |
Merge "replace sleep wait into property wait"
-rw-r--r-- | transport/LegacySupport.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/transport/LegacySupport.cpp b/transport/LegacySupport.cpp index 17371d4..0032fc3 100644 --- a/transport/LegacySupport.cpp +++ b/transport/LegacySupport.cpp @@ -15,36 +15,39 @@ */ #define LOG_TAG "libhidltransport" +#include <inttypes.h> + #include <hidl/LegacySupport.h> #include <chrono> -#include <cutils/properties.h> #include <thread> #include <utils/misc.h> #include <utils/Log.h> +#include <utils/SystemClock.h> + +#include <android-base/properties.h> namespace android { namespace hardware { -static const char* kDataProperty = "vold.post_fs_data_done"; - -void waitForData() { - using namespace std::literals::chrono_literals; - - // TODO(b/34274385) remove this - while (!property_get_bool(kDataProperty, false)) { - std::this_thread::sleep_for(300ms); - } +namespace details { - // TODO(b/35178781) wait a bit longer - std::this_thread::sleep_for(300ms); -} +using android::base::GetBoolProperty; +using android::base::GetUintProperty; +using android::base::WaitForPropertyCreation; -namespace details { +static const char* kPersistPropReadyProperty = "ro.boottime.persistent_properties"; +static const char* kBinderizationProperty = "persist.hal.binderization"; bool blockingHalBinderizationEnabled() { - waitForData(); - return property_get_bool("persist.hal.binderization", false); + uint64_t t = GetUintProperty<uint64_t>(kPersistPropReadyProperty, 0, UINT64_MAX); + if (t == 0) { // not set yet + int64_t startTime = elapsedRealtime(); + WaitForPropertyCreation(kPersistPropReadyProperty, std::chrono::milliseconds::max()); + ALOGI("Waiting for %s took %" PRId64 " ms", kPersistPropReadyProperty, + elapsedRealtime() - startTime); + } + return GetBoolProperty(kBinderizationProperty, false); } void blockIfBinderizationDisabled(const std::string& interface, |