Commit Graph

403 Commits

Author SHA1 Message Date
James Mattis
4ab1ffca29 Update to ConnectivityService to use utils
Update to ConnectivityService to use permission utils to validate the
existence of a system feature.

Bug: 210485380
Test: atest FrameworksNetTests:
com.android.server.ConnectivityServiceTest

Change-Id: Ia537cc5b37ef8d80f49f1a83ba572b3b8a9f6874
2022-01-05 09:15:24 -08:00
Maciej Żenczykowski
577c46a185 Merge "Add bpf jni into connectivity module" 2021-12-23 18:44:48 +00:00
markchien
8fb75e3916 Add bpf jni into connectivity module
This is the preparing CL for connectivity module to use bpf.

Bug: 179733303
Bug: 205088391
Test: atest ConnectivityCoverageTests
Change-Id: Ibe49d7f671b5050461e2c63c080d9457ad76c26c
2021-12-23 14:33:01 +08:00
Chalard Jean
f4802fa4c2 Genericize NC#hasSameUids
This will be used by another set of UIDs in a future patch

Test: FrameworksNetTests
Change-Id: I2c5d18ef93e73b702723814592ef3f3baf5dfbc4
2021-12-16 23:03:42 +09:00
Chiachang Wang
e5c363a3bd Merge "Enable strict_updatability_linting in connectivity src" am: 81bc609550
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1902533

Change-Id: I5cf42aa64a838f711cd1ecc589f86aecb19b358f
2021-12-08 02:53:16 +00:00
Chiachang Wang
81bc609550 Merge "Enable strict_updatability_linting in connectivity src" 2021-12-08 02:36:16 +00:00
Chalard Jean
57864d9400 Remove the legacy int policy from NetworkRanker am: 132ff9ef2e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1906317

Change-Id: I2847dc951d05916da1dc41a1f06e63180bbb0162
2021-11-30 13:11:21 +00:00
Chalard Jean
132ff9ef2e Remove the legacy int policy from NetworkRanker
This code is now dead and can't be resurrected. It can safely
be removed.

Test: FrameworksNetTests
Change-Id: I7bc2ce3d43a92e463b6aed73914c3f7a3a0c8103
2021-11-30 20:00:55 +09:00
Paul Hu
192f0c63f1 Merge "Simplify the permission update conditions" am: 5e3ef685ef
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1903462

Change-Id: I0e9774887d2c2cc1adf140d544457f07bca830b1
2021-11-29 05:46:14 +00:00
Paul Hu
5e3ef685ef Merge "Simplify the permission update conditions" 2021-11-29 05:31:14 +00:00
Paul Hu
b0a10cd127 Merge "Save uid netd network permissions" am: 6fafdc1548
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1773890

Change-Id: Ibff437f91017017cc6fcc7e456e621e2ad81995a
2021-11-29 03:45:46 +00:00
Paul Hu
6fafdc1548 Merge "Save uid netd network permissions" 2021-11-29 03:27:33 +00:00
paulhu
7bbffbd7d8 Simplify the permission update conditions
Bug: 192431153
Test: atest FrameworksNetTests
Change-Id: Ibef4f3b26932a3d12959e2e1d585e184a4ec73cb
2021-11-26 16:14:47 +08:00
paulhu
b2d5b054d3 Save uid netd network permissions
PermissionMonitor only saves netd network permissions by appId.
Then apply same permision to uids which are same appId. But
UIDS_ALLOWED_ON_RESTRICTED_NETWORKS can allow single uid has
restricted network permission. Thus, save the netd network
permissions by uid that can apply different permission to each
uid.

Bug: 192431153
Test: atest FrameworksNetTests
Change-Id: I942cbe0fa30758a7497c47a1b684ed70c4e3b09e
2021-11-26 14:47:01 +08:00
Aaron Huang
2797722d0c Merge "Remove TODO that was already done" am: 93d437ba0c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1900213

Change-Id: Ie6370d66be8d4de22465b31be0b0eba680ed0a16
2021-11-26 04:16:55 +00:00
Chiachang Wang
3bc5276568 Enable strict_updatability_linting in connectivity src
Bug: 188851968
Test: m lint-check
Change-Id: I3cd06ea16f05cb37d9369a48dd0285d8239fd764
2021-11-26 10:31:58 +08:00
Aaron Huang
2f8e0319d4 Remove TODO that was already done
The TODO is used to track to remove dependencies from
ConnectivityService. Remove it since that was already done.

