Commit Graph

579 Commits

Author SHA1 Message Date
Chalard Jean
a4aff26c51 Straighten AIDL interface for the memory store
Some names were still wrong somehow, and the wrappers were
missing.

Test: NetworkStack & FrameworkNetTests
Change-Id: I475bd011ad9bc714a07021a9dfd85c4876f8e9ad
2019-04-03 15:18:08 +09:00
Paul Hu
91252ebe9a Merge "Address leftover comments on 923337 and 930217." am: b5db40605c am: 5d94f74e87
am: 426f2771e0

Change-Id: I75eadb66c81d72c768e77feddd383d60f8accd65
2019-04-02 01:29:08 -07:00
Paul Hu
b5db40605c Merge "Address leftover comments on 923337 and 930217." 2019-04-02 07:39:04 +00:00
Xiao Ma
b6fd5dc3c0 Merge "Add DHCP address lease expiry in IpMemoryStore." am: 0f1ffb3b77 am: 5bdb41fdcf
am: 72da4758de

Change-Id: Ib09ee6a702fb25a682d4782a8822237ebb9a0dfb
2019-04-01 06:35:34 -07:00
Xiao Ma
0f1ffb3b77 Merge "Add DHCP address lease expiry in IpMemoryStore." 2019-04-01 12:59:20 +00:00
paulhu
a9a6e2a2a2 Address leftover comments on 923337 and 930217.
- Restrict unprivileged apps to use
  NetworkRequest.Builder#setSignalStrength.

- Remove the "throws NullPointerException" in
  CaptivePortalProbeSpec constructor.

- Remove the null check in LinkProperties.

- Add annotataion into all ConnectivityManager.NetworkCallback
  methods.

Change-Id: Id275cac1d6a30d7515cd7b113394f5e8a0179314
Fix: 129097486
Test: atest FrameworksNetTests
2019-04-01 16:24:10 +08:00
Remi NGUYEN VAN
ede73bb437 Merge "Fix race when starting NetworkMonitor" am: ca5b44477a am: 9e85030e71
am: bf761cce3e

Change-Id: I595ecdbf0b8e91fec4287c3476239a1e6c9c80a7
2019-03-31 21:35:25 -07:00
Remi NGUYEN VAN
ca5b44477a Merge "Fix race when starting NetworkMonitor" 2019-04-01 03:54:03 +00:00
Remi NGUYEN VAN
f59a5d4580 Fix race when starting NetworkMonitor
NetworkMonitor obtained LinkProperties and NetworkCapabilities via
synchronous calls to ConnectivityManager after receiving an asynchronous
notification, which is prone to races: the network could be gone before
the LinkProperties/NetworkCapabilities can be fetched.

Fix the race by passing LinkProperties/NetworkCapabilities directly to
NetworkMonitor in the asynchronous notifications.

Test: atest FrameworksNetTests NetworkStackTests
Test: booted, WiFi works
Bug: 129375892
Change-Id: I200ac7ca6ff79590b11c9be705f650c92fd3cb63
2019-04-01 11:33:10 +09:00
Luke Huang
592905c826 Merge "Use IDnsResolver instead of INetd for resolver related binder commands" am: 8c3d79e813 am: 3b2c0dda05
am: bdf234395b

Change-Id: I2d642b71df25934fddd8a1476b5d27457628b8e2
2019-03-29 02:24:24 -07:00
Luke Huang
8c3d79e813 Merge "Use IDnsResolver instead of INetd for resolver related binder commands" 2019-03-29 08:45:19 +00:00
Xiao Ma
314a2312aa Add DHCP address lease expiry in IpMemoryStore.
Bug:122710829
Test: atest FrameworksNetTests
Change-Id: I643fe1231edcd18923514ab66c64a6cf83e69443
2019-03-29 16:51:47 +09:00
Varun Anand
f004bcbbf5 Merge changes from topic "vpn_data_accounting"
* changes:
  Move BatteryStats and StatsCompanionService to use NetworkStatsService.
  NetworkStatsService: Fix getDetailedUidStats to take VPNs into account.
  Take all VPN underlying networks into account when migrating traffic for VPN uid.
2019-03-29 00:40:53 +00:00
Varun Anand
23e1e5e300 NetworkStatsService: Fix getDetailedUidStats to take VPNs into account.
This API is similar to one provided by NetworkStatsFactory with the
difference that NSS also migrates traffic from VPN UID to other apps.

Since traffic can only be migrated over NetworkStats delta, NSS
therefore maintains NetworkStats snapshot across all UIDs/ifaces/tags.

