Merge "Rename getAllInterfaceOffloadServiceInfos to notifyOffloadStart" into main

This commit is contained in:
Treehugger Robot 2025-08-28 21:22:59 -07:00 • committed by Android (Google) Code Review
commit 94c93cbbe4
3 changed files with 9 additions and 8 deletions

View file

@ -2242,7 +2242,7 @@ public class NsdService extends INsdManager.Stub {
final String targetInterface = offloadEngineInfo.mInterfaceName;
final IOffloadEngine offloadEngine = offloadEngineInfo.mOffloadEngine;
final List<MdnsAdvertiser.OffloadServiceInfoWrapper> offloadWrappers =
mAdvertiser.getAllInterfaceOffloadServiceInfos(targetInterface);
mAdvertiser.notifyOffloadStart(targetInterface);
for (MdnsAdvertiser.OffloadServiceInfoWrapper wrapper : offloadWrappers) {
try {
offloadEngine.onOffloadServiceUpdated(wrapper.mOffloadServiceInfo);

View file

@ -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<OffloadServiceInfoWrapper> getAllInterfaceOffloadServiceInfos(
@NonNull String interfaceName) {
public List<OffloadServiceInfoWrapper> notifyOffloadStart(@NonNull String interfaceName) {
return mInterfaceOffloadServices.getOrDefault(interfaceName, Collections.emptyList());
}

View file

@ -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);