Commit Graph

772 Commits

Author SHA1 Message Date
Aaron Huang
c37d806dfd Merge "Migrate buildTemplate* to use NetworkTemplate.Builder" 2022-07-26 07:40:49 +00:00
James Mattis
fce2777a9b 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
2022-07-25 12:36:49 -07:00
Aaron Huang
1c14fa9b08 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
2022-07-25 11:30:13 +08:00
Patrick Rohr
df9fbd37c6 Merge changes If13254d4,I2424bd4f
* changes:
  Sendcallback when setting eth interface up
  ethernet: add test for enable/disable interface
2022-07-22 14:44:34 +00:00
James Mattis
a199735a88 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
2022-07-21 21:39:52 -07:00
Paul Hu
9c8cda2335 Merge "Add more NsdService tests" 2022-07-22 01:40:30 +00:00
Lucas Lin
95f801a104 Merge "Test if VpnManager event will be sent to Settings VPN or not" 2022-07-21 11:05:42 +00:00
lucaslin
6baebebbe1 Test if VpnManager event will be sent to Settings VPN or not
Bug: 236315805
Test: atest FrameworksNetTests:VpnTest
Change-Id: I0ee4a70ded4937a1573d34cddab552f762e4fc18
2022-07-21 00:58:38 +00:00
Lucas Lin
4887b5f98f Merge "Test if VPN app can grant ACTIVATE_PLATFORM_VPN with CONTROL_VPN" 2022-07-20 13:28:43 +00:00
Paul Hu
64f36446c7 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
2022-07-20 10:11:18 +00:00
Aaron Huang
1ba1febf2b Merge "Replace buildTemplate* with NetworkTemplate.Builder" 2022-07-20 02:56:33 +00:00
Patrick Rohr
b916ff898b Merge "ethernet: fix receiving NetworkOffer callbacks on stale object" 2022-07-18 15:50:14 +00:00
Aaron Huang
a4fcb8b4cf 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
2022-07-18 17:16:49 +08:00
Patrick Rohr
7c4e2a918c 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
2022-07-15 10:32:25 -07:00
Motomu Utsumi
fe72021c06 Merge "Use java BpfMap in BpfNetMaps#setUidRule" 2022-07-15 01:06:48 +00:00
Paul Hu
0ce40ac75d Merge "Add common parameters to reduce duplicated code" 2022-07-14 08:00:16 +00:00
Paul Hu
601644c8a7 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
2022-07-14 02:21:41 +00:00
Motomu Utsumi
40230beb5f Use java BpfMap in BpfNetMaps#setUidRule
Bug: 217624062
Test: atest BpfNetMapsTest
android.net.cts.ConnectivityManagerTest#testFirewallBlocking

Change-Id: I79745231edac77d07571fa1909da5b9e811a69c4
2022-07-14 02:12:34 +00:00
Motomu Utsumi
599c4e5cf4 Use java BpfMap in removeUidInterfaceRules
Bug: 217624062
Test: atest BpfNetMapsTest HostsideVpnTests#testBlockIncomingPacket
Change-Id: I253c75aaeabe138a4f9d57c226744f5766ef1006
2022-07-13 11:12:19 +00:00
Motomu Utsumi
5f52f4f2fb Use java BpfMap in BpfNetMaps#addUidInterfaceRules
Bug: 217624062
Test: atest BpfNetMapsTest HostsideVpnTests#testBlockIncomingPacket
Change-Id: I8aeb4712c852167d553eb331f32d770582199b13
2022-07-13 11:11:59 +00:00
Motomu Utsumi
fabb53a881 Merge changes I58cd6145,I32299ce8,I0433459e
* changes:
  Use java BpfMap in updateUidLockdownRule
  Use java BpfMap in BpfNetMaps#addNiceApp
  Use java BpfMap in BpfNetMaps#removeNiceApp
