Commit Graph

1673 Commits

Author SHA1 Message Date
Jean Chalard
11162e97c6 Merge "Revert "Prioritize non-slices over slices"" into main 2023-11-24 02:50:35 +00:00
Paul Hu
976e52a2c4 Merge "Add Thread#join to guarantee the termination of the thread" into main 2023-11-22 06:22:23 +00:00
Paul Hu
005fb887e6 Merge "Fix the memory leak in nsd tests" into main 2023-11-22 02:57:24 +00:00
Mike Yu
faa10d066b Merge "Update Andorid.bp to use DnsResolver v13" into main 2023-11-21 12:04:30 +00:00
Jean Chalard
6121a7656c Revert "Prioritize non-slices over slices"
This reverts commit 14499f0119.

Reason for revert: b/312408745

Change-Id: I8b03799fe6e0e256263240909ee7446c178bf508
2023-11-21 10:25:14 +00:00
Paul Hu
0788d8ee7e Add Thread#join to guarantee the termination of the thread
Also add MonitorThreadLeak annotation to check thread leak.

Test: atest ConnectivityCoverageTests --test-filter mdns*
Change-Id: Ie47f30360e36784428173f6cc87a4a6b09826405
2023-11-21 16:08:41 +08:00
Paul Hu
27662f0cc3 Fix the memory leak in nsd tests
The NsdManager constructor creates a new thread, which is not
intended to be closed. However, the test in NsdMangerTest and
NsdServiceTest create a new NsdManager instance, resulting in a
large number of threads running during the tests. This can lead
to an out-of-memory error for the tests. To resolve this issue,
use the common singleton thread ConnectivityThread to handle
tasks from the various instances.

Fix: 308544734
Test: atest ConnectivityCoverageTests --test-filter Nsd*
Change-Id: I1908a2bb1bd20da8e0498353bca26f7e89e16626
2023-11-21 14:04:07 +08:00
Jean Chalard
4a013c47c2 Merge changes I30f8814c,Ifdf67318,If312b8f8 into main
* changes:
  Rename hasCarrierPrivilege... to isCarrierServiceUid...
  Detect discrepancies in subIds
  Allow carrier service UIDs to access their own WiFi networks.
2023-11-20 06:55:04 +00:00
Chalard Jean
96ff954464 Stop CarrierPrivilegeAuthenticator thread in tests
Bug: 308519360
Test: CarrierPrivilegeAuthenticatorTest
Change-Id: I59164be00a9e1fcced8538537c1dcabd214f2170
2023-11-20 14:31:32 +09:00
Chalard Jean
8c63ed851f Rename hasCarrierPrivilege... to isCarrierServiceUid...
This method tests whether the UID is the carrier service
UID, not whether the UID has carrier privilege.

Note that in normal operation, the carrier service UID always
has carrier privilege.

