Commit Graph

5086 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
b7c67f8e24 Call clearSettingsProvider before and after test
FakeSettingsProvider requires this method to be called before and after
use. Without this, the settings value or content provider may be cached
statically, so the test will be affected by code accessing settings
before it is run.

Bug: b/116668105
Test: atest FrameworksNetTests
Change-Id: I1480f3f3bbb17791752582a70327bb5c7c348d7c
2018-09-28 14:46:34 +09:00
Jeff Vander Stoep
39a51e0191 Add ConnectivityManager.getConnectionOwnerUid()
Allow VPN apps to lookup the UID owner of a network connection.

Requires specifying the:
 - IP address and port for both the source and destination of a TCP
   connection.
 - IP address and port for either source and destination or just
   source for a UDP connection.
Only TCP and UDP protocols are supported. Only connections for UIDs
that apply to the calling VPN app will be resolved. This is intended
to replace direct app access to /proc/net/{tcp,tcp6,udp,udp6}.

The implementation uses netlink inet_diag sockets[1] to perform
the lookup on TCP sockets as well as UDP sockets when supported
(kernel has CONFIG_INET_UDP_DIAG=y).

[1] http://man7.org/linux/man-pages/man7/sock_diag.7.html

Bug: 9496886
Bug: 109758967
Test: atest HostsideVpnTests
Test: atest InetDiagSocketTest on Taimen with CONFIG_INET_UDP_DIAG
    and on Sailfish without CONFIG_INET_UDP_DIAG.
Change-Id: I2bbc7072dd091e2e653dadf6dc05024c04180f34
2018-09-21 06:16:09 +00:00
Benedict Wong
a2f1eb6cf3 Merge "Use UID as requestID" 2018-09-12 18:51:33 +00:00
Hugo Benichi
078f0ce714 Merge changes Ie28e6c80,I3cb9b2ce
* changes:
  ConnectivityService: dumpsys args for dumping networks or requests only.
  ConnectivityService: Sort requests and networks in dumpsys.
2018-09-05 05:54:24 +00:00
Hugo Benichi
5df91ce8be ConnectivityService: dumpsys args for dumping networks or requests only.
This patch adds two arguments to ConnectivityService dumpsys handler so
that only current networks or only current requests are dumped:

- "adb shell dumpsys connectivity networks" will dump current networks.
- "adb shell dumpsys connectivity requests" will dump current requests.

Bug: none
Test: Compiled, flashed, booted, checked that both new dumpsys args work
      as expected.

Change-Id: Ie28e6c800795eb49f386b609e8222a25e73dfc84
2018-09-05 13:04:12 +09:00
Hugo Benichi
a480ba57f5 ConnectivityService: Sort requests and networks in dumpsys.
This patch adds two utility functions for sorting requests and networks
tracked by ConnectivityService by request id and network id
respectively.

These utility functions are then used to improve the output of
adb shell dumpsys connectivity so that networks and requests are
printed in a more stable fashion.

Bug: none
Test: Compiled, flashed, booted, checked output of adb shell
      dumpsys connectivity.

Change-Id: I3cb9b2ceab64145611a416dcb8c5d512838a2626
2018-09-05 13:03:55 +09:00
Benedict Wong
c268c30491 Use UID as requestID
This change makes all requestIDs use the UID of the creator, ensuring
that rekeys always use the same requestID. This also has the nice
property of separating app's resources from each other, and allowing for
identification of which app/UID allocated the resources from
command-line dumps (eg ip xfrm state show)

Bug: 111841561
Test: Updated tests & passing taimen
Change-Id: I4f1eadcdb795766ae4682b15e41727359c52fa38
2018-09-04 14:25:13 -07:00
Paul Hu
cb0e6f589a Merge "PermissionMonitor: Limit preinstalled apps network permissions" 2018-09-03 09:16:52 +00:00
paulhu
c7a3a56e57 PermissionMonitor: Limit preinstalled apps network permissions
Not all preinstalled apps should have access to background
networks or restricted networks. But we give them all network
access permissions currently, it's not a good design. So we
shall limit preinstalled apps permissions, they should just
request the appropriate permission for their use case from
the network permissions.

Bug:19610688
Test: runtest frameworks-net
Change-Id: I184ae3197208c979847ca134c8f01b32528badf1
2018-08-29 13:49:33 +08:00
Erik Kline
767b7f2021 Remove ResolveUtil from frameworks/base callers
Use the Private DNS bypass logic that was moved into Network.

Once all callers of ResolvUtil are updated to use this interface
ResolvUtil can be deleted.

Test: as follows
    - built, flashed, booted
    - runtest frameworks-net passes
    - connection to captive portal network detects portal correctly
      and the login activity functions as expected

