Commit graph android_packages_modules_Co.../tests/common/java
Message SHA1
Support matches transport types in NetworkTemplate
Flag: EXEMPT implemented in the counter-part CL
Test: atest CtsNetTestCases --test-filter \
      'NetworkStats*' --update-device
Test: atest ConnectivityCoverageTests --test-filter \
      'NetworkStats*' --update-device
Test: atest ConnectivityCoverageTests --test-filter \
      'NetworkTemplate*' --update-device
Bug: 419123367
Change-Id: I0c8bf2e24502befd810081f519ff915491b0a905

Junyu Lai   commited 2025-05-27 20:35:40 +08:00
3fd36e5f93
Fix kotlin lint errors in NetworkTemplateTests
Flag: EXEMPT Test only refactor
Test: atest ConnectivityCoverageTests --test-filter \
  'NetworkTemplate*' --update-device
Bug: 419123367
Change-Id: I7f87c4a9f4f3e40c0274bf6539ccff4e42967cc8

Junyu Lai   commited 2025-05-23 15:34:53 +08:00
ab696ccc1b
Remove RecorderCallback.
This class doesn't actually serve a purpose, it only makes
TestableNetworkCallbck more complex.

Test: CtsNetTestCases ConnectivityCoverageTests
Flag: EXEMPT test-only
Change-Id: I39a598b82a3215384bdfe04980f4b280ab2c2716

Chalard Jean   commited 2025-05-19 16:35:53 +09:00
f2994122c1
Merge "Parcel Network#mPrivateDnsBypass" into main
Jean Chalard   authored and   Android (Google) Code Review   commited 2025-05-19 00:03:32 -07:00
499961d60f
Remove deprecated SC_V2 constant
Test: TH
Flag: EXEMPT test-only
Change-Id: I3444fad305f49294ed8c3a850b631f385678c117

Chalard Jean   commited 2025-05-15 09:03:59 +09:00
9373e3442e
Parcel Network#mPrivateDnsBypass
Though all versions will parcel this, the behavior will not change
before B. Starting with B, this flag is parceled and handed over
to apps.

Test: ConnectivityCoverageTests, CtsNetTestCases
Flag: EXEMPT no behavior change before B
Change-Id: I7e9ae9011c74b80c208d8f297aa3b7d1aea176f2

Chalard Jean   authored and   Xiao Ma   commited 2025-04-07 11:46:38 +09:00
4f07a5b911
Add MatchNonThreadLocalNetworks flag in NetworkCapabilities
This is for backwards compatibility. Apps targeting V or lower
SDK should not see Tethering network agent.

This restriction is still disabled to maintain no-op in this
change. Will be enabled when introducing ConnectivityService
part in the subsequent change.

Test: atest CtsNetTestCases:android.net.NetworkCapabilitiesTest \
      ConnectivityCoverageTests:android.net.connectivity.com.android.server \
      --update-device
Bug: 349487600
Change-Id: I99405ab62e82ff4b7fcebffd3a1a31ec6d8962a9

Junyu Lai   commited 2025-03-21 10:36:41 +08:00
f3ae766e8e
Merge "Revert "Add SkipNativeNetworkCreation flag in NetworkAgentConfig"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-02-26 03:02:34 -08:00
689297411a
Revert "Add SkipNativeNetworkCreation flag in NetworkAgentConfig"
This reverts commit fef111ce47.

Reason for revert: Replaced by early native network creation

Change-Id: I692f716d8651badf6d0037e55a2385d0fb0049d1

Junyu Lai   authored and   Gerrit Code Review   commited 2025-02-26 01:30:20 -08:00
b04a8048a1
Merge changes Icecb889a,Id06116ad into main
* changes:
  Set the reservationId when a new NetworkRequest is created
  Add reservationId to NetworkCapabilities

Treehugger Robot   authored and   Gerrit Code Review   commited 2024-12-12 16:08:35 -08:00
3a5b37a87c
Add reservationId to NetworkCapabilities
The reservationId is an internal field used for RESERVATION requests and
acts much like an internal, unique NetworkSpecifier value. A
NetworkRequest with a reservationId set can be satisfied by a Network /
Offer with the same reservationId or an Offer with the wildcard {@code
RES_ID_MATCH_ALL_RESERVATIONS}.

Regular requests do not set the reservationId and match any Network /
Offer (except the blanket offer) independent of their reservationId.

Test: NetworkCapabilitiesTest
Change-Id: Id06116adf776dbf09cb9f8ccb7f25ff51734e02e

