Commit graph android_packages_modules_Co.../tests/net/java/com/android
Message SHA1
Merge changes Id4632e1b,I31985822,Ibbf96a25
* changes:
  Test passing an underlying network array with null network in it.
  Make testVpnNetworkActive more deterministic.
  Add a test for restricted profile added/removed with VPN up.

Treehugger Robot   authored and   Gerrit Code Review   commited 2020-11-26 03:40:44 +00:00
b459e5166d
Test passing an underlying network array with null network in it.
Current code treats these nulls as if they weren't there.

Bug: 173331190
Test: test-only change
Change-Id: Id4632e1b004c09910b4b7613f7233d2c19e2f0ac

Lorenzo Colitti   commited 2020-11-26 10:33:23 +09:00
c64d177ed9
Make testVpnNetworkActive more deterministic.
This test is a bit brittle because it sets the underlying
networks while the VPN is undergoing validation by
NetworkMonitor. The test does attempt to disable validation,
but that's not actually possible - the only thing that's possible
is to tell NetworkMonitor to validate immediately without sending
any probes. So the underlying network change races with the
validation. I'm not sure why the test isn't flaky. It might be
because both the network change and the validation result in a
capabilities change, and the test expects "a capabilities change"
without expressing what change that should be.

Make this a bit more predictable by ensuring that the network
validates before the underlying networks are set.

This is useful because an upcoming CL will change the way
underlying network capabilities are propagated. With this test
CL, both the old and the new code pass.

Bug: 173331190
Test: test-only change
Change-Id: I319858228e8d097c0b60a107029f296385f91269

Lorenzo Colitti   commited 2020-11-26 10:33:23 +09:00
621f5a9e8f
Add a test for restricted profile added/removed with VPN up.
Bug: 173331190
Test: test-only change
Change-Id: Ibbf96a259a73068d110a159d54059720121117cc

Lorenzo Colitti   commited 2020-11-26 10:33:23 +09:00
97ade70ce8
Update requestsSortedById() to sort by collection
Update requestsSortedById() to sort NetworkRequestInfo by their
nested collection of NetworkRequest objects vs a single request.
Before the NetworkRequestInfo with the request with the lowest
requestId would be sorted to the top. Now the NetworkRequestInfo
which contains the request with the lowest requestId will be
sorted to the top.

Bug: 173292541
Bug: 171991028
Test: atest FrameworksNetTests
Change-Id: I51e3c00d59443e37ddbf168c423d13df8d14fa64

James Mattis   commited 2020-11-19 17:04:02 -08:00
f8eb49ab6b
Merge "Make MockVpn more realistic and easier to use."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-11-19 10:32:19 +00:00
0dd10f43c7
Merge changes I3711b362,I49421183,Icc0701cb,I2f5ccc1d
* changes:
  Increase test coverage for VPN info sent to NetworkStatsService.
  Simplify MockVpn.
  Test a VPN with an underlying network that does not yet exist.
  Minor fixes to NetworkCapabilities#toString.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-11-19 10:20:00 +00:00
40b4ef6dd7
Make MockVpn more realistic and easier to use.
MockVpn is very difficult to use because it requires the test
caller keeping track of both the MockVpn object and an
accompanying TestNetworkAgentWrapper.

It's also not very realistic: for example, connect() doesn't
actually connect anything, it just makes it so that if
ConnectivityService tries to update the capabilities, the attempt
will not be ignored. Also, unlike the real code in Vpn, it
connects with empty NetworkCapabilities (in particular, with
empty UID ranges).

Make this easier to use and a bit more realistic by:
- Allowing TestNetworkAgentWrapper to take a "NetworkCapabilities
  template" that will form the initial capabilities sent when the
  agent registers with ConnectivityService. This allows the VPN
  to register its agent with its UID ranges already set, like the
  production code does.
- Providing separate methods to register the NetworkAgent and
  mark it connected for cases where the test needs to make
  changes to the NetworkAgent before connecting (e.g., poking
  NetworkMonitor).
- Putting the TestNetworkAgentWrapper inside MockVpn and driving
  it through MockVpn's methods. In order not to have too many
  wrapper functions (and because we can't delegate like in
  Kotlin), there's still an agent() method that returns the
  TestNetworkAgentWrapper.

Bug: 173331190
Test: test-only change
Change-Id: I749ff325bc13ac96f512270b86d1f67686eec378

