Merge "Refactor IpReachabilityMonitor#notifyLost callback by removing ip param." into main
diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java
index ec8ec93..a69505c 100644
--- a/src/android/net/ip/IpClient.java
+++ b/src/android/net/ip/IpClient.java
@@ -2391,7 +2391,7 @@
                     mLog,
                     new IpReachabilityMonitor.Callback() {
                         @Override
-                        public void notifyLost(InetAddress ip, String logMsg, NudEventType type) {
+                        public void notifyLost(String logMsg, NudEventType type) {
                             final int version = mCallback.getInterfaceVersion();
                             if (version >= VERSION_ADDED_REACHABILITY_FAILURE) {
                                 final int reason = nudEventTypeToInt(type);
diff --git a/src/android/net/ip/IpReachabilityMonitor.java b/src/android/net/ip/IpReachabilityMonitor.java
index 324946e..b67046e 100644
--- a/src/android/net/ip/IpReachabilityMonitor.java
+++ b/src/android/net/ip/IpReachabilityMonitor.java
@@ -173,7 +173,7 @@
          *
          * TODO: refactor to something like notifyProvisioningLost(String msg).
          */
-        void notifyLost(InetAddress ip, String logMsg, NudEventType type);
+        void notifyLost(String logMsg, NudEventType type);
     }
 
     /**
@@ -443,7 +443,7 @@
             final NudEventType type =
                     getMacAddressChangedEventType(isFromProbe(), isNudFailureDueToRoam());
             mLog.w(logMsg);
-            mCallback.notifyLost(event.ip, logMsg, type);
+            mCallback.notifyLost(logMsg, type);
             logNudFailed(event, type);
             return;
         }
@@ -471,7 +471,6 @@
             @NonNull final NeighborEvent event) {
         final LinkProperties whatIfLp = new LinkProperties(mLinkProperties);
 
-        InetAddress ip = null;
         for (Map.Entry<InetAddress, NeighborEvent> entry : mNeighborWatchList.entrySet()) {
             // TODO: Consider using NeighborEvent#isValid() here; it's more
             // strict but may interact badly if other entries are somehow in
@@ -485,7 +484,7 @@
             // populate the map and the subsequent FAILED event will be processed.
             if (val == null || val.nudState != StructNdMsg.NUD_FAILED) continue;
 
-            ip = entry.getKey();
+            final InetAddress ip = entry.getKey();
             for (RouteInfo route : mLinkProperties.getRoutes()) {
                 if (ip.equals(route.getGateway())) {
                     whatIfLp.removeRoute(route);
@@ -544,14 +543,12 @@
                     + ", NUD event type: " + type.name()
                     + (isOrganicNudFailureAndToBeIgnored ? ", to be ignored" : "");
             Log.w(TAG, logMsg);
-            // TODO: remove |ip| when the callback signature no longer has
-            // an InetAddress argument.
             // Notify critical neighbor lost as long as the NUD failures
             // are not from kernel organic or the NUD failure event type is
             // NUD_ORGANIC_FAILED_CRITICAL but the experiment flag is not
             // enabled. Regardless, the event metrics are still recoreded.
             if (!isOrganicNudFailureAndToBeIgnored) {
-                mCallback.notifyLost(ip, logMsg, type);
+                mCallback.notifyLost(logMsg, type);
             }
         }
         logNudFailed(event, type);
diff --git a/tests/unit/src/android/net/ip/IpReachabilityMonitorTest.kt b/tests/unit/src/android/net/ip/IpReachabilityMonitorTest.kt
index 12913da..ee0f525 100644
--- a/tests/unit/src/android/net/ip/IpReachabilityMonitorTest.kt
+++ b/tests/unit/src/android/net/ip/IpReachabilityMonitorTest.kt
@@ -342,7 +342,6 @@
 
         neighborMonitor.enqueuePacket(makeNewNeighMessage(TEST_IPV4_DNS, NUD_FAILED))
         verify(callback, timeout(TEST_TIMEOUT_MS)).notifyLost(
-            eq(TEST_IPV4_DNS),
             anyString(),
             eq(NUD_ORGANIC_FAILED_CRITICAL)
         )
@@ -374,12 +373,11 @@
 
         if (expectedNotifyLost) {
             verify(callback, timeout(TEST_TIMEOUT_MS)).notifyLost(
-                eq(lostNeighbor),
                 anyString(),
                 eq(eventType)
             )
         } else {
-             verify(callback, never()).notifyLost(eq(lostNeighbor), anyString(), any())
+             verify(callback, never()).notifyLost(anyString(), any())
         }
     }
 
@@ -415,7 +413,7 @@
 
         neighborMonitor.enqueuePacket(makeNewNeighMessage(lostNeighbor, NUD_FAILED))
         handlerThread.waitForIdle(TEST_TIMEOUT_MS)
-        verify(callback, never()).notifyLost(any(), anyString(), any(NudEventType::class.java))
+        verify(callback, never()).notifyLost(anyString(), any(NudEventType::class.java))
         verifyNudFailureMetrics(eventType, ipType, lostNeighborType)
     }
 
@@ -429,7 +427,6 @@
         neighborMonitor.enqueuePacket(makeNewNeighMessage(neighbor, NUD_REACHABLE, macaddr))
         handlerThread.waitForIdle(TEST_TIMEOUT_MS)
         verify(callback, never()).notifyLost(
-            eq(neighbor),
             anyString(),
             any(NudEventType::class.java)
         )
@@ -805,7 +802,6 @@
     ) {
         neighborMonitor.enqueuePacket(makeNewNeighMessage(neighbor, NUD_REACHABLE, TEST_MAC_2))
         verify(callback, timeout(TEST_TIMEOUT_MS)).notifyLost(
-            eq(neighbor),
             anyString(),
             eq(eventType)
         )
@@ -816,7 +812,7 @@
         neighbor: InetAddress,
     ) {
         neighborMonitor.enqueuePacket(makeNewNeighMessage(neighbor, NUD_REACHABLE, TEST_MAC_2))
-        verify(callback, never()).notifyLost(eq(neighbor), anyString(), any())
+        verify(callback, never()).notifyLost(anyString(), any())
         verifyNudFailureMetricsNotReported()
     }