Patrick Rohr   commited 2024-12-12 14:18:54 -08:00
cb91a25bb7
Merge "CaptivePortal: implement setDelegateUid API." into main
Xiao Ma   authored and   Gerrit Code Review   commited 2024-12-11 22:43:58 -08:00
69aa3c5469
CaptivePortal: implement setDelegateUid API.
This API is designed to set the UID of the app that is allowed to
perform network traffic for captive protal login, communication will
bypass network access restrictions such as VPNs and private DNS settings
when a portal page is launched by Android Custom Tabs and bind the
upcoming traffic to that portal network.

Bug: 373773542
Test: atest ConnectivityCoverageTests
Change-Id: I9992671634b8e88f5a647455811a6157fb15a44b

Patrick Rohr   authored and   Xiao Ma   commited 2024-12-11 20:27:10 +09:00
7d6dfd52b2
Add SkipNativeNetworkCreation flag in NetworkAgentConfig
This flag allows ConnectivityService to skip native network creation,
deferring this responsibility to Tethering. This is necessary because:

- ConnectivityService requires the NetworkAgent to be in the CONNECTED
  state to configure routing and invokes NetworkCallback#onAvailable
  once ready.
- Tethering requires lower-layer interactions to be completed before
  notifying applications.

This approach ensures proper synchronization between ConnectivityService
and Tethering during network setup.

Long-term, all netd operations should be handled by ConnectivityService
when it supports early native network creation in the CONNECTING state.

As a mid-term solution, this flag enables Tethering to manage native
network creation within the IpServer.

Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.NetworkAgentConfigTest
Bug: 349487600
Change-Id: I84da9c74dc4d40c7cd36c6657f17a158affed689

Junyu Lai   commited 2024-12-11 15:22:36 +08:00
fef111ce47
Support NetworkStats#addEntries API
Currently, NetworkStats#addEntry creates a new instance
containing the requested result instead of mutating the
original object. This creates a heavy memory footprint
when the caller invokes it in a loop because a new NetworkStats
instance is created whenever an addEntry is called.

This change introduces a new API that allows callers to
add a set of entries to a NetworkStats instance. This new
API will clone the instance only once, return the newly
created (and modified) instance, and ensure that the original
instance remains immutable.

Additionally, the change adopts config libraries for flagging
the API and corresponding CTS tests, since Android U-based
branches are no longer downstream of current development branches.

Test: atest FrameworksNetTests:android.net.connectivity.android.net.netstats.NetworkStatsApiTest
Test: atest CtsNetTestCases:NetworkStatsApiTest
Bug: 335680025
Fix: 357772271
API-Coverage-Bug: 357772271
Change-Id: I58513844e681c0621a6107ec4b198cd3957f289d

Junyu Lai   commited 2024-08-09 14:19:38 +08:00
d0e049455c
Stop throwing when the invalid capability is passed
When new capability is introduced and added to capaility or
forbiddenCapability by default, module rollback could cause system
server crash since JobScheduler persists network request that contains
new capability that is invalid for old code.
This CL updates capability validation not to throw exception to avoid
system crash in this case.

Bug: 343823469
Bug: 313030307
Test: NetworkCapabilitiesTest
Change-Id: I5708c475f3b4974284531212b77f9788ca9f497e

Motomu Utsumi   commited 2024-06-05 11:57:18 +09:00
ab1a0671c7
[mdns] add hidden API for public key
This commit adds support of registering a public key for a host/service.
This is required to enable Advertising Proxy feature for Thread devices.

For example:
```
NsdServiceInfo info = new NsdServiceInfo();

info.setServiceName("My Service");
info.setServiceType("_test._tcp");
info.setHostname("MyHost");
info.setHostAddresses(List.of(address1, address2));
info.setPublicKey(/* KEY RDATA */);

nsdManager.registerService(info, PROTOCOL_DNS_SD, listener);
```

Bug: 317946010

Change-Id: I367ebff8119d5c1dff0410c85e6fb86dca6c66b8

Handa Wang   commited 2024-04-24 07:02:42 +00:00
364aa570e2
Update the imports to androidx.test.filters.*
Bug: 316941721
Test: mmma .
Change-Id: I113714afaeb99bf76ff4dc19304371ad0ec097e0

Fangqiu Su   commited 2024-02-29 17:56:14 +00:00
61a14ca475
Udpate setNetworkSpecifier to support Satellite Transport.
- Allow adding two non test transports i.e. satellite and cellular
  at setNetworkSpecifier, to receive network requests related to
  satellite transport capabilities

Bug: 324347502
Test: atest FrameworksNetTests
Change-Id: I03a3d701e214792184bacfe5b5b59cdef61d555e