Test: remove comment only
Change-Id: Ida8c1124e110f64262a693dcddfbc7a9549510da
2021-11-23 14:39:16 +08:00
Remi NGUYEN VAN
e03f77170a Remove unused service and test dependencies am: f96ecf2708
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1895317

Change-Id: I677a6b4c0b68648b4fab0e6f67edc88aa8be77b2
2021-11-19 15:59:07 +00:00
Remi NGUYEN VAN
f96ecf2708 Remove unused service and test dependencies
Nothing uses StateMachine in service-connectivity, and
FrameworksNetTestsLib pulled a lot of unused dependencies with
services.core and services.net.

Remove unused dependencies. This helps measure code coverage more
accurately.

Bug: 207020032
Test: atest ConnectivityCoverageTests
Change-Id: I39857865594a3263c4b1deeda23312c8e4f86a77
2021-11-19 21:14:39 +09:00
Xin Li
e41bbea995 Merge sc-qpr1-dev-plus-aosp-without-vendor@7810918
Bug: 205056467
Merged-In: I745ef4d42ecaf06bb81d9dbe0b7162267fea65a8
Change-Id: I7b2a1fc519124cfc10806dde5fd543504a51e072
2021-11-10 08:06:18 +00:00
Remi NGUYEN VAN
959d2cb6bd Don't rematch all requests when adding new ones
With the network selection rewrite in S, rematching a single request can
now easily be done; this can be used as an optimization in
handleRegisterNetworkRequests to avoid rematching all requests when
registering a new one.

This can be disabled by a flag that is unset by default,
REMATCH_ALL_REQUESTS_ON_REGISTER.

Test: atest ConnectivityServiceTest
Change-Id: If76f79b41ac88863974f7025624667134bea2570
2021-11-08 19:17:57 +09:00
Treehugger Robot
aa5532cb6f Merge "Add IFF_MULTICAST to test interfaces" 2021-11-05 20:01:41 +00:00
Remi NGUYEN VAN
6fc44359eb Add IFF_MULTICAST to test interfaces
This allows using test interfaces for multicast scenarios, such as
testing mDNS behavior.

Test: atest CtsNetTestCases
Change-Id: Ib5d8a997176f910d499021fdcd12c361aff1233d
2021-11-05 17:15:20 +09:00
Remi NGUYEN VAN
1d1b1fe999 Merge "Move fromStableParcelable to KeepaliveController" 2021-11-04 06:19:17 +00:00
Treehugger Robot
f475961aca Merge "Add permission update logs" 2021-11-02 02:27:56 +00:00
paulhu
819e8625e6 Add permission update logs
Save permission update result when package added /
package removed / setting changed.

Log:
Permission Monitor:
  Interface filtering rules:

  Update log:
    2021-10-27T11:04:23.472 - Package remove: name=com.vzw.apnlib, uid=10001, nPerm=(NONE/NONE), tPerm=UNINSTALLED
    2021-10-27T11:03:38.307 - Setting change: update={}, remove={10001=1}
    2021-10-27T11:02:22.589 - Setting change: update={10001=2}, remove={}
    2021-10-27T11:01:08.615 - Package add: name=com.vzw.apnlib, uid=10001, nPerm=(NONE/NONE), tPerm=NONE

Bug: 204260474
Test: build / flash / adb shell dumpsys connectivity
Change-Id: I889a8f2c82751f227655b39a4281a6f044508a86
2021-11-01 16:35:06 +08:00
Remi NGUYEN VAN
5d99aa78f7 Move fromStableParcelable to KeepaliveController
TcpKeepaliveController is the only user of
KeepalivePacketDataUtil.fromStableParcelable. Because of
fromStableParcelable, networkstack-client needs to depend on
net-utils-framework-commonm, which pulls a lot of unnecessary classes.
This is particularly problematic considering that networkstack-client
may need to be redistributed as a prebuilt.

Move the method to TcpKeepaliveController, simplifying dependencies.
This also shows that fromStableParcelable could be removed altogether
(or moved to tests) if TcpKeepaliveController built a
TcpKeepalivePacketData class directly.

