Commit graph android_packages_modules_Co.../tests/unit/java
Message SHA1
Merge "Test VpnProfile is not modified in startLegacyVpn" into main
Hansen Kurli   authored and   Gerrit Code Review   commited 2023-11-16 10:04:19 +00:00
77f9fb300f
Merge "Add test for verifying if setVpnDefaultForUids() is called correctly" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-11-16 06:16:11 +00:00
dff6b91649
Merge "Use FromS() on LocalNetworkConfig" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-11-16 04:45:15 +00:00
cc2e72735d
Test VpnProfile is not modified in startLegacyVpn
The profile is modified within startLegacyVpnPrivileged(), e.g.
ipsecCaCert, ipsecUserCert. This causes subsequent calls from
callers such as LockdownVpnTracker to fail.

Add a new test to ensure the VpnProfile is not modified in
startLegacyVpn.
Add testClone in VpnProfileTest.

Bug: 190572822
Bug: 309591931
Test: atest FrameworksNetTests, test before and after fix.
Test: Manual test
Change-Id: Id090e0dd3b9e74a7461ae90e68c41e802b458744

Hansen Kurli   commited 2023-11-16 12:28:12 +08:00
e949124bcc
Add test for verifying if setVpnDefaultForUids() is called correctly
This commit verifies that
- If VPN network preference is set when
    - Ikev2VpnRunner is created
    - Retrying VPN
    - Updating exclusion list
- If VPN network preference is cleared when
    - Exiting VPN runner
    - NOT_RECOVERABLE happens

Bug: 231749077
Test: atest FrameworksNetTests:VpnTest
Change-Id: I71f48f18fd4556e04c131d5939afaa1ef5a0f814

lucaslin   authored and   Hansen Kurli   commited 2023-11-16 12:03:13 +08:00
cca1652bdb
Merge "[BR11] Read data saver status from bpf" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-11-16 02:57:55 +00:00
d3447a1d52
Merge "Pass VPN uid range to AutomaticOnOffKeepaliveTracker" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-11-16 01:30:48 +00:00
9481063d42
Merge changes from topic "multi_network_activity_tracking" into main
* changes:
  Make ConnectivityService update BatteryStats radio power state
  Track multiple network activities on V+
  Use netId as idleTimer label on V+

Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-11-15 13:58:37 +00:00
1cd89fca86
Pass VPN uid range to AutomaticOnOffKeepaliveTracker
This is a preliminary change for filtering sockets that is not
in the uid ranges for automatic on/off keepalives. This commit
itself is a no-op change to pass the uid information to
AutomaticOnOffKeepaliveTracker.

Bug: 311119352
Test: atest FrameworksNetTests
Change-Id: I7d96e7a0d3f3054d1409de350420a24378b28cdb

Chiachang Wang   commited 2023-11-15 08:50:27 +00:00
59bcabe3f4
Merge "Ensure no thread leak after NetworkStatsServiceTest" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-11-15 07:45:34 +00:00
c7126bb997
Use FromS() on LocalNetworkConfig
Like NetworkScore, this object is not available on R because
of the absence of the tethering module. Therefore it needs to
be wrapped to be protected against introspection by the test
libraries.

Change-Id: Ia5f84d2926433398cef33d89819a8c6588024ea0
Test: FrameworkNetTests

Chalard Jean   commited 2023-11-15 16:27:19 +09:00
b86a574fe9
Ensure no thread leak after NetworkStatsServiceTest
This change includes:
 1. A mechanism in DevSdkIngoreRunnrer to dump thread counts
    before/after tests, and compare thread counts to detect leaks.
 2. Add an annotation @MonitorThreadLeak for test classes to
    annotate the classes which should monitor thread leaks.
 3. Annotated NetworkStatsServiceTest to apply the enforcement.

Sample output:
[1/2] android.net.connectivity.com.android.server.net.NetworkStatsServiceTest#testDumpStatsMap: PASSED (1.187s)
[2/2] android.net.connectivity.com.android.server.net.NetworkStatsServiceTest#ThreadLeakMonitor: FAILED (7ms)

STACKTRACE:
java.lang.IllegalStateException: Expected threads: {binder:26055_3=1, Instr: androidx.test.runner.AndroidJUnitRunner=1, main=1, InstrumentationConnectionThread=1, binder:26055_2=1, binder:26055_1=1} but got: {binder:26055_3=1, NetworkStatsObservers=1, Instr: androidx.test.runner.AndroidJUnitRunner=1, main=1, InstrumentationConnectionThread=1, binder:26055_2=1, binder:26055_1=1}

Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
      --rerun-until-failure 100
Bug: 308544001
Bug: 307693729
Change-Id: Ia0bccb82c5985df608b8402009b32626b6b17c5a

