From 20556631d8f7242ccc06c9e9921defdb05fb23d7 Mon Sep 17 00:00:00 2001 From: Paul Hu Date: Sat, 26 Apr 2025 04:15:47 +0000 Subject: [PATCH] Rename getAllInterfaceOffloadServiceInfos to notifyOffloadStart This renaming is to align the DiscoveryManager design and reflect its real usage. Bug: 410734687 Test: atest ConnectivityCoverageTests NsdManagerTest Flag: EXEMPT rename method only Change-Id: I0d198aa0752ef51353e4164b612b6ff268ace16a --- service-t/src/com/android/server/NsdService.java | 2 +- .../android/server/connectivity/mdns/MdnsAdvertiser.java | 7 ++++--- tests/unit/java/com/android/server/NsdServiceTest.java | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/service-t/src/com/android/server/NsdService.java b/service-t/src/com/android/server/NsdService.java index ebd5caa901..821a145272 100644 --- a/service-t/src/com/android/server/NsdService.java +++ b/service-t/src/com/android/server/NsdService.java @@ -2242,7 +2242,7 @@ public class NsdService extends INsdManager.Stub { final String targetInterface = offloadEngineInfo.mInterfaceName; final IOffloadEngine offloadEngine = offloadEngineInfo.mOffloadEngine; final List offloadWrappers = - mAdvertiser.getAllInterfaceOffloadServiceInfos(targetInterface); + mAdvertiser.notifyOffloadStart(targetInterface); for (MdnsAdvertiser.OffloadServiceInfoWrapper wrapper : offloadWrappers) { try { offloadEngine.onOffloadServiceUpdated(wrapper.mOffloadServiceInfo); diff --git a/service-t/src/com/android/server/connectivity/mdns/MdnsAdvertiser.java b/service-t/src/com/android/server/connectivity/mdns/MdnsAdvertiser.java index 767834bd09..e726a555a0 100644 --- a/service-t/src/com/android/server/connectivity/mdns/MdnsAdvertiser.java +++ b/service-t/src/com/android/server/connectivity/mdns/MdnsAdvertiser.java @@ -153,13 +153,14 @@ public class MdnsAdvertiser { } /** - * Gets the current status of the OffloadServiceInfos per interface. + * Notifies the Advertiser that an offload operation is starting for a specific network + * interface. + * * @param interfaceName the target interfaceName * @return the list of current offloaded services. */ @NonNull - public List getAllInterfaceOffloadServiceInfos( - @NonNull String interfaceName) { + public List notifyOffloadStart(@NonNull String interfaceName) { return mInterfaceOffloadServices.getOrDefault(interfaceName, Collections.emptyList()); } diff --git a/tests/unit/java/com/android/server/NsdServiceTest.java b/tests/unit/java/com/android/server/NsdServiceTest.java index d19b74d1d3..bb501c6880 100644 --- a/tests/unit/java/com/android/server/NsdServiceTest.java +++ b/tests/unit/java/com/android/server/NsdServiceTest.java @@ -2127,7 +2127,7 @@ public class NsdServiceTest { "Android.local", new byte[] { 0x1, 0x2, 0x3 }, 1 /* priority */, OFFLOAD_TYPE_REPLY); doReturn(List.of(new MdnsAdvertiser.OffloadServiceInfoWrapper(123, advertingInfo))) - .when(mAdvertiser).getAllInterfaceOffloadServiceInfos(interfaceName); + .when(mAdvertiser).notifyOffloadStart(interfaceName); final FilterRepliesInfo filerRepliesInfo = new FilterRepliesInfo( "_testService", "_testType", List.of("_sub1", "_sub2"), "Android.local"); final OffloadServiceInfo discoveryInfo = @@ -2137,7 +2137,7 @@ public class NsdServiceTest { final OffloadEngine offloadEngine = registerOffloadEngine(interfaceName); // Verify that the OffloadServiceInfo retrieves from the advertiser and discoveryManager and // then sends it to the OffloadEngine. - verify(mAdvertiser).getAllInterfaceOffloadServiceInfos(interfaceName); + verify(mAdvertiser).notifyOffloadStart(interfaceName); verify(mDiscoveryManager).notifyOffloadStart(eq(interfaceName)); verify(offloadEngine).onOffloadServiceUpdated(advertingInfo); verify(offloadEngine).onOffloadServiceUpdated(discoveryInfo); @@ -2165,11 +2165,11 @@ public class NsdServiceTest { "Android.local", new byte[] { 0x1, 0x2, 0x3 }, 1 /* priority */, OFFLOAD_TYPE_REPLY); doReturn(Collections.emptyList()).when(mAdvertiser) - .getAllInterfaceOffloadServiceInfos(anyString()); + .notifyOffloadStart(anyString()); final OffloadEngine offloadEngine = registerOffloadEngine(interfaceName); // Verify that the OffloadServiceInfo retrieves from the advertiser and that no info is // sent to the OffloadEngine. - verify(mAdvertiser).getAllInterfaceOffloadServiceInfos(interfaceName); + verify(mAdvertiser).notifyOffloadStart(interfaceName); verify(offloadEngine, never()).onOffloadServiceUpdated(any()); verifyOffloadServiceUpdatedAndRemoved( interfaceName, info, mOffloadCallback, offloadEngine);