Commit graph android_packages_modules_Co.../tests/common
Message SHA1
Don't ignore exceptions in NsdManagerDownstreamTetheringTest
tryTest{} catches and returns and must be ended with a cleanup{}
block to throw. That is why it's marked with @CheckReturnValue.
The IDE marks the entire block as a huge warning.

Ideally this should really be an error, but that flag only exists
in Kotlin 2.2 and above, which is not out of beta yet, so
add a TODO in the bp file

Test: NsdManagerDownstreamTetheringTest
Flag: EXEMPT test-only
Change-Id: I62a9d0a16926574eb286d45b61d4d5d2e8c870ab

Chalard Jean   commited 2025-05-15 09:04:02 +09:00
ebaef1230b
Don't warn in tests for deprecation
This change removes hundreds of lines of useless warnings, since
tests must check the continued working of old and deprecated methods.

Test: build manually and observe the warnings are gone
Flag: EXEMPT test-only
Change-Id: Ie50b2f35b09041e8e201b30b1e575e66e045bc44

Chalard Jean   commited 2025-05-15 09:04:02 +09:00
87df372535
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
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
Expose Connectivity libraries to VCN and tests
This patch exposes Connectivity libraries to allow migrating VCN to
its own non-updatable framework and service libraries. It also
creates a utility library for VCN.

Bug: 369703242
Test: atest FrameworksVcnTests && atest CtsVcnTestCases
Flag: EXEMPT no functional change
Change-Id: I1981f1cc824dcf426a76a0af8e4e3460fccb754e

Yan Yan   commited 2024-11-23 23:07:44 -08:00
587f996eb4
Remove dependencies on the 1-variant fallback
When adding a dependencies, if the variants don't match, but the
dependency only has 1 variant anyways, soong will always use that
variant. This makes it hard to add new variants to soong, because the
1-variant fallback stops being used and you start getting missing
variant errors. Make changes to bp files such that all dependencies
correctly specify the variant to use.

Bug: 372091092
Flag: EXEMPT refactor
Test: m nothing
Change-Id: I8d4f59044f268088b44357d27322abbdcdc3001c

Cole Faust   commited 2024-10-22 16:31:00 -07:00
9ff8f4c81b
Remove module tests from FrameworksNetTests
Connectivity module tests are currently included in both
FrameworksNetTests and ConnectivityCoverageTests. This causes confusion,
may cause tests to fail in one configuration but not the other, is
inefficient in terms of build time and infrastructure usage, and forces
developers to keep tests passing in two different configurations that
may use different libraries.

Only include non-connectivity-module-test in FrameworksNetTests, and
keep them excluded from ConnectivityUnitTestsLib (renamed from
FrameworksNetTestsLib).

Test: atest
Change-Id: I1c557c1b4c643b3eba3bffffd89634e1141d5c0e

Remi NGUYEN VAN   commited 2024-10-16 09:56:17 +09:00
96267ec798
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
Build mainline tests with static libc++ and version script
Bug: 341216801
Test: bpf_existence_test connectivity_native_test
Change-Id: Ib1ad48902472fcf2fbfad3012426f9fd6a5102f6

Ryan Prichard   commited 2024-05-20 17:00:24 -07:00
3ae062d8d6
[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
[DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
<add g3 doc link>

Bug: 304529413
Test: N/A
Change-Id: I243f17b3f0ad7af9ffa15ca242456e36688733f5
Merged-In: I243f17b3f0ad7af9ffa15ca242456e36688733f5

Aditya Choudhary   commited 2024-01-31 12:34:50 +00:00
01b5ede2b2
[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
Set test component in common OWNERS
Move the test component configuration from subdirectories
to the common OWNERS file. This ensures that all test directories
like unit/ that did not have the component set are covered.

Bug: 288137916
Change-Id: I48fbe846309cace41588c5ff3dfd46e878c38576
Test: TH

Remi NGUYEN VAN   commited 2023-06-21 02:54:13 +00:00
64020abf11
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
Update the SDK version to 34 in ConnectivityTestsLatestSdkDefaults
NsdManagerTest need to be updated because the older check was incorrect,
the new behavior should be observed on T when the compat flag is enabled
as well.

Test: m
Change-Id: I5d2e87b1ab5a114005a223e7ccd865540c0fdb78

Yuyang Huang   commited 2023-05-29 15:31:45 +09:00
79a245e16f
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
Merge "Allow jarjar com.android.server*"
Mark Chien   authored and   Gerrit Code Review   commited 2023-02-15 02:07:03 +00:00
7c3e8e62af
Allow jarjar com.android.server*
Jarjar com.android.server* and adjust the test by jarjar
FrameworksNetTestsLib to make sure the test cases still can access
package sope fields. Don't auto-jarjar non-connectivity module tests
in FrameworksNetTests because some non-connectivity module test cases
rely on service.core and service.net. The reason why not auto-jarjar
whole ConnectivityCoverageTests because tethering doesn't adopt
auto-jarjar-gen yet. The coverage test must jarjar the same as module so
that test coverage can calculate correctly.

Remove com.android.server* from proguard becasue it already be covered
by android.net* after jarjar'ed.

Move MetricsTestUtil to non connectivity module test group because it
only be used for IpConnectivityEventBuilderTest which is non connectivity
module test. Only jarjar the util without jarjar the caller make the test
failure.

Bug: 248001529
Test: atest ConnectivityCoverageTests FrameworksNetTests

Change-Id: I8439341ef4c03f29697fdf34557ea8ef2825d691

Mark   commited 2023-02-14 15:43:43 +00:00
53e71c3f3f
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