This patch only adjusts the existing tests for the change
in the companion patch. Actual tests will come as a followup
because this patch is already big enough.
Test: VpnTest
Bug: 269715746
Change-Id: I65542a8f4151b4857f1b3758b2cae887bfbfe261
Regardless of IFF_MULTICAST (and IFF_BROADCAST), always include wifi
transport interfaces, and always exclude cellular transport interfaces.
Some interfaces do not have the multicast or broadcast flag set
properly. Use the transport to determine whether to use them, rather
than the interface flags.
Bug: 268138840
Test: atest MdnsSocketProviderTest
Change-Id: Idbddfa9d2cc05ce1850786aa634da4c38afd3fc0
only the test code ever passes in anything that isn't
a limit {UID_ALL, INTERFACES_ALL, TAG_ALL} (ie. no limit)
Test: TreeHugger, atest libnetworkstats_test FrameworksNetTests
Bug: 276296921
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ida489f25c4da4b12541c6001b41d9e4b30804eff
INetd.LOCAL_NET_ID cannot be referred to by system SDK. To make the
MdnsSocketProvider built with system SDK, the reference to
INetd.LOCAL_NET_ID must be removed.
This network is created in MdnsSocketProvider.java and propagated
through MdnsSocketProvider.java -> MdnsMultinetworkSocketClient.java ->
MdnsDiscoveryManager.java -> MdnsServiceTypeClient.java ->
NsdService.java. In NsdService.java, it was used in
handleMdnsDiscoveryManagerEvent() -> buildNsdServiceInfoFromMdnsEvent()
-> setServiceNetworkForCallback(). The setServiceNetworkForCallback() is
updated to handle the NETID_UNSET the same as LOCAL_NET_ID.
Test: atest CtsNetTestCases FrameworksNetTests
Bug: 272392042
Change-Id: I07c573948e9dc6249325f0733807bb7a7ffc281c
The system polls TCP connections every 2 minutes for the auto
on/off keepalives. For some carriers, the NAT-T keepalive delay
is lower than this, which means it's possible a TCP connection
is opened seconds after the poll. This may cause connections
being disconnected because keepalive timed-out.
The minimal acceptable value should be the same as the keepalive
delay. But the system may take time to restart keepalive. Adjust
the delay of the polling alarm to be lower than the keepalive
delay to preserve some time for the system to restart the
keepalive.
Bug: 273411114
Test: atest FrameworksNetTests
Change-Id: I28f71ceb7b72d83e6e0f8f7d22d3d1e9dbdaa467
The active network LinkProperties are not cleaned up after stop
socket monitoring. Then the apps will have duplicate sockets
to discover on one interface if the interface has been toggled,
because requestSocket will return both the old socket (for the
old netId that is actually gone) and a new socket on the same
interface, for the new netId. Thus, clean up the LinkProperties
when stop monitoring sockets.
Bug: 274063187
Test: atest FrameworksNetTests android.net.cts.NsdManagerTest
Change-Id: I3d600169b069a1534bd740e711bc21db107b1201
Somewhat surprisingly, HandlerThread#quitSafely is *not* a synchronous
method, so the tearDown() method still needs to wait for the thread to
join.
Test: TH
Change-Id: I0433e2100adf9299a67af5c259a518cf44f4be57
Apps targeting sdk < U are considered to use a legacy native
daemon as NsdManager backend, but other apps use a
platform-integration mDNS implementation as backend. So add a
CompatChange flag to enable platform backend for non-legacy
apps.
Bug: 270306772
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I7ba58f8a5186fb49ad5f8aeacc8b8234bef1eabe
When the test is very slow (e.g. in coverage tests) it's
possible this test takes > 30 seconds and cell finishes
lingering before the end of the test. This will cause a
disconnection of cell before wifi and fail the test.
Address this by requesting cell.
Bug: 273383734
Test: atest --iterations 100 'FrameworksNetTests:android.net.connectivity.com.android.server.ConnectivityServiceTest#testExplicitlySelected'
Change-Id: I06a7ef82de966b522e58a969c25a4c0335dbc497
after the commit aosp/1948496, both mMobileIfaces and mWifiIfaces
already contain the stacked interfaces. Hence, the method is not
really useful.
Test: TH
Fix: 215633405
Change-Id: Id132a166e9cf94cab711f417a4f7ffc84eab6185
The running task in MdnsServiceTypeClient would be cancel if the
requests using other networks for the same service type start a
new discovery. Besides, the instanceNameToResponse cache would
be incorrect too. The service attributes may be different on
different networks, so there needs to be a different instance
of the cache. Thus, the MdnsServiceTypeClient needs to be
Network-specific.
Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: Id5ac42f3522a774fe9789c0de4d5357501b63868
The required sockets may not have been created yet when
MdnsServiceTypeClient#startSendAndReceive is called on
MdnsDiscoveryManager#registerListener, so the first send would go
nowhere, and only later retries would be sent. Ideally the code
would wait for some sockets to be created before calling
startSendAndReceive.
Bug: 265787401
Bug: 264634275
Test: atest FrameworksNetTests
Change-Id: Id789d564d125c0192e742d7dd246367afdb93413
matchesWifiNetworkKey expects a non-null value of the
wifiNetworkKey, however, it might be null in practice
and the null wifiNetworkKey will be stored into disk.
And then when the matchesWifiNetworkKey is called, the
requireNonNull will crash the system. Thus, remove the
requireNonNull from matchesWifiNetworkKey to avoid
system crash and handle if the wifiNetworkKey is null
then it should not match a template with non-empty
mMatchWifiNetworkKeys.
Check if WifiInfo contains a null network key then skip it
to prevent adding the identity to the network identity set.
Also, add a Log.wtf when setWifiNetworkKey(info.getNetworkKey()),
this might be useful to catch why the wifiNetworkKey is
null.
Bug: 267815242
Bug: 266598304
Test: FrmeworksNetTests
Change-Id: I9c21f7e3dca9482133c7e331741cf808105414e9
API council has requested that the recently added BroadcastOptions
APIs be modified to better match API guidelines.
Bug: 267646347
Test: treehugger
Change-Id: Ia701ae31079476d0cc05079d62cd90ba81279cdd
Although case should not matter when comparing attributes,
converting all keys to lowercase breaks NsdServiceInfo APIs which
provide the original case to the caller.
Use a TreeMap with a case-insensitive comparator to ignore case when
querying keys, while keeping case information in the map.
Bug: 270885892
Test: atest MdnsServiceInfoTest
Change-Id: Id15947b1e8650eb6b59126c5d2dc8624ae4f8100
- Make a method addOrReplaceRecord() that can support point,
inet4Address and inet6Address records adding.
- Also fix some leftover comments in aosp/2431933
Bug: 268586836
Test: atest FrameworksNetTests
Change-Id: I01462a967a04e88f14dcbb92ca207deb4268612c
Now, the multiple addresses is supported in resolution service
with the new java backend. Thus, fill in all resolved addresses
into NsdServiceInfo.
Bug: 268586836
Test: atest FrameworksNetTests
Change-Id: I499a749255429df9fe9fbad678074ad383159240
registerServiceInfoCallback currently only sends updates for
addresses added, but does not handle removes (expiration) and
TXT/SRV record updates. Thus, migrate its backend to
MdnsDiscoveryManager which can support the expiration update.
Bug: 266030646
Test: atest FrameworksNetTests CteNetTestCases
Change-Id: I72add213935dc1beacb6277007868ad30bd89c00
If the mDNS service has multiple IPv4 / IPv6 addresses, only the
last added address will be present on the response. Since the
NsdServiceInfo supports multiple host addresses in Android U, the
MdnsResponse should also support multiple IPv4 / IPv6 addresses
in favor of providing accurate service info to clients.
Check cache flush flag on the response when adding a new address
record. Per RFC6762 10.2, clear all address records if the
cache-flush bit set.
Bug: 268586836
Test: atest FrameworksNetTests
Change-Id: I04548a3f16837939f3131b84c1033377ff81d521
The flags allow enabling MdnsDiscoveryManager or MdnsAdvertiser for
specific service types only. For example:
mdns_type_allowlist_flags = "_type1._tcp:flag1,_type2._tcp:flag2"
mdns_discovery_manager_allowlist_flag1_version = 1234
mdns_advertiser_allowlist_flag2_version = 2345
will enable MdnsDiscoveryManager when discovering/resolving services of
type _type1._tcp, and MdnsAdvertiser when advertising services of type
_type2._tcp.
Test: atest NsdServiceTest
Bug: 270885892
Change-Id: I75c31a28472210bf8777409ea7aff1e3d8bf0a0d
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
* changes:
Return ERROR_NO_ANSWERS for replies with no answer
Allow resolving previously undiscovered services
Use resolveInstanceName in NsdService
Add missing SRV/TXT/address records to responses
Update record TTL in set/add methods
Clear inetaddress fields when removing the record
The resolveService() uses new mdns backend if the
MdnsDiscoveryManager feature is enabled. So the new API
stopServiceResolution() should have new mdns backend
implementation as well.
Test: atest FrameworksNetTests
Change-Id: I73fa9ca71c0afc5db99db9252f4c030d4f2b8066