Test: atest ConnectivityCoverageTests
Change-Id: I554318f6bcd07c73d153598a0231e9fcaf912e90
2021-11-01 13:23:27 +09:00
Chalard Jean
ba551d4dbb Improve logs in checkNrisConsistency
Test: ConnectivityServiceTest
Change-Id: If5235443217ad4abbdd40e89d5721d4f7832d52f
2021-10-28 12:45:12 +09:00
Chalard Jean
524f0b1d7f Apply a workaround, and try to detect a system crash
This will prevent the system crash in b/194394697, and on T try to
detect the issue much earlier and crash the system at that time
together with much more expansive logs.

Bug: 194394697
Test: ConnectivityServiceTest
Change-Id: Ia4be82179160216d41bf4d88b896e4814385063a
2021-10-27 16:00:56 +09:00
Chalard Jean
e88bfbc015 Merge "No-op cleanup" 2021-10-26 02:39:47 +00:00
Chalard Jean
a3578a5465 No-op cleanup
Binders from the system server don't help, because if the process
dies there is nobody to listen to its binder deaths.

Test: ConnectivityServiceTest
Change-Id: I993cb9481edfaeb652b875be7f90166db16d0e1d
2021-10-25 19:24:48 +09:00
Lucas Lin
9c9850b944 Merge "Add underlying networks into NetworkAgentInfo if any" 2021-10-21 08:33:29 +00:00
Treehugger Robot
5dc1edd9a8 Merge "Dependency update for StateMachine" 2021-10-20 13:43:58 +00:00
lucaslin
6adf5ac19b Add underlying networks into NetworkAgentInfo if any
Now, VPN will set underlying networks into NetworkCapabilities
directly. So the declaredUnderlyingNetworks can also be set
directly when creating a NetworkAgentInfo.

Bug: 191918368
Test: atest FrameworksNetTests:ConnectivityServiceTest
Change-Id: I507072d00ae1eb0c391e5261ab93e359b9c4cb5c
2021-10-19 15:04:56 +08:00
Treehugger Robot
29f0350da3 Merge "Update Permission only if the network is created" 2021-10-14 06:13:54 +00:00
Paul Hu
2541cf6d81 Merge "Stop using PerUidCounter#transact" am: a7db5ddda5 am: fe5e2742b6 am: 707437622a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1821293

Change-Id: I30d748c01fa05f05a02ee5ef8bbc721fc32eafae
2021-10-04 14:23:49 +00:00
Paul Hu
fe5e2742b6 Merge "Stop using PerUidCounter#transact" am: a7db5ddda5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1821293

Change-Id: Icd1072ef5b8281fa54f71796e7eaa981b0fd943b
2021-10-04 13:58:26 +00:00
Paul Hu
a7db5ddda5 Merge "Stop using PerUidCounter#transact" 2021-10-04 13:48:07 +00:00
Treehugger Robot
3fcefe8039 Merge "Updating formatting and text for per-app dumpsys" am: 7ece4bb71e am: 3a44ebe9a1 am: 388ae1444f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1723618

Change-Id: Iaac0cb2ec69b2335759f10787a3698c636b11753
2021-10-03 06:32:52 +00:00
Treehugger Robot
3a44ebe9a1 Merge "Updating formatting and text for per-app dumpsys" am: 7ece4bb71e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1723618

Change-Id: Id13fe82d772d51b935a86076b1b660f57b4f5032
2021-10-03 06:11:23 +00:00
Treehugger Robot
7ece4bb71e Merge "Updating formatting and text for per-app dumpsys" 2021-10-03 05:53:26 +00:00
William Escande
ea9e22e10b Dependency update for StateMachine
StateMachine was in a custom filegroup in base.
It's now built in stand-alone library in modules-utils.

Bug: 198418216
Tag: #refactor
Test: Build
Merged-In: I7499fad6c4c5076e2bd98f0d9f91c5f243fb1ed2
Change-Id: I7499fad6c4c5076e2bd98f0d9f91c5f243fb1ed2
2021-10-01 17:06:42 +02:00
TreeHugger Robot
0a2d680a4d Merge "Ensure calling package name and uid are matched" into sc-qpr1-dev am: e93efb6f96
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15618365