Nagendra Prasad Nagarle Basavaraju   commited 2024-02-26 11:24:19 +00:00
a8a74e2ccc
[mdns] add API support for custom hostname
This commit adds support of regsitering a service with a custom
hostname. This is required to enable Advertising Proxy feature for Thread
devices.

For example:
```
NsdServiceInfo info = new NsdServiceInfo();

info.setServiceName("My Service");
info.setServiceType("_test._tcp");
info.setHostname("MyHost");
info.setHostAddresses(List.of(address1, address2));

nsdManager.registerService(info, PROTOCOL_DNS_SD, listener);
```

This CL also adds two new error codes for service/host registration
conflict: `FAILURE_SERVICE_NAME_CONFLICT` and
`FAILURE_HOST_NAME_CONFLICT`.

Bug: 284904661
Test: atest CtsNetTestCases FrameworksNetTests

Change-Id: I2fb974c38d851ba99144a18c7047084bbd61b938

Handa Wang   commited 2024-01-29 06:46:43 +00:00
1c2be6b391
[mdns] add support for advertising subtypes
This commit adds support of advertising and discovering services
with subtypes.

With this change, client can publish a new service with subtypes with
code:
```
NsdServiceInfo info = new NsdServiceInfo();
info.setServiceName("My Service");
info.setServiceType("_meshcop._udp");
info.setSubtypes(Set.of("_abc"));

nsdManager.registerService(info, PROTOCOL_DNS_SD, listener);
```

Bug: 265095929
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: Ia83182e2d43002243d1ef4357d14a8056d7da14b

Kangping Dong   commited 2023-12-18 10:03:16 +08:00
6d618d77fe
Allow to query NetworkStats for TYPE_PROXY
Test: atest FrameworksNetTests CtsNetTestCases
Bug: 307217169

Change-Id: I006e3191a8c6100af3d2906d5d37f4e38a3db519

Ivo Kay   commited 2023-11-16 13:43:00 +00:00
65186a72aa
Remove @IgnoreUpTo(Q) annotation and isAtLeastR() check
Remove the Q test annotation/check since mainline updates does
not push to Q anymore. This annotation is unnecessary now.

Test: atest FrameworksNetTests
Change-Id: Iba4f38731db9f369f99ba12a3ab7ef3f3b1630b8

Chiachang Wang   commited 2023-11-06 09:35:28 +00:00
a8efe40865
Add hidden constants for communicating about local network agents
Test: FrameworksNetTests
Change-Id: Ic490fee6ee70d74acff0a290199b2946817173d0

Chalard Jean   commited 2023-10-12 13:30:49 +09:00
d6f4efb1a8
Merge "Add some tests back which were removed for fixing kotlin nullable errors" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-08-24 04:14:28 +00:00
760bcac429
Add some tests back which were removed for fixing kotlin nullable errors
Followup CL for aosp/2700076

Bug: 296972712
Test: build with aosp/2688146
Change-Id: I617b330c42a99e4c839adac2ea614756b5955ce9

Motomu Utsumi   commited 2023-08-24 11:25:21 +09:00
5324475f6e
Merge "Ignore EXCLUDED_ROUTES LinkPropertiesTest up to S_V2" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-08-22 08:19:25 +00:00
b5208bad3e
Ignore EXCLUDED_ROUTES LinkPropertiesTest up to S_V2
The platform doesn't allow overwriting compat flags that have target SDK
lower than the platform SDK in release build. Ignoring the test cases
that need compat flag overwrite up to S_V2 makes the MTS pass on S
device.

Bug: 296248982
Test: TH
Change-Id: Iab102725004c39b4dc3c0200c9bc673dd6be1302

Yuyang Huang   commited 2023-08-22 15:17:38 +09:00
7fe61f4cbd
Fix kotlin nullable errors in Connectivity tests
Fix kotlin nullable errors that were exposed by setting the retention
of android.annotation.NonNull and android.annotation.Nullable to
class retention.

Bug: 294110802
Test: builds
Change-Id: Id49e4a2ee0b7b463d99bce6eb22919b84c21443a

Colin Cross   commited 2023-08-09 10:57:35 -07:00
4e5a061f26
Create v4 mapped v6 correctly
Tests verifies the behavior with v4 mapped v6. The
taken parameter should be a v6 address. However,
InetAddresses.parseNumericAddress() will translate a v4
mapped v6 address into v4. This does not actually test
the behavior. The constant should be created via
Inet6Address.getByAddress() so that it will be an
expected Inet6Address.