Lorenzo Colitti   commited 2020-11-19 16:23:07 +09:00
925d1a9a82
Increase test coverage for VPN info sent to NetworkStatsService.
Bug: 173331190
Test: test-only change
Change-Id: I3711b362f31cb92b759e9f5c9d244fb88d9bd5e7

Lorenzo Colitti   commited 2020-11-19 14:56:50 +09:00
fdce3dde08
Simplify MockVpn.
This CL removes four methods in MockVpn by slightly changing the
test code to leverage the actual methods implemented by the
(production) Vpn superclass.

This works because setting mInterface results in
isRunningLocked() returning true, which makes a number of methods
behave as if the VPN is connected (which is what the test
expects).

The more realistic behaviour exposes a minor bug in the treatment
of underlying networks. Add a TODO to fix it.

Bug: 173331190
Test: test-only change
Change-Id: I49421183538ba61ca790af71e309ece36b653bf9

Lorenzo Colitti   commited 2020-11-19 14:53:53 +09:00
d97d6e304b
Test a VPN with an underlying network that does not yet exist.
This test checks that if a VPN declares an underlying network
that does not exist, the capabilities of that network are applied
to the VPN as soon as the network starts to exist.

Bug: 173331190
Test: test-only change
Change-Id: Icc0701cb4cea7d91f7738c1e426e94cd26686b74

Lorenzo Colitti   commited 2020-11-19 14:46:32 +09:00
e50c0f8af4
Merge "Replace InterfaceConfiguration usage with stable aidl"
Chiachang Wang   authored and   Gerrit Code Review   commited 2020-11-18 09:05:59 +00:00
c0c71a50d6
Replace InterfaceConfiguration usage with stable aidl
Replace InterfaceConfiguration with InterfaceConfigurationParcel
for the incoming ConnectivityService mainline since mainline
modules could not use @hide API.

Bug: 170598012
Test: atest FrameworksNetTests
Change-Id: I17ce8741e985fd30e3c8f0c34e79564a82890dc6

Chiachang Wang   commited 2020-11-18 14:46:13 +08:00
db04f067b0
Add hardware tethering traffic in testTethering test
Test: atest com.android.server.net.NetworkStatsServiceTest#testTethering
Bug: 162292214
Change-Id: Ifec6bde5fd3231f2135f12536c42e42ec6b707de

junyulai   commited 2020-11-12 14:22:31 +08:00
2fae9c3667
Remove unused getTetherStats
Before Android R, getTetherStats were used to collect tethering
iface stats of all clients who extends ITetheringStatsProvider,
which typically contains NetdTetheringStatsProvider and
OffloadController.

However, this always returns 0 since Android R, because:
  1. OffloadController implemented NetworkStatsProvider and no
     longer reports stats through getTetherStats.
  2. NetdTetheringStatsProvider always return 0 by design since
     non-offloaded iface tethering stats are already included
     in native iface stats.

This change is a no-op refactoring to remove unused
getTetherStats and update test which is not pratical.
Fix for offloaded tethering stats will be in follow-up CLs.

Test: atest FrameworksNetTests TetheringTests
Bug: 162292214
Change-Id: Icd0717c5c2807ae3bd98626b897e4b148f142815

junyulai   commited 2020-11-06 19:02:44 +08:00
10b443adbb
Merge "Replace Context @hide APIs"
Paul Hu   authored and   Gerrit Code Review   commited 2020-11-05 08:05:09 +00:00
f021a81854
Merge "Replace AppOpsManager @hide APIs"
Paul Hu   authored and   Gerrit Code Review   commited 2020-11-05 08:03:55 +00:00
12e9b2ecb5
DO NOT MERGE: Introduce DPMS shim for active DO/PO check
Introduce a shim into DevicePolicyManagerInternal &
DevicePolicyManagerService so that NetworkStatsAccessTest would not
diverge from internal development branches.

The DevicePolicyManagerService refactoring on the internal branch
removed isActiveAdminWithPolicy in favour of isActiveDeviceOwner and
isActiveProfileOwner.

These methods are being made available in AOSP for
NetworkStatsAccessTest.

Bug: 170459325
Test: atest NetworkStatsAccessTest
Change-Id: Ic7e0898989fb8222aaba2b35436765c04eb3250c

Eran Messeri   commited 2020-11-04 10:07:06 +00:00
5c91bdecce
Replace Context @hide APIs
Connectivity service module is using some Context @hide APIs but
they are not able to call after CS becomes a mainline module.
Thus, replace them with similar System APIs.

