Commit graph android_packages_modules_Co.../tests/unit/java
Message SHA1
Merge "Update VpnTest to use VpnNetworkAgentWrapper"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-08-02 12:08:13 +00:00
7dce599f42
Merge changes I6fff65eb,Ie49d2319,Ief974217
* changes:
  Make all ConnectivityService#doTestXyz methods private.
  Expect creating the DNS event listener in setUp, not in tests.
  Rename testPreferenceForUserNetworkUpDownForGivenPreference.

Treehugger Robot   authored and   Gerrit Code Review   commited 2022-08-02 06:49:46 +00:00
2719dc8682
Merge changes Id2a6bfdf,I5cab2b78
* changes:
  Remove qtaguid support in NetworkStatsFactory
  Refactor NetworkStatsFactoryTest

Junyu Lai   authored and   Gerrit Code Review   commited 2022-08-02 05:32:45 +00:00
2dba76105c
Make all ConnectivityService#doTestXyz methods private.
They are not tests so there is no need for them to be public.

Test: TH
Bug: 143158421
Change-Id: I6fff65eb62b1689432dc1c9c7347261433317fac

Lorenzo Colitti   commited 2022-08-02 09:52:51 +09:00
db04c60658
Expect creating the DNS event listener in setUp, not in tests.
This simplifies the code a bit.

Also remove an unnecessary reset(mMockNetd) call.

Bug: 143158421
Test: test-only change
Change-Id: Ie49d23193ef8d9dcb3f724a7dff249755c67a971

Lorenzo Colitti   commited 2022-08-02 09:52:51 +09:00
410d4e18b0
Rename testPreferenceForUserNetworkUpDownForGivenPreference.
This method name is confusing because it is not a test, and
convention in this file is that only test methods are called
testXyz. Rename it to doTestXyz.

Bug: 143158421
Test: test-only change
Change-Id: Ief9742174a7fc9966ade29d9a32a13277ce747ac

Lorenzo Colitti   commited 2022-08-01 18:42:24 +09:00
b82e25c51b
Merge "Add back compat config for NSD"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2022-07-29 08:09:54 +00:00
a39d54bf43
Remove qtaguid support in NetworkStatsFactory
All devices shipped with S+ release would have 4.9+ kernel
with bpf enabled. And for older devices qtag uid is
already broken for a long time. Hence, it is safe to
remove the related code.

Bug: 234315786
Test: atest FrameworksNetTests CtsNetTestCases \
      ConnectivityCoverageTests
Change-Id: Id2a6bfdf32793e5f48eb74da3b662906e5ed380e

Junyu Lai   commited 2022-07-29 16:00:29 +08:00
e9f8d8516c
Refactor NetworkStatsFactoryTest
This patch changes the way of mocking samples in the tests, and
enabling use bpf stats flag, testing through the code path
that is not running in the production code does not make any
sense.

This change also copied methods from NetworkStatsFactory
as we want to continue parsing the golden files to test the
464xlat adjustment which historically has been prone to errors.
And deleting tests that does not execrise NetworkStatsFactory
code or rely on monotonic accumulative readings from native
layer, which is not happening today.

Bug: 234315786
Test: atest FrameworksNetTests CtsNetTestCases \
      ConnectivityCoverageTests
Change-Id: I5cab2b78651f1da628705c191e42857c8b59d826

junyulai   authored and   Junyu Lai   commited 2022-07-29 15:46:18 +08:00
8c77e385bd
Add flag to test BpfNetMaps refactoring
Following CLs will switch previous codepath (JNI) and new codepath
(Java) for bpf map operations based on this flag.

Bug: 217624062
Test: atest BpfNetMapsTest
Change-Id: I74f10d5c97390993acea110f6528ef8980bb2aa4

Motomu Utsumi   commited 2022-07-28 02:32:41 +00:00
f688eeb10a
Update VpnTest to use VpnNetworkAgentWrapper
Bug: 192077544
Test: atest VpnTest
Change-Id: Id0be4c4f2c9eba6cb7445d5c5ea4889165971317

Yan Yan   commited 2022-07-28 00:40:02 +00:00
bbb586d7f1
Merge "Use java BpfMap in BpfNetMaps#replaceUidChain"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2022-07-27 13:21:50 +00:00
6bcb3c290c
Add back compat config for NSD
Add back compat config for RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS, which was
lost when moving NsdManager to framework-connectivity-t.

This causes NsdManager to start mdnsresponder again when used by apps
with target SDK < 31.

The change also changes the compat ID used, to make sure it does not
conflict with the ID already in use in S and below, when the module is
installed on such a platform. This is the only ChangeId used by
framework-t.

