Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fcee20f5 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8374152 from 64bab39e to mainline-appsearch-release

Change-Id: I4bcea5c730992954a76886a621a3c9edb91f278e
parents f80afed1 64bab39e
Loading
Loading
Loading
Loading
+2 −4
Original line number Original line Diff line number Diff line
@@ -31,10 +31,8 @@
bool resolv_init(const ResolverNetdCallbacks* callbacks) {
bool resolv_init(const ResolverNetdCallbacks* callbacks) {
    android::base::InitLogging(/*argv=*/nullptr);
    android::base::InitLogging(/*argv=*/nullptr);
    LOG(INFO) << __func__ << ": Initializing resolver";
    LOG(INFO) << __func__ << ": Initializing resolver";
    // TODO(b/170539625): restore log level to WARNING after clarifying flaky tests.
    resolv_set_log_severity(android::base::WARNING);
    const bool isDebug = isUserDebugBuild();
    doh_init_logger(DOH_LOG_LEVEL_WARN);
    resolv_set_log_severity(isDebug ? android::base::DEBUG : android::base::WARNING);
    doh_init_logger(isDebug ? DOH_LOG_LEVEL_DEBUG : DOH_LOG_LEVEL_WARN);
    using android::net::gApiLevel;
    using android::net::gApiLevel;
    gApiLevel = getApiLevel();
    gApiLevel = getApiLevel();
    using android::net::gResNetdCallbacks;
    using android::net::gResNetdCallbacks;
+5 −0
Original line number Original line Diff line number Diff line
@@ -3,5 +3,10 @@
        {
        {
            "name": "FrameworksNetTests"
            "name": "FrameworksNetTests"
        }
        }
    ],
    "hwasan-postsubmit": [
        {
            "name": "FrameworksNetTests"
        }
    ]
    ]
}
}
+16 −1
Original line number Original line Diff line number Diff line
@@ -233,7 +233,7 @@ impl DohFrontend {
        backend_socket.connect(self.backend_socket_addr)?;
        backend_socket.connect(self.backend_socket_addr)?;
        backend_socket.set_nonblocking(true)?;
        backend_socket.set_nonblocking(true)?;


        let frontend_socket = std::net::UdpSocket::bind(self.listen_socket_addr)?;
        let frontend_socket = bind_udp_socket_retry(self.listen_socket_addr)?;
        frontend_socket.set_nonblocking(true)?;
        frontend_socket.set_nonblocking(true)?;


        let clients = ClientMap::new(create_quiche_config(
        let clients = ClientMap::new(create_quiche_config(
@@ -473,3 +473,18 @@ fn build_pipe() -> Result<(File, File)> {
    }
    }
    Err(anyhow::Error::new(std::io::Error::last_os_error()).context("build_pipe failed"))
    Err(anyhow::Error::new(std::io::Error::last_os_error()).context("build_pipe failed"))
}
}

// Can retry to bind the socket address if it is in use.
fn bind_udp_socket_retry(addr: std::net::SocketAddr) -> Result<std::net::UdpSocket> {
    for _ in 0..3 {
        match std::net::UdpSocket::bind(addr) {
            Ok(socket) => return Ok(socket),
            Err(e) if e.kind() == std::io::ErrorKind::AddrInUse => {
                warn!("Binding socket address {} that is in use. Try again", addr);
                std::thread::sleep(Duration::from_millis(50));
            }
            Err(e) => return Err(anyhow::anyhow!(e)),
        }
    }
    Err(anyhow::anyhow!(std::io::Error::last_os_error()))
}
+0 −14
Original line number Original line Diff line number Diff line
@@ -791,9 +791,6 @@ TEST_F(PrivateDnsDohTest, ExcessDnsRequests) {
    const int initial_max_idle_timeout_ms = 2000;
    const int initial_max_idle_timeout_ms = 2000;
    ASSERT_TRUE(doh.stopServer());
    ASSERT_TRUE(doh.stopServer());
    EXPECT_TRUE(doh.setMaxIdleTimeout(initial_max_idle_timeout_ms));
    EXPECT_TRUE(doh.setMaxIdleTimeout(initial_max_idle_timeout_ms));
    // Sleep a while to avoid binding socket failed.
    // TODO: Make DohFrontend retry binding sockets.
    sleep_for(milliseconds(100));
    ASSERT_TRUE(doh.startServer());
    ASSERT_TRUE(doh.startServer());


    auto parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
    auto parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
@@ -886,9 +883,6 @@ TEST_F(PrivateDnsDohTest, RunOutOfDataLimit) {


    ASSERT_TRUE(doh.stopServer());
    ASSERT_TRUE(doh.stopServer());
    EXPECT_TRUE(doh.setMaxBufferSize(initial_max_data));
    EXPECT_TRUE(doh.setMaxBufferSize(initial_max_data));
    // Sleep a while to avoid binding socket failed.
    // TODO: Make DohFrontend retry binding sockets.
    sleep_for(milliseconds(100));
    ASSERT_TRUE(doh.startServer());
    ASSERT_TRUE(doh.startServer());


    const auto parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
    const auto parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
@@ -938,8 +932,6 @@ TEST_F(PrivateDnsDohTest, RunOutOfStreams) {


    ASSERT_TRUE(doh.stopServer());
    ASSERT_TRUE(doh.stopServer());
    EXPECT_TRUE(doh.setMaxStreamsBidi(initial_max_streams_bidi));
    EXPECT_TRUE(doh.setMaxStreamsBidi(initial_max_streams_bidi));
    // Sleep a while to avoid binding socket failed.
    sleep_for(milliseconds(100));
    ASSERT_TRUE(doh.startServer());
    ASSERT_TRUE(doh.startServer());


    const auto parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
    const auto parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
@@ -978,8 +970,6 @@ TEST_F(PrivateDnsDohTest, ReconnectAfterIdleTimeout) {


    ASSERT_TRUE(doh.stopServer());
    ASSERT_TRUE(doh.stopServer());
    EXPECT_TRUE(doh.setMaxIdleTimeout(initial_max_idle_timeout_ms));
    EXPECT_TRUE(doh.setMaxIdleTimeout(initial_max_idle_timeout_ms));
    // Sleep a while to avoid binding socket failed.
    sleep_for(milliseconds(100));
    ASSERT_TRUE(doh.startServer());
    ASSERT_TRUE(doh.startServer());


    const auto parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
    const auto parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
@@ -1062,8 +1052,6 @@ TEST_F(PrivateDnsDohTest, SessionResumption) {


        ASSERT_TRUE(doh.stopServer());
        ASSERT_TRUE(doh.stopServer());
        EXPECT_TRUE(doh.setMaxIdleTimeout(initial_max_idle_timeout_ms));
        EXPECT_TRUE(doh.setMaxIdleTimeout(initial_max_idle_timeout_ms));
        // Sleep a while to avoid binding socket failed.
        sleep_for(milliseconds(100));
        ASSERT_TRUE(doh.startServer());
        ASSERT_TRUE(doh.startServer());


        const auto parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
        const auto parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
@@ -1112,8 +1100,6 @@ TEST_F(PrivateDnsDohTest, RemoteConnectionClosed) {
    // Make the server close the connection. This will also reset the stats, so the doh query
    // Make the server close the connection. This will also reset the stats, so the doh query
    // count below is still 2 rather than 4.
    // count below is still 2 rather than 4.
    ASSERT_TRUE(doh.stopServer());
    ASSERT_TRUE(doh.stopServer());
    // Sleep a while to avoid binding socket failed.
    sleep_for(milliseconds(100));
    ASSERT_TRUE(doh.startServer());
    ASSERT_TRUE(doh.startServer());


    EXPECT_NO_FAILURE(sendQueryAndCheckResult());
    EXPECT_NO_FAILURE(sendQueryAndCheckResult());
+0 −5
Original line number Original line Diff line number Diff line
@@ -55,11 +55,6 @@ inline uint64_t getApiLevel() {
    return std::max(buildVersionSdk + !!buildVersionPreviewSdk, firstApiLevel);
    return std::max(buildVersionSdk + !!buildVersionPreviewSdk, firstApiLevel);
}
}


// It's the identical strategy as frameworks/base/core/java/android/os/Build.java did.
inline bool isUserDebugBuild() {
    return (android::base::GetProperty("ro.build.type", "user") == "userdebug");
}

inline bool isDoHEnabled() {
inline bool isDoHEnabled() {
    static bool isAtLeastT = android::modules::sdklevel::IsAtLeastT();
    static bool isAtLeastT = android::modules::sdklevel::IsAtLeastT();
    return android::net::Experiments::getInstance()->getFlag("doh", isAtLeastT ? 1 : 0);
    return android::net::Experiments::getInstance()->getFlag("doh", isAtLeastT ? 1 : 0);