Commit Graph

1320 Commits

Author SHA1 Message Date
Chiachang Wang
ebab250383 Merge "Add test to verify null ProxyInfo in Ikev2VpnProfile" 2022-09-02 12:15:09 +00:00
Aaron Huang
279733e3f5 Merge "Fix settings show data usage with the uid of a removed package" 2022-09-02 07:43:55 +00:00
chiachangwang
715dc5b447 Add test to verify null ProxyInfo in Ikev2VpnProfile
Bug: 244281603
Test: atest FrameworksNetTests
Change-Id: Ice195b60a0f62ae541ede9277c6e36f9c72b2dbb
2022-09-02 03:51:43 +00:00
Jean Chalard
3db58490ff Merge "Convert EthTrackTest from when() to doReturn()" 2022-09-02 02:52:39 +00:00
Treehugger Robot
24ca302311 Merge "Convert booleans in NAI to timestamps" 2022-09-01 23:06:09 +00:00
Chalard Jean
254bd168a3 Convert booleans in NAI to timestamps
These timestamps will be useful for debugging issues where
debuggers need to know what happened to long-lived networks,
where logcat doesn't span long enough.

These timestamps are also likely to be useful in the future,
in particular for metrics.

Test: FrameworksNetTests
Change-Id: I8f46ce92e2ab301fa32e18e714a43a4130719199
2022-09-01 18:37:01 +09:00
Chalard Jean
61525a57a0 Convert EthTrackTest from when() to doReturn()
Bug: 242671512
Test: FrameworksNetTests
Change-Id: I5f13ebe1c1e8e1ecd3d561cae8380ec12b31dc95
2022-09-01 18:02:12 +09:00
Motomu Utsumi
171c817072 Merge "Use IBpfMap type instead of BpfMap type" 2022-08-31 03:54:28 +00:00
Junyu Lai
1c685c1e97 Merge "[ST01] Attributes data usage of test network by specifier" 2022-08-30 05:50:40 +00:00
Aaron Huang
095438420c Fix settings show data usage with the uid of a removed package
When an app is removed, the stats still be included in
the persist snapshot in NetworkStatsFactory which
causes settings show the data usage with the uid of the
removed app. Thus, remove the stats of the removed
package from the persist snapshot when NetworkStatsService
receives ACTION_UID_REMOVED intent.

Bug: 239899930
Bug: 209360825
Test: FrameworksNetTests:NetworkStatsServiceTest
      FrameworksNetTests:NetworkStatsFactoryTest
Change-Id: I73cca367ac6bf0d2d29ef0a7d94500f1e6917dcb
2022-08-29 22:31:26 +08:00
Treehugger Robot
c6c4dc719f Merge "unit test of offernetwork and unoffernetwork" 2022-08-29 13:59:18 +00:00
Junyu Lai
c9f1ca62d9 [ST01] Attributes data usage of test network by specifier
Currently, data usage of all test networks are all attributed to
the same NetworkIdentity, which does not allow services to
distinguish upload & download traffic of different test networks.

Thus, this CL put specifier that comes along with
TestNetworkAgent into wifiNetworkKey field to build different
NetworkIdentity to attribute data usage to different for
individual networks. And allow querying test network usage with
wifiNetworkKeys.

Bug: 139774492
Test: atest FrameworksNetTests
      atest android.net.cts.ConnectivityManagerTest
Change-Id: I1bb38fd20781eaf3105735440a04b27bef36fcae
2022-08-29 13:55:08 +08:00
Aaron Huang
827dbd9277 Merge "Rename expect* methods that are used in NetworkStatsServiceTest" 2022-08-26 14:18:43 +00:00
Lucas Lin
e87c1e0187 Merge "Revert "Test if VPN app can grant ACTIVATE_PLATFORM_VPN with CON..."" 2022-08-25 05:41:01 +00:00
Paul Hu
914d0def25 Make onPackage[Added|Removed] as non-public methods
In the past, CS would receive package add/remove intent and notify
PermissionMonitor by onPackage[Added|Removed] method.
Now, PermissionMonitor receives those intents itself, so CS will
not call these two methods anymore. Thus, these two methods do not
need to be public, make them as package private methods.