Bug: 170593746
Test: atest FrameworksNetTests
Test: Manully check that receiving intent and starting activity
      can work normally.
Change-Id: I0f5b53ce0da4e3fc0f927896e9a9e444048401bd

paulhu   commited 2020-11-04 00:02:42 +08:00
fa229ae8a5
Replace AppOpsManager @hide APIs
Connectivity service module is using some AppOpsManager @hide
APIs but they are not able to call after CS become a
mainline module. Thus, replace them with similar System APIs.

Bug: 170593746
Test: atest FrameworksNetTests
Change-Id: I51f66b64fcc3ebdbc2fddff8371eb8d9ff134137

paulhu   commited 2020-11-03 22:27:16 +08:00
1c15b17d78
NetworkNotificationManager gets NotificationManager locally
It's confusing that NetworkNotificationManager uses
NotificationManager to put up notifcation which is passed from
ConnectivityService. And that NotificationManager should be
gotten from a context with UserHandle.ALL because the
notification should notify to all users. But the future developer
may not know this and pass incorrect NotificationManager
probably. Therefore, adjust the design that
NetworkNotificationManager will get NotificationManager locally.

Bug: 170593746
Test: atest FrameworksNetTests
Change-Id: Id65c998052b7b223171c5194ea46b49d7e84729d

paulhu   authored and   Paul Hu   commited 2020-10-30 03:37:50 +00:00
13cafd92b9
Merge "Replace NotificationManager @hide APIs"
Paul Hu   authored and   Gerrit Code Review   commited 2020-10-30 03:36:40 +00:00
39516dec37
Merge changes from topic "revert-1353490-revert-1323251-ipv6_prov_loss_quirk_parcelable-DVBHZDYMHA-MDHWFKJABZ"
* changes:
  Add jarjar rule for IPv6ProvisioningLossQuirk.
  Revert "Revert "Test IPv6ProvisioningLossParcelable in the NetworkAttributes"""

Xiao Ma   authored and   Gerrit Code Review   commited 2020-10-29 05:39:16 +00:00
780d3d2115
Merge changes I6a51d803,I162fae5c
* changes:
  Replace hidden NMS API for setting MTU
  Replace hidden NMS default network configuration API

Chiachang Wang   authored and   Gerrit Code Review   commited 2020-10-29 05:03:43 +00:00
b75c584971
Merge "Replace hidden NMS interface to network API"
Chiachang Wang   authored and   Gerrit Code Review   commited 2020-10-29 05:02:21 +00:00
689399aa75
Replace NotificationManager @hide APIs
Connectivity service module is using some NotificationManager
@hide APIs but they are not able to call after CS become a
mainline module. Thus, replace them with similar System APIs.

Bug: 170593746
Test: atest FrameworksNetTests
Change-Id: I2644867cfc01d8d651c7029134294a9d44fdb471

paulhu   commited 2020-10-28 16:24:37 +08:00
e7a50004d8
Replace hidden NMS interface to network API
Replace the hidden NMS addInterfaceToNetwork and
removeInterfaceFromNetwork with calling INetd directly for
incoming ConnectivityService mainline.

Bug: 170598012
Test: atest FrameworksNetTests
Test: manually connect and disconnect network
Change-Id: I0f1f866be2f8084b992b340aeabfb5d62420686b

Chiachang Wang   commited 2020-10-28 14:38:18 +08:00
a93ddb250b
Replace hidden NMS default network configuration API
Replace the hidden setDefaultNetId and clearDefaultNetId NMS
APIs with accessing INetd directly for the incoming
ConnectivityService mainline.

Bug: 170598012
Test: atest FrameworksNetTests
Test: manually connect and disconnect wifi
Change-Id: I162fae5ca444207a037e5ac4bf8fa0a77a648ca1

Chiachang Wang   commited 2020-10-28 14:38:18 +08:00
c1fe7a0a37
Add jarjar rule for IPv6ProvisioningLossQuirk.
A new stable parcelable IPv6ProvisioningLossQuirk added in network
stack module, which is used to record the network quirk info which
causes IPv6 provisioning loss, e.g. the router lifetime in RA is 0
and the default route will be removed from LinkProperties.

Previously this change breaks CtsStrictJavaPackagesTestCases due to
a jarjar rule is missed. Also rename the package name based on the
revert change.

Also include slight stable AIDL package and variable rename.

Bug: 157534516
Test: atest CtsStrictJavaPackagesTestCases FrameworksNetTests
Change-Id: Ic2f6b75beefb574f7e2fb4c157667e7734eccd05

Xiao Ma   commited 2020-10-27 08:04:29 +00:00
1cd2532d26
Revert "Revert "Test IPv6ProvisioningLossParcelable in the NetworkAttributes"""
Test IPv6ProvisioningLossParcelable in the NetworkAttributes.