This snapshot gets updated whenever NSS records a new snapshot
(based on various hooks such as VPN updating its underlying networks,
network getting lost, etc.), or getDetailedUidStats API is invoked by
one of its callers.

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests
Test: manually verified that battery stats are migrating traffic off of
TUN (after patching above CL where we point BatteryStats to use this
API).
Change-Id: Ib0f0c2d4d41ee1d7a027ea9da457baaf198d649e
2019-03-28 10:31:51 -07:00
Varun Anand
2dbf6e6978 Take all VPN underlying networks into account when migrating traffic for
VPN uid.

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests
Test: Manually verified on device that stats from VPN UID are moved
      appropriately based on its declared underlying network set.
Test: vogar --mode app_process --benchmark NetworkStatsBenchmark.java

Change-Id: I9d8d0cc58d18002c1c96f8ddff780ef8dc452d21
2019-03-28 10:31:49 -07:00
Junyu Lai
4bfa391000 Merge changes I0baf582f,I4bba01ba am: ae26195e6a am: 92adef2970
am: 9cd8136d86

Change-Id: I2cc021899270b41e4b9047ef32869af53ea6fb65
2019-03-27 18:43:18 -07:00
Junyu Lai
ae26195e6a Merge changes I0baf582f,I4bba01ba
* changes:
  Block unpriviledged apps which create keepalives with null fd
  Fix keepalive don't get removed when lower layer error
2019-03-28 00:53:20 +00:00
junyulai
c4fb248ef7 Block unpriviledged apps which create keepalives with null fd
Currently, socketKeepalive implementation is accepting null fd
due to backward compatibility with legacy packet keepalive API.
However, due to lack of the fd, the service cannot guarantee the
port is not reused by another app if the caller release the port
for any reason.

Thus, grant the null fd access only for priviledged apps.

This commit also address some comments from aosp/918533.

Bug: 126699232
Test: atest FrameworksNetTests
Change-Id: I0baf582ff4ca8af6082c3754e8dfbcd867f39792
2019-03-27 19:51:08 +08:00
Luke Huang
e3d6a7907b Use IDnsResolver instead of INetd for resolver related binder commands
migrate resolver related commands from INetd to IDnsResolver

Bug: 126141549
Test: atest FrameworksNetTests ConnectivityServiceTest Nat464XlatTest
      atest DnsManagerTest
Change-Id: I559c0c1304d53dde408c062e1a52e742595e7cbe
2019-03-27 17:39:07 +08:00
Lucas Lin
06a19ccd6d Merge "Fix flaky test for ConnectivityServiceTest#testPartialConnectivity" am: 15b9eb4e43 am: 8fc2439929
am: 8c64dd081a

Change-Id: I80399f9980119342ba5cd3d4f1922badb1fee3e9
2019-03-26 19:00:50 -07:00
Lucas Lin
15b9eb4e43 Merge "Fix flaky test for ConnectivityServiceTest#testPartialConnectivity" 2019-03-27 01:29:51 +00:00
lucaslin
563b751b21 Fix flaky test for ConnectivityServiceTest#testPartialConnectivity
There are 2 problems will make testPartialConnectivity flaky:
1. If we call setNetworkValid() before expectCapabilitiesWith(),
there may be a timing issue that network will become VALID before
NetworkMonitor send PARTIAL_CONNECTIVITY to ConnectivityService.
Solution:
We should set network to valid after ConnectivityService received
NETWORK_TEST_RESULT_PARTIAL_CONNECTIVITY to ensure NetworkMonitor
will send PARTIAL_CONNECTIVITY to ConnectivityService first then
send VALID.

2. When test case call explicitlySelected(true) first then call
connect(true), NetworkMonitor will report the network validation
test result twice because ConnectivityServiceTest() will trigger
notifyNetworkTested() when setAcceptPartialConnectivity() is
called, it may cause a timing that before the second test result
send to ConnectivityService, connect() already called
setNetworkInvalid. So, NET_CAPABILITY_VALIDATED will be removed
and ConnectivityService will trigger onCapabilitiesChanged()
unexpectedly.
Solution:
Don't trigger notifyNetworkTested() when
setAcceptPartialConnectivity() is called. If there is needed,
use mCm.reportNetworkConnectivity() to report the test result
instead.

Bug: 128426024
Test: 1. atest FrameworksNetTests: \
      ConnectivityServiceTest#testPartialConnectivity \
      --generate-new-metrics 1000

Change-Id: I7200528378201a3c7c09a78ff827b41f2741dfa1
2019-03-26 17:49:49 +08:00
Junyu Lai
23bf315b90 Merge "Reveal the call trace of failed test cases which run in executors" am: 43dc93b180 am: ca9b494b83
am: a71b378095