Bug: 232048835
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I516edd1e900d7515bf383eeab2492eace97d780a
2022-08-25 02:08:51 +00:00
Patrick Rohr
f37e7c645b Merge changes Id6ae7929,I70474ef5,I4958df65,Ifc0e1ba2
* changes:
  ethernet: remove callback from factory updateInterfaceLinkState
  ethernet: updateConfiguration result should not rely on ip provisioning
  ethernet: remove callback boilerplate from EthernetNetworkFactory
  ethernet: add EthernetCallback class to wrap OutcomeReceiver
2022-08-24 17:45:04 +00:00
Motomu Utsumi
73599a5f5d Use IBpfMap type instead of BpfMap type
Currently, production code uses BpfMap type and TestBpfMap extends
BpfMap but this makes it diffcult to test because TestBpfMap loads the
JNI.

This CL updates to use IBpfMap type in the production code.
Upcoming CL updates TestBpfMap to implement IBpfMap instead of extending
BpfMap so that test can still use TestBpfMap but tests do not need to
load JNI.

Bug: 217624062
Test: atest BpfCoordinatorTest BpfNetMapsTest
Change-Id: Ie67e14bf5519fb4427474ecc0fda441877a9555f
2022-08-24 23:31:19 +09:00
Jean Chalard
38a01e080d Merge "Add tests for callback visibility" 2022-08-24 09:51:36 +00:00
Paul Hu
f37dfa3a11 Merge "Add null check for clientInfo" 2022-08-24 03:54:49 +00:00
Motomu Utsumi
9988869442 Merge changes from topic "cookie_tag_map_raw_dump"
* changes:
  Add option to dump cookieTagMap in base64 format
  Use BpfDump#fromBase64EncodedString
2022-08-24 03:16:53 +00:00
Chiachang Wang
cbe38b46a2 Merge "Decouple VpnManagerService from ConnectivityServiceTest" 2022-08-24 03:05:24 +00:00
Patrick Rohr
750036b286 ethernet: remove callback from factory updateInterfaceLinkState
updateInterfaceLinkState already returns true / false depending on the
success, so the EthernetCallback can be removed and sent from
EthernetTracker instead.

Test: atest EthernetManagerTest
Bug: 225317892
Change-Id: Id6ae7929097840ac5c9a4d244fdf669a06b94ed5
2022-08-23 13:07:57 -07:00
Treehugger Robot
6a8166cf5e Merge "Use PerUidCounter in the connectivity static library" 2022-08-23 18:25:03 +00:00
Patrick Rohr
ea5c6dd136 ethernet: updateConfiguration result should not rely on ip provisioning
In addition, the result should always be success if the new
configuration is stored. This allows updating interfaces that are not
currently registered with ethernet service.

Bug: 236312641
Test: atest EthernetManagerTest
Change-Id: I70474ef5f046c65a6f74161137e25debd8dfe612
2022-08-23 11:01:47 -07:00
Motomu Utsumi
405d676a08 Merge "Support java BpfMap in BpfNetMaps#swapActiveStatsMap" 2022-08-23 04:01:30 +00:00
Jean Chalard
595a98b352 Merge "Address comments on aosp/1781202" 2022-08-23 03:13:12 +00:00
Patrick Rohr
251f2fcf13 ethernet: add EthernetCallback class to wrap OutcomeReceiver
The OutcomeReceiver that gets passed into the EthernetServiceImpl is
hard to use (it is nullable and both onError and onResult can throw
RemoteExceptions).

Note: This is an intermediary state.
The next step will be to completely tear EthernetCallback out of
EthernetNetworkFactory, which will remove a lot of boilerplate code.

Bug: 225317892
Test: atest EthernetManagerTest
Change-Id: Ifc0e1ba29ded933c418e4b335cb731c3496d7e44
2022-08-22 12:10:27 -07:00
Motomu Utsumi
618b9b0fa0 Merge "Support java BpfMap in BpfNetMaps#setNetPermForUids" 2022-08-21 04:01:19 +00:00
Lucas Lin
d17c5ea7f0 Merge "Check if VpnConfig#allowBypass is set or not" 2022-08-19 09:13:35 +00:00
Aaron Huang
8509ef03a9 Rename expect* methods that are used in NetworkStatsServiceTest
These expect* methods are used to have NetworkStatsService
returns the given stats instead of expecting anything.
Therefore, give these methods more appropriate naming.

