aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.bp8
-rw-r--r--Dns64Configuration.cpp4
-rw-r--r--Dns64Configuration.h3
-rw-r--r--DnsProxyListener.cpp6
-rw-r--r--ResolverController.cpp2
-rw-r--r--ResolverController.h2
-rw-r--r--aidl_api/dnsresolver_aidl_interface/14/.hash1
-rw-r--r--aidl_api/dnsresolver_aidl_interface/14/android/net/IDnsResolver.aidl70
-rw-r--r--aidl_api/dnsresolver_aidl_interface/14/android/net/ResolverHostsParcel.aidl25
-rw-r--r--aidl_api/dnsresolver_aidl_interface/14/android/net/ResolverOptionsParcel.aidl26
-rw-r--r--aidl_api/dnsresolver_aidl_interface/14/android/net/ResolverParamsParcel.aidl41
-rw-r--r--aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/DnsHealthEventParcel.aidl26
-rw-r--r--aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/DohParamsParcel.aidl27
-rw-r--r--aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/IDnsResolverUnsolicitedEventListener.aidl33
-rw-r--r--aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/Nat64PrefixEventParcel.aidl27
-rw-r--r--aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/PrivateDnsValidationEventParcel.aidl28
-rw-r--r--aidl_api/dnsresolver_aidl_interface/current/android/net/IDnsResolver.aidl1
-rw-r--r--apex/Android.bp10
-rw-r--r--binder/android/net/IDnsResolver.aidl1
-rw-r--r--doh/ffi.rs12
-rw-r--r--doh/tests/doh_frontend/Android.bp1
-rw-r--r--doh/tests/doh_frontend/src/ffi.rs4
-rw-r--r--res_debug.cpp72
-rw-r--r--sethostent.cpp7
-rw-r--r--tests/Android.bp60
-rw-r--r--tests/dns_metrics_listener/Android.bp6
-rw-r--r--tests/dns_responder/Android.bp6
-rw-r--r--tests/resolv_callback_unit_test.cpp2
-rw-r--r--tests/resolv_integration_test.cpp10
-rw-r--r--tests/resolv_private_dns_test.cpp25
-rw-r--r--tests/resolv_test_utils.cpp13
-rw-r--r--tests/resolv_test_utils.h1
-rw-r--r--tests/unsolicited_listener/Android.bp1
33 files changed, 473 insertions, 88 deletions
diff --git a/Android.bp b/Android.bp
index f3165324..7c9d5b7f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,4 +1,5 @@
package {
+ default_team: "trendy_team_fwk_core_networking",
default_applicable_licenses: ["packages_modules_DnsResolver_license"],
}
@@ -53,7 +54,7 @@ cc_library_headers {
],
}
-dnsresolver_aidl_interface_lateststable_version = "V13"
+dnsresolver_aidl_interface_lateststable_version = "V14"
cc_library_static {
name: "dnsresolver_aidl_interface-lateststable-ndk",
@@ -153,6 +154,10 @@ aidl_interface {
version: "13",
imports: ["netd_event_listener_interface-V1"],
},
+ {
+ version: "14",
+ imports: ["netd_event_listener_interface-V1"],
+ },
],
frozen: true,
@@ -277,7 +282,6 @@ cc_library {
"libprotobuf-cpp-lite",
"libstatslog_resolv",
"libsysutils",
- "libutils",
"netd_event_listener_interface-lateststable-ndk",
"server_configurable_flags",
"stats_proto",
diff --git a/Dns64Configuration.cpp b/Dns64Configuration.cpp
index fc1428db..c09ce368 100644
--- a/Dns64Configuration.cpp
+++ b/Dns64Configuration.cpp
@@ -24,7 +24,6 @@
#include <netdutils/DumpWriter.h>
#include <netdutils/InternetAddresses.h>
#include <netdutils/ThreadUtil.h>
-#include <utils/StrongPointer.h>
#include <thread>
#include <utility>
@@ -37,7 +36,6 @@
namespace android {
-using android::sp;
using netdutils::DumpWriter;
using netdutils::IPAddress;
using netdutils::IPPrefix;
@@ -63,7 +61,7 @@ void Dns64Configuration::startPrefixDiscovery(unsigned netId) {
// Emplace a copy of |cfg| in the map.
mDns64Configs.emplace(std::make_pair(netId, cfg));
- const sp<Dns64Configuration> thiz = sp<Dns64Configuration>::fromExisting(this);
+ const std::shared_ptr<Dns64Configuration> thiz = shared_from_this();
// Note that capturing |cfg| in this lambda creates a copy.
std::thread discovery_thread([thiz, cfg, netId] {
setThreadName(fmt::format("Nat64Pfx_{}", netId));
diff --git a/Dns64Configuration.h b/Dns64Configuration.h
index 4170e32d..35d3afed 100644
--- a/Dns64Configuration.h
+++ b/Dns64Configuration.h
@@ -27,7 +27,6 @@
#include <android-base/thread_annotations.h>
#include <netdutils/DumpWriter.h>
#include <netdutils/InternetAddresses.h>
-#include <utils/RefBase.h>
struct android_net_context;
@@ -49,7 +48,7 @@ namespace net {
* Thread-safety: All public methods in this class MUST be thread-safe.
* (In other words: this class handles all its locking privately.)
*/
-class Dns64Configuration : virtual public RefBase {
+class Dns64Configuration : public std::enable_shared_from_this<Dns64Configuration> {
public:
// Simple data struct for passing back packet NAT64 prefix event information to the
// Dns64PrefixCallback callback.
diff --git a/DnsProxyListener.cpp b/DnsProxyListener.cpp
index e70ddb40..8064aef7 100644
--- a/DnsProxyListener.cpp
+++ b/DnsProxyListener.cpp
@@ -685,7 +685,8 @@ IsUidBlockedFn resolveIsUidNetworkingBlockedFn() {
InitFn ADnsHelper_init = reinterpret_cast<InitFn>(dlsym(handle, "ADnsHelper_init"));
if (!ADnsHelper_init) {
LOG(ERROR) << __func__ << ": " << dlerror();
- abort();
+ // TODO: Change to abort() when NDK is finalized
+ return nullptr;
}
const int ret = (*ADnsHelper_init)();
if (ret) {
@@ -697,7 +698,8 @@ IsUidBlockedFn resolveIsUidNetworkingBlockedFn() {
reinterpret_cast<IsUidBlockedFn>(dlsym(handle, "ADnsHelper_isUidNetworkingBlocked"));
if (!f) {
LOG(ERROR) << __func__ << ": " << dlerror();
- abort();
+ // TODO: Change to abort() when NDK is finalized
+ return nullptr;
}
return f;
}
diff --git a/ResolverController.cpp b/ResolverController.cpp
index 757e3f74..3198ec25 100644
--- a/ResolverController.cpp
+++ b/ResolverController.cpp
@@ -155,7 +155,7 @@ int getDnsInfo(unsigned netId, std::vector<std::string>* servers, std::vector<st
} // namespace
ResolverController::ResolverController()
- : mDns64Configuration(android::sp<Dns64Configuration>::make(
+ : mDns64Configuration(make_shared<Dns64Configuration>(
[](uint32_t netId, uint32_t uid, android_net_context* netcontext) {
gResNetdCallbacks.get_network_context(netId, uid, netcontext);
},
diff --git a/ResolverController.h b/ResolverController.h
index b74cff92..c2fc8e77 100644
--- a/ResolverController.h
+++ b/ResolverController.h
@@ -66,7 +66,7 @@ class ResolverController {
void dump(netdutils::DumpWriter& dw, unsigned netId);
private:
- android::sp<Dns64Configuration> mDns64Configuration;
+ std::shared_ptr<Dns64Configuration> mDns64Configuration;
};
} // namespace net
} // namespace android
diff --git a/aidl_api/dnsresolver_aidl_interface/14/.hash b/aidl_api/dnsresolver_aidl_interface/14/.hash
new file mode 100644
index 00000000..178f03ed
--- /dev/null
+++ b/aidl_api/dnsresolver_aidl_interface/14/.hash
@@ -0,0 +1 @@
+a78c9283ca1e898aacc621b1295fd4e4b008473f
diff --git a/aidl_api/dnsresolver_aidl_interface/14/android/net/IDnsResolver.aidl b/aidl_api/dnsresolver_aidl_interface/14/android/net/IDnsResolver.aidl
new file mode 100644
index 00000000..5f1adbb6
--- /dev/null
+++ b/aidl_api/dnsresolver_aidl_interface/14/android/net/IDnsResolver.aidl
@@ -0,0 +1,70 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net;
+/* @hide */
+interface IDnsResolver {
+ boolean isAlive();
+ void registerEventListener(android.net.metrics.INetdEventListener listener);
+ void setResolverConfiguration(in android.net.ResolverParamsParcel resolverParams);
+ void getResolverInfo(int netId, out @utf8InCpp String[] servers, out @utf8InCpp String[] domains, out @utf8InCpp String[] tlsServers, out int[] params, out int[] stats, out int[] wait_for_pending_req_timeout_count);
+ void startPrefix64Discovery(int netId);
+ void stopPrefix64Discovery(int netId);
+ @utf8InCpp String getPrefix64(int netId);
+ void createNetworkCache(int netId);
+ void destroyNetworkCache(int netId);
+ void setLogSeverity(int logSeverity);
+ void flushNetworkCache(int netId);
+ void setPrefix64(int netId, @utf8InCpp String prefix);
+ void registerUnsolicitedEventListener(android.net.resolv.aidl.IDnsResolverUnsolicitedEventListener listener);
+ void setResolverOptions(int netId, in android.net.ResolverOptionsParcel optionParams);
+ const int RESOLVER_PARAMS_SAMPLE_VALIDITY = 0;
+ const int RESOLVER_PARAMS_SUCCESS_THRESHOLD = 1;
+ const int RESOLVER_PARAMS_MIN_SAMPLES = 2;
+ const int RESOLVER_PARAMS_MAX_SAMPLES = 3;
+ const int RESOLVER_PARAMS_BASE_TIMEOUT_MSEC = 4;
+ const int RESOLVER_PARAMS_RETRY_COUNT = 5;
+ const int RESOLVER_PARAMS_COUNT = 6;
+ const int RESOLVER_STATS_SUCCESSES = 0;
+ const int RESOLVER_STATS_ERRORS = 1;
+ const int RESOLVER_STATS_TIMEOUTS = 2;
+ const int RESOLVER_STATS_INTERNAL_ERRORS = 3;
+ const int RESOLVER_STATS_RTT_AVG = 4;
+ const int RESOLVER_STATS_LAST_SAMPLE_TIME = 5;
+ const int RESOLVER_STATS_USABLE = 6;
+ const int RESOLVER_STATS_COUNT = 7;
+ 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;
+ const int TC_MODE_DEFAULT = 0;
+ const int TC_MODE_UDP_TCP = 1;
+ const int TRANSPORT_UNKNOWN = (-1) /* -1 */;
+ const int TRANSPORT_CELLULAR = 0;
+ const int TRANSPORT_WIFI = 1;
+ const int TRANSPORT_BLUETOOTH = 2;
+ const int TRANSPORT_ETHERNET = 3;
+ const int TRANSPORT_VPN = 4;
+ const int TRANSPORT_WIFI_AWARE = 5;
+ const int TRANSPORT_LOWPAN = 6;
+ const int TRANSPORT_TEST = 7;
+ const int TRANSPORT_USB = 8;
+ const int TRANSPORT_THREAD = 9;
+ const int TRANSPORT_SATELLITE = 10;
+}
diff --git a/aidl_api/dnsresolver_aidl_interface/14/android/net/ResolverHostsParcel.aidl b/aidl_api/dnsresolver_aidl_interface/14/android/net/ResolverHostsParcel.aidl
new file mode 100644
index 00000000..2a1c748f
--- /dev/null
+++ b/aidl_api/dnsresolver_aidl_interface/14/android/net/ResolverHostsParcel.aidl
@@ -0,0 +1,25 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net;
+/* @hide */
+@JavaDerive(equals=true)
+parcelable ResolverHostsParcel {
+ @utf8InCpp String ipAddr;
+ @utf8InCpp String hostName = "";
+}
diff --git a/aidl_api/dnsresolver_aidl_interface/14/android/net/ResolverOptionsParcel.aidl b/aidl_api/dnsresolver_aidl_interface/14/android/net/ResolverOptionsParcel.aidl
new file mode 100644
index 00000000..b07263f8
--- /dev/null
+++ b/aidl_api/dnsresolver_aidl_interface/14/android/net/ResolverOptionsParcel.aidl
@@ -0,0 +1,26 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net;
+/* @hide */
+@JavaDerive(equals=true, toString=true)
+parcelable ResolverOptionsParcel {
+ android.net.ResolverHostsParcel[] hosts = {};
+ int tcMode = 0;
+ boolean enforceDnsUid = false;
+}
diff --git a/aidl_api/dnsresolver_aidl_interface/14/android/net/ResolverParamsParcel.aidl b/aidl_api/dnsresolver_aidl_interface/14/android/net/ResolverParamsParcel.aidl
new file mode 100644
index 00000000..2dd93dd5
--- /dev/null
+++ b/aidl_api/dnsresolver_aidl_interface/14/android/net/ResolverParamsParcel.aidl
@@ -0,0 +1,41 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net;
+/* @hide */
+@JavaDerive(equals=true, toString=true)
+parcelable ResolverParamsParcel {
+ int netId;
+ int sampleValiditySeconds;
+ int successThreshold;
+ int minSamples;
+ int maxSamples;
+ int baseTimeoutMsec;
+ int retryCount;
+ @utf8InCpp String[] servers;
+ @utf8InCpp String[] domains;
+ @utf8InCpp String tlsName;
+ @utf8InCpp String[] tlsServers;
+ @utf8InCpp String[] tlsFingerprints = {};
+ @utf8InCpp String caCertificate = "";
+ int tlsConnectTimeoutMs = 0;
+ @nullable android.net.ResolverOptionsParcel resolverOptions;
+ int[] transportTypes = {};
+ boolean meteredNetwork = false;
+ @nullable android.net.resolv.aidl.DohParamsParcel dohParams;
+}
diff --git a/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/DnsHealthEventParcel.aidl b/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/DnsHealthEventParcel.aidl
new file mode 100644
index 00000000..d32be919
--- /dev/null
+++ b/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/DnsHealthEventParcel.aidl
@@ -0,0 +1,26 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.resolv.aidl;
+/* @hide */
+@JavaDerive(toString=true)
+parcelable DnsHealthEventParcel {
+ int netId;
+ int healthResult;
+ int[] successRttMicros;
+}
diff --git a/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/DohParamsParcel.aidl b/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/DohParamsParcel.aidl
new file mode 100644
index 00000000..ba1ea747
--- /dev/null
+++ b/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/DohParamsParcel.aidl
@@ -0,0 +1,27 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.resolv.aidl;
+/* @hide */
+@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
+parcelable DohParamsParcel {
+ String name = "";
+ String[] ips = {};
+ String dohpath = "";
+ int port = (-1) /* -1 */;
+}
diff --git a/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/IDnsResolverUnsolicitedEventListener.aidl b/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/IDnsResolverUnsolicitedEventListener.aidl
new file mode 100644
index 00000000..32963dfd
--- /dev/null
+++ b/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/IDnsResolverUnsolicitedEventListener.aidl
@@ -0,0 +1,33 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.resolv.aidl;
+/* @hide */
+interface IDnsResolverUnsolicitedEventListener {
+ oneway void onDnsHealthEvent(in android.net.resolv.aidl.DnsHealthEventParcel dnsHealthEvent);
+ oneway void onNat64PrefixEvent(in android.net.resolv.aidl.Nat64PrefixEventParcel nat64PrefixEvent);
+ oneway void onPrivateDnsValidationEvent(in android.net.resolv.aidl.PrivateDnsValidationEventParcel privateDnsValidationEvent);
+ const int DNS_HEALTH_RESULT_OK = 0;
+ const int DNS_HEALTH_RESULT_TIMEOUT = 255;
+ const int PREFIX_OPERATION_ADDED = 1;
+ const int PREFIX_OPERATION_REMOVED = 2;
+ const int VALIDATION_RESULT_SUCCESS = 1;
+ const int VALIDATION_RESULT_FAILURE = 2;
+ const int PROTOCOL_DOT = 1;
+ const int PROTOCOL_DOH = 2;
+}
diff --git a/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/Nat64PrefixEventParcel.aidl b/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/Nat64PrefixEventParcel.aidl
new file mode 100644
index 00000000..2daccb0e
--- /dev/null
+++ b/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/Nat64PrefixEventParcel.aidl
@@ -0,0 +1,27 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.resolv.aidl;
+/* @hide */
+@JavaDerive(toString=true)
+parcelable Nat64PrefixEventParcel {
+ int netId;
+ int prefixOperation;
+ @utf8InCpp String prefixAddress;
+ int prefixLength;
+}
diff --git a/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/PrivateDnsValidationEventParcel.aidl b/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/PrivateDnsValidationEventParcel.aidl
new file mode 100644
index 00000000..f3bfbc76
--- /dev/null
+++ b/aidl_api/dnsresolver_aidl_interface/14/android/net/resolv/aidl/PrivateDnsValidationEventParcel.aidl
@@ -0,0 +1,28 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.resolv.aidl;
+/* @hide */
+@JavaDerive(toString=true)
+parcelable PrivateDnsValidationEventParcel {
+ int netId;
+ @utf8InCpp String ipAddress;
+ @utf8InCpp String hostname;
+ int validation;
+ int protocol;
+}
diff --git a/aidl_api/dnsresolver_aidl_interface/current/android/net/IDnsResolver.aidl b/aidl_api/dnsresolver_aidl_interface/current/android/net/IDnsResolver.aidl
index 6b539c47..5f1adbb6 100644
--- a/aidl_api/dnsresolver_aidl_interface/current/android/net/IDnsResolver.aidl
+++ b/aidl_api/dnsresolver_aidl_interface/current/android/net/IDnsResolver.aidl
@@ -66,4 +66,5 @@ interface IDnsResolver {
const int TRANSPORT_TEST = 7;
const int TRANSPORT_USB = 8;
const int TRANSPORT_THREAD = 9;
+ const int TRANSPORT_SATELLITE = 10;
}
diff --git a/apex/Android.bp b/apex/Android.bp
index 41fb4475..82302dd1 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-
package {
+ default_team: "trendy_team_fwk_core_networking",
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "packages_modules_DnsResolver_license"
@@ -27,7 +27,7 @@ apex {
manifest: "manifest.json",
multilib: {
first: {
- native_shared_libs: ["libnetd_resolv"],
+ native_shared_libs: ["libnetd_resolv"],
},
},
key: "com.android.resolv.key",
@@ -56,7 +56,7 @@ apex_key {
}
android_app_certificate {
- name: "com.android.resolv.certificate",
- // will use cert.pk8 and cert.x509.pem
- certificate: "testcert",
+ name: "com.android.resolv.certificate",
+ // will use cert.pk8 and cert.x509.pem
+ certificate: "testcert",
}
diff --git a/binder/android/net/IDnsResolver.aidl b/binder/android/net/IDnsResolver.aidl
index 82fff140..34de515a 100644
--- a/binder/android/net/IDnsResolver.aidl
+++ b/binder/android/net/IDnsResolver.aidl
@@ -199,6 +199,7 @@ interface IDnsResolver {
const int TRANSPORT_TEST = 7;
const int TRANSPORT_USB = 8;
const int TRANSPORT_THREAD = 9;
+ const int TRANSPORT_SATELLITE = 10;
/**
* Sets the NAT64 prefix for the given network.
diff --git a/doh/ffi.rs b/doh/ffi.rs
index 63b98cc8..e183a620 100644
--- a/doh/ffi.rs
+++ b/doh/ffi.rs
@@ -122,8 +122,8 @@ pub const DOH_LOG_LEVEL_TRACE: u32 = 4;
const DOH_PORT: u16 = 443;
-fn level_from_u32(level: u32) -> Option<log::Level> {
- use log::Level::*;
+fn level_from_u32(level: u32) -> Option<log::LevelFilter> {
+ use log::LevelFilter::*;
match level {
DOH_LOG_LEVEL_ERROR => Some(Error),
DOH_LOG_LEVEL_WARN => Some(Warn),
@@ -139,17 +139,15 @@ fn level_from_u32(level: u32) -> Option<log::Level> {
/// If called more than once, it will have no effect on subsequent calls.
#[no_mangle]
pub extern "C" fn doh_init_logger(level: u32) {
- let log_level = level_from_u32(level).unwrap_or(log::Level::Error);
- android_logger::init_once(android_logger::Config::default().with_min_level(log_level));
+ let log_level = level_from_u32(level).unwrap_or(log::LevelFilter::Error);
+ android_logger::init_once(android_logger::Config::default().with_max_level(log_level));
}
/// Set the log level.
/// If an invalid level is passed, defaults to logging errors only.
#[no_mangle]
pub extern "C" fn doh_set_log_level(level: u32) {
- let level_filter = level_from_u32(level)
- .map(|level| level.to_level_filter())
- .unwrap_or(log::LevelFilter::Error);
+ let level_filter = level_from_u32(level).unwrap_or(log::LevelFilter::Error);
log::set_max_level(level_filter);
}
diff --git a/doh/tests/doh_frontend/Android.bp b/doh/tests/doh_frontend/Android.bp
index e4db22ef..156fb5cc 100644
--- a/doh/tests/doh_frontend/Android.bp
+++ b/doh/tests/doh_frontend/Android.bp
@@ -1,4 +1,5 @@
package {
+ default_team: "trendy_team_fwk_core_networking",
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "packages_modules_DnsResolver_license"
diff --git a/doh/tests/doh_frontend/src/ffi.rs b/doh/tests/doh_frontend/src/ffi.rs
index 37a5fba0..f4960fe4 100644
--- a/doh/tests/doh_frontend/src/ffi.rs
+++ b/doh/tests/doh_frontend/src/ffi.rs
@@ -198,7 +198,9 @@ pub extern "C" fn frontend_stats_clear_queries(doh: &DohFrontend) -> bool {
#[no_mangle]
pub extern "C" fn init_android_logger() {
android_logger::init_once(
- android_logger::Config::default().with_tag("DohFrontend").with_min_level(log::Level::Debug),
+ android_logger::Config::default()
+ .with_tag("DohFrontend")
+ .with_max_level(log::LevelFilter::Debug),
);
}
diff --git a/res_debug.cpp b/res_debug.cpp
index 55356fea..4210f48c 100644
--- a/res_debug.cpp
+++ b/res_debug.cpp
@@ -129,8 +129,6 @@
#define RESOLV_ALLOW_VERBOSE_LOGGING 0
#endif
-using fmt::format_to;
-
struct res_sym {
int number; /* Identifying number, like T_MX */
const char* name; /* Its symbolic name, like "MX" */
@@ -148,25 +146,25 @@ static void do_section(ns_msg* handle, ns_sect section) {
*/
for (;;) {
if (ns_parserr(handle, section, rrnum, &rr)) {
- if (errno != ENODEV) format_to(out, "ns_parserr: {}", strerror(errno));
+ if (errno != ENODEV) fmt::format_to(out, "ns_parserr: {}", strerror(errno));
LOG(VERBOSE) << s;
return;
}
if (rrnum == 0) {
int opcode = ns_msg_getflag(*handle, ns_f_opcode);
- format_to(out, ";; {} SECTION:\n", p_section(section, opcode));
+ fmt::format_to(out, ";; {} SECTION:\n", p_section(section, opcode));
}
if (section == ns_s_qd)
- format_to(out, ";;\t{}, type = {}, class = {}\n", ns_rr_name(rr),
- p_type(ns_rr_type(rr)), p_class(ns_rr_class(rr)));
+ fmt::format_to(out, ";;\t{}, type = {}, class = {}\n", ns_rr_name(rr),
+ p_type(ns_rr_type(rr)), p_class(ns_rr_class(rr)));
else if (section == ns_s_ar && ns_rr_type(rr) == ns_t_opt) {
size_t rdatalen;
uint16_t optcode, optlen;
rdatalen = ns_rr_rdlen(rr);
- format_to(out, "; EDNS: version: {}, udp={}, flags={}\n", (rr.ttl >> 16) & 0xff,
- static_cast<int>(ns_rr_class(rr)), rr.ttl & 0xffff);
+ fmt::format_to(out, "; EDNS: version: {}, udp={}, flags={}\n", (rr.ttl >> 16) & 0xff,
+ static_cast<int>(ns_rr_class(rr)), rr.ttl & 0xffff);
const uint8_t* cp = ns_rr_rdata(rr);
while (rdatalen <= ns_rr_rdlen(rr) && rdatalen >= 4) {
int i;
@@ -175,33 +173,33 @@ static void do_section(ns_msg* handle, ns_sect section) {
GETSHORT(optlen, cp);
if (optcode == NS_OPT_NSID) {
- format_to(out, "; NSID: ");
+ fmt::format_to(out, "; NSID: ");
if (optlen == 0) {
- format_to(out, "; NSID\n");
+ fmt::format_to(out, "; NSID\n");
} else {
- format_to(out, "; NSID: ");
+ fmt::format_to(out, "; NSID: ");
for (i = 0; i < optlen; i++) {
- format_to(out, "{:02x} ", cp[i]);
+ fmt::format_to(out, "{:02x} ", cp[i]);
}
- format_to(out, " (");
+ fmt::format_to(out, " (");
for (i = 0; i < optlen; i++) {
- format_to(out, "{} ", isprint(cp[i]) ? cp[i] : '.');
+ fmt::format_to(out, "{} ", isprint(cp[i]) ? cp[i] : '.');
}
- format_to(out, ")\n");
+ fmt::format_to(out, ")\n");
}
} else {
if (optlen == 0) {
- format_to(out, "; OPT={}\n", optcode);
+ fmt::format_to(out, "; OPT={}\n", optcode);
} else {
- format_to(out, "; OPT={}: ", optcode);
+ fmt::format_to(out, "; OPT={}: ", optcode);
for (i = 0; i < optlen; i++) {
- format_to(out, "{:02x} ", cp[i]);
+ fmt::format_to(out, "{:02x} ", cp[i]);
}
- format_to(out, " (");
+ fmt::format_to(out, " (");
for (i = 0; i < optlen; i++) {
- format_to(out, "{}", isprint(cp[i]) ? cp[i] : '.');
+ fmt::format_to(out, "{}", isprint(cp[i]) ? cp[i] : '.');
}
- format_to(out, ")\n");
+ fmt::format_to(out, ")\n");
}
}
rdatalen -= 4 + optlen;
@@ -216,16 +214,16 @@ static void do_section(ns_msg* handle, ns_sect section) {
buflen += 1024;
continue;
} else {
- format_to(out, "buflen over 131072");
+ fmt::format_to(out, "buflen over 131072");
PLOG(VERBOSE) << s;
return;
}
}
- format_to(out, "ns_sprintrr failed");
+ fmt::format_to(out, "ns_sprintrr failed");
PLOG(VERBOSE) << s;
return;
}
- format_to(out, ";; {}\n", buf.get());
+ fmt::format_to(out, ";; {}\n", buf.get());
}
rrnum++;
}
@@ -273,19 +271,19 @@ void res_pquery(std::span<const uint8_t> msg) {
std::string s = fmt::format(";; ->>HEADER<<- opcode: {}, status: {}, id: {}\n",
_res_opcodes[opcode], p_rcode((int)rcode), id);
auto out = std::back_inserter(s);
- format_to(out, ";; flags:");
- if (ns_msg_getflag(handle, ns_f_qr)) format_to(out, " qr");
- if (ns_msg_getflag(handle, ns_f_aa)) format_to(out, " aa");
- if (ns_msg_getflag(handle, ns_f_tc)) format_to(out, " tc");
- if (ns_msg_getflag(handle, ns_f_rd)) format_to(out, " rd");
- if (ns_msg_getflag(handle, ns_f_ra)) format_to(out, " ra");
- if (ns_msg_getflag(handle, ns_f_z)) format_to(out, " ??");
- if (ns_msg_getflag(handle, ns_f_ad)) format_to(out, " ad");
- if (ns_msg_getflag(handle, ns_f_cd)) format_to(out, " cd");
- format_to(out, "; {}: {}", p_section(ns_s_qd, (int)opcode), qdcount);
- format_to(out, ", {}: {}", p_section(ns_s_an, (int)opcode), ancount);
- format_to(out, ", {}: {}", p_section(ns_s_ns, (int)opcode), nscount);
- format_to(out, ", {}: {}", p_section(ns_s_ar, (int)opcode), arcount);
+ fmt::format_to(out, ";; flags:");
+ if (ns_msg_getflag(handle, ns_f_qr)) fmt::format_to(out, " qr");
+ if (ns_msg_getflag(handle, ns_f_aa)) fmt::format_to(out, " aa");
+ if (ns_msg_getflag(handle, ns_f_tc)) fmt::format_to(out, " tc");
+ if (ns_msg_getflag(handle, ns_f_rd)) fmt::format_to(out, " rd");
+ if (ns_msg_getflag(handle, ns_f_ra)) fmt::format_to(out, " ra");
+ if (ns_msg_getflag(handle, ns_f_z)) fmt::format_to(out, " ??");
+ if (ns_msg_getflag(handle, ns_f_ad)) fmt::format_to(out, " ad");
+ if (ns_msg_getflag(handle, ns_f_cd)) fmt::format_to(out, " cd");
+ fmt::format_to(out, "; {}: {}", p_section(ns_s_qd, (int)opcode), qdcount);
+ fmt::format_to(out, ", {}: {}", p_section(ns_s_an, (int)opcode), ancount);
+ fmt::format_to(out, ", {}: {}", p_section(ns_s_ns, (int)opcode), nscount);
+ fmt::format_to(out, ", {}: {}", p_section(ns_s_ar, (int)opcode), arcount);
LOG(VERBOSE) << s;
diff --git a/sethostent.cpp b/sethostent.cpp
index 419ee869..70bb9553 100644
--- a/sethostent.cpp
+++ b/sethostent.cpp
@@ -77,6 +77,8 @@ int _hf_gethtbyname2(const char* name, int af, getnamaddr* info) {
return (rc == NETDB_SUCCESS ? 0 : EAI_NODATA);
}
+ // TODO: Wrap the 'hf' into a RAII class or std::shared_ptr and modify the
+ // sethostent_r()/endhostent_r() to get rid of manually endhostent_r(&hf) everywhere.
FILE* hf = NULL;
sethostent_r(&hf);
if (hf == NULL) {
@@ -88,6 +90,7 @@ int _hf_gethtbyname2(const char* name, int af, getnamaddr* info) {
}
if ((ptr = buf = (char*) malloc(len = info->buflen)) == NULL) {
+ endhostent_r(&hf);
return EAI_MEMORY;
}
@@ -111,6 +114,7 @@ int _hf_gethtbyname2(const char* name, int af, getnamaddr* info) {
if (hp->h_name == nullptr) {
free(buf);
+ endhostent_r(&hf);
return EAI_FAIL;
}
const char* h_name = hp->h_name;
@@ -136,9 +140,9 @@ int _hf_gethtbyname2(const char* name, int af, getnamaddr* info) {
if ((size_t)(ptr - buf) >= info->buflen) goto nospc;
}
- if (num >= MAXADDRS) goto nospc;
if (hp->h_addr_list[0] == nullptr) {
free(buf);
+ endhostent_r(&hf);
return EAI_FAIL;
}
const char* addr = hp->h_addr_list[0];
@@ -193,6 +197,7 @@ int _hf_gethtbyname2(const char* name, int af, getnamaddr* info) {
free(buf);
return 0;
nospc:
+ endhostent_r(&hf);
free(buf);
return EAI_MEMORY;
}
diff --git a/tests/Android.bp b/tests/Android.bp
index b1266037..7cb4a2a4 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -1,4 +1,5 @@
package {
+ default_team: "trendy_team_fwk_core_networking",
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "packages_modules_DnsResolver_license"
@@ -9,7 +10,10 @@ package {
cc_test_library {
name: "libnetd_test_resolv_utils",
- defaults: ["netd_defaults", "resolv_test_defaults"],
+ defaults: [
+ "netd_defaults",
+ "resolv_test_defaults",
+ ],
srcs: [
"resolv_test_utils.cpp",
],
@@ -64,9 +68,9 @@ genrule {
srcs: ["testdata/*.pbtxt"],
// convert .pbtxt to .pb files; zip them as a single pb.zip.
cmd: "mkdir $(genDir)/pb && for fname in $(in); " +
- "do $(location resolv_gold_test_pbtxt2pb_host) --in_file=$$fname " +
- "--out_dir=$(genDir)/pb; done && " +
- "$(location soong_zip) -o $(out) -C $(genDir)/pb -D $(genDir)/pb",
+ "do $(location resolv_gold_test_pbtxt2pb_host) --in_file=$$fname " +
+ "--out_dir=$(genDir)/pb; done && " +
+ "$(location soong_zip) -o $(out) -C $(genDir)/pb -D $(genDir)/pb",
out: ["testdata/pb.zip"],
}
@@ -85,14 +89,20 @@ cc_library_static {
cc_test {
name: "resolv_gold_test",
- test_suites: ["general-tests", "mts-dnsresolver"],
+ test_suites: [
+ "general-tests",
+ "mts-dnsresolver",
+ ],
isolated: false,
require_root: true,
// b/151392634, this is a workaround because MTS
// can not handle the test with testdata correctly.
// TODO: Remove the xml after MTS fixing the problem.
test_config: "resolv_gold_test_config.xml",
- defaults: ["netd_defaults", "resolv_test_defaults"],
+ defaults: [
+ "netd_defaults",
+ "resolv_test_defaults",
+ ],
data: [":resolv_gold_test_pbtxt2pb"],
srcs: [
"resolv_gold_test.cpp",
@@ -136,12 +146,19 @@ cc_test {
cc_test {
name: "resolv_stress_test",
- test_suites: ["general-tests", "mts-dnsresolver"],
+ test_suites: [
+ "general-tests",
+ "mts-dnsresolver",
+ ],
isolated: false,
// This won't work with test_config
// require_root: true,
// TODO: Remove resolv_test_mts_coverage_defaults after mts coverage switched to 64-bit device.
- defaults: ["netd_defaults", "resolv_test_defaults", "resolv_test_mts_coverage_defaults"],
+ defaults: [
+ "netd_defaults",
+ "resolv_test_defaults",
+ "resolv_test_mts_coverage_defaults",
+ ],
srcs: [
"resolv_stress_test.cpp",
],
@@ -165,11 +182,17 @@ cc_test {
cc_test {
name: "resolv_integration_test",
- test_suites: ["general-tests", "mts-dnsresolver"],
+ test_suites: [
+ "general-tests",
+ "mts-dnsresolver",
+ ],
isolated: false,
require_root: true,
test_config_template: ":resolv_test_config_template",
- defaults: ["netd_defaults", "resolv_test_defaults"],
+ defaults: [
+ "netd_defaults",
+ "resolv_test_defaults",
+ ],
tidy: false, // cuts test build time by > 1m30s
srcs: [
"dns_responder/dns_responder.cpp",
@@ -228,7 +251,7 @@ cc_test {
// after the build process.
host_required: [
"net-tests-utils-host-common",
- ]
+ ],
}
cc_test {
@@ -262,6 +285,7 @@ cc_test {
"netd_aidl_interface-lateststable-ndk",
"netd_event_listener_interface-lateststable-ndk",
"libcrypto_static",
+ "libconnectivity_native_test_utils",
"libcutils",
"libdoh_ffi_for_test",
"libgmock",
@@ -274,7 +298,6 @@ cc_test {
"libstatslog_resolv",
"libstatspush_compat",
"libsysutils",
- "libutils",
"resolv_stats_test_utils",
"server_configurable_flags",
"stats_proto",
@@ -284,9 +307,12 @@ cc_test {
cc_test_library {
name: "resolv_stats_test_utils",
srcs: [
- "resolv_stats_test_utils.cpp"
+ "resolv_stats_test_utils.cpp",
+ ],
+ defaults: [
+ "netd_defaults",
+ "resolv_test_defaults",
],
- defaults: ["netd_defaults", "resolv_test_defaults"],
export_include_dirs: ["."],
static_libs: [
"libgmock",
@@ -394,11 +420,11 @@ cc_defaults {
},
},
fuzz_config: {
- cc: [
+ cc: [
"cken@google.com",
"kfcchen@google.com",
- ],
- componentid: 31808, // Android > Android OS & Apps > Systems > core networking
+ ],
+ componentid: 31808, // Android > Android OS & Apps > Systems > core networking
},
}
diff --git a/tests/dns_metrics_listener/Android.bp b/tests/dns_metrics_listener/Android.bp
index 339f63cf..91fdf8d5 100644
--- a/tests/dns_metrics_listener/Android.bp
+++ b/tests/dns_metrics_listener/Android.bp
@@ -1,4 +1,5 @@
package {
+ default_team: "trendy_team_fwk_core_networking",
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "packages_modules_DnsResolver_license"
@@ -9,7 +10,10 @@ package {
cc_test_library {
name: "libnetd_test_metrics_listener",
- defaults: ["netd_defaults", "resolv_test_defaults"],
+ defaults: [
+ "netd_defaults",
+ "resolv_test_defaults",
+ ],
srcs: [
"base_metrics_listener.cpp",
"dns_metrics_listener.cpp",
diff --git a/tests/dns_responder/Android.bp b/tests/dns_responder/Android.bp
index f69db964..3d63b689 100644
--- a/tests/dns_responder/Android.bp
+++ b/tests/dns_responder/Android.bp
@@ -1,4 +1,5 @@
package {
+ default_team: "trendy_team_fwk_core_networking",
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "packages_modules_DnsResolver_license"
@@ -9,7 +10,10 @@ package {
cc_test_library {
name: "libnetd_test_dnsresponder_ndk",
- defaults: ["netd_defaults", "resolv_test_defaults"],
+ defaults: [
+ "netd_defaults",
+ "resolv_test_defaults",
+ ],
shared_libs: [
"libbinder_ndk",
"libnetd_client",
diff --git a/tests/resolv_callback_unit_test.cpp b/tests/resolv_callback_unit_test.cpp
index 6814697e..391951b9 100644
--- a/tests/resolv_callback_unit_test.cpp
+++ b/tests/resolv_callback_unit_test.cpp
@@ -108,6 +108,7 @@ class CallbackTest : public NetNativeTestBase {
initDnsResolverCallbacks();
// Create cache for test
android::net::gDnsResolv->resolverCtrl.createNetworkCache(TEST_NETID);
+ AllowNetworkInBackground(TEST_UID, true);
}
void TearDown() override {
@@ -116,6 +117,7 @@ class CallbackTest : public NetNativeTestBase {
resetDnsResolverCallbacks();
// Delete cache for test
android::net::gDnsResolv->resolverCtrl.destroyNetworkCache(TEST_NETID);
+ AllowNetworkInBackground(TEST_UID, false);
}
int SetResolvers() {
diff --git a/tests/resolv_integration_test.cpp b/tests/resolv_integration_test.cpp
index ef2bf1e5..a7cc7a8b 100644
--- a/tests/resolv_integration_test.cpp
+++ b/tests/resolv_integration_test.cpp
@@ -221,8 +221,14 @@ class ResolverTest : public NetNativeTestBase {
// Start the binder thread pool for listening DNS metrics events and receiving death
// recipient.
ABinderProcess_startThreadPool();
+ AllowNetworkInBackground(TEST_UID, true);
+ AllowNetworkInBackground(TEST_UID2, true);
+ }
+ static void TearDownTestSuite() {
+ AIBinder_DeathRecipient_delete(sResolvDeathRecipient);
+ AllowNetworkInBackground(TEST_UID, false);
+ AllowNetworkInBackground(TEST_UID2, false);
}
- static void TearDownTestSuite() { AIBinder_DeathRecipient_delete(sResolvDeathRecipient); }
protected:
void SetUp() {
@@ -4833,7 +4839,7 @@ TEST_F(ResolverTest, ConnectTlsServerTimeout_ConcurrentQueries) {
// DOT_SERVER_UNRESPONSIVE_TIME_MS, DoT queries should timeout.
TEST_F(ResolverTest, QueryTlsServerTimeout) {
constexpr int DOT_SERVER_UNRESPONSIVE_TIME_MS = 2000;
- constexpr int TIMING_TOLERANCE_MS = 200;
+ constexpr int TIMING_TOLERANCE_MS = 500;
constexpr char hostname1[] = "query1.example.com.";
const std::vector<DnsRecord> records = {
{hostname1, ns_type::ns_t_a, "1.2.3.4"},
diff --git a/tests/resolv_private_dns_test.cpp b/tests/resolv_private_dns_test.cpp
index c9b8f46c..1f5a2328 100644
--- a/tests/resolv_private_dns_test.cpp
+++ b/tests/resolv_private_dns_test.cpp
@@ -541,6 +541,13 @@ TEST_P(TransportParameterizedTest, BlockDnsQuery) {
dot_backend.addMapping(r.host_name, r.type, r.addr);
doh_backend.addMapping(r.host_name, r.type, r.addr);
+ // TODO: Remove the flags and fix the test.
+ // These two flags are not necessary for this test case because the test does not expect DNS
+ // queries to be sent by DNS resolver. However, We should still set these two flags so that we
+ // don't forget to set them when writing similar tests in the future by referring to this one.
+ ScopedSystemProperties sp1(kDotAsyncHandshakeFlag, "0");
+ ScopedSystemProperties sp2(kDotMaxretriesFlag, "3");
+
auto parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
ASSERT_TRUE(mDnsClient.SetResolversFromParcel(parcel));
@@ -575,14 +582,14 @@ TEST_P(TransportParameterizedTest, BlockDnsQuery) {
// DataSaver information is only meaningful after V.
// TODO: Add 'else' to check that DNS queries are not blocked before V.
if (android::modules::sdklevel::IsAtLeastV()) {
- expectQueriesAreBlocked();
+ EXPECT_NO_FAILURE(expectQueriesAreBlocked());
}
} else {
// Block network access by setting UID firewall rules.
ScopeBlockedUIDRule scopeBlockUidRule(mDnsClient.netdService(), TEST_UID);
- expectQueriesAreBlocked();
+ EXPECT_NO_FAILURE(expectQueriesAreBlocked());
}
- expectQueries(0 /* dns */, 0 /* dot */, 0 /* doh */);
+ EXPECT_NO_FAILURE(expectQueries(0 /* dns */, 0 /* dot */, 0 /* doh */));
}
}
@@ -601,6 +608,13 @@ TEST_P(TransportParameterizedTest, BlockDnsQuery_FlaggedOff) {
doh_backend.addMapping(r.host_name, r.type, r.addr);
ScopedSystemProperties sp1(kFailFastOnUidNetworkBlockingFlag, "0");
+ // TODO: Remove the flags and fix the test.
+ // Context: Fake DoT server closes SSL connection after replying to each query. But a single DNS
+ // API can send two queries for A and AAAA. One of them will failed in MTS because the current
+ // setting pushed by server is no retry.
+ ScopedSystemProperties sp2(kDotAsyncHandshakeFlag, "0");
+ ScopedSystemProperties sp3(kDotMaxretriesFlag, "3");
+
resetNetwork();
auto parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
@@ -642,11 +656,12 @@ TEST_P(TransportParameterizedTest, BlockDnsQuery_FlaggedOff) {
if (testParamHasDoh()) {
EXPECT_NO_FAILURE(expectQueries(0 /* dns */, 0 /* dot */, 2 /* doh */));
- dot.clearQueries();
+ doh.clearQueries();
} else {
EXPECT_NO_FAILURE(expectQueries(0 /* dns */, 2 /* dot */, 0 /* doh */));
- doh.clearQueries();
+ dot.clearQueries();
}
+ flushCache();
}
}
diff --git a/tests/resolv_test_utils.cpp b/tests/resolv_test_utils.cpp
index 4b09b213..a1a9e4e6 100644
--- a/tests/resolv_test_utils.cpp
+++ b/tests/resolv_test_utils.cpp
@@ -21,6 +21,7 @@
#include <android-base/chrono_utils.h>
#include <android-base/logging.h>
+#include <firewall.h>
using android::netdutils::ScopedAddrinfo;
@@ -230,6 +231,18 @@ void RemoveMdnsRoute() {
EXPECT_EQ(0, ForkAndRun(args_v6));
}
+void AllowNetworkInBackground(int uid, bool allow) {
+ if (android::modules::sdklevel::IsAtLeastV()) {
+ // Background networking is always allowed on earlier versions.
+ Firewall* firewall = Firewall::getInstance();
+ if (allow) {
+ firewall->addRule(uid, BACKGROUND_MATCH);
+ } else {
+ firewall->removeRule(uid, BACKGROUND_MATCH);
+ }
+ }
+}
+
bool is64bitAbi() {
return android::base::GetProperty("ro.product.cpu.abi", "").find("64") != std::string::npos;
}
diff --git a/tests/resolv_test_utils.h b/tests/resolv_test_utils.h
index e3f744ce..7dc1c994 100644
--- a/tests/resolv_test_utils.h
+++ b/tests/resolv_test_utils.h
@@ -431,6 +431,7 @@ android::netdutils::ScopedAddrinfo safe_getaddrinfo(const char* node, const char
void SetMdnsRoute();
void RemoveMdnsRoute();
+void AllowNetworkInBackground(int uid, bool allow);
#define SKIP_IF_BEFORE_T \
do { \
diff --git a/tests/unsolicited_listener/Android.bp b/tests/unsolicited_listener/Android.bp
index f68fc7bd..22688e2c 100644
--- a/tests/unsolicited_listener/Android.bp
+++ b/tests/unsolicited_listener/Android.bp
@@ -1,4 +1,5 @@
package {
+ default_team: "trendy_team_fwk_core_networking",
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "packages_modules_DnsResolver_license"