Also add a CtsNetTestCasesMaxTargetSdk30 test to verify that behavior.

Bug: 235355681
Test: atest CtsNetTestCasesMaxTargetSdk30
Change-Id: I7ca6051d0a4ba5aff3e44bece2cbac22eb1be32d

Remi NGUYEN VAN   commited 2022-07-27 19:53:25 +09:00
348bbb0231
Use java BpfMap in BpfNetMaps#replaceUidChain
Bug: 217624062
Test: atest BpfNetMapsTest
Change-Id: Ib2a2c2646834110a3eeeb786a4ea7a3f85718be8

Motomu Utsumi   commited 2022-07-27 06:01:47 +00:00
9be2ea0080
Merge changes Ic18521b6,Ibede8137
* changes:
  Move tag/untag socket BPF map access from JNI to Java
  Move struct CookieTagMap{Key, Value} to Connectivity/common

Maciej Å»enczykowski   authored and   Gerrit Code Review   commited 2022-07-26 08:35:58 +00:00
a1b3378285
Merge "Migrate buildTemplate* to use NetworkTemplate.Builder"
Aaron Huang   authored and   Gerrit Code Review   commited 2022-07-26 07:40:49 +00:00
c37d806dfd
Changing EthernetNetworkFactoryTest assert order
Changing multiple instances where the assert order for an assert.equals
was (actual, expected) to the more widely (and suggested) ordering of
(expected, actual).

Bug: 235605892
Test: atest FrameworksNetTests
:com.android.server.ethernet.EthernetNetworkFactoryTest

Change-Id: I6e9459d34d6cc7f43a2bfe346d2c2ca9551d46da

James Mattis   commited 2022-07-25 12:36:49 -07:00
fce2777a9b
Migrate buildTemplate* to use NetworkTemplate.Builder
Use new Builder API which was introduced in Android T.

Bug: 238843364
Test: FrameworksNetTests
      dumpsys netstats --checkin and check the output
Change-Id: Ieb0a2ee04056a1cedb71274ea710ff5153e2d68c

Aaron Huang   commited 2022-07-25 11:30:13 +08:00
1c14fa9b08
Move tag/untag socket BPF map access from JNI to Java
Tag socket as uid AID_CLAT to avoid duplicated data usage counting by
bpf program.

Bug: 237369591
Test: ClatCoordinatorTest
Change-Id: Ic18521b63b3feadd53d77d7f4f0b44ab983e5fbf

Hungming Chen   commited 2022-07-23 03:19:13 +08:00
913507f150
Move struct CookieTagMap{Key, Value} to Connectivity/common
Need to share struct CookieTagMap{Key, Value} with:
service/src/com/android/server/connectivity/ClatCoordinator.java
service-t/src/com/android/server/net/NetworkStatsService.java
tests/unit/java/com/android/server/connectivity/ClatCoordinatorTest.java
tests/unit/java/com/android/server/net/NetworkStatsServiceTest.java

These files only have different package name as expected.

$ diff common/src/com/android/net/module/util/bpf/CookieTagMapKey.java service-t/src/com/android/server/net/CookieTagMapKey.java
  17c17
  <- package com.android.net.module.util.bpf;
  ---
  -> package com.android.server.net;

$ diff common/src/com/android/net/module/util/bpf/CookieTagMapValue.java service-t/src/com/android/server/net/CookieTagMapValue.java
  17c17
  <- package com.android.net.module.util.bpf;
  ---
  -> package com.android.server.net;

Bug: 237369591
Test: atest ConnectivityCoverageTests
Change-Id: Ibede81376382f0dd7a032c8c988dd84c7422eece

Hungming Chen   commited 2022-07-23 03:18:55 +08:00
ef0280288e
Merge changes If13254d4,I2424bd4f
* changes:
  Sendcallback when setting eth interface up
  ethernet: add test for enable/disable interface

Patrick Rohr   authored and   Gerrit Code Review   commited 2022-07-22 14:44:34 +00:00
df9fbd37c6
Sendcallback when setting eth interface up
Fix so callbacks are sent when changing the interface link state for an
ethernet interface from down -> up.

Bug: 235605892
Test: atest FrameworksNetTests
:com.android.server.ethernet.EthernetNetworkFactoryTest

Change-Id: If13254d4882aa2f0021f6443f31ef173b3867727