Bug: 236819091
Test: FrameworksNetTests:NetworkStatsServiceTest
Change-Id: Ife877dede5b8ac78001679792d7459764bbc38f0
2022-08-18 14:34:33 +08:00
lucaslin
03dcd7123f Check if VpnConfig#allowBypass is set or not
Bug: 242931436
Test: atest FrameworksNetTests:VpnTest
Change-Id: I00e28717b35ed8b024b1d44e0689392d924c18bf
2022-08-18 12:06:22 +08:00
Motomu Utsumi
e6120b409f Add option to dump cookieTagMap in base64 format
This is a preparation for testing SkDestroyListener that removes
cookieTagMap entry when socket is destroyed.

Bug: 217624062
Test: atest NetworkStatsServiceTest
Change-Id: Ia1091130101360e37557e6f00efe0f736134de05
2022-08-18 13:00:33 +09:00
Maciej Żenczykowski
22f0604474 Merge "fix clat on restricted networks" 2022-08-18 00:43:06 +00:00
lucaslin
4360a9ee8d Replace requestNetwork with registerSystemDefaultNetworkCallback
Vpn used registerSystemDefaultNetworkCallback to listen the
underlying network, so the test code should also update.

Bug: 236409954
Test: atest FrameworksNetTests
Change-Id: Ide344a1bbac9d8560fbe8addac667ff5b14a4c6f
2022-08-17 15:29:51 +00:00
Motomu Utsumi
7abeaa499c Support java BpfMap in BpfNetMaps#swapActiveStatsMap
Bug: 217624062
Test: atest BpfNetMapsTest
android.net.cts.NetworkStatsManagerTest
android.net.cts.TrafficStatsTest

Change-Id: I9cb673673d2ed1dda8fa14c0877e2fc683267791
2022-08-17 14:40:53 +00:00
Motomu Utsumi
65271207f6 Support java BpfMap in BpfNetMaps#setNetPermForUids
Bug: 217624062
Test: atest BpfNetMapsTest
Change-Id: Ia32a73a49ee6a0b05e1abd0c09766e7769e7e760
2022-08-17 14:20:13 +00:00
chiachangwang
4597a749cb Decouple VpnManagerService from ConnectivityServiceTest
The test scope of ConnectivityService should verify how and
what ConnectivityService works in the unit test, so remove
the VpnManagerService related mocking from ConnectivityServiceTest.

This commit replaces the way to handle package added/remove and
user unlock intent in VpnManagerService. The flows interacting
with those intents in VpnManagerService are verified in
VpnManagerServiceTest, so unit test still maintains the same
coverage.

Bug: 230548427
Test: atest ConnectivityServiceTest
Change-Id: Ia2279bd1023296e3c949fa05bd74e921bf17da79
2022-08-17 14:15:44 +00:00
chiachangwang
ab86a89a4c Test MOBIKE trigged while VPN data stall
Add tests to verify MOBIKE being triggered when VPN meets data
stall.

Bug: 238692379
Test: atest FrameworksNetTests
Change-Id: I736a55e02f020fcafd7b6d49b6bcfc4716743095
2022-08-17 13:48:18 +00:00
Junyu Lai
00d92df645 Use PerUidCounter in the connectivity static library
This is a no-op refactoring which uses common PerUidCounter
from the static library and delete the private implementation
inside ConnectivityService. This refactoring includes:
  1. Make a private implementation that inherite PerUidCounter
     to convert and rethrow exception to maintain backward
     compatibility.
  2. Adjust per-uid max limit argument in the counter constructor
     since the private implementation is already buggy.
  3. Use the getter in PerUidCounter for the existing tests.

Test: testNetworkCallbackMaximum
      testProfileNetworkPrefCountsRequestsCorrectlyOnSet
      testRequestCountLimits