Test: NetworkAgentTest
Change-Id: I30f8814cc0419a2d6bdbe75fdc82156516eba026
2023-11-20 14:01:02 +09:00
Chalard Jean
a093b452f3 Allow carrier service UIDs to access their own WiFi networks.
Bug: 236669534
Test: New tests in this patch
Change-Id: If312b8f8359888558969c022811d6b203be602a0
2023-11-20 14:01:02 +09:00
Jean Chalard
51c80a72d8 Merge "Add more powerful CTS for allowedUids" into main 2023-11-20 04:44:22 +00:00
Chalard Jean
5301778ad8 Add more powerful CTS for allowedUids
This tests that the network providers are subject to appropriate
limitations as to what they can set as allowedUids – both in the
positive (can do) case, and the negative (can't do) case.

Test: this
Change-Id: I115e2a4bc02ddcd03ecf2f35130fcb0378da22bd
2023-11-20 12:16:39 +09:00
Mike Yu
d0ad17c2d1 Update Andorid.bp to use DnsResolver v13
Bug: 240259333
Test: atest ConnectivityCoverageTests
Change-Id: I92ab5e1eef7ba1715176e3628222084067d14603
2023-11-20 01:48:53 +00:00
Michał Brzeziński
dec578072a Merge "Revert "Make PRIORITIZE_* networks non-default"" into main 2023-11-17 12:21:56 +00:00
Michał Brzeziński
05cba24cd8 Revert "Make PRIORITIZE_* networks non-default"
This reverts commit 30fb9b1ca4.

Reason for revert: Potential culprit for CtsLibcoreTestCases test failures b/311612650

Change-Id: Ie7de97159f92a174476a8fa8ea83e3e01914aea1
2023-11-17 11:18:56 +00:00
Chiachang Wang
35c1bc4fbb Merge "Update test as the parameters are removed from production code" into main 2023-11-17 08:55:12 +00:00
Jean Chalard
9a5252ba50 Merge "Make PRIORITIZE_* networks non-default" into main 2023-11-17 05:55:22 +00:00
Chiachang Wang
a34e045610 Update test as the parameters are removed from production code
Bug: 161776767
Test: atest FrameworksNetTests
Change-Id: Id2cef626c5893a4ff29161c801e497b7de551136
2023-11-17 01:25:22 +00:00
Hansen Kurli
77f9fb300f Merge "Test VpnProfile is not modified in startLegacyVpn" into main 2023-11-16 10:04:19 +00:00
Chalard Jean
30fb9b1ca4 Make PRIORITIZE_* networks non-default
As a specialized network, a network with PRIORITIZE_* is not
generally a good default network, and might cause unexpected
charges if allowed to become one.

Test: CSDefaultNetworkTests
Change-Id: I8f7184f80bb987da720bd067862bd7a546a38e26
2023-11-16 18:45:10 +09:00
Chiachang Wang
dff6b91649 Merge "Add test for verifying if setVpnDefaultForUids() is called correctly" into main 2023-11-16 06:16:11 +00:00
Jean Chalard
cc2e72735d Merge "Use FromS() on LocalNetworkConfig" into main 2023-11-16 04:45:15 +00:00
Hansen Kurli
e949124bcc 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
2023-11-16 12:28:12 +08:00
lucaslin
cca1652bdb 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
2023-11-16 12:03:13 +08:00
Chiachang Wang
9481063d42 Merge "Pass VPN uid range to AutomaticOnOffKeepaliveTracker" into main 2023-11-16 01:30:48 +00:00
Motomu Utsumi
1cd89fca86 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+
2023-11-15 13:58:37 +00:00
Chiachang Wang
59bcabe3f4 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
2023-11-15 08:50:27 +00:00
Junyu Lai
c7126bb997 Merge "Ensure no thread leak after NetworkStatsServiceTest" into main 2023-11-15 07:45:34 +00:00
Chalard Jean
b86a574fe9 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
2023-11-15 16:27:19 +09:00
Junyu Lai
17f589cf47 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
2023-11-15 14:03:45 +08:00
Quang Luong
2cfffe7bfb Merge "Allow SysUi to see the connectivity diagnostic callbacks" into main 2023-11-15 05:51:28 +00:00
Quang Anh Luong
28eefef05d 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
2023-11-15 11:06:42 +09:00
Paul Hu
596a500607 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
2023-11-14 09:13:42 +00:00
Motomu Utsumi
db537accdc 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
2023-11-14 15:50:42 +09:00
Motomu Utsumi
1f5ffa4273 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
2023-11-14 15:50:36 +09:00
Motomu Utsumi
5fce43e548 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
2023-11-14 13:43:45 +09:00
Hansen Kurli
8b61783b78 Merge changes from topics "RemoveFindIPv4", "RemoveLegacyVpnRunner" into main
* changes:
  Expect no error for startLegacyVpn with IPv6.
  Remove tests related to LegacyVpnRunner.
2023-11-13 05:27:07 +00:00
Paul Hu
a96c86d34a Merge "Add NSD_LIMIT_LABEL_COUNT flag" into main 2023-11-09 14:09:29 +00:00
Jean Chalard
7cf6e5a3b0 Merge "Add test to make sure that unwanted local nets disconnect correctly" into main 2023-11-09 02:08:36 +00:00
Suprabh Shukla
2d893b68a9 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
2023-11-08 10:17:30 +00:00
Paul Hu
fd357ef695 Add NSD_LIMIT_LABEL_COUNT flag
Bug: 307475137
Test: atest FrameworksNetTests android.net.cts.NsdManagerTest
Merged-In: I48b1dc26f41549ec4afc71f87e98a02ac773430f
Change-Id: Ic4c2e4c0d61b76b1afd556560c18171bdb7a088e
2023-11-08 16:25:27 +08:00
Maciej Żenczykowski
87f7f27ad0 Merge changes Ie1a36c3c,Id727cf7b,Ifba198d9 into main
* changes:
  Remove unnecessary check for skDestroyListener
  Remove TrafficController
  Remove native code path in BpfNetMaps.java
2023-11-07 19:32:51 +00:00
Chalard Jean
4fe2339f2c 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
2023-11-07 22:28:25 +09:00
Motomu Utsumi
96b6c39229 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
2023-11-07 17:45:32 +09:00
Chalard Jean
22350c93b4 Add LocalNetworkInfo and send callbacks when it changes
Test: CSLocalAgentTest
Change-Id: I8caca97b891081f9212a01d428a34ed1a08d5126
2023-11-07 17:29:38 +09:00
Jean Chalard
85fce4f871 Merge "Set up forwarding rules for local network agents" into main 2023-11-07 02:50:50 +00:00
Chalard Jean
1e4c218c28 Set up forwarding rules for local network agents
Test: CSLocalAgentTests, new tests for this
Change-Id: I8994af350a1799ab5f6ebb2872f2abfaf174bd61
2023-11-06 20:18:50 +09:00
Motomu Utsumi
d872c3c960 Merge "Add methods for updating ingressDiscardRule bpf map to BpfNetMaps" into main 2023-11-06 10:41:53 +00:00
Chalard Jean
820ce9df2d Add forwarding methods to RoutingCoordinator
Test: RoutingCoordinatorServiceTest
      TetheringTest
Change-Id: I2fa6250875d517c3452c85a3678d3feb0c0354d8
2023-11-02 23:25:32 +09:00