Bug: 64133961
Bug: 72345192
Bug: 73872000
Bug: 78548486

Change-Id: If11ef2b5ffdc729f8449cf18dccd5f1eccbc51e6
2018-08-28 12:59:21 +09:00
Treehugger Robot
43afefcd97 Merge "Fix typo in IpConfiguration comment" 2018-08-24 03:43:38 +00:00
Blake Lawson
4253b45cbb Fix typo in IpConfiguration comment
Bug: NONE
Test: NONE
Change-Id: Ib2ce166532292266da17ec85c16e400afe4f9111
2018-08-23 08:43:07 -07:00
Remi NGUYEN VAN
aa3d9ac73b Add DhcpServingParams
Those parameters will be used to start DhcpServer or update its
configuration.

Test: runtest DhcpServingParamsTest.java
Bug: b/109584964
Change-Id: Id8d3dcf62d66dcb02accffa8d8500e30f07af452
2018-08-23 17:29:48 +09:00
Remi NGUYEN VAN
029434e9ac Add util to add an ARP table entry
This is to be used by the new DhcpServer to add ARP entries with new
addresses before sending unicast responses.

Test: manual: cat /proc/net/arp with implementation based on this
Bug: b/109584964
Change-Id: I3559893583aa3c49b188ad689a41ee2f3e9d9bf3
2018-08-23 16:01:44 +09:00
Remi NGUYEN VAN
e358e840ab Merge "Fix testRegisterUsageCallback failure in setUp" 2018-08-17 01:51:10 +00:00
Mathew Inwood
c5b9bec94e Add @UnsupportedAppUsage annotations
For packages:
  android.net.wimax
  android.net.wifi.p2p.nsd
  android.net.wifi.p2p
  android.net.wifi.hotspot2.pps
  android.net.wifi.hotspot2.omadm
  android.net.wifi.hotspot2
  android.net.wifi.aware
  android.net.wifi
  android.net.util
  android.net.sip
  android.net.rtp
  android.net.nsd
  android.net.metrics
  android.net.lowpan
  android.net.http
  android.net.captiveportal
  android.net

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: Ie25423113ee1a8071cd5039382c00de6ce0af7fd
Merged-In: I520be7a4c79e68310c12e4f55bf66acaa94145a1
2018-08-14 14:44:29 +01:00
Remi NGUYEN VAN
5dd7f07260 Fix testRegisterUsageCallback failure in setUp
LocalServices.addService in NetworkStatsService is currently failing
with IllegalStateException "Overriding service registration". Setting up
LocalServices in the test to avoid this issue might be possible, but
moving the registration to the only non-test caller of that constructor
as done here solves the issue and avoids side-effects from a constructor.

Test: atest FrameworksNetTests does not choke on this test
Bug: b/78487385
Bug: b/80082746
Change-Id: I5dba98fc79aec0800c8b71e6c7e23d1cfbcae852
Merged-In: I884a7a8bd7db3fcd220b785ba9914ac8c77720f0
(Clean cherry-pick of go/ag/4061255)
2018-08-14 18:14:09 +09:00
Treehugger Robot
bc63072e52 Merge "NetworkAgent: Send primitive integer in explicitlySelected" 2018-08-13 17:09:51 +00:00
Roshan Pius
00ef96bc0e NetworkAgent: Send primitive integer in explicitlySelected
|Boolean| object is not parcelable and hences crashes when the binder call
crosses a process boundary. Using a primitive integer instead to
represent the boolean value.

Bug: 112358948
Test: Device boots up and able to make wifi connection.
Change-Id: Iac69fd302e1f1338ed0da1446105ffc5855451cc
2018-08-10 07:44:33 -07:00
Roshan Pius
45190f8e7f Merge "NetworkAgent: Send primitive integer in score" 2018-08-10 14:33:07 +00:00
Roshan Pius
d594290fd9 NetworkAgent: Send primitive integer in score
|Integer| is not parcelable and hences crashes when the binder call
crosses a process boundary. Using a primitive integer should suffice
for sending the value to the server. There are no other usage of
|EVENT_NETWORK_SCORE_CHANGED| in the codebase.

Bug: 112358948
Test: Device boots up and able to make wifi connection.
Change-Id: I4c8fc17f4b803f69a4d882c71a8ce014a194d1ba
2018-08-09 07:10:27 -07:00
Remi NGUYEN VAN
6ee63e03dc Merge "Add tests for NetworkMonitor isCaptivePortal" 2018-08-08 04:59:12 +00:00
Remi NGUYEN VAN
de25687203 Add tests for NetworkMonitor isCaptivePortal
Bug: b/79499239
Test: added tests, ConnectivityService tests pass