Bug: 157534516
Test: atest NetworkStackTests

This reverts commit_3740bfadadaaf268f92aaf35dd92e4ce432b39cb

Reason for revert:
Roll forward the previous change, as the CtsStrictJavaPackagesTestCases
breakage has been addressed by adding the jarjar rule in wifi module.

Change-Id: Ib4d70ce557cad98643c811b219f51e9b68179ee8

Xiao Ma   commited 2020-10-27 07:49:05 +00:00
ef20ba23a4
Using Context#getSystemService instead of ServiceManager#checkService
ConnectivityService is going to be a mainline module, it can only
use formal APIs or @SystemApi. So use public API -
Context#getSystemService() instead of hidden API -
ServiceManager#checkService().

Bug: 170598012
Test: atest FrameworksNetTests
Change-Id: I9824caa7aec57e70f0ba405fcce39f9bc068732d

lucaslin   authored and   Lucas Lin   commited 2020-10-23 03:07:07 +00:00
f0d393d530
Merge "Do not use hidden SystemProperties.set"
Chiachang Wang   authored and   Gerrit Code Review   commited 2020-10-21 07:00:56 +00:00
93961f7b21
Do not use hidden SystemProperties.set
ConnectivityService is going to become a mainline module, and
it will not able to use hidden method anymore. Thus, use
alternative new sysprop as API to control the tcp init rwnd
value.

Bug: 170917042
Test: adb shell getprop net.tcp_def_init_rwnd and check if
      value is set correctly
Test: atest FrameworksNetTests
Change-Id: If9e99c88de50b6829721b0dfacc430a3b53c7728

Chiachang Wang   commited 2020-10-20 19:35:01 +08:00
c43d68f0d0
Remove unused MockableSystemProperties from DnsManager constructor
DnsManager does not use MockableSystemProperties to communicate
with netd to configure the dns server anymore. ConnectivityService
does not need to take it into DnsManager as a parameter. Thus,
clean up the unused code.

Bug: 33308258
Test: atest FrameworksNetTests
Change-Id: I2ac89944391f7d1fd5d67f26cf7f2b11a4a4cf84

Chiachang Wang   commited 2020-10-20 15:46:30 +08:00
6710686910
Merge "Create service-connectivity.jar"
Aaron Huang   authored and   Gerrit Code Review   commited 2020-10-20 06:09:41 +00:00
4a19a57729
Create service-connectivity.jar
Create a new target service-connectivity to split
ConnectivityService from services.core.

Add ConnectivityServiceInitializer for initializing
ConnectivityService and add systemReady() in
ConnectivityManager so that SystemServer can call systemReady()
through ConnectivityManager which won't change current behavior.

Bug: 158268939
Test: make target-java, make host-java
      atest FrameworksNetIntegrationTests
      atest FrameworksNetTests
      make, device can boot,
      atest CtsStrictJavaPackagesTestCases
      wifi and mobile data work.
Change-Id: I99401772ba9c1c34adca20040da3c7c72d86ddd9
Merged-In: Ie732bfaf381404af0bb599ca2f421a96e7aa4257

Aaron Huang   commited 2020-10-16 22:46:14 +08:00
925d09b779
Stop setting the legacy net.dnsX system properties
These have been locked down via SELinux for a while and thus
they should be safe to delete at this point.

Test: atest FrameworksNetTest
Bug: 33308258
Bug: 148724751
Change-Id: I3a1e9c6ad92c8d2367e0048e5d6cd7d06bbc6e80

Chiachang Wang   commited 2020-10-16 08:19:25 +00:00
e62f378b9c
Merge "Support dynamically update IMSI"
Junyu Lai   authored and   Gerrit Code Review   commited 2020-10-13 02:41:47 +00:00
2d74c2e267
Support dynamically update IMSI
Currently, NetworkStatsSubscriptionsMonitor will skip the
listener registration until the IMSI is available to deal
with SIM PIN locked case. However, this solution can only
handle the case that IMSI changes from/to null. And it also
relies on the assumption that IMSI never changes for a subId.

Thus, support dynamically update IMSI to handle IMSI changes
more robustly.

This patch also address leftover comments at ag/12400327.

