Commit graph android_packages_modules_Co.../tests/unit/java/com
Message SHA1
Avoid creating a Network with INetd.LOCAL_NET_ID
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

Yuyang Huang   commited 2023-04-05 13:06:13 +09:00
3bee9d4099
Merge "Request cell in #testExplicitlySelected"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-03-28 07:57:33 +00:00
dafaf2a08b
Merge "Adjust polling interval for auto on/off keepalives"
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-03-27 06:05:08 +00:00
0342985117
Adjust polling interval for auto on/off keepalives
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

chiachangwang   commited 2023-03-25 09:15:08 +00:00
d953d0182a
Merge "Verify the update of shouldLongLivedTcpExcluded in VpnTransportInfo"
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-03-25 04:12:22 +00:00
ce1bc54e66
Merge "Clean up the LinkProperties when stop monitoring sockets"
Paul Hu   authored and   Gerrit Code Review   commited 2023-03-21 01:30:05 +00:00
46eb5f4b5e
Clean up the LinkProperties when stop monitoring sockets
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

Paul Hu   commited 2023-03-20 15:06:05 +08:00
13921b2cdc
Merge changes from topics "nonAutoIPSelection", "preferredIpProtocol"
* changes:
  Test IP version and encap type set in non-auto IP selection mode
  Test reading preferred IP protocol from carrierconfig

Chiachang Wang   authored and   Gerrit Code Review   commited 2023-03-20 02:39:42 +00:00
f6682143ac
Merge "Add a CompatChange flag to enable platform backend"
Paul Hu   authored and   Gerrit Code Review   commited 2023-03-17 13:14:19 +00:00
62503cfef1
Connectivity Tests: join handler thread after calling quitSafely
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

Patrick Rohr   commited 2023-03-17 01:01:09 -07:00
98021b650b
Merge "Factor out adding records to a generic"
Paul Hu   authored and   Gerrit Code Review   commited 2023-03-17 02:30:39 +00:00
a08f8867f8
Verify the update of shouldLongLivedTcpExcluded in VpnTransportInfo
Bug: 273422889
Test: atest FrameworksNetTests
Change-Id: I5e25d1b8b1f86dc4474cef1616cb16668119240a

chiachangwang   commited 2023-03-17 02:04:13 +00:00
052dbb85d3
Add a CompatChange flag to enable platform backend
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

Paul Hu   commited 2023-03-17 09:10:46 +08:00
2e0a88c0fa
Request cell in #testExplicitlySelected
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

Chalard Jean   commited 2023-03-16 22:12:52 +09:00
7cf34ec1cd
Test IP version and encap type set in non-auto IP selection mode
Test: atest FrameworksNetTests
Change-Id: I8f4a54f7b35135806c940b5cee2c600f4454f2fb

chiachangwang   commited 2023-03-16 03:00:45 +00:00
e1aacc797c
IpConfigStoreTest: increase timeout for waitForIdle
waitForIdle in readIpConfigurationFromFilePath times out.

Test: TH
Change-Id: I5bc8c5b4678b984ec6406d85725297a63faeaabf

Patrick Rohr   commited 2023-03-15 19:48:25 +00:00
c641e019ef
Test reading preferred IP protocol from carrierconfig
Bug: 259000745
Test: atest FrameworksNetTests
Change-Id: Ie9f546ae60fcc2e21479e5d7cbc86c96cfbedc84

chiachangwang   commited 2023-03-15 05:20:22 +00:00
55dc7b6e9f
Merge changes from topics "kpFromCarrier", "noNetCapNoMigration"
* changes:
  Verify no migration started without valid network capabilties
  Test reading keepalive timer from carrierconfig

Chiachang Wang   authored and   Gerrit Code Review   commited 2023-03-09 12:17:21 +00:00
c211511b64
Verify no migration started without valid network capabilties
Bug: 269714970
Test: atest FrameworksNetTests
Change-Id: I0f1a8cbdcb0a8a102036388b39162dca775c3f5d

chiachangwang   commited 2023-03-09 09:02:40 +00:00
334b8dba3a
Test reading keepalive timer from carrierconfig
Bug: 259000745
Test: atest FrameworksNetTests
Change-Id: I2e750a7b090dd09553fae921163e19fc99a2d582