2022-07-12 03:00:28 +00:00
Motomu Utsumi
697b299e3a Use java BpfMap in updateUidLockdownRule
Bug: 217624062
Test: atest BpfNetMapsTest HostsideVpnTests#testBlockIncomingPacket
Change-Id: I58cd614575a98c4b5a8f9c34d47dd2dfff187b26
2022-07-11 07:19:05 +00:00
Motomu Utsumi
9ab777b5d5 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
2022-07-11 07:14:53 +00:00
Motomu Utsumi
f2eca2f13a Merge "Update error handling in BpfNetMaps" 2022-07-11 06:28:50 +00:00
Motomu Utsumi
55630d0dc8 Use java BpfMap in BpfNetMaps#addNiceApp
Bug: 217624062
Test: atest BpfNetMapsTest HostsideRestrictBackgroundNetworkTests
Change-Id: I32299ce8cde34d46999ecb966c3305c966c0509f
2022-07-11 03:14:07 +00:00
Motomu Utsumi
389278ec8b Use java BpfMap in BpfNetMaps#addNaughtyApp
Bug: 217624062
Test: atest BpfNetMapsTest HostsideRestrictBackgroundNetworkTests
Change-Id: I69a2970d20be41431b774273bc0902bd325421f4
2022-07-11 03:14:07 +00:00
Motomu Utsumi
7392eb4f4c Use java BpfMap in BpfNetMaps#removeNiceApp
Bug: 217624062
Test: atest BpfNetMapsTest HostsideRestrictBackgroundNetworkTests
Change-Id: I0433459ec43b6a84c4417152884d10fae5fecee6
2022-07-11 03:14:07 +00:00
Motomu Utsumi
60ed3be43b Use java BpfMap in BpfNetMaps#removeNaughtyApp
Bug: 217624062
Test: atest BpfNetMapsTest HostsideRestrictBackgroundNetworkTests
Change-Id: Ibfb3ae48427b7dc5d06708e63f4a16f7527ce86c
2022-07-11 03:14:07 +00:00
Motomu Utsumi
5a68a21926 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
2022-07-11 03:14:05 +00:00
Motomu Utsumi
305975ffb0 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
2022-07-11 03:13:04 +00:00
chiachangwang
826f0b01d2 Verify calling thread for intent receiver
Bug: 230548427
Test: atest VpnManagerServiceTest
Change-Id: Ibe5f7aba8e31dfecfb2eaac3fb109eb442879ede
2022-07-07 08:54:52 +00:00
chiachangwang
26de58ea79 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
2022-07-07 08:54:27 +00:00
chiachangwang
a412026c6b 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
2022-07-07 06:46:15 +00:00
chiachangwang
9460f45c04 Update the prefix of VPN_APP_EXCLUDED in the test
Update the string according to the change in Vpn.java

Bug: 237345836
Test: atest FrameworksNetTests
Change-Id: I9bfe0a1fad29ba1435eeb8b8b2cffa9d385b1cb5
2022-07-07 06:46:08 +00:00
chiachangwang
72fe97ea1c Add tests to verify getProvisionedVpnProfileState
Add tests to verify that calling getProvisionedVpnProfileState works
normally from the same package but gets a security exception from a
differnet package.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: I0132c42dce1b8269859fca8d0143304142162838
2022-07-07 06:45:55 +00:00
Treehugger Robot
78cf7c5e29 Merge "ClatCoordinator: Dump ClatdTracker information" 2022-07-05 15:01:11 +00:00
Hungming Chen
a760a10474 ClatCoordinator: Dump ClatdTracker information
Test: atest ClatCoordinatorTest
Change-Id: I6bb47c84321e1323496b728f2db939ee8d74504a
2022-07-05 15:30:50 +08:00
Motomu Utsumi
1f73fedfef Remove unnecessary null check
Address review comments from aosp/2131752 and aosp/2117045
sConfigurationMap must have a entry for UID_RULES_CONFIGURATION_KEY
because this bpf map is an array