Junyu Lai   commited 2023-11-15 14:03:45 +08:00
17f589cf47
Merge "Allow SysUi to see the connectivity diagnostic callbacks" into main
Quang Luong   authored and   Gerrit Code Review   commited 2023-11-15 05:51:28 +00:00
2cfffe7bfb
[BR11] Read data saver status from bpf
Writing data saver status to bpf is supported on Android V or
later devices. Thus, read that from bpf if available.

Test: atest FrameworksNetTests:android.net.connectivity.android.net.BpfNetMapsReaderTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.ConnectivityManagerTest
Fix: 310801259
Change-Id: Ibd2616328d83f72ee6d2665239c3a44379d1ebf5

Junyu Lai   commited 2023-11-15 12:26:40 +08:00
9e88052fe7
Allow SysUi to see the connectivity diagnostic callbacks
SysUi needs to see connectivity diagnostic callbacks to display
 "Checking for internet access..." -> "Connected" or "No internet access".

Bug: 307161342
Test: atest FrameworksNetTests, manually connect to a network without internet connectivity,
verify Internet Dialog doesn't get stuck showing
 "Checking for internet access..."

Change-Id: I86e2b852ff9e5dfbfc37ba711f477166b0ac6835

Quang Anh Luong   commited 2023-11-15 11:06:42 +09:00
28eefef05d
Check service ttl expiration
Now, every services are cached on MdnsServiceCache, so the
remaining TTL should be checked when retrieving services from
the MdnsServiceCache and have a callback to notify the
MdnsServiceTypeClient about expired services.

Bug: 265787401
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I99da6cc79bdf5df3c899e642e067907501bc9d4f

Paul Hu   commited 2023-11-14 09:13:42 +00:00
596a500607
Make ConnectivityService update BatteryStats radio power state
Currently, BatteryStatsService register netd callback and track radio
power state only for the default network.
So, battery stats are not accurate if cellular and Wi-Fi networks are
active at the same time.

aosp/2561090 updates BatteryStatsService not to register netd callback
on V+ devices.
This CL updates LegacyNetworkActivityTracker to call BatteryStats API
and update radio power state for networks including non default networks
on V+ devices.

Bug: 267870186
Bug: 279380356
Test: atest FrameworksNetTests
Change-Id: I826b3b4046cc7b8aef46c13300854eaf14b1b777

Motomu Utsumi   commited 2023-11-14 15:50:42 +09:00
db537accdc
Track multiple network activities on V+
on V+ devices, NetworkActivityTracker adds idleTimer when the network is
first connected and removes idleTimer when the network is disconnected
so that activity tracker can receive netd
onInterfaceClassActivityChanged callback for multiple networks.

Bug: 267870186
Bug: 279380356
Test: atest FrameworksNetTests
Change-Id: I6f3a95c27e3e58f3f60c40065f562d00431a56b1

Motomu Utsumi   commited 2023-11-14 15:50:36 +09:00
1f5ffa4273
Use netId as idleTimer label on V+
Following CL adds idleTimer for multiple networks and track activities
including non default network on V+
Current LegacyNetworkActivityTracker uses transport type as an idleTimer
label but this makes it difficult to have multiple idleTimers.
So, this CL updates LegacyNetworkActivityTracker to support using netId
as an idleTimer label.

Bug: 267870186
Bug: 279380356
Test: atest FrameworksNetTests
Change-Id: I0039f5624ae1d142dbacba53aa90ca9bf6d43599

Motomu Utsumi   commited 2023-11-14 13:43:45 +09:00
5fce43e548
Merge changes from topics "RemoveFindIPv4", "RemoveLegacyVpnRunner" into main
* changes:
  Expect no error for startLegacyVpn with IPv6.
  Remove tests related to LegacyVpnRunner.

Hansen Kurli   authored and   Gerrit Code Review   commited 2023-11-13 05:27:07 +00:00
8b61783b78
Add equals, hashCode to MulticastRoutingConfig
Add helper functions to help compare if MulticastRoutingConfig
has changed.

Test: atest MulticastRoutingConfigTest
Change-Id: I30ed4796efbaafbcf1a273c12a9231ec02bc36f0

Yang Sun   commited 2023-11-10 13:06:22 +08:00
d25444ffce
Merge "Add NSD_LIMIT_LABEL_COUNT flag" into main
Paul Hu   authored and   Gerrit Code Review   commited 2023-11-09 14:09:29 +00:00
a96c86d34a
Merge "Add test to make sure that unwanted local nets disconnect correctly" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-11-09 02:08:36 +00:00
7cf6e5a3b0
New firewall chain for default background restrictions
A new firewall chain is needed to configure background network
restrictions for apps.
This change only adds the API stubs and traffic controller constants to
make the chain work. Policy changes using this chain will follow in
the framework code.

Test: atest CtsNetTestCases:ConnectivityManagerTest
Test: atest ConnectivityServiceTest