chiachangwang   commited 2023-03-09 09:01:17 +00:00
3a91e2d4f6
Merge "Remove unused augmentWithStackedInterfaces"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-03-09 06:55:24 +00:00
e9df7ca57f
Merge "Update system APIs based on feedback."
Jeff Sharkey   authored and   Gerrit Code Review   commited 2023-03-09 02:47:49 +00:00
31b6c65f51
Merge changes from topic "PerNetworkServiceTypeClient"
* changes:
  Create MdnsServiceTypeClient per network
  Wait for a socket to be created before sending packets

Paul Hu   authored and   Gerrit Code Review   commited 2023-03-08 11:14:57 +00:00
71c006bd14
Merge "Migrate reigster service callback backend"
Paul Hu   authored and   Gerrit Code Review   commited 2023-03-08 10:27:57 +00:00
ee0e6cd701
Remove unused augmentWithStackedInterfaces
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

Junyu Lai   commited 2023-03-08 13:49:00 +08:00
615610c3d1
Create MdnsServiceTypeClient per network
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

Paul Hu   commited 2023-03-08 10:01:50 +08:00
da3c0fe857
Wait for a socket to be created before sending packets
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

Paul Hu   commited 2023-03-07 19:21:24 +08:00
bf9d2a0ea0
Update system APIs based on feedback.
API council has requested that the recently added BroadcastOptions
APIs be modified to better match API guidelines.

Bug: 267646347
Test: treehugger
Change-Id: Ia701ae31079476d0cc05079d62cd90ba81279cdd

Jeff Sharkey   commited 2023-03-06 14:10:34 -07:00
4ffd34cc42
Merge "Keep case in MdnsServiceInfo attributes"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-03-06 13:03:46 +00:00
2172a5a370
Keep case in MdnsServiceInfo attributes
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

Remi NGUYEN VAN   commited 2023-03-06 19:52:53 +09:00
0e929ddfcd
Factor out adding records to a generic
- 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

Paul Hu   commited 2023-03-06 15:13:00 +08:00
ab4b7d886c
Fill in all resolved addresses into NsdServiceInfo
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

Paul Hu   commited 2023-03-06 14:27:53 +08:00
2b86591d39
Migrate reigster service callback backend
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

Paul Hu   commited 2023-03-06 13:49:19 +08:00
30bd70d168
Merge "Support multiple IPv4 / IPv6 addresses in MdnsResponse"
Paul Hu   authored and   Gerrit Code Review   commited 2023-03-06 03:47:09 +00:00
6477d7b697
Support multiple IPv4 / IPv6 addresses in MdnsResponse
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

Paul Hu   commited 2023-03-03 21:40:47 +08:00
3a632aeb6b
Merge changes I987ab866,I73fa9ca7
* changes:
  Drop dot at the end of service type
  Implement the stop resolution with MdnsDiscoveryManager

Paul Hu   authored and   Gerrit Code Review   commited 2023-03-03 12:56:38 +00:00
e4407fb469
Add flags for allowlisting types for new NSD impl
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

Remi NGUYEN VAN   commited 2023-03-03 18:00:59 +09:00
151d0a5528
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

Paul Hu   commited 2023-03-03 16:18:32 +08:00
7445e3dc78
Merge changes I488cc768,Icb9ed7ae,Ib18c3afb,Iba293b47,Ied55829c, ...
* 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

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-03-03 07:45:24 +00:00
de5adc4f1f
Implement the stop resolution with MdnsDiscoveryManager
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

Paul Hu   commited 2023-03-03 14:20:11 +08:00
e4f5f258d6
Allow resolving previously undiscovered services
Previously resolve queries for SRV/TXT/A/AAAA were only sent when there
was a known but incomplete MdnsResponse for the service.

Allow sending the resolve queries when there is no known MdnsResponse,
so no known PTR record, but the client specified the resolveInstanceName
in the MdnsSearchOptions. This is achieved by adding the serviceName as
an additional field in MdnsResponse, as it is always known when
constructing the MdnsResponse. The serviceName can either be set from a
discovered PTR record, or from the client-specified resolveInstanceName.

Bug: 267570781
Test: atest NsdManagerTest#testResolveWhenServerSendsNoAdditionalRecord
      (see separate change).
