diff --git a/Utils.cpp b/Utils.cpp index 15b3c0b..529cfb2 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -20,11 +20,11 @@ #include #include +#include #include #include -#include -#include #include +#include #include #include @@ -639,19 +639,12 @@ dev_t GetDevice(const std::string& path) { status_t RestoreconRecursive(const std::string& path) { LOG(VERBOSE) << "Starting restorecon of " << path; - // TODO: find a cleaner way of waiting for restorecon to finish - const char* cpath = path.c_str(); - property_set("selinux.restorecon_recursive", ""); - property_set("selinux.restorecon_recursive", cpath); - - char value[PROPERTY_VALUE_MAX]; - while (true) { - property_get("selinux.restorecon_recursive", value, ""); - if (strcmp(cpath, value) == 0) { - break; - } - usleep(100000); // 100ms - } + static constexpr const char* kRestoreconString = "selinux.restorecon_recursive"; + + android::base::SetProperty(kRestoreconString, ""); + android::base::SetProperty(kRestoreconString, path); + + android::base::WaitForProperty(kRestoreconString, path); LOG(VERBOSE) << "Finished restorecon of " << path; return OK; @@ -670,7 +663,7 @@ status_t SaneReadLinkAt(int dirfd, const char* path, char* buf, size_t bufsiz) { } bool IsRunningInEmulator() { - return property_get_bool("ro.kernel.qemu", 0); + return android::base::GetBoolProperty("ro.kernel.qemu", false); } } // namespace vold