NO_IFTTT=The Lint rule along with the relevant code in Common.h is
being deleted in aosp/2819759

Bug: 304347838
Change-Id: I33e2db6671431f7c576fc931d9f96e684fc1e78a

Suprabh Shukla   commited 2023-11-08 10:17:30 +00:00
2d893b68a9
Add NSD_LIMIT_LABEL_COUNT flag
Bug: 307475137
Test: atest FrameworksNetTests android.net.cts.NsdManagerTest
Merged-In: I48b1dc26f41549ec4afc71f87e98a02ac773430f
Change-Id: Ic4c2e4c0d61b76b1afd556560c18171bdb7a088e

Paul Hu   commited 2023-11-08 16:25:27 +08:00
fd357ef695
Merge changes Ie1a36c3c,Id727cf7b,Ifba198d9 into main
* changes:
  Remove unnecessary check for skDestroyListener
  Remove TrafficController
  Remove native code path in BpfNetMaps.java

Maciej Å»enczykowski   authored and   Gerrit Code Review   commited 2023-11-07 19:32:51 +00:00
87f7f27ad0
Add test to make sure that unwanted local nets disconnect correctly
Also add some toString() methods that were useful in debugging.

Test: new test in CSLocalAgentTests
Change-Id: Ife95815e39d92bbef84b1c5ea75a151882590d09

Chalard Jean   commited 2023-11-07 22:28:25 +09:00
4fe2339f2c
Remove native code path in BpfNetMaps.java
BpfNetMaps uses java library for updating bpf map as the default code
path.
This is already released to 100% production without any issues.
So this CL removes the old code path from BpfNetMaps.

Note that native_init only opens the bpf maps if sEnableJavaBpfMap is
true.
But if sEnableJavaBpfMap is true, no native code in TrafficController
access the bpf map.
So this CL can remove native_init.

Following CL will remove the nativce codes for old code path.

Bug: 217624062
Test: NetworkStaticLibsTests
Change-Id: Ifba198d9e6f93b53fd1dbf3b2aafb644da0b147d

Motomu Utsumi   commited 2023-11-07 17:45:32 +09:00
96b6c39229
Add LocalNetworkInfo and send callbacks when it changes
Test: CSLocalAgentTest
Change-Id: I8caca97b891081f9212a01d428a34ed1a08d5126

Chalard Jean   commited 2023-11-07 17:29:38 +09:00
22350c93b4
Merge "Set up forwarding rules for local network agents" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-11-07 02:50:50 +00:00
85fce4f871
Set up forwarding rules for local network agents
Test: CSLocalAgentTests, new tests for this
Change-Id: I8994af350a1799ab5f6ebb2872f2abfaf174bd61

Chalard Jean   commited 2023-11-06 20:18:50 +09:00
1e4c218c28
Merge "Add methods for updating ingressDiscardRule bpf map to BpfNetMaps" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-11-06 10:41:53 +00:00
d872c3c960
Add forwarding methods to RoutingCoordinator
Test: RoutingCoordinatorServiceTest
      TetheringTest
Change-Id: I2fa6250875d517c3452c85a3678d3feb0c0354d8

Chalard Jean   commited 2023-11-02 23:25:32 +09:00
820ce9df2d
Rename KEEP_CONNECTED_DOWNSTREAM_NETWORK to K_C_LOCAL_NETWORK
...following feedback

Test: FrameworksNetTests
Change-Id: I9c25f0b066a58980bf071d2b958223ed609f0d8e

Chalard Jean   commited 2023-11-02 23:25:31 +09:00
842a914dff
Enforce structural NetworkAgent constraints
Avoid network agents trying to do things that the stack
does not support.

Test: new test in this change
Change-Id: I3ffa1c3ddbb0b648b06862dc0a44f8525d358acc

Chalard Jean   commited 2023-11-02 23:25:11 +09:00
78c9a381c9
Expect no error for startLegacyVpn with IPv6.
findIPv4DefaultRoute() is removed from Vpn, so
IllegalStateException is no longer thrown for IPv6 only
networks.

The test testStartLegacyVpnIpv6 is now not testing anything new
and so it is removed. Note that other tests that will be calling
startLegacyVpn() ensure coverage is not lost.

Bug: 161776767
Test: atest FrameworksNetTests
Change-Id: I6ac9d7c196b7bc4c44fc2ad32baa25b106640ef4

Hansen Kurli   commited 2023-11-02 21:11:12 +08:00
70bc73223e
Remove tests related to LegacyVpnRunner.
LegacyVpnRunner is removed, remove the following related tests:
1. testStartRacoonNumericAddress
2. testStartRacoonHostname
3. testStartPptp
4. testStartPptp_NoMppe

Create a new test that asserts UnsupportedOperationException for
the VPN types in those tests.