Change-Id: Icb9ed7ae44179a5df5b69a1e6a0486ffc2d8e42c

Remi NGUYEN VAN   commited 2023-03-03 12:51:40 +09:00
448100884e
Use resolveInstanceName in NsdService
For resolve requests, specify the resolveInstanceName in
MdnsSearchOptions.

This will cause discovery to send followup queries when TXT/SRV/A/AAAA
records are missing; for example if only a PTR record is returned
following the discovery probes, or if no discovery probe is sent at all.

Test: atest NsdServiceTest
Bug: 267570781
Change-Id: Ib18c3afbd1533ada7a78dd8ccac993adb439d014

Remi NGUYEN VAN   commited 2023-03-03 11:58:21 +09:00
bb62b1de50
Add missing SRV/TXT/address records to responses
MdnsResponses were only updated through
MdnsResponse.mergeRecordsFrom(MndsResponse), meaning that MdnsResponse
cannot be updated unless a MdnsResponse can be built from the update
packet.

Because a PTR record is required to build a MdnsResponse, this means
that it was not possible to add records to a MdnsResponse unless the
update packet contains a PTR record.

Fix this by having MdnsServiceTypeClient augment its current known
responses in addition to creating new responses from incoming
MdnsPackets.

Bug: 267570781
Test: atest NsdManagerTest#testPtrOnlyResponse with
      mdns_discovery_manager_version set to 1.
Change-Id: Iba293b4772fcd79e94ee6412c9af8225a3349f12

Remi NGUYEN VAN   commited 2023-03-03 11:58:21 +09:00
42b1042f36
Update record TTL in set/add methods
MdnsResponse would not replace records if the TTL changed, but this is
necessary in particular in case of exit announcements (RFC6762 10.1)
where the TTL is updated to zero.

Update MdnsResponse to update records if the TTL changed. The
receiptTimeMillis is still not considered to update records, but doing
so would generate service change notifications every time a reply is
received, so this is not covered here.

Bug: 267570781
Test: atest MdnsResponseTests
Change-Id: Ied55829cba6b043d13603a8230bda457c07de42f

Remi NGUYEN VAN   commited 2023-03-03 11:58:20 +09:00
36981e2352
Clear inetaddress fields when removing the record
When calling MdnsResponse.setInet4AddressRecord with null, the record
was removed from the records list, but not from the inet4AddressRecord /
inet6AddressRecord fields.

Fix that, and update the MdnsResponseDecoder test that missed the bug
because it modified the same incomplete MdnsResponse multiple times
(so isComplete keeps returning false), instead of using a copy of
a complete MdnsResponse.

This requires using a copy constructor, which will be useful for future
changes, so add it with a test.

Bug: 267570781
Test: atest
Change-Id: I199a8e4bc9a54a142c1fec1acee2ab6b1baa7efb

Remi NGUYEN VAN   commited 2023-03-03 11:43:03 +09:00
af4ea5826b
Merge "Uses identical hostName across all interface"
Yuyang Huang   authored and   Gerrit Code Review   commited 2023-03-02 23:40:29 +00:00
09cad2bc2d
Merge "Revert "Implement the stop resolution with MdnsDiscoveryManager""
Ahmad Khalil   authored and   Gerrit Code Review   commited 2023-03-02 11:58:28 +00:00
8d45846632
Revert "Implement the stop resolution with MdnsDiscoveryManager"
This reverts commit 6d77c41f2a.

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=aosp-master&target=aosp_cf_x86_64_phone-userdebug&lkgb=9678930&lkbb=9678975&fkbb=9678975, bug b/271400306

Change-Id: I8bfd2b8117ea401df7441116b983f5fe19f63d5d
BUG: 271400306

Ahmad Khalil   authored and   Gerrit Code Review   commited 2023-03-02 11:43:25 +00:00
4b8d45a4c1
Merge "Implement the stop resolution with MdnsDiscoveryManager"
Paul Hu   authored and   Gerrit Code Review   commited 2023-03-02 10:31:30 +00:00
1246c7243b
Merge "Stop monitoring sockets until all sockets are unrequested"
Paul Hu   authored and   Gerrit Code Review   commited 2023-03-02 10:21:05 +00:00
6772a31c5a