James Mattis   commited 2022-07-21 21:39:52 -07:00
a199735a88
Merge "Add more NsdService tests"
Paul Hu   authored and   Gerrit Code Review   commited 2022-07-22 01:40:30 +00:00
9c8cda2335
Merge "Test if VpnManager event will be sent to Settings VPN or not"
Lucas Lin   authored and   Gerrit Code Review   commited 2022-07-21 11:05:42 +00:00
95f801a104
Test if VpnManager event will be sent to Settings VPN or not
Bug: 236315805
Test: atest FrameworksNetTests:VpnTest
Change-Id: I0ee4a70ded4937a1573d34cddab552f762e4fc18

lucaslin   authored and   Lucas Lin   commited 2022-07-21 00:58:38 +00:00
6baebebbe1
Merge "Test if VPN app can grant ACTIVATE_PLATFORM_VPN with CONTROL_VPN"
Lucas Lin   authored and   Gerrit Code Review   commited 2022-07-20 13:28:43 +00:00
4887b5f98f
Add more NsdService tests
This is a no-op and test only change. Test the scenarios below:
- Registration service successful and failed.
- Discovery service failed.
- Resolution service failed.
- Getting an address failed.

Bug: 236788977
Test: atest FrameworksNetTests
Change-Id: I533d0be2abfa5c1832a060b4b2d4d1dd382c5b71

Paul Hu   commited 2022-07-20 10:11:18 +00:00
64f36446c7
Merge "Replace buildTemplate* with NetworkTemplate.Builder"
Aaron Huang   authored and   Gerrit Code Review   commited 2022-07-20 02:56:33 +00:00
1ba1febf2b
Merge "ethernet: fix receiving NetworkOffer callbacks on stale object"
Patrick Rohr   authored and   Gerrit Code Review   commited 2022-07-18 15:50:14 +00:00
b916ff898b
Replace buildTemplate* with NetworkTemplate.Builder
Use Builder API which was provided in Android T to
build a template.

Bug: 238843364
Test: build, FrameworksNetTests:NetworkStatsManagerTest
Change-Id: Ibf1ac16541d6f3ddaf9b241e2f47ae04acbedf93

Aaron Huang   commited 2022-07-18 17:16:49 +08:00
a4fcb8b4cf
ethernet: fix receiving NetworkOffer callbacks on stale object
unregisterNetworkOffer() does not execute synchronously, so it is
possible that NetworkOffer callbacks are received after the offer was
unregistered.

Test: atest EthernetManagerTest && atest EthernetNetworkFactoryTest
Bug: 171872016
Change-Id: I2c50b01176e4968c31f83148f1831b55f8b06908

Patrick Rohr   commited 2022-07-15 10:32:25 -07:00
7c4e2a918c
Merge "Use java BpfMap in BpfNetMaps#setUidRule"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2022-07-15 01:06:48 +00:00
fe72021c06
Merge "Add common parameters to reduce duplicated code"
Paul Hu   authored and   Gerrit Code Review   commited 2022-07-14 08:00:16 +00:00
0ce40ac75d
Add common parameters to reduce duplicated code
This is a no-op and test only change. Some parameters use many
times, so add common parameters to reduce duplicated code.

Bug: 236788977
Test: atest FrameworksNetTests
Change-Id: I94370817ea87d1da5c30ea2ed467c1746edecba3

Paul Hu   commited 2022-07-14 02:21:41 +00:00
601644c8a7
Use java BpfMap in BpfNetMaps#setUidRule
Bug: 217624062
Test: atest BpfNetMapsTest
android.net.cts.ConnectivityManagerTest#testFirewallBlocking

Change-Id: I79745231edac77d07571fa1909da5b9e811a69c4

Motomu Utsumi   commited 2022-07-14 02:12:34 +00:00
40230beb5f
Use java BpfMap in removeUidInterfaceRules
Bug: 217624062
Test: atest BpfNetMapsTest HostsideVpnTests#testBlockIncomingPacket
Change-Id: I253c75aaeabe138a4f9d57c226744f5766ef1006

Motomu Utsumi   commited 2022-07-13 11:12:19 +00:00
599c4e5cf4
Use java BpfMap in BpfNetMaps#addUidInterfaceRules
Bug: 217624062
Test: atest BpfNetMapsTest HostsideVpnTests#testBlockIncomingPacket
Change-Id: I8aeb4712c852167d553eb331f32d770582199b13

Motomu Utsumi   commited 2022-07-13 11:11:59 +00:00
5f52f4f2fb
Merge changes I58cd6145,I32299ce8,I0433459e
* changes:
  Use java BpfMap in updateUidLockdownRule
  Use java BpfMap in BpfNetMaps#addNiceApp
  Use java BpfMap in BpfNetMaps#removeNiceApp

