Commit graph android_packages_modules_Co.../service/src/com/android/server/ConnectivityService.java
Message SHA1
Merge "Apply multicast routing configs" into main
Yang Sun   authored and   Gerrit Code Review   commited 2024-01-22 00:57:42 +00:00
cc23753288
Apply multicast routing configs
Applies multicast routing configs when they are updated in
LocalNetworkConfig, or when local network/upstream network
status changes.

Bug: 281217735

Test: atest CSLocalAgentTests
Change-Id: Ib1c43c645a367d0f91e5cf0a0d9f8e5883be2c40

Yang Sun   commited 2024-01-20 21:32:20 +08:00
29037f6046
Remove the UID range check for TCP sockets
The original patch (aosp/2891011) incorrectly counted TCP
sockets with keepalive enabled for VPNs. This issue was
caused by the UID range verification. On bypassable VPNs,
the socket mark is always correct. It's possible for an
app that is not in the UID ranges to establish a socket
on the VPN. But that socket should be counted for the
purposes of keepalive. The old code would correctly count
it and the new code will incorrectly not count it. Also,
the UID range verification does not help on non-bypassable
VPNs since the socket mark is always the mark of default
network, not the socket mark of the VPN.

Instead of reverting the entire patch, this commit
removes the UID range mechanism. The code refactoring from
the original commit (which used structured classes to read
socket information) has been kept as it is a valuable
improvement.

Bug: 320842519
Test: atest FrameworksNetTests
Change-Id: I00731796144c982b9fd4d9771f3d0db1f1529a89

Chiachang Wang   commited 2024-01-19 02:50:35 +00:00
ac2e8f354d
Merge changes Ifafafcd6,I5802dedc into main
* changes:
  Fix incorrect nullability annotations
  Add helper method to enfore a package name belongs to an uid

Junyu Lai   authored and   Gerrit Code Review   commited 2024-01-18 07:35:38 +00:00
fbc97d95bb
Add helper method to enfore a package name belongs to an uid
This is no-op refactor to move utility methods from
ConnectivityService to a common place.

Test: atest NetworkStaticLibTests#com.android.net.moduletests.util.PermissionUtilsTest#testEnforcePackageNameMatchesUid
Bug: N/A
Change-Id: I5802dedcc91fa6e130a5c534bba5080ca37dbeec

Junyu Lai   commited 2024-01-18 11:26:55 +08:00
8fdc4318c7
Implement NetworkRequestsState atom
Bug: 278833398
Test: atest FrameworksNetTests
Change-Id: I95a8c8dddd2d8f6863fe64cd4a65ef48dfb5153a

Danuta Brotikovskaya   commited 2024-01-16 21:50:12 +00:00
878fd25d84
Merge "Revert "Implement NetworkRequestsState atom"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-01-12 05:18:49 +00:00
a8062d9ed0
Merge "Migrate Tethering#dump to use runWithScissorsForDump" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2024-01-10 09:46:12 +00:00
7b4ebdf2ef
Migrate Tethering#dump to use runWithScissorsForDump
This change includes:
  1. Refactor the logic in Tethering#dump into utils class.
  2. Move the utils class to a common place which could be referenced
     from other sub-modules.
  3. Add @MonitorThreadLeak annotation to enforce
     there is no thread leak problem.

Test: atest FrameworksNetTests NetworkStaticLibTests
Test: atest ConnectivityCoverageTests:com.android.networkstack.tethering.TetheringTest#testDumpTetheringLog
Test: adb shell dumpsys tethering (with hardcoded exception)
Fix: 312669345

Change-Id: Ia6fdfeeec2110afa0ec9e056e9db3843748845c3

Junyu Lai   commited 2024-01-10 13:56:55 +08:00
2ff42d264b
Revert "Implement NetworkRequestsState atom"
This reverts commit e3245081b1.

Reason for revert: The change is unsafe as it introduces code with writings to a separate thread whose message queue size is unlimited.
Test: atest FrameworksNetTests

Change-Id: I392a30f77cfbcd17f420e29f0944604fd789b10a

Danuta Brotikovskaya   commited 2023-12-28 18:19:20 +00:00
2971ffc776
Merge "Revert "Rename checkSystemBarServicePermission"" into main
Karl Shaffer   authored and   Gerrit Code Review   commited 2023-12-27 17:22:36 +00:00
ac6a617415
Revert "Rename checkSystemBarServicePermission"
This reverts commit c0baea5406.

Reason for revert: Checking if culprit of b/317506400

Change-Id: Icbe9d993c6d4bfdf305f2a4c7b8422095c8846a6
Bug: 317506400

Chris Göllner   commited 2023-12-26 16:13:51 +00:00
cc9620267e
Merge "Implement NetworkRequestsState atom" into main
Danuta Brotikovskaya   authored and   Gerrit Code Review   commited 2023-12-21 18:02:50 +00:00
0d8a980059
Implement NetworkRequestsState atom
Bug: 278833398
Test: atest FrameworksNetTests
Change-Id: Ie83bf49693411e4c3f629c07d98071505f48c08f

Danuta Brotikovskaya   commited 2023-12-21 15:56:03 +00:00
e3245081b1
Merge "Rename checkSystemBarServicePermission" into main
Quang Luong   authored and   Gerrit Code Review   commited 2023-12-21 04:43:03 +00:00
b8eedd186d
Rename checkSystemBarServicePermission
Rename checkSystemBarServicePermission to checkStatusBarServicePermission to be consistent with the actual permission name.

