Loading apex/Android.bp +2 −4 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ package { apex { name: "com.android.resolv", updatable: true, manifest: "manifest.json", multilib: { first: { Loading @@ -41,14 +40,13 @@ apex { // Whether it actually will be compressed is controlled on per-device basis. compressible: true, // IMPORTANT: For the APEX to be installed on Android 10, // min_sdk_version should be 29. This enables the build system to make // IMPORTANT: q-launched-apex-module enables the build system to make // sure the package compatible to Android 10 in two ways: // - build the APEX package compatible to Android 10 // so that the package can be installed. // - build artifacts (lib/javalib/bin) against Android 10 SDK // so that the artifacts can run. min_sdk_version: "29", defaults: ["q-launched-apex-module"], } apex_key { Loading tests/resolv_integration_test.cpp +0 −60 Original line number Diff line number Diff line Loading @@ -383,66 +383,6 @@ class ResolverTest : public ::testing::Test { return fmt::format("127.0.100.{}", (++counter & 0xff)); } int WaitChild(pid_t pid) { int status; const pid_t got_pid = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)); if (got_pid != pid) { PLOG(WARNING) << __func__ << ": waitpid failed: wanted " << pid << ", got " << got_pid; return 1; } if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { return 0; } else { return status; } } int ForkAndRun(const std::vector<std::string>& args) { std::vector<const char*> argv; argv.resize(args.size() + 1, nullptr); std::transform(args.begin(), args.end(), argv.begin(), [](const std::string& in) { return in.c_str(); }); pid_t pid = fork(); if (pid == -1) { // Fork failed. PLOG(ERROR) << __func__ << ": Unable to fork"; return -1; } if (pid == 0) { execv(argv[0], const_cast<char**>(argv.data())); PLOG(ERROR) << __func__ << ": execv failed"; _exit(1); } int rc = WaitChild(pid); if (rc != 0) { PLOG(ERROR) << __func__ << ": Failed run: status=" << rc; } return rc; } // Add routing rules for MDNS packets, or MDNS packets won't know the destination is MDNS // muticast address "224.0.0.251". void SetMdnsRoute() { const std::vector<std::string> args = { "system/bin/ip", "route", "add", "local", "224.0.0.251", "dev", "lo", "proto", "static", "scope", "host", "src", "127.0.0.1", }; EXPECT_EQ(0, ForkAndRun(args)); } void RemoveMdnsRoute() { const std::vector<std::string> args = { "system/bin/ip", "route", "del", "local", "224.0.0.251", "dev", "lo", "proto", "static", "scope", "host", "src", "127.0.0.1", }; EXPECT_EQ(0, ForkAndRun(args)); } DnsResponderClient mDnsClient; bool mIsResolverOptionIPCSupported = false; Loading tests/resolv_private_dns_test.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -1029,6 +1029,8 @@ TEST_F(PrivateDnsDohTest, RemoteConnectionClosed) { // Make the server close the connection. This will also reset the stats, so the doh query // count below is still 2 rather than 4. ASSERT_TRUE(doh.stopServer()); // Sleep a while to avoid binding socket failed. sleep_for(milliseconds(100)); ASSERT_TRUE(doh.startServer()); EXPECT_NO_FAILURE(sendQueryAndCheckResult()); Loading tests/resolv_test_utils.cpp +61 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <arpa/inet.h> #include <android-base/chrono_utils.h> #include <android-base/logging.h> using android::netdutils::ScopedAddrinfo; Loading Loading @@ -154,3 +155,63 @@ ScopedAddrinfo safe_getaddrinfo(const char* node, const char* service, } return ScopedAddrinfo(result); } int WaitChild(pid_t pid) { int status; const pid_t got_pid = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)); if (got_pid != pid) { PLOG(WARNING) << __func__ << ": waitpid failed: wanted " << pid << ", got " << got_pid; return 1; } if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { return 0; } else { return status; } } int ForkAndRun(const std::vector<std::string>& args) { std::vector<const char*> argv; argv.resize(args.size() + 1, nullptr); std::transform(args.begin(), args.end(), argv.begin(), [](const std::string& in) { return in.c_str(); }); pid_t pid = fork(); if (pid == -1) { // Fork failed. PLOG(ERROR) << __func__ << ": Unable to fork"; return -1; } if (pid == 0) { execv(argv[0], const_cast<char**>(argv.data())); PLOG(ERROR) << __func__ << ": execv failed"; _exit(1); } int rc = WaitChild(pid); if (rc != 0) { PLOG(ERROR) << __func__ << ": Failed run: status=" << rc; } return rc; } // Add routing rules for MDNS packets, or MDNS packets won't know the destination is MDNS // muticast address "224.0.0.251". void SetMdnsRoute() { const std::vector<std::string> args = { "system/bin/ip", "route", "add", "local", "224.0.0.251", "dev", "lo", "proto", "static", "scope", "host", "src", "127.0.0.1", }; EXPECT_EQ(0, ForkAndRun(args)); } void RemoveMdnsRoute() { const std::vector<std::string> args = { "system/bin/ip", "route", "del", "local", "224.0.0.251", "dev", "lo", "proto", "static", "scope", "host", "src", "127.0.0.1", }; EXPECT_EQ(0, ForkAndRun(args)); } No newline at end of file tests/resolv_test_utils.h +3 −0 Original line number Diff line number Diff line Loading @@ -213,3 +213,6 @@ bool PollForCondition(const std::function<bool()>& condition, android::netdutils::ScopedAddrinfo safe_getaddrinfo(const char* node, const char* service, const struct addrinfo* hints); void SetMdnsRoute(); void RemoveMdnsRoute(); No newline at end of file Loading
apex/Android.bp +2 −4 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ package { apex { name: "com.android.resolv", updatable: true, manifest: "manifest.json", multilib: { first: { Loading @@ -41,14 +40,13 @@ apex { // Whether it actually will be compressed is controlled on per-device basis. compressible: true, // IMPORTANT: For the APEX to be installed on Android 10, // min_sdk_version should be 29. This enables the build system to make // IMPORTANT: q-launched-apex-module enables the build system to make // sure the package compatible to Android 10 in two ways: // - build the APEX package compatible to Android 10 // so that the package can be installed. // - build artifacts (lib/javalib/bin) against Android 10 SDK // so that the artifacts can run. min_sdk_version: "29", defaults: ["q-launched-apex-module"], } apex_key { Loading
tests/resolv_integration_test.cpp +0 −60 Original line number Diff line number Diff line Loading @@ -383,66 +383,6 @@ class ResolverTest : public ::testing::Test { return fmt::format("127.0.100.{}", (++counter & 0xff)); } int WaitChild(pid_t pid) { int status; const pid_t got_pid = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)); if (got_pid != pid) { PLOG(WARNING) << __func__ << ": waitpid failed: wanted " << pid << ", got " << got_pid; return 1; } if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { return 0; } else { return status; } } int ForkAndRun(const std::vector<std::string>& args) { std::vector<const char*> argv; argv.resize(args.size() + 1, nullptr); std::transform(args.begin(), args.end(), argv.begin(), [](const std::string& in) { return in.c_str(); }); pid_t pid = fork(); if (pid == -1) { // Fork failed. PLOG(ERROR) << __func__ << ": Unable to fork"; return -1; } if (pid == 0) { execv(argv[0], const_cast<char**>(argv.data())); PLOG(ERROR) << __func__ << ": execv failed"; _exit(1); } int rc = WaitChild(pid); if (rc != 0) { PLOG(ERROR) << __func__ << ": Failed run: status=" << rc; } return rc; } // Add routing rules for MDNS packets, or MDNS packets won't know the destination is MDNS // muticast address "224.0.0.251". void SetMdnsRoute() { const std::vector<std::string> args = { "system/bin/ip", "route", "add", "local", "224.0.0.251", "dev", "lo", "proto", "static", "scope", "host", "src", "127.0.0.1", }; EXPECT_EQ(0, ForkAndRun(args)); } void RemoveMdnsRoute() { const std::vector<std::string> args = { "system/bin/ip", "route", "del", "local", "224.0.0.251", "dev", "lo", "proto", "static", "scope", "host", "src", "127.0.0.1", }; EXPECT_EQ(0, ForkAndRun(args)); } DnsResponderClient mDnsClient; bool mIsResolverOptionIPCSupported = false; Loading
tests/resolv_private_dns_test.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -1029,6 +1029,8 @@ TEST_F(PrivateDnsDohTest, RemoteConnectionClosed) { // Make the server close the connection. This will also reset the stats, so the doh query // count below is still 2 rather than 4. ASSERT_TRUE(doh.stopServer()); // Sleep a while to avoid binding socket failed. sleep_for(milliseconds(100)); ASSERT_TRUE(doh.startServer()); EXPECT_NO_FAILURE(sendQueryAndCheckResult()); Loading
tests/resolv_test_utils.cpp +61 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <arpa/inet.h> #include <android-base/chrono_utils.h> #include <android-base/logging.h> using android::netdutils::ScopedAddrinfo; Loading Loading @@ -154,3 +155,63 @@ ScopedAddrinfo safe_getaddrinfo(const char* node, const char* service, } return ScopedAddrinfo(result); } int WaitChild(pid_t pid) { int status; const pid_t got_pid = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)); if (got_pid != pid) { PLOG(WARNING) << __func__ << ": waitpid failed: wanted " << pid << ", got " << got_pid; return 1; } if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { return 0; } else { return status; } } int ForkAndRun(const std::vector<std::string>& args) { std::vector<const char*> argv; argv.resize(args.size() + 1, nullptr); std::transform(args.begin(), args.end(), argv.begin(), [](const std::string& in) { return in.c_str(); }); pid_t pid = fork(); if (pid == -1) { // Fork failed. PLOG(ERROR) << __func__ << ": Unable to fork"; return -1; } if (pid == 0) { execv(argv[0], const_cast<char**>(argv.data())); PLOG(ERROR) << __func__ << ": execv failed"; _exit(1); } int rc = WaitChild(pid); if (rc != 0) { PLOG(ERROR) << __func__ << ": Failed run: status=" << rc; } return rc; } // Add routing rules for MDNS packets, or MDNS packets won't know the destination is MDNS // muticast address "224.0.0.251". void SetMdnsRoute() { const std::vector<std::string> args = { "system/bin/ip", "route", "add", "local", "224.0.0.251", "dev", "lo", "proto", "static", "scope", "host", "src", "127.0.0.1", }; EXPECT_EQ(0, ForkAndRun(args)); } void RemoveMdnsRoute() { const std::vector<std::string> args = { "system/bin/ip", "route", "del", "local", "224.0.0.251", "dev", "lo", "proto", "static", "scope", "host", "src", "127.0.0.1", }; EXPECT_EQ(0, ForkAndRun(args)); } No newline at end of file
tests/resolv_test_utils.h +3 −0 Original line number Diff line number Diff line Loading @@ -213,3 +213,6 @@ bool PollForCondition(const std::function<bool()>& condition, android::netdutils::ScopedAddrinfo safe_getaddrinfo(const char* node, const char* service, const struct addrinfo* hints); void SetMdnsRoute(); void RemoveMdnsRoute(); No newline at end of file