Test: enable SIM PIN and manually test
Test: atest NetworkStatsSubscriptionsMonitorTest#testSubscriberIdUnavailable
Test: atest NetworkStatsSubscriptionsMonitorTest#testSubscriberIdChanged
Test: ./out/host/linux-x86/bin/statsd_testdrive 10082
Bug: 160941101

Change-Id: I625a5b10ee4806f6fee99c2d9d6c5e7977ff785e

junyulai   commited 2020-10-12 15:31:02 +08:00
c822fe5e07
Merge "Speculatively fix L2TP keepalive issues by reducing mtu"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-10-12 00:40:44 +00:00
f67e00b803
Update to positive logic to better match the method naming
The method checkInterfacePresent seems that should return if the
interface is present or not, but it actually return an opposite
result. It may confuse the caller. E.g. The override method in
VpnTest assume it always returns true in the test. It will fail
the vpn start flow due to interface gone.

Bug: 169215213
Test: atest FrameworksNetTess
Change-Id: I3e9a64f0900336b8205674b94db68f090b4e9ff9

Chiachang Wang   commited 2020-10-07 06:48:15 +00:00
8cdc2856b7
Speculatively fix L2TP keepalive issues by reducing mtu
This change reduces MTU/MRU values for racoon/pppd from 1400 to 1388 in
an attempt to fix keepalive issues experienced in the field.

Bug: 119076193
Test: Speculative change, original issues were not reproducible.
Change-Id: I7731503260fdc8bcbc6c5fcda6991ead6fb7c52e

Benedict Wong   commited 2020-09-28 20:55:55 -07:00
b29fb3654a
Merge "Provide more feedback to Settings when sessions fail"
Benedict Wong   authored and   Gerrit Code Review   commited 2020-09-25 17:25:02 +00:00
d8957b5481
Provide more feedback to Settings when sessions fail
This change updates the VPN state when IKEv2 sessions fail, and when
configuration errors occur.

Bug: 162289824
Test: Manual testing with IKEv2/PSK
Change-Id: I2e8c6f421d2898f97b0ac422b2276edf9ef923f1

Benedict Wong   commited 2020-09-24 23:32:09 -07:00
fdebd3d644
Skip stop if keepalive is already in stopping state
In current design, crash has been generated when stop function
has been re-entered to catch unexpected behavior. However,
it is possible to re-enter stop function if the network
disconnection occurs after stopping.

Thus, skip stop if keepalive is already in stopping state.

Test: atest ConnectivityServiceTest#testNattSocketKeepalives \
      --rerun-until-failure 60000
Bug: 167332570
Change-Id: Ic7068ad3dc990e957c37b8d87d48ebb6469b101f

junyulai   commited 2020-09-17 19:51:34 +08:00
e30a5c2730
Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27
Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2

Xin Li   commited 2020-08-31 21:21:38 -07:00
4037c36d47
Merge "Notify the keepalive is stopped after the slot has been released"
Junyu Lai   authored and   Gerrit Code Review   commited 2020-08-28 10:12:44 +00:00
09a0f57f87
Merge "Skip RAT type listener registration if IMSI is not available"
Treehugger Robot   authored and   Gerrit Code Review   commited 2020-08-25 19:55:09 +00:00
1e9c48bfec
Skip RAT type listener registration if IMSI is not available
Currently, if SIM is inserted but IMSI is not available, such
as SIM PIN locked state. Information of such SIM will still
be available but IMSI is not. Which makes
NetworkStatsSubscriptionMonitor failed to store IMSI locally
for later RAT type query. Hence, NETWORK_TYPE_UNKNOWN is
always returned for such SIM.

Skip the registration until the IMSI is available. This is safe
since there will be another onSubscriptionsChanged event when
that happens.

Test: enable SIM PIN and manually test
Test: atest NetworkStatsSubscriptionsMonitorTest#testSubscriberIdUnavailable
Test: ./out/host/linux-x86/bin/statsd_testdrive 10082
Bug: 160941101
Merged-In: I408379b3c432d9e62e0837d6b4f6551cc7838e29
Change-Id: I408379b3c432d9e62e0837d6b4f6551cc7838e29
(cherry-picked from ag/12400327)

junyulai   commited 2020-08-25 18:03:38 +08:00
8c91a5f6cf
Merge "Revert "[RFPM03] Check permission by uid.""
Paul Hu   authored and   Gerrit Code Review   commited 2020-08-20 08:24:30 +00:00
0925015de5