Change-Id: I023c8140c94966479db7f12647838699324462af
2019-03-26 00:13:47 -07:00
junyulai
b454b0fc0e Reveal the call trace of failed test cases which run in executors
Currently, the fails in testTcpSocketKeepalives are triggered by
fail() inside the executor, which is hiding the actual call trace
but only message remains. And it made the fail case hard to
debug.

So this commit is to bubble up the Exception by using a custom
functional interface.

Bug: 123987272
Test: 1. atest FrameworksNetTests
      2. manually fail the test case and see the call trace

Change-Id: I125e673938a5e9d1de86f83c1a732227a4bd3207
2019-03-25 12:56:47 +00:00
Junyu Lai
639ba7742d Merge "Fix SocketKeepalive APIs which do not meet API review requirement" am: 5fdd1748fa am: b7ed180e64
am: 7f8cfa3536

Change-Id: I873a82de90efce6f3baa17761c0576dc9c8210be
2019-03-25 04:16:18 -07:00
junyulai
6114378ad2 Fix SocketKeepalive APIs which do not meet API review requirement
Per API review, change the use of FileDescriptor to
ParcelFileDescriptor.
This change also fix nullability according to API review
feedbacks.

Fix: 126698610
Fix: 126699425
Fix: 126699232
Fix: 126700278

Test: 1. m -j
      2. atest FrameworksNetTests --generate-new-metrics 50
      3. m -j doc-comment-check-docs
Change-Id: I19476c50dd1ca290bf3f41973829da2bd229796a
2019-03-25 15:56:35 +08:00
lucaslin
372cc04dc3 Merge "Temporarily disable flaky test." am: d2ff961201 am: ead65ee6f8
am: c20c0bd4d9

Change-Id: I583ed9aa0e42e864ef0c1e74fbcd9357e093cc25
2019-03-21 08:39:31 -07:00
Treehugger Robot
d2ff961201 Merge "Temporarily disable flaky test." 2019-03-21 15:04:15 +00:00
lucaslin
0f755c31a5 Temporarily disable flaky test.
Test: None
Bug: 128426024
Change-Id: I6fa12e50decbafe9d934030865c5a8f20d42b86f
2019-03-21 19:14:32 +08:00
Luke Huang
d7a9b23429 Merge "Cleanup NetworkManagementService for Netd commnads binder migrartion" am: cfd6cdf447 am: f3b2546131
am: df6794ca21

Change-Id: Ib6730d87eeebcd82964feeb96d12c09ae652d0d5
2019-03-20 23:40:30 -07:00
Luke Huang
cfd6cdf447 Merge "Cleanup NetworkManagementService for Netd commnads binder migrartion" 2019-03-21 06:01:25 +00:00
Lucas Lin
59bab9709f Merge "Improve partial connectivity" am: ce8235772b am: 8f78c70595
am: 7e756a45cd

Change-Id: I25f9d056c26bf947c2e09516da51b627c3da9685
2019-03-20 21:15:34 -07:00
Lucas Lin
ce8235772b Merge "Improve partial connectivity" 2019-03-21 03:34:30 +00:00
Luke Huang
c5fdf01476 Cleanup NetworkManagementService for Netd commnads binder migrartion
remove dead code used for netd UNIX sokcet

Bug: 65862741
Test: atest NetworkManagementServiceTest FrameworksNetTests
Change-Id: I5db61cb86325b71ac8a8fce7b15dbf569abc5935
2019-03-20 20:02:24 +08:00
lucaslin
2afb4bcbcb Improve partial connectivity
Improve the design and fix some nits.

Bug: 113450764
Test: 1. Build pass
      2. atest FrameworksNetTests
      3. atest NetworkStackTests
      4. Change captive_portal_https_url to https://invalid.com
      to simulate partial connectivity.
Change-Id: Ia56645841d00d2ed8406cfeacb86a4a27fd58650
2019-03-20 18:21:59 +08:00
Varun Anand
fb2624d4f3 Merge "Add unit tests related to data accounting for VPNs with one underlying network." am: 0572cf6752 am: 42db9375aa
am: fefcada377

Change-Id: I80e3ebb556ac0b6bff5d232b881f7d869cb74f00
2019-03-19 09:47:04 -07:00
Treehugger Robot
0572cf6752 Merge "Add unit tests related to data accounting for VPNs with one underlying network." 2019-03-19 16:18:28 +00:00
Remi NGUYEN VAN
bd87531730 Merge "Remove NetworkParcelable" am: 7391d04a26 am: 7dc93f8a1e
am: f363d924dc