Bug: 291869581
Test: atest NattKeepalivePacketDataTest
      w/ and w/o aosp/2626269
Change-Id: I2f086f0fe7d1dd038f5d850f2281deb807c837cf

chiachangwang   commited 2023-07-20 03:14:08 +00:00
65240048ce
Merge "Move NsdServiceInfoTest to common tests"
Paul Hu   authored and   Gerrit Code Review   commited 2023-07-03 06:24:43 +00:00
f51a0139a2
Fix flaky test in NattKeepalivePacketDataTest
The testConstructor_afterR is a new added test which should be
run with latest connectivity module, but some test combinations
do not contain latest connectivity module which will fail the
test. Add ConnectivityModuleTest annotation to skip combinations
without latest connectivity module.

Bug: 287226038
Bug: 196453719
Test: atest ConnectivityCoverageTests
Change-Id: I16dfa8f86f77bb3561a24684e7823f8d45b7613d

chiachangwang   authored and   Chiachang Wang   commited 2023-06-15 02:20:44 +00:00
e91f8dc3c4
Add helper method to generate a v6 NAT-T keepalive packet
This is a part of preliminary work for sending a v6 NAT-T
keepalive packet in a v6 only network. This commit
release the constraint on constructing a v6 NAT-T keepalive
packet.

Bug: 196453719
Test: Manually connect to v6 only network and check if the
      keepalive packets are sent with subsequent commit
Test: atest FrameworksNetTests with the updated test
Change-Id: I9dc96e840265c5dee6b9e3ef2b3901a0aeb4ff9e

chiachangwang   commited 2023-06-13 11:50:13 +00:00
c18f0bbbb3
Use assertFailsWith to verify exception cases
Test: atest FrameworksNetTests
Change-Id: If7373a1e6543975bee9c646384f6ca4d643a1711

chiachangwang   commited 2023-06-09 06:08:39 +00:00
60179ec28e
Correct the order of import and remove unused definition
Test: atest
Change-Id: I60c409db5436a5ba9fffdee9df24158f15751658

chiachangwang   commited 2023-06-07 06:46:29 +00:00
8af048721a
Merge "Do not crash when passing null into buildTemplateMobileAll"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-04-04 01:27:41 +00:00
8a78f043ea
Retain subscription IDs on restricted test networks
Fix the bug where subscription IDs will be cleared
on a restricted test network

Bug: 263415068
Test: NetworkCapabilitiesTest
Change-Id: I977781cd81f9d86858bd264825d66a2a69f6ce53

Yan Yan   commited 2023-03-30 07:49:13 +00:00
966fb798a1
Do not crash when passing null into buildTemplateMobileAll
Test: atest FrameworksNetTests:android.net.connectivity.android.net.NetworkTemplateTest
Test: atest FrameworksNetTests:android.net.connectivity.android.net.netstats.NetworkTemplateTest
Bug: 273963543
Change-Id: I0a8f94df124147e92d35cf474b3d69d1dee6902c

Junyu Lai   commited 2023-03-30 13:59:02 +08:00
2c12f922de
Add allowed capabilities on non cellular test networks
This commit expands the allowed capabilities of non cellular test
networks to include another three values, so that CTS can verify
features that do network selection based on those capabilities.

It is relatively safe becuase for apps that request TRANSPORT_CELLULAR
and the affected capabilities, test networks will still not become their
default networks.

Bug: 263415068
Test: atest NetworkCapabilitiesTest(new tests)
Change-Id: I2e348e4722ecdaa6e277fe77968916ffa2f16af9

Yan Yan   commited 2023-03-22 18:27:19 -07:00
acd71e68a6
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
Move NsdServiceInfoTest to common tests
- NsdServiceInfoTest can be the unit and cts test because
  NsdServiceInfo is a Parcelable class. Thus, move
  NsdServiceInfoTest class to common tests directory.
- Also add ConnectivityModuleTest annotation because the tests
  are using some connectivity APIs which need to run with the
  latest module.
- Fix some coding style errors.
- Remove unnecessary ThreadPolicy code which may affect other
  tests.

Bug: 266839012
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Idc4251ef7a1efa294c8a692eb09129440691a22e

Paul Hu   commited 2023-03-08 01:43:11 +00:00
839b81e22f
Delete testUnsupportedAppUsageConstructor from coverage test
This tests @hide API which doesn't really officially supported.
Removed from coverage test.

Test: build, FrameworksNetTests
Change-Id: I6375e7713b8ae67486b3df80d13c19b3adaa3560