Change-Id: I98d503b8f92d7f35e59dd1621a90f2eca8c7a63c
2018-08-07 08:57:35 +00:00
Remi NGUYEN VAN
c9f4d7be9e Merge "Add utils to convert Inet4Address <-> int"
am: 2587292cd1

Change-Id: I347d23f4682eca623e3b10f72bc9000b1c5954a3
2018-08-06 09:34:55 -07:00
Remi NGUYEN VAN
2587292cd1 Merge "Add utils to convert Inet4Address <-> int" 2018-08-06 05:49:52 +00:00
Remi NGUYEN VAN
6e2a93cf9a Add utils to convert Inet4Address <-> int
The current utilities map the higher-order bytes of ints to the
lower-order bytes of IPv4 addresses, which makes applying masks and
generating series of addresses confusing.

For example, the current utilities would convert 1.2.3.4 to 0x04030201,
or generate 0x0080ffff for a /17 subnet mask. The utilities in this CL
convert 1.2.3.4 to 0x01020304, and a /17 subnet mask is represented as
0xffff8000.

Includes tests for all the above methods and migration of
NetworkUtilsTest to JUnit4.

Test: added tests pass
Change-Id: I5f5aa2e6e3b054b66b9dc507dab64f41be9139b1
2018-08-03 15:55:24 +09:00
Nathan Harold
2bc5a4c9ee Merge "Count and Report Bandwidth Requests by UID"
am: e1d140619f

Change-Id: Iadfb7c04a49055c57cc8eed2ce9ad5f10e15cf52
2018-08-01 15:48:12 -07:00
Nathan Harold
b89cbfbdca Count and Report Bandwidth Requests by UID
To debug power drain due to modem wakeups,
one of the signals we'd like to track is
requests for bandwidth estimate to see which
apps are making requests and how often. This
patch keeps a simple count per-UID when an
app requests a bandwidth update, and that
count is made available in dumpsys.

Bug: 77498849
Test: runtest frameworks-net
Change-Id: I30d2ce85f9fa6747030cf4039d1080113a32e386
2018-07-31 02:37:38 +00:00
Remi NGUYEN VAN
86bbc9e887 Merge "Increase network request timeouts"
am: dab690a61a

Change-Id: Iaae31d7eaa5e5ccccdcf63ba39dd3fdc729161a5
2018-07-27 06:08:08 -07:00
Treehugger Robot
dab690a61a Merge "Increase network request timeouts" 2018-07-27 11:56:31 +00:00
Remi NGUYEN VAN
68225bc676 Merge "Use timeout consts in all ConnService tests"
am: bbba1f7f9f

Change-Id: Ie62b9893c5b5f4e7b24197c1308d33e06a6c8f71
2018-07-27 00:11:06 -07:00
Remi NGUYEN VAN
524ea05e39 Increase network request timeouts
With recent performance degradations on apct, the current timeouts are
too short and some requests trigger onUnavailable() before networks are
validated.

Test: runtest -x ConnectivityServiceTest.java
Bug: b/111778226
Change-Id: I083f529787f108065637a0aff3e5bb88e05e6510
2018-07-27 15:37:13 +09:00
Remi NGUYEN VAN
bbba1f7f9f Merge "Use timeout consts in all ConnService tests" 2018-07-27 05:50:35 +00:00
Remi NGUYEN VAN
626885b750 Use timeout consts in all ConnService tests
Fix some timeouts that were forgotten in parent CL.

Bug: b/111778226
Test: runtest --no-hidden-api-checks -x ConnectivityServiceTest.java
Change-Id: Ib848eaba8c69c07ac596aa4386a741c9a2a87fc9
2018-07-27 11:47:25 +09:00
Remi NGUYEN VAN
3b498060f6 Merge "Increase linger delay and test callback timeout"
am: 0544dfde7e

Change-Id: I088de7dae4191a65e75feb9e071dcf18c30dcf21
2018-07-26 04:10:02 -07:00
Remi NGUYEN VAN
0544dfde7e Merge "Increase linger delay and test callback timeout" 2018-07-26 09:54:03 +00:00
Remi NGUYEN VAN
b6bd15ac29 Increase linger delay and test callback timeout
Tests appear to have become much slower on apct in recent runs, although
local runs do not seem to be affected. As a first measure, increase our
timeouts to eliminate flakyness.

Bug: b/111778226
Test: runtest --no-hidden-api-checks -x ConnectivityServiceTest.java
Change-Id: I7a3bfb646eb554bcd9d50d026142f2a2cff74beb
2018-07-26 16:43:58 +09:00
Remi NGUYEN VAN
6cbacfa17e Merge "Increase TEST_LINGER_DELAY_MS"
am: 9a783699cc