Motomu Utsumi   authored and   Gerrit Code Review   commited 2022-07-12 03:00:28 +00:00
fabb53a881
Use java BpfMap in updateUidLockdownRule
Bug: 217624062
Test: atest BpfNetMapsTest HostsideVpnTests#testBlockIncomingPacket
Change-Id: I58cd614575a98c4b5a8f9c34d47dd2dfff187b26

Motomu Utsumi   commited 2022-07-11 07:19:05 +00:00
697b299e3a
Merge changes I69a2970d,Ibfb3ae48,Ie595cf1f
* changes:
  Use java BpfMap in BpfNetMaps#addNaughtyApp
  Use java BpfMap in BpfNetMaps#removeNaughtyApp
  Add bpf map and lock for UidOwnerMap

Motomu Utsumi   authored and   Gerrit Code Review   commited 2022-07-11 07:14:53 +00:00
9ab777b5d5
Merge "Update error handling in BpfNetMaps"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2022-07-11 06:28:50 +00:00
f2eca2f13a
Use java BpfMap in BpfNetMaps#addNiceApp
Bug: 217624062
Test: atest BpfNetMapsTest HostsideRestrictBackgroundNetworkTests
Change-Id: I32299ce8cde34d46999ecb966c3305c966c0509f

Motomu Utsumi   commited 2022-07-11 03:14:07 +00:00
55630d0dc8
Use java BpfMap in BpfNetMaps#addNaughtyApp
Bug: 217624062
Test: atest BpfNetMapsTest HostsideRestrictBackgroundNetworkTests
Change-Id: I69a2970d20be41431b774273bc0902bd325421f4

Motomu Utsumi   commited 2022-07-11 03:14:07 +00:00
389278ec8b
Use java BpfMap in BpfNetMaps#removeNiceApp
Bug: 217624062
Test: atest BpfNetMapsTest HostsideRestrictBackgroundNetworkTests
Change-Id: I0433459ec43b6a84c4417152884d10fae5fecee6

Motomu Utsumi   commited 2022-07-11 03:14:07 +00:00
7392eb4f4c
Use java BpfMap in BpfNetMaps#removeNaughtyApp
Bug: 217624062
Test: atest BpfNetMapsTest HostsideRestrictBackgroundNetworkTests
Change-Id: Ibfb3ae48427b7dc5d06708e63f4a16f7527ce86c

Motomu Utsumi   commited 2022-07-11 03:14:07 +00:00
60ed3be43b
Add bpf map and lock for UidOwnerMap
This commit is a preparation for replacing JNI codes that modify
UidOwnerMap by Java.

Bug: 217624062
Test: atest BpfNetMapsTest HostsideRestrictBackgroundNetworkTests
android.net.cts.ConnectivityManagerTest#testFirewallBlocking

Change-Id: Ie595cf1f77a3ed86addbcdaea1a1be972e0265b3

Motomu Utsumi   commited 2022-07-11 03:14:05 +00:00
5a68a21926
Update error handling in BpfNetMaps
Address review comments from aosp/2117045
Throw AssertionError if bpf map init get error
Update tests to avoid getting AssertionError

Bug: 217624062
Test: atest BpfNetMapsTest
Change-Id: I2194b825aa73b88d5334077d17acb9abbd367c69

Motomu Utsumi   commited 2022-07-11 03:13:04 +00:00
305975ffb0
Verify calling thread for intent receiver
Bug: 230548427
Test: atest VpnManagerServiceTest
Change-Id: Ibe5f7aba8e31dfecfb2eaac3fb109eb442879ede

chiachangwang   commited 2022-07-07 08:54:52 +00:00
826f0b01d2
Refactor to mock package add and remove event
Use mock intent receiver to handle intent related events instead
of exposing the private methods even for testing only.

The visibility for onPackageAdded, onPackageRemoved and
onUserStarted were exposed for testing only in former commit.
The test coverage for intent receiver part may be missed.
The other intent related methods will be verified in the
follow up commits. This refactor will also help to not to
expose further private methods.

Bug: 230548427
Test: atest VpnManagerServiceTest
Change-Id: If2aa88d8d5c1643e8bd4937673aa792186047fd8

chiachangwang   commited 2022-07-07 08:54:27 +00:00
26de58ea79
Test reconnect VpnManager VPN with always on enabled
Verify reconnect using startVpnProfile with the same package with
always-on package should work without exception.

Bug: 235322391
Test: atest FrameworksNetTests
Change-Id: I9a780d970208032e2468e9c5b3334373627c6a20

chiachangwang   commited 2022-07-07 06:46:15 +00:00
a412026c6b