Drop dot at the end of service type
The service type that found from NsdManager#discoverServices() with old backend(mDnsResponder) has an extra dot at the end. And the previous API accepted both formats, so we need to keep backwards compatibility with both formats. Thus, drop that extra dot when constructing the service type for the new backend. Bug: 266030646 Test: atest FrameoworksNetTests Change-Id: I987ab866f6a3a7cff654f96978057fdd93b859d6
This commit is contained in:
@@ -21,6 +21,7 @@ import static android.net.nsd.NsdManager.FAILURE_BAD_PARAMETERS;
|
||||
import static android.net.nsd.NsdManager.FAILURE_INTERNAL_ERROR;
|
||||
import static android.net.nsd.NsdManager.FAILURE_OPERATION_NOT_RUNNING;
|
||||
|
||||
import static com.android.server.NsdService.constructServiceType;
|
||||
import static com.android.testutils.ContextUtils.mockService;
|
||||
|
||||
import static libcore.junit.util.compat.CoreCompatChangeRule.DisableCompatChanges;
|
||||
@@ -1181,6 +1182,19 @@ public class NsdServiceTest {
|
||||
verify(mSocketProvider, timeout(CLEANUP_DELAY_MS + TIMEOUT_MS)).requestStopWhenInactive();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructServiceType() {
|
||||
final String serviceType1 = "test._tcp";
|
||||
final String serviceType2 = "_test._quic";
|
||||
final String serviceType3 = "_123._udp.";
|
||||
final String serviceType4 = "_TEST._999._tcp.";
|
||||
|
||||
assertEquals(null, constructServiceType(serviceType1));
|
||||
assertEquals(null, constructServiceType(serviceType2));
|
||||
assertEquals("_123._udp", constructServiceType(serviceType3));
|
||||
assertEquals("_TEST._sub._999._tcp", constructServiceType(serviceType4));
|
||||
}
|
||||
|
||||
private void waitForIdle() {
|
||||
HandlerUtils.waitForIdle(mHandler, TIMEOUT_MS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user