Loading DnsResolver.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -28,9 +28,7 @@ bool resolv_init(const ResolverNetdCallbacks& callbacks) { android::base::InitLogging(/*argv=*/nullptr); android::base::SetDefaultTag("libnetd_resolv"); LOG(INFO) << __func__ << ": Initializing resolver"; const std::string logSeverityStr = android::base::GetProperty("persist.sys.nw_dns_resolver_log", "WARNING"); android::base::SetMinimumLogSeverity(logSeverityStrToEnum(logSeverityStr)); resolv_set_log_severity(android::base::WARNING); android::net::gResNetdCallbacks = callbacks; android::net::gDnsResolv = android::net::DnsResolver::getInstance(); Loading Loading @@ -76,5 +74,9 @@ bool DnsResolver::start() { return true; } int DnsResolver::setLogSeverity(int32_t logSeverity) { return resolv_set_log_severity(logSeverity); } } // namespace net } // namespace android DnsResolver.h +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ class DnsResolver { public: static DnsResolver* getInstance(); bool start(); int setLogSeverity(int32_t logSeverity); DnsResolver(DnsResolver const&) = delete; void operator=(DnsResolver const&) = delete; Loading DnsResolverService.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -278,6 +278,15 @@ static std::vector<uint8_t> parseBase64(const std::string& input) { return ::ndk::ScopedAStatus(AStatus_newOk()); } ::ndk::ScopedAStatus DnsResolverService::setLogSeverity(int32_t logSeverity) { ENFORCE_NETWORK_STACK_PERMISSIONS(); auto entry = gDnsResolverLog.newEntry().prettyFunction(__PRETTY_FUNCTION__).arg(logSeverity); int res = gDnsResolv->setLogSeverity(logSeverity); gResNetdCallbacks.log(entry.returns(res).withAutomaticDuration().toString().c_str()); return statusFromErrcode(res); } ::ndk::ScopedAStatus DnsResolverService::destroyNetworkCache(int netId) { // Locking happens in res_cache.cpp functions. ENFORCE_NETWORK_STACK_PERMISSIONS(); Loading DnsResolverService.h +3 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,9 @@ class DnsResolverService : public aidl::android::net::BnDnsResolver { // (internal use only) ::ndk::ScopedAStatus getPrefix64(int netId, std::string* stringPrefix) override; // Debug log command ::ndk::ScopedAStatus setLogSeverity(int32_t logSeverity) override; private: DnsResolverService() {} // TODO: Remove below items after libbiner_ndk supports check_permission. Loading binder/android/net/IDnsResolver.aidl +17 −0 Original line number Diff line number Diff line Loading @@ -144,4 +144,21 @@ interface IDnsResolver { * @param netId the network ID of the network to destroy. */ void destroyNetworkCache(int netId); // Refer to enum LogSeverity from system/core/base/include/android-base/logging.h const int DNS_RESOLVER_LOG_VERBOSE = 0; const int DNS_RESOLVER_LOG_DEBUG = 1; const int DNS_RESOLVER_LOG_INFO = 2; const int DNS_RESOLVER_LOG_WARNING = 3; const int DNS_RESOLVER_LOG_ERROR = 4; /** * Set DNS resolver log severity * * @param logSeverity print log in "VERBOSE", "DEBUG", "INFO", "WARNING", "ERROR". * * @throws ServiceSpecificException in case of failure, with an error code corresponding to the * POSIX errno. */ void setLogSeverity(int logSeverity); } Loading
DnsResolver.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -28,9 +28,7 @@ bool resolv_init(const ResolverNetdCallbacks& callbacks) { android::base::InitLogging(/*argv=*/nullptr); android::base::SetDefaultTag("libnetd_resolv"); LOG(INFO) << __func__ << ": Initializing resolver"; const std::string logSeverityStr = android::base::GetProperty("persist.sys.nw_dns_resolver_log", "WARNING"); android::base::SetMinimumLogSeverity(logSeverityStrToEnum(logSeverityStr)); resolv_set_log_severity(android::base::WARNING); android::net::gResNetdCallbacks = callbacks; android::net::gDnsResolv = android::net::DnsResolver::getInstance(); Loading Loading @@ -76,5 +74,9 @@ bool DnsResolver::start() { return true; } int DnsResolver::setLogSeverity(int32_t logSeverity) { return resolv_set_log_severity(logSeverity); } } // namespace net } // namespace android
DnsResolver.h +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ class DnsResolver { public: static DnsResolver* getInstance(); bool start(); int setLogSeverity(int32_t logSeverity); DnsResolver(DnsResolver const&) = delete; void operator=(DnsResolver const&) = delete; Loading
DnsResolverService.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -278,6 +278,15 @@ static std::vector<uint8_t> parseBase64(const std::string& input) { return ::ndk::ScopedAStatus(AStatus_newOk()); } ::ndk::ScopedAStatus DnsResolverService::setLogSeverity(int32_t logSeverity) { ENFORCE_NETWORK_STACK_PERMISSIONS(); auto entry = gDnsResolverLog.newEntry().prettyFunction(__PRETTY_FUNCTION__).arg(logSeverity); int res = gDnsResolv->setLogSeverity(logSeverity); gResNetdCallbacks.log(entry.returns(res).withAutomaticDuration().toString().c_str()); return statusFromErrcode(res); } ::ndk::ScopedAStatus DnsResolverService::destroyNetworkCache(int netId) { // Locking happens in res_cache.cpp functions. ENFORCE_NETWORK_STACK_PERMISSIONS(); Loading
DnsResolverService.h +3 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,9 @@ class DnsResolverService : public aidl::android::net::BnDnsResolver { // (internal use only) ::ndk::ScopedAStatus getPrefix64(int netId, std::string* stringPrefix) override; // Debug log command ::ndk::ScopedAStatus setLogSeverity(int32_t logSeverity) override; private: DnsResolverService() {} // TODO: Remove below items after libbiner_ndk supports check_permission. Loading
binder/android/net/IDnsResolver.aidl +17 −0 Original line number Diff line number Diff line Loading @@ -144,4 +144,21 @@ interface IDnsResolver { * @param netId the network ID of the network to destroy. */ void destroyNetworkCache(int netId); // Refer to enum LogSeverity from system/core/base/include/android-base/logging.h const int DNS_RESOLVER_LOG_VERBOSE = 0; const int DNS_RESOLVER_LOG_DEBUG = 1; const int DNS_RESOLVER_LOG_INFO = 2; const int DNS_RESOLVER_LOG_WARNING = 3; const int DNS_RESOLVER_LOG_ERROR = 4; /** * Set DNS resolver log severity * * @param logSeverity print log in "VERBOSE", "DEBUG", "INFO", "WARNING", "ERROR". * * @throws ServiceSpecificException in case of failure, with an error code corresponding to the * POSIX errno. */ void setLogSeverity(int logSeverity); }