Bug: 217624062
Test: atest BpfNetMapsTest
Change-Id: Ic52623e11c1f53e363416d57c0d8705d5510ef04
2022-07-04 09:20:23 +00:00
lucaslin
31dcf69b74 Test if VPN app can grant ACTIVATE_PLATFORM_VPN with CONTROL_VPN
Bug: 232051081
Test: atest FrameworksNetTests:VpnTest
Change-Id: I0580baca69df6a00d59f4a387ec9b357f6c988ab
2022-07-01 10:44:02 +08:00
Motomu Utsumi
51a03d629e Merge "Refactor BpfNetMaps and getChainEnabled" 2022-06-30 06:48:10 +00:00
Chiachang Wang
bb2e871cce Merge "Decouple security exception check test from ConnectivityServiceTest" 2022-06-30 01:36:46 +00:00
Chiachang Wang
5b4ad7c47a Merge changes from topic "appExclusionPackage"
* changes:
  Test VPN app exclusion
  Add VpnTestBase for VPN test common code
2022-06-30 01:34:54 +00:00
chiachangwang
1aef309197 Decouple security exception check test from ConnectivityServiceTest
Decouple security exception check test from ConnectivityServiceTest
to VpnManagerServiceTest.

These security exception tests landed in ConnectivityServiceTest
because of no VpnManagerServiceTest. Move the tests to the
VpnManagerServiceTest where is better place to put the VPN related
tests to reduce the size of ConnectivityServiceTest.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: I94b691c4d1f63bd5226e3296e6d0160dcb03107c
2022-06-29 06:15:41 +00:00
chiachangwang
7f5d04962b Test VPN app exclusion
Initialize the VpnManagerServiceTest and verify app exclusion
design.

Bug: 231373589
Test: atest FrameworksNetTests
Change-Id: Icf3994a58de7b2fcc6fafe9712b5ac94e6c2c134
2022-06-29 06:15:41 +00:00
chiachangwang
9f672bdae6 Add VpnTestBase for VPN test common code
This is a no-op change to move some common codes that share
between different VPN unit tests to the new base class.
It's helpful to reduce the code duplication for the follow up
work to add the VpnManagerServiceTest and other test codes
refactor.

Bug: 231373589
Test: atest FrameworksNetTests
Change-Id: Id5111e7ca33ea8f9eb4bcc6c13d0e681f0664d24
2022-06-29 03:06:09 +00:00
chiachangwang
337726529b Use import for testAndCleanup
Follow up work to remove the TODO since it's available in all
branches.

Test: ates VpnTest
Change-Id: I0830148e8577f98616f24d9ee4224496f51bd692
2022-06-28 10:57:25 +00:00
Paul Hu
57852487b8 Merge "Add mdns files and unit tests" 2022-06-28 05:43:58 +00:00
Paul Hu
3e1f4489bf Add mdns files and unit tests
- Put mdns code to service/mdns because we don't want to impact
  coverage for code that's not yet in use.
- Also fix some lint errors
  - Common typo errors
  - Lines longer than 100 characters
- Update IgnoreUpTo from S to SC_V2 because the tests should be
  ignored until T.

Bug: 232766079
Test: atest FrameworksNetTests
Change-Id: I19af3bf7ae004bd37960f2ad9014cf0c6a804c8d
2022-06-28 09:54:39 +08:00
Motomu Utsumi
25cf86fc95 Refactor BpfNetMaps and getChainEnabled
Address comments from aosp/2117045 and aosp/2131752
Rename USE_NETD to PRE_T
Rename getChainEnabled to isChainEnabled
Remove unnecessary parentheses
Fix comment

Bug: 217624062
Test: atest BpfNetMapsTest
Change-Id: Iaff8c9fc5f74de3fe41a7fb010355b1742fbce90
2022-06-27 14:33:28 +00:00
Motomu Utsumi
bccf9df50e Merge "Use java BpfMap in BpfNetMaps#setChildChain" 2022-06-27 05:44:38 +00:00