Bug: 235771502
Change-Id: I5c49edab18774acf819828201041c9931fabccc4
2022-08-17 15:50:39 +08:00
Chalard Jean
9cc32051ac Address comments on aosp/1781202
This also imports FunctionalUtils (ex-ExceptionUtils) with
its new name, as the companion change changes the name of
that class.

Test: ConnectivityServiceTest
Change-Id: I3fbc28835419864e536dd6727670328658a9b7cf
2022-08-17 07:11:55 +00:00
Lucas Lin
1d68ed690d Revert "Test if VPN app can grant ACTIVATE_PLATFORM_VPN with CON..."
Revert "Grant the ACTIVATE_PLATFORM_VPN appop if VPN app has CON..."

Revert submission 2141595-GRANT_PLATFORM_VPN

Reason for revert: Refer to the comment in ag/19491935.
Reverted Changes:
I0e0566bb8:Grant the ACTIVATE_PLATFORM_VPN appop if VPN app h...
I0580baca6:Test if VPN app can grant ACTIVATE_PLATFORM_VPN wi...

Change-Id: I9208fc124a5d37014b28e531da271e43e47c165a
2022-08-17 06:31:29 +00:00
Maciej Żenczykowski
ef4b1bc50f fix clat on restricted networks
this is the case for example when a tethering dun is in use

Bug: 235523181
Bug: 241055859
Change-Id: Ie261db0329179ff7f92c61202af30ab55130ae03
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
2022-08-16 10:28:09 +00:00
Chalard Jean
8aa28fe733 Add tests for callback visibility
Test: this
Change-Id: Ic1d8fab0105c2fa29536795a1c1359a026009fac
2022-08-16 17:34:06 +09:00
wangshengrjxtjcb
d89374cf11 unit test of offernetwork and unoffernetwork
BUG:238033349
Change-Id: Ibdedbae5d785145af155bb5bf10a5ba5dfaffcff
2022-08-16 07:44:24 +00:00
Paul Hu
116b4c0b6b Add null check for clientInfo
If the binder death notification for a INsdManagerCallback was
received before any calls are received by NsdService, the
clientInfo would be cleared and cause NPE. Thus, add a null check
to prevent crash.

Bug: 241741274
Test: atest FrameworksNetTests
Change-Id: Iebe761cd579bf3ee46ead389620bed60a21e3154
2022-08-16 07:21:55 +00:00
Patrick Rohr
7b0fa6f14d Merge "ethernet: replace netd link observer with NetlinkMonitor" am: ab97a38ba8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2180636

Change-Id: Idba67c11bd370935d2811f235df0186e6884560b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-12 15:59:11 +00:00
Patrick Rohr
ab97a38ba8 Merge "ethernet: replace netd link observer with NetlinkMonitor" 2022-08-12 15:55:44 +00:00
Xiao Ma
ace5b3635b Merge "Remove filegroup connectivity-module-utils-srcs in connectivity." am: 7f15ce1d9c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2153736

Change-Id: Idd2df16857eab2f7b7e7a971f876c36531fcb736
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-12 09:24:40 +00:00
Xiao Ma
7f15ce1d9c Merge "Remove filegroup connectivity-module-utils-srcs in connectivity." 2022-08-12 09:06:58 +00:00
Patrick Rohr
734f24e6d7 ethernet: replace netd link observer with NetlinkMonitor
The netd based InterfaceObserver uses two different netlink sockets for
updates on interface added / removed and link up / down events. This
means that these events are not ordered, which causes lots of
interesting issues in the ethernet service. Netd does not use
RTM_DELLINK at all, so this code has to use NetlinkMonitor to do
implement its own link tracking.

The EthernetManagerTests are currently disabled. There are still a
couple of flakes: one due to some link state issue which stops occurring
when bringing up the interface in TestNetworkService (weird -- I don't
yet know why this happens). Another due to the maybeTrackInterface
looking at the running flag (which races with the bringup code).

Test: atest EthernetManagerTest
Bug: 218785176
Bug: 234314411
Change-Id: I92b737f693402c1a8fd0a864736673de94904f2d
2022-08-11 11:40:54 -07:00