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

Commit ba4abf75 authored by Ken Chen's avatar Ken Chen Committed by Automerger Merge Worker
Browse files

Merge "Fix AIBinder_linkToDeath not being called issue" am: c6626fdd

Original change: https://android-review.googlesource.com/c/platform/packages/modules/DnsResolver/+/1492676

Change-Id: Iafbee54b4270e25568ae5aba3e71bdf1663b1ede
parents fda614c2 c6626fdd
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -184,8 +184,8 @@ class ResolverTest : public ::testing::Test {
        // service.
        // service.


        AIBinder* binder = AServiceManager_getService("dnsresolver");
        AIBinder* binder = AServiceManager_getService("dnsresolver");
        ndk::SpAIBinder resolvBinder = ndk::SpAIBinder(binder);
        sResolvBinder = ndk::SpAIBinder(binder);
        auto resolvService = aidl::android::net::IDnsResolver::fromBinder(resolvBinder);
        auto resolvService = aidl::android::net::IDnsResolver::fromBinder(sResolvBinder);
        ASSERT_NE(nullptr, resolvService.get());
        ASSERT_NE(nullptr, resolvService.get());


        // Subscribe the death recipient to the service IDnsResolver for detecting Netd death.
        // Subscribe the death recipient to the service IDnsResolver for detecting Netd death.
@@ -371,11 +371,16 @@ class ResolverTest : public ::testing::Test {
    // Use a shared static death recipient to monitor the service death. The static death
    // Use a shared static death recipient to monitor the service death. The static death
    // recipient could monitor the death not only during the test but also between tests.
    // recipient could monitor the death not only during the test but also between tests.
    static AIBinder_DeathRecipient* sResolvDeathRecipient;  // Initialized in SetUpTestSuite.
    static AIBinder_DeathRecipient* sResolvDeathRecipient;  // Initialized in SetUpTestSuite.

    // The linked AIBinder_DeathRecipient will be automatically unlinked if the binder is deleted.
    // The binder needs to be retained throughout tests.
    static ndk::SpAIBinder sResolvBinder;
};
};


// Initialize static member of class.
// Initialize static member of class.
std::shared_ptr<DnsMetricsListener> ResolverTest::sDnsMetricsListener;
std::shared_ptr<DnsMetricsListener> ResolverTest::sDnsMetricsListener;
AIBinder_DeathRecipient* ResolverTest::sResolvDeathRecipient;
AIBinder_DeathRecipient* ResolverTest::sResolvDeathRecipient;
ndk::SpAIBinder ResolverTest::sResolvBinder;


TEST_F(ResolverTest, GetHostByName) {
TEST_F(ResolverTest, GetHostByName) {
    constexpr char nonexistent_host_name[] = "nonexistent.example.com.";
    constexpr char nonexistent_host_name[] = "nonexistent.example.com.";