Change-Id: I80aa5da33f8c4c5154a721ceec58852b6c2d42f1
2021-10-01 14:21:16 +00:00
TreeHugger Robot
e93efb6f96 Merge "Ensure calling package name and uid are matched" into sc-qpr1-dev 2021-10-01 14:08:56 +00:00
paulhu
3c811e1e55 Add comment for not listening EXTERNAL_APPLICATIONS_UNAVAILABLE am: e7e02d7880
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1826071

Change-Id: Ib46d16e9d96ff331a486ec4151aa498236f29d8f
2021-10-01 01:48:36 +00:00
paulhu
e7e02d7880 Add comment for not listening EXTERNAL_APPLICATIONS_UNAVAILABLE
Bug: 192653840
Test: only add comment.
Change-Id: I5a61ea76a40cf74e15ec36e415d6d4eb8ef6016f
2021-10-01 01:30:31 +00:00
James Mattis
8b298a00b2 Updating formatting and text for per-app dumpsys
Fixing the indentation for dumpsys CONNECTIVITY for per app network
info. Also updated to more clearly show when the active network is
currently tagged to the "no service network" for configured apps so as
to more clearly show intent to dumpsys consumers. Finally, correctly
showing profile network preferences which weren't being shown
previously.

Prior formatting with no per-app networks:
Current per-app default networks: Per-App Network Preference:
    none

Updated formatting with no per-app networks:
Current network preferences:
  Default requests:

Prior formatting with active per-app networks ("none" is shown in this
case since profile network preferences weren't correctly displayed):
Current per-app default networks: Per-App Network Preference:
    none
  Is per-app network active:
    true
    Active network: 100
    Tracked UIDs:
      {1100000-1199999}

Updated formatting with active per-app networks:
Current network preferences:
  Profile preferences:
    [[ProfileNetworkPreference user=UserHandle{11} caps=[ Capabilities:
    INTERNET&TRUSTED&NOT_VCN_MANAGED&ENTERPRISE Uids:
    <{1100000-1199999}>]]]
  OEM preferences:
    OemNetworkPreferences{mNetworkMappings={android.net.cts=-1}}
  Mobile data preferred UIDs:
    mMobileDataPreferredUids: {1, 2, 3}
  Default requests:
    Request: [uid/pid:1000/1423] - Satisfier: [100] Preference order: 10
    Tracked UIDs:{1100000-1199999}

Bug: 189860802
Test: adb shell dumpsys connectivity
Change-Id: I5ed4bb83e9e5a4497f5019ab4e4c0f238989a246
2021-09-30 11:47:36 -07:00
paulhu
74128521ad Stop using PerUidCounter#transact
PerUidCounter#transact is used to adjust the request counter for
the per-app API flows. Directly adjusting the counter is not
ideal however in the per-app flows, the nris can't be removed
until they are used to create the new nris upon set.

In fact, satisfiers are the info that new nris need reference.
Without satisfiers in new nris, the avaiable callbacks would be
sent to listeners agin when assign new satisfiers. Even the new
best networks are same as previous satisfiers, but the new nris
have lost those info if calling handleRemoveNetworkRequests()
before createPerAppCallbackRequestsToRegister().

However, removing satisfiers from nris is not necessary actually
because the CS will update the best network to nri when compute
network reassignment. It doesn't need to be cleared when
calling handleRemoveNetworkRequest(). Thus, keep that info and
adjust the sequence to remove nri first. The counter is still
correct and doesn't hit limit artificially.

Bug: 201648050
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I4cbc953def7866b23c2b8ebc8deaadf0ffc3b75d
2021-09-30 15:35:53 +00:00
Pavan Kumar M
be994246f4 Update Permission only if the network is created
Reproduction steps:

- Register a NetworkAgent but don't mark it as connected.
- Set teardownDelayMs for the NetworkAgent to 100
- Unregister the NetworkAgent then see system crashed.

Tests:

- Builds, Boots
- ConnectivityServiceTest

Change-Id: Ib8e517acb0193a2454d672612fe61fc199de46a4
Bug: 200023207
2021-09-29 12:37:42 +00:00
Chalard Jean
8c06f9991b Merge "Check NetworkAgentInfo Map Before Destroying Network" am: 9d31c63e03
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1802528

Change-Id: Ibcf989ffd494108faeeb4419041fb32389208c4d
2021-09-29 06:20:06 +00:00