Bug: 161776767
Test: atest FrameworksNetTests
Change-Id: Id66d09ea54576ca4c641e8f69d104dc26a42c46b

Hansen Kurli   commited 2023-11-02 21:07:06 +08:00
879655c77b
Merge "Run CSDestroyedNetworkTests starting in R" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-11-02 10:23:50 +00:00
4fd9451cdb
Merge "[BR06] Support check whether network is blocked by data saver" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-11-02 07:09:50 +00:00
31ab762e42
Run CSDestroyedNetworkTests starting in R
This can only run where the connectivity module is updated

Bug: 308601625
Test: TH
Change-Id: Icc5df3013e90070502a805abe89725591470b464

Chalard Jean   commited 2023-11-02 14:00:16 +09:00
0a0be176d2
Merge "Fix NetworkStatsObersers thread leak in the NetworkStatsServiceTest" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-11-01 10:18:50 +00:00
2deeef4f5e
Fix NetworkStatsObersers thread leak in the NetworkStatsServiceTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
     (with debug code that dump all threads at the end of tests)
Fix: 308544001
Change-Id: I597054633bbb008ffd0edebe34dcf6935958aa5d

Junyu Lai   commited 2023-11-01 17:11:17 +08:00
8b5ebfc342
Merge changes I5fffc137,Ifc076a8d into main
* changes:
  Add Log.wtf when keepalive metrics are unexpected.
  Add dump of KeepaliveStatsTracker

Hansen Kurli   authored and   Gerrit Code Review   commited 2023-11-01 08:50:39 +00:00
8f329c2e97
Add Log.wtf when keepalive metrics are unexpected.
To debug unexpected keepalive metrics values, print the built
metrics in a Log.wtf before writing it to statsd.

Bug: 297292877
Test: atest FrameworksNetTests
Change-Id: I5fffc13721e50e28f24b0da12a961364f3f77e21

Hansen Kurli   commited 2023-11-01 14:41:35 +08:00
a746c1a4da
Add dump of KeepaliveStatsTracker
To debug unexpected metrics values, print the built metrics into
the connectivity dump.

Sample of the added log dump:
KeepaliveStatsTracker enabled: true
   # android.net.connectivity.com.android.metrics.Dailykeepalive
InfoReported@3293424e
   automatic_keepalive_requests: 2
   distinct_user_count: 1
   duration_per_num_of_keepalive {
     duration_for_num_of_keepalive {
       keepalive_active_durations_msec: 36
       keepalive_registered_durations_msec: 36
       num_of_keepalive: 0
     }
     duration_for_num_of_keepalive {
       keepalive_active_durations_msec: 9
       keepalive_registered_durations_msec: 6
       num_of_keepalive: 1
     }
     duration_for_num_of_keepalive {
       keepalive_active_durations_msec: 7
       keepalive_registered_durations_msec: 10
       num_of_keepalive: 2
     }
   }
   keepalive_lifetime_per_carrier {
     keepalive_lifetime_for_carrier {
       active_lifetime_msec: 23
       carrier_id: -1
       intervals_msec: 10000
       lifetime_msec: 26
       transport_types: 1
     }
   }
   keepalive_requests: 2
   uid: 10097

Bug: 297292877
Test: adb shell dumpsys connectivity
Test: New test testDumpDoesNotCrash()
Change-Id: Ifc076a8dce734e9c175f1b1f28e1c448b9a792e5

Hansen Kurli   commited 2023-11-01 14:41:24 +08:00
723c273be3
Merge "Quit handler threads at the end of the tests" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-11-01 06:29:33 +00:00
006f9d2998
Merge "[BR02] Implement isUidNetworkingBlocked" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-11-01 03:40:05 +00:00
2c8e96d599
[BR06] Support check whether network is blocked by data saver
This change adds a DataSaverStatusTracker, which is a helper
class to continuously track data saver status through NPMS
public API and intents. ConnectivityManager#isUidNetworkingBlocked
would use this cached information along with bpf maps to decide
whether networking of an uid is blocked.

Test: atest FrameworksNetTests:android.net.connectivity.android.net.BpfNetMapsReaderTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.ConnectivityManagerTest
Bug: 297836825
Change-Id: I7e13191759430f3ea1f4dec7facc02f16be7146d

Junyu Lai   commited 2023-11-01 11:10:01 +08:00
c3dc5b6222
Quit handler threads at the end of the tests
The created handler threads should be quit after the tests to
prevent memory leakage. Also, this commit updates the method
used to close the created HandlerThread to do it correctly.

Bug: 308537727
Test: atest ConnectivityCoverageTests
Change-Id: I3715a73a9142418c05f98bc95e275f97161ab3cd

Chiachang Wang   commited 2023-11-01 01:24:07 +00:00
2973cf4363
Merge "Destroyed networks can't hope to beat champions" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-31 10:01:09 +00:00
de33ada087