123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- Submodule src/incremental_delivery contains modified content
- diff --git a/src/incremental_delivery/sysprop/IncrementalProperties.sysprop.cpp b/src/incremental_delivery/sysprop/IncrementalProperties.sysprop.cpp
- new file mode 100644
- index 0000000..dfe0671
- --- /dev/null
- +++ b/src/incremental_delivery/sysprop/IncrementalProperties.sysprop.cpp
- @@ -0,0 +1,217 @@
- +// Generated by the sysprop generator. DO NOT EDIT!
- +
- +#include <IncrementalProperties.sysprop.h>
- +#include <strings.h>
- +
- +#include <cctype>
- +#include <cerrno>
- +#include <cstdio>
- +#include <cstring>
- +#include <limits>
- +#include <utility>
- +#ifdef __BIONIC__
- +#include <sys/system_properties.h>
- +[[maybe_unused]] static bool SetProp(const char* key, const char* value) {
- + return __system_property_set(key, value) == 0;
- +}
- +#else
- +#include <android-base/properties.h>
- +[[maybe_unused]] static bool SetProp(const char* key, const char* value) {
- + android::base::SetProperty(key, value);
- + return true;
- +}
- +#endif
- +
- +#include <android-base/parseint.h>
- +#include <log/log.h>
- +
- +namespace {
- +
- +using namespace android::sysprop::IncrementalProperties;
- +
- +template <typename T>
- +T DoParse(const char* str);
- +
- +template <typename T>
- +constexpr bool is_vector = false;
- +
- +template <typename T>
- +constexpr bool is_vector<std::vector<T>> = true;
- +
- +template <>
- +[[maybe_unused]] std::optional<bool> DoParse(const char* str) {
- + static constexpr const char* kYes[] = {"1", "true"};
- + static constexpr const char* kNo[] = {"0", "false"};
- +
- + for (const char* yes : kYes) {
- + if (strcasecmp(yes, str) == 0) return std::make_optional(true);
- + }
- +
- + for (const char* no : kNo) {
- + if (strcasecmp(no, str) == 0) return std::make_optional(false);
- + }
- +
- + return std::nullopt;
- +}
- +
- +template <>
- +[[maybe_unused]] std::optional<std::int32_t> DoParse(const char* str) {
- + std::int32_t ret;
- + return android::base::ParseInt(str, &ret) ? std::make_optional(ret) : std::nullopt;
- +}
- +
- +template <>
- +[[maybe_unused]] std::optional<std::uint32_t> DoParse(const char* str) {
- + std::uint32_t ret;
- + return android::base::ParseUint(str, &ret) ? std::make_optional(ret) : std::nullopt;
- +}
- +
- +template <>
- +[[maybe_unused]] std::optional<std::int64_t> DoParse(const char* str) {
- + std::int64_t ret;
- + return android::base::ParseInt(str, &ret) ? std::make_optional(ret) : std::nullopt;
- +}
- +
- +template <>
- +[[maybe_unused]] std::optional<std::uint64_t> DoParse(const char* str) {
- + std::uint64_t ret;
- + return android::base::ParseUint(str, &ret) ? std::make_optional(ret) : std::nullopt;
- +}
- +
- +template <>
- +[[maybe_unused]] std::optional<double> DoParse(const char* str) {
- + int old_errno = errno;
- + errno = 0;
- + char* end;
- + double ret = std::strtod(str, &end);
- + if (errno != 0) {
- + return std::nullopt;
- + }
- + if (str == end || *end != '\0') {
- + errno = EINVAL;
- + return std::nullopt;
- + }
- + errno = old_errno;
- + return std::make_optional(ret);
- +}
- +
- +template <>
- +[[maybe_unused]] std::optional<std::string> DoParse(const char* str) {
- + return *str == '\0' ? std::nullopt : std::make_optional(str);
- +}
- +
- +template <typename Vec>
- +[[maybe_unused]] Vec DoParseList(const char* str) {
- + Vec ret;
- + if (*str == '\0') return ret;
- + const char* p = str;
- + for (;;) {
- + const char* r = p;
- + std::string value;
- + while (*r != ',') {
- + if (*r == '\\') ++r;
- + if (*r == '\0') break;
- + value += *r++;
- + }
- + ret.emplace_back(DoParse<typename Vec::value_type>(value.c_str()));
- + if (*r == '\0') break;
- + p = r + 1;
- + }
- + return ret;
- +}
- +
- +template <typename T>
- +inline T TryParse(const char* str) {
- + if constexpr (is_vector<T>) {
- + return DoParseList<T>(str);
- + } else {
- + return DoParse<T>(str);
- + }
- +}
- +
- +[[maybe_unused]] std::string FormatValue(const std::optional<std::int32_t>& value) {
- + return value ? std::to_string(*value) : "";
- +}
- +
- +[[maybe_unused]] std::string FormatValue(const std::optional<std::uint32_t>& value) {
- + return value ? std::to_string(*value) : "";
- +}
- +
- +[[maybe_unused]] std::string FormatValue(const std::optional<std::int64_t>& value) {
- + return value ? std::to_string(*value) : "";
- +}
- +
- +[[maybe_unused]] std::string FormatValue(const std::optional<std::uint64_t>& value) {
- + return value ? std::to_string(*value) : "";
- +}
- +
- +[[maybe_unused]] std::string FormatValue(const std::optional<double>& value) {
- + if (!value) return "";
- + char buf[1024];
- + std::sprintf(buf, "%.*g", std::numeric_limits<double>::max_digits10, *value);
- + return buf;
- +}
- +
- +[[maybe_unused]] std::string FormatValue(const std::optional<bool>& value) {
- + return value ? (*value ? "true" : "false") : "";
- +}
- +
- +template <typename T>
- +[[maybe_unused]] std::string FormatValue(const std::vector<T>& value) {
- + if (value.empty()) return "";
- +
- + std::string ret;
- + bool first = true;
- +
- + for (auto&& element : value) {
- + if (!first)
- + ret += ',';
- + else
- + first = false;
- + if constexpr (std::is_same_v<T, std::optional<std::string>>) {
- + if (element) {
- + for (char c : *element) {
- + if (c == '\\' || c == ',') ret += '\\';
- + ret += c;
- + }
- + }
- + } else {
- + ret += FormatValue(element);
- + }
- + }
- +
- + return ret;
- +}
- +
- +template <typename T>
- +T GetProp(const char* key, const char* legacy = nullptr) {
- + std::string value;
- +#ifdef __BIONIC__
- + auto pi = __system_property_find(key);
- + if (pi != nullptr) {
- + __system_property_read_callback(
- + pi,
- + [](void* cookie, const char*, const char* value, std::uint32_t) {
- + *static_cast<std::string*>(cookie) = value;
- + },
- + &value);
- + }
- +#else
- + value = android::base::GetProperty(key, "");
- +#endif
- + if (value.empty() && legacy) {
- + ALOGV("prop %s doesn't exist; fallback to legacy prop %s", key, legacy);
- + return GetProp<T>(legacy);
- + }
- + return TryParse<T>(value.c_str());
- +}
- +
- +} // namespace
- +
- +namespace android::sysprop::IncrementalProperties {
- +
- +std::optional<std::string> enable() {
- + return GetProp<std::optional<std::string>>("ro.incremental.enable");
- +}
- +
- +} // namespace android::sysprop::IncrementalProperties
- \ No newline at end of file
- diff --git a/src/incremental_delivery/sysprop/include/IncrementalProperties.sysprop.h b/src/incremental_delivery/sysprop/include/IncrementalProperties.sysprop.h
- new file mode 100644
- index 0000000..19e2fea
- --- /dev/null
- +++ b/src/incremental_delivery/sysprop/include/IncrementalProperties.sysprop.h
- @@ -0,0 +1,14 @@
- +// Generated by the sysprop generator. DO NOT EDIT!
- +
- +#pragma once
- +
- +#include <cstdint>
- +#include <optional>
- +#include <string>
- +#include <vector>
- +
- +namespace android::sysprop::IncrementalProperties {
- +
- +std::optional<std::string> enable();
- +
- +} // namespace android::sysprop::IncrementalProperties
- \ No newline at end of file
|