Bug: 307161342
Change-Id: Ib0d353d33f1fc64d298919c107d3bc6691dc0bfe
Test: build

Quang Luong   commited 2023-12-18 07:31:17 +00:00
c0baea5406
Merge "[BR14] Tracker Data Saver status in ConnectivityService" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-12-11 10:09:57 +00:00
5ad399d8c3
[BR14] Tracker Data Saver status in ConnectivityService
BYPASS_INCLUSIVE_LANGUAGE_REASON=Using public API
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.CSBpfNetMapsTest
      (on U and V devices respectively)
Bug: 297836825
Fix: 314858283

Change-Id: Ibeac8cd3a33468c6539234255328affc6b3f8ffe

Junyu Lai   commited 2023-12-08 13:54:29 +08:00
38c7503ab5
Merge "Support network slicing permission check in multi-user environment" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-12-07 12:32:18 +00:00
38f871c8e0
Revert canSeeAllowedUids for ownerUid
aosp/2405720 allowed network owner uid to see allowed uids
But this breaked old cts.
This CL reverts the behavior for network owner uid.

Bug: 312093253
Bug: 313025186
Bug: 312196228
Test: TH
Change-Id: Iaa732d22f67ecce7678e68bb8b20cec526116dc9

Motomu Utsumi   commited 2023-12-01 00:45:14 +09:00
eb4a1968ef
Merge "Log bpf rc file if it differs from the template files." into main
Yuyang Huang   authored and   Gerrit Code Review   commited 2023-11-30 03:32:56 +00:00
8670809d7f
Log bpf rc file if it differs from the template files.
Check if the bpf loader rc file is differs from the template files when
ConnectivityService starts. Use Log.wtf() to log the file if there is a
diff.

Bug: 312638861
Test: TH
Change-Id: I0b9ed9962ad0954a051a17b01357d04a0e655ff4

Yuyang Huang   commited 2023-11-29 19:58:15 +09:00
41557553f6
Support network slicing permission check in multi-user environment
In multi-user environment, the App might not be installed by system user.
As a result, the ConnectivityService should use the packageManager from
the user's context to be able to read the property correctly.

Bug: 300274339
Test: TH
Change-Id: I5398c95562bcaf5752270b52f38cca1f02698ba1

Yuyang Huang   commited 2023-11-28 16:54:49 +09:00
4c7deee859
Replace useTls with mode in PrivateDnsConfig
In PrivateDnsConfig class, `useTls` is replaced with `mode`.
This CL a corresponding change.

Bug: 240259333
Test: atest ConnectivityCoverageTests
Change-Id: I60c53e52f287fc7fa05543603a62632d934bb2e6

Mike Yu   commited 2023-11-28 07:49:58 +00:00
9738b47758
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.

Jean Chalard   authored and   Gerrit Code Review   commited 2023-11-20 06:55:04 +00:00
4a013c47c2
Stop CarrierPrivilegeAuthenticator thread in tests
Bug: 308519360
Test: CarrierPrivilegeAuthenticatorTest
Change-Id: I59164be00a9e1fcced8538537c1dcabd214f2170

Chalard Jean   commited 2023-11-20 14:31:32 +09:00
96ff954464
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

Chalard Jean   commited 2023-11-20 14:01:02 +09:00
8c63ed851f
Merge "Add more powerful CTS for allowedUids" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-11-20 04:44:22 +00:00
51c80a72d8
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

Chalard Jean   commited 2023-11-20 12:16:39 +09:00
5301778ad8
Merge "Revert "Make PRIORITIZE_* networks non-default"" into main
MichaÅ‚ BrzeziÅ„ski   authored and   Gerrit Code Review   commited 2023-11-17 12:21:56 +00:00
dec578072a
Revert "Make PRIORITIZE_* networks non-default"
This reverts commit 30fb9b1ca4.

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

Change-Id: Ie7de97159f92a174476a8fa8ea83e3e01914aea1

MichaÅ‚ BrzeziÅ„ski   authored and   Gerrit Code Review   commited 2023-11-17 11:18:56 +00:00
05cba24cd8
Merge "Make PRIORITIZE_* networks non-default" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-11-17 05:55:22 +00:00
9a5252ba50
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

Chalard Jean   commited 2023-11-16 18:45:10 +09:00
30fb9b1ca4
Apply forwarding rules before sending onAvailable
Ideally the rules should be set up before onAvailable is
sent, but onLocalNetworkChanged should be sent after.

The previous code had CSLocalAgentTests#testForwardingRules
flaky because it was waiting for onAvailable and immediately
checking that the routing rules have been set up.

There are other ways to fix this flake (e.g. wait for
onLocalNetworkChange in the test or add a timeout on
the verify(netd) call) but this patch probably implements
the best production code behavior.

Bug: 309688089
Test: CSLocalAgentTests#testForwardingRules 1'000 times
      Before this patch : flakes after 50~200 iterations
      After this patch : no flake in 1'000 iterations
Change-Id: I4dcccaa3607c1e28aa89f268f0c721d87b1e9466

Chalard Jean   commited 2023-11-16 17:04:15 +09:00
68eab721fc
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 "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
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
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 "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 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
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
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
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
Merge "[BR02] Implement isUidNetworkingBlocked" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-11-01 03:40:05 +00:00
2c8e96d599
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