Aaron Huang   authored and   Junyu Lai   commited 2023-03-03 15:16:36 +08:00
7e6e5b425c
Fix backward compatibility issue for removed wildcard match rule
A template with type MATCH_MOBILE could have empty subscriber
IDs but it should not contain one of subscriber IDs is null.

An app might still build a template through the constructor
which is annotated with @UnsupportedAppUsage. NetworkTemplate
will throw an exception when the app trying to construct a
template with type *_WILDCARD. The constructor should be
backward compatible with old version so this change is to add
the backward compatibility to have NetworkTemplate not throw
an exception.

Bug: 267701889
Test: FrameworksNetTests
Change-Id: I23a607dae508e0c53520e2edf187cb611ed36b68

Aaron Huang   commited 2023-02-21 14:07:15 +08:00
69086d6cbc
Moves all compatibility flags to ConnectivityCompatChanges.java
ConnectivityCompatChanges.java becomes the centralized place for all the
CompatChanges used in the Connectivity module. By putting all the
CompatChanges here, we are able to manage them under a single
platform_compat_config.

Bug: 268440216
Test: atest FrameworksNetTests
Change-Id: I3e17af545718073d7d1c96e27298e7790563fd33

Yuyang Huang   commited 2023-02-09 19:51:37 +09:00
90a2cbdd8d
Remove *_WILDCARD constants from NetworkTemplate
NetworkTemplate was moved into mainline module and
provide Builder for external users to build template.
MATCH_MOBILE_WILDCARD and MATCH_WIFI_WILDCARD are not
exposed so currently the usage of these two constants
only in module. This change is to remove the constants.

After removing the constants, two methods matchesWifi
and matchesMobile are changed to adapt the original
matches[Wifi|Mobile]Wildcard behavior.

Bug: 238843364
Test: FrameworksNetTests
Change-Id: I9e156b504ce4eb903b39279e443fad27bc921186

Aaron Huang   commited 2022-12-28 18:49:37 +08:00
ece181997c
Remove mSubscriberId from NetworkTemplate
Currently NetworkTemplate provides Builder for users to build a
template and it supports multiple subscriber ids. The mSubscriberId
is a local variable in current design so it can be removed from
NetworkTemplate and also can be removed from the parameter of a
constructor as long as the constructor is not annotated with
@UnsupportedAppUsage.

Bug: 238843364
Test: build, FrameworksNetTests
      CtsNetTestCases
Change-Id: Ic6a695e1c1719111bf26ba905a38673952a24736

Aaron Huang   commited 2022-12-28 12:09:21 +08:00
ee23c03121
Remove mSubscriberIdMatchRule from NetworkTemplate
Currently, mSubscriberIdMatchRule is only used in NetworkTemplate
and it depends on if mMatchSubscriberIds is empty or not. Thus,
remove it since is not really necessary and replace it with
checking matchSubscriberIds if needed.

Bug: 238843364
Test: build, FrameworksNetTests
      CtsNetTestCases
Change-Id: Ic66d2ff2826846778b004bb15a4718a62fa1f470

Aaron Huang   commited 2022-12-28 12:09:09 +08:00
4854d055bb
Rename getBypassable to isBypassable
Bug: 262336021
Bug: 256775913
Test: atest FrameworksNetTests
Change-Id: I5ac8f4f9a2a64189fc66d3c14af6da201a35e3e2

chiachangwang   authored and   Chiachang Wang   commited 2022-12-15 04:22:43 +00:00
2ed983512c
Add areLongLivedTcpConnectionsExpensive in VpnTransportInfo
Add VpnTransportInfo.areLongLivedTcpConnectionsExpensive() in API
surface to allow privileged apps to know whether the long-lived
TCP connections should be expensive in the VPN network.

This is expected to be used combined with getBypassable()
because connections should always go through a VPN that is not
bypassable.

Bug: 259000745
Test: atest FrameworksNetTests
Change-Id: Ic9bcdf43f252f22d12a1136902cc8bbf9cc731f5

chiachangwang   commited 2022-12-13 10:15:49 +00:00
a07cef1059
Make mMatchSubscriberIds as a NonNull variable
In current design, mMatchSubscriberIds can be null which has the
same meaning with empty set, and is not easy to maintain since it
need more checks for this variable when mSubscriberId is null.
Thus make mMatchSubscriberIds NonNull for the maintenance.

Bug: 238843364
Test: build, FrameworksNetTests
Change-Id: I6cfc529b5f4a39ded8598283ff968f2f4d1bc89f

Aaron Huang   commited 2022-11-30 16:38:24 +00:00
859884a48f