Change-Id: Ifec0dd683bf9c9b73c4af12835b76d284559daf8
2019-03-17 19:12:02 -07:00
Remi NGUYEN VAN
7391d04a26 Merge "Remove NetworkParcelable" 2019-03-18 01:30:25 +00:00
Varun Anand
e22525bf92 Add unit tests related to data accounting for VPNs with one underlying
network.

This is to establish a baseline for the existing behavior, and to ensure
that following changes are not causing a regression in existing
behavior.

This CL is also adding missing cleanup for NetworkStatsCollectionTest
which was forcing all network types in NetworkTemplate that was causing
NetworkStatsService related tests to fail.

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests
Change-Id: I285f186cfb16bc9fa704c797996b1e4f8a73dee4
2019-03-15 17:23:28 -07:00
Remi NGUYEN VAN
633c331167 Remove NetworkParcelable
With the @JavaOnlyStableParcelable annotation, Network can now be used
as-is as a framework parcelable.

Test: atest FrameworksNetTests NetworkStackTests
Bug: 126477266
Change-Id: I5d9695a31b3ac48d10edcf08ccd0c34375353b79
2019-03-16 03:51:09 +09:00
Junyu Lai
6c1a593fef Merge "[KA02.5] Use binder thread and executor to invoke callback" am: f9ae70a41c am: 750fbd0ab2
am: 686be8c9b0

Change-Id: I881c1ab09187ab23facc03bb71cc38a7978e442c
2019-03-15 01:19:55 -07:00
junyulai
9f87223db2 [KA02.5] Use binder thread and executor to invoke callback
Currently, client side of keepalive event handling rely on a
newly created thread, looper, messenger and handler per object.

However, by creating oneway AIDL interface with the executor,
the callbacks can be invoked on the binder thread with user
specified context, which not only greatly simplify the design
but also reduce the cost of current thread modeling.

Bug: 114151147
Bug: 123969871
Test: 1. atest FrameworksNetTests --generate-new-metric 10
      2. atest-deflake.sh

Change-Id: I27504074cd28d5b5eb94a7ec0e97ebaaaaa1ae3d
2019-03-14 19:24:12 +08:00
Ian Kasprzak
e04686ec67 Merge "Temporarily disable flaky test." am: d146d717c7 am: 3bab305ed9
am: 40088b623f

Change-Id: Ifcfee2d83c2a173f1cc2f22597aff3cffe558281
2019-03-12 22:40:38 -07:00
Xiao Ma
50caf2e4c4 Merge "[KA13]: add unit test for exposed TCP socket keepalive API." am: a0b41a33e0 am: c8131b1668
am: 3893672a94

Change-Id: Ib2b2474a74e2e84b3bb75c36b518ad48009065af
2019-03-12 22:19:28 -07:00
Chalard Jean
40f6974c7a Merge "Tell the factory it is already serving a request." 2019-03-13 02:07:29 +00:00
Ian Kasprzak
d146d717c7 Merge "Temporarily disable flaky test." 2019-03-13 01:52:21 +00:00
Xiao Ma
a0b41a33e0 Merge "[KA13]: add unit test for exposed TCP socket keepalive API." 2019-03-13 01:13:08 +00:00
Lorenzo Colitti
dc1e7d9bba Temporarily disable flaky test.
Test: None
Bug: 128426024
Change-Id: Id88bf452f41f512703d5831e357d9ba72dc5b911
2019-03-13 09:23:54 +09:00
Chalard Jean
44689aab3b Tell the factory it is already serving a request.
This is a cherry-pick of ag/607226 that has been rebased on
top of four years of changes and with comments addressed.

Gives each factory a serial number and propagates it to every
NetworkAgent so when a score comes back indicating a request is
being handled the factory can account for it properly.

Without this, a new request that's already handled by a network
offered by a factory will not cause an increment of the factorys
ref count. Concretely this results in issues like the RAT icon
not being displayed in spite of the network actually being up
and usable.

This will be ported to AOSP as soon as possible, but immediately
some master-only WiFi tests need to be adjusted with this change
which would not let me submit to AOSP.

Bug: 18637384
Bug: 29030667
Test: manual
Test: atest frameworks/opt/telephony/tests/telephonytests
Test: atest frameworks-net
Test: atest CtsNetTestCases CtsHostsideNetworkTests
Change-Id: I597ac588f76dd507512ff02868fd1310b7e63f7e
Merged-In: I597ac588f76dd507512ff02868fd1310b7e63f7e
2019-03-12 21:47:21 +09:00