Change-Id: Iff68ee39ead571293877464c03ab98ab594dfcca
2018-07-24 22:05:37 -07:00
Remi NGUYEN VAN
50cb7dbc11 Increase TEST_LINGER_DELAY_MS
The current timeout is short enough that lingered networks are torn down
before assertions can be run, causing flakyness in testMultipleLingering.
This CL sets the timeout to 300 in that particular test.

Verified that 300ms is enough with 500 successful runs on Sailfish.

An alternative would be to mock firing of the lingering timer, but
keeping the WakeupMessage logic realistic has already proven useful in
detecting races.

Bug: b/110673602
Test: runtest --no-hidden-api-checks frameworks-net
Change-Id: I6f9a656190bcff0b071ae2584d0f5fa74158472b
2018-07-19 17:12:38 +09:00
Erik Kline
7ae1277cd3 Merge "Push DNS configuration on network validation"
am: b71c6a1b7e

Change-Id: I5907831e5f5f1f3659580cc56e2e081cbe88b1cc
2018-07-03 03:09:16 -07:00
Treehugger Robot
b71c6a1b7e Merge "Push DNS configuration on network validation" 2018-07-03 09:03:35 +00:00
Erik Kline
a73af00583 Push DNS configuration on network validation
Test: as follows
    - built, flashed, booted
    - runtest frameworks-net passes
    - connected to captive portal network,
      saw failed validation attempt (opportunistic),
      passed portal, saw successful revalidation attempt
Bug: 64133961
Bug: 72344805
Bug: 109928338

Change-Id: I0471685c2234af8a8c7f5b2ad3205eb6e36333c5
2018-07-03 13:33:34 +09:00
Erik Kline
a3b085b226 Merge "Prefer default Internet network for upstream tethering."
am: 9442987fc6

Change-Id: I0990d077627aed71b03e7aa40a8acc460448a774
2018-06-25 06:24:22 -07:00
Treehugger Robot
9442987fc6 Merge "Prefer default Internet network for upstream tethering." 2018-06-25 12:08:46 +00:00
Erik Kline
a34b584026 Prefer default Internet network for upstream tethering.
Rather than use the crufty config.xml list of upstream transport types,
use ConnectivityService's notion of the default network for the upstream.
In cases where a DUN network is required and the default network is
currently a mobile network, look for a DUN network (code in Tethering
is currently responsible for requesting one).

Test: as follows
    - built, flashed, booted
    - runtest frameworks-net
    - tethered via mobile, joined captive portal network, maintained
      laptop access via mobile until captive passed (then used wifi)
    - disabled client mode wifi, disabled mobile data, plugged in
      ethernet adapter, observed connectivity via ethernet
Bug: 32163131
Bug: 62648872
Bug: 63282480
Bug: 109786760
Bug: 110118584
Bug: 110260419
Merged-In: I9cddf1fb7aa3b8d56bf048c563556244e74808c2
Merged-In: Icac3e5e20e99093ddb85aae1ca07ed7b5cf309fd
Change-Id: I925b75994e31df8046f3ef9916a2457b4210485e
(cherry picked from commit 359d4c6d61)
2018-06-25 19:25:17 +09:00
Chalard Jean
e71a3833fe Merge "Add StackedLinkProperties test case"
am: faf31f8638

Change-Id: I33d75bf593708317dca4ba6cec035b7f035cfa86
2018-06-20 21:23:17 -07:00
junyulai
74f9a8b52a Add StackedLinkProperties test case
Change access level of getNetworkAgentInfoForNetwork in ConnectivityService to get
better testability. And add test case to verify clat state transition and make sure
linkProperties are updated correctly.

Bug: 80261579, 109913107
Test: runtest frameworks-net -c com.android.server.ConnectivityServiceTest \
          -m testStackedLinkProperties
Change-Id: I72fce594d74bd349f65557edca03640e1b86317c
2018-06-19 16:53:08 +08:00
Chalard Jean
fb5f0d1c37 Merge changes I4b1bca8b,Idb7d2f28,I4825e632
am: 84d4e535ae

Change-Id: I7278ffe7ca8e25b040d6bce7fb880ccf0984f6ee
2018-06-18 03:06:05 -07:00
Chalard Jean
24749e0b40 Merge changes I6abd2221,I2c149d29,I45d22857,I1f879b2c,If4986a25, ...
am: 6c0106b57f

Change-Id: I86bc83e2bd859b48017f12832e9ff0080ec162b8
2018-06-12 06:57:33 -07:00
Chalard Jean
fe357814b4 [PT09] Add javadoc comments to all ProxyTracker methods/members.
Also rename some vars and inline a function that is now private.

Test: runtest
Change-Id: I4b1bca8b29f46d97056973cd38ed8effc3f5b591
2018-06-12 19:03:16 +09:00