Commit Graph

374 Commits

Author SHA1 Message Date
Jeff Sharkey
07e19362de Define NOT_ROAMING network capability.
The "roaming" state of a network really belongs on NetworkCapabilities
instead of being published through NetworkInfo.isRoaming().  One major
reason is to support developers creating NetworkRequests for a
non-roaming network.

Watch for any capability changes that network statistics are
interested in (either metered or roaming) and notify it to perform
an update pass; fixes bug where we previously only triggered on
roaming changes.

Fix bug in VPNs where metered/roaming capabilities of underlying
networks weren't being propagated; this was probably preventing
some jobs from running over unmetered networks, and causing other
jobs to run over roaming networks!  Also passes along link bandwidth
information from underlying networks, and propegates any changes
to underlying networks.

Fix race condition by reading prevNc inside lock.  Utility methods
correctly calculate min/max link bandwidth values.

Test: bit FrameworksNetTests:android.net.,com.android.server.net.,com.android.server.connectivity.,com.android.server.ConnectivityServiceTest
Bug: 68397798, 16207332
Change-Id: I3e1a6544c902bf3a79356b72d3616af1fd2b0f49
2017-11-01 19:05:42 -06:00
Manoj Boopathi Raj
7b76b5f4ac Merge "Fixed NullPointerException in IpSecService-Netd binder layer" am: 626046b7f5 am: a096e8d177
am: 6e94f3f675

Change-Id: I8c51bfa708622dfb47ae55438f08b98f04c1d6c6
2017-10-27 18:21:48 +00:00
Manoj Boopathi Raj
6e94f3f675 Merge "Fixed NullPointerException in IpSecService-Netd binder layer" am: 626046b7f5
am: a096e8d177

Change-Id: I23ea94140ac3e34fc92fdc6a2c0d694396489e03
2017-10-27 18:06:09 +00:00
Manoj Boopathi Raj
626046b7f5 Merge "Fixed NullPointerException in IpSecService-Netd binder layer" 2017-10-27 17:32:56 +00:00
Manoj Boopathi Raj
03bb7d9304 Fixed NullPointerException in IpSecService-Netd binder layer
Replaced null with empty byte array in createTransportModeTransform
for null auth.getKey, crypt.getKey() and authCrypt.getKey()

Test: Ran CTS test
Bug: 68052730
Change-Id: I5110b1297b4bfbb5766e8ecfd3d64f8110b52945
2017-10-26 13:10:22 -07:00
Hugo Benichi
efc9cdb106 Merge changes I59b6e04f,I55694d89 am: bccc497249 am: 93134fea64
am: 2eca2c0e3a

Change-Id: I61f321ebd67432e02b5621fa1c662953295999fd
2017-10-26 06:34:27 +00:00
Hugo Benichi
2eca2c0e3a Merge changes I59b6e04f,I55694d89 am: bccc497249
am: 93134fea64

Change-Id: I923fe9cc37463e695182c7a279d201ba7e9d6518
2017-10-26 06:23:31 +00:00
Hugo Benichi
7e86f2e10f Remove Parcelable interface from DefaultNetworkEvent
This patch takes advantage of the direct DefaultNetworkMetrics interface
between ConnectivityService and IpConnectivityMetrics and removes the
Parcelable interface from DefaultNetworkEvent.

IpConnectivityMetrics, IpConnectivityEventBuilder and associated tests
are updated as necessary.

Bug: 34901696
Test: runtest frameworks-net
Change-Id: I59b6e04fc126051320d08a422cfbd4d27042123e
2017-10-25 12:40:13 +09:00
Hugo Benichi
cd8d58c405 Extract logging of default network events
This patch extracts the logging of DefaultNetworkEvent from inside
ConnectivityService and move it to a new DefaultNetworkMetrics class.

The DefaultNetworkMetrics is a singleton owned by the
IpConnectivityMetrics singleton implementing the metrics service for
core networking. ConnectivityService has access to this singleton via
LocalServices.

This class layout will allow to remove the Parcelable interface of
DefaultNetworkEvent and will instead let the IpConnectivityMetrics
service grab metrics from the DefaultNetworkMetrics directly.

Bug: 34901696
Test: runtest frameworks-net
Change-Id: I55694d89124272732aba114198776462372de18b
2017-10-25 12:36:29 +09:00
Benedict Wong
396f1030d3 Merge "Return a port from bindToPort() in IpSecService" am: 51de41dea2 am: 0d4a1ae642
am: a52b3a7775

Change-Id: I0d1c17c3740983ab0cbc24c2cd0d3a530b56ca99
2017-10-24 17:09:28 +00:00
Benedict Wong
a52b3a7775 Merge "Return a port from bindToPort() in IpSecService" am: 51de41dea2
am: 0d4a1ae642

Change-Id: Ie59d496a38bf9775c1f40a543a24cb3fec5719bf
2017-10-24 16:54:57 +00:00
Benedict Wong
51de41dea2 Merge "Return a port from bindToPort() in IpSecService" 2017-10-24 16:31:21 +00:00
Benedict Wong
ce0dababb2 Merge "Add support for AES-GCM-ESP as an IPSec algorithm" am: b6df7f0d35 am: f0d0bdc372 am: f92bfc3b77
am: 10a7405642

Change-Id: Ie9a43c7f0519a2d7ac3326944608190503804483
2017-10-19 17:48:53 +00:00
Benedict Wong
10a7405642 Merge "Add support for AES-GCM-ESP as an IPSec algorithm" am: b6df7f0d35 am: f0d0bdc372
am: f92bfc3b77

Change-Id: I49932a5fc048b4a60512fac45a3537f050397168
2017-10-19 17:37:22 +00:00
Benedict Wong
212777930f Return a port from bindToPort() in IpSecService
When binding to a random port, the port number was not being
returned, so the user is incorrectly receiving a port of zero.
Return the port number that was ultimately bound.

Bug: 67662580
Test: Ran CTS test on aosp_angler-eng
Change-Id: I22f4e5cdc83d43dc453788889990feb34e451bd3
2017-10-18 11:43:43 -07:00
Benedict Wong
edc1d285d7 Add support for AES-GCM-ESP as an IPSec algorithm
Allows native AES-GCM-ESP to be used as an IPSec transport/tunnel mode
algorithm with kernel support

Bug: 63589918
Test: IPsecService tests added, existing ones pass
Change-Id: Ie1a9a902be205f269aa37bf956198f2e5b177c21
2017-10-18 11:22:24 -07:00
Hugo Benichi
d551adff6d Merge "Fix ConnectivityServiceTest#testNetworkCallbackMaximum" am: f7929f37b9 am: a5ea707a44 am: 4071792cce
am: fa684574da

Change-Id: I65c210d8f0ee27540339233d45def0c464920aea
2017-10-15 03:39:01 +00:00
Hugo Benichi
fa684574da Merge "Fix ConnectivityServiceTest#testNetworkCallbackMaximum" am: f7929f37b9 am: a5ea707a44
am: 4071792cce

Change-Id: Id5ee94ae9a7e2a92289f2b25b0d5c0f0b5b7381a
2017-10-15 02:53:58 +00:00
TreeHugger Robot
3d0712af87 Merge "Migrating remaining core networking tests to Junit4" 2017-10-13 05:26:31 +00:00
Hugo Benichi
739e2eacac Migrating remaining core networking tests to Junit4
Bug: 62918393
Test: runtest frameworks-net
Change-Id: I30f7eaa0307b8fad5a8de7a0da235a4f76c18677
2017-10-13 12:16:32 +09:00
Hugo Benichi
602996fe25 Fix ConnectivityServiceTest#testNetworkCallbackMaximum
Although commit 2a84d1cbcf fixed some flakyness issues in
testNetworkCallbackMaximum so that it became stable when ran on its own,
it introduced a new source of random failures because instead of
registering callbacks after callbacks until a limit was reached, commit
2a84d1cbcf changed the test logic to push the assertions right up to
the theoretical limit.

More precisely when registering and unregistering PendingIntents in a
loop, not introducing some delay for checking that previous
PendingIntents have been effectively unregistered can cause the test to
fail. This patch fixes this issue.

Bug: 32561414
Bug: 62918393
Test: runtest frameworks-net
      testNetworkCallbackMaximum now succeeds 100 in a row on sailfish

Change-Id: I086817a738ab99fd53ba76ca8faada6151f46472
2017-10-12 23:15:14 +09:00
Hugo Benichi
470f4382fa Merge "Migrate most of core networking tests to junit4" am: 649a997437 am: 06cfeaf51f
am: c40687f85a

Change-Id: Ic59ca37bbb31ba091c8b6d31170584b946c2527a
2017-10-12 09:43:11 +00:00
Hugo Benichi
1c0f4e27bc Migrate most of core networking tests to junit4
This patch is a batch of mechanical changes to test classes to migrate
away from AndroidTestCase and TestCase.

Bug: 62918393
Test: runtest frameworks-net
Change-Id: I74134609e511f22c4d9ecd65780e981f9ba7ae3f
2017-10-12 15:26:09 +09:00
Chalard Jean
0da609859d Merge "Add some useful helpers and constants." am: ed8d236319 am: 316bc4e19c
am: 06d401ae73

Change-Id: Iaf611b8e39080d677c9cfe7edb124c11bbdf8a81
2017-10-06 10:11:04 +00:00
Chalard Jean
8c827b7eb2 Add some useful helpers and constants.
Test: Pulled out of a client app ; the client app is behaving
Test: identically to how it was behaving before. Wrote unit
Test: tests in frameworks-net.

Change-Id: I397137748a95c65cee2e1e1b243a1a260e83a6f7
2017-10-06 13:38:46 +09:00
nharold
869d47e66d Merge changes from topic "ipsec-svc-cleanup" am: 9778c7884f am: 83d7776121
am: 4e793fd0b5

Change-Id: Ib7eae5c9e223493281524e862979e16d25984dde
2017-10-04 20:53:04 +00:00
Nathan Harold
f69cb0a207 Split IpSecServiceTest to add IPv6 Tests
-Split IpSecServiceTest into parameterized
 and single tests.
-Add IPv6 parameters

Bug: 66954381
Test: this
Change-Id: Ib98c112560014f73bccc3d2842c31d297c7a07ef
2017-10-03 19:45:59 -07:00
Nathan Harold
bfbda18d48 Input Validation for IpSecService
All of the input to IpSecService over the Binder
interface needs to be validated both for sanity
and for safety.

-Sanity check all the parameters coming from binder.
-Added setters for IpSecConfig to decouple the test
 from the IpSecManager. This was needed because the
 input validation caused the tests to fail due to a
 null parameter that was previously un-tested.
-Added the mode flag to the IpSecConfig bundle this
 oversight was found during testing.
-Expose the getResourceId() methods for testing in
 UdpEncapsulationSocket, SecurityParameterIndex, and
 IpSecTransform classes.
-Remove the unneeded getIpSecConfig() from
 IpSecTransform: unneeded now that we can synthesize
 configs.

Bug: 38397094
Test: runtest frameworks-net
Change-Id: I5241fc7fbfa9816d54219acd8d81a9f7eef10dd4
2017-10-03 19:45:55 -07:00
Hugo Benichi
a8565a7716 Merge "ConnectivityServiceTest: fix flaky testNetworkRequestMaximum" am: 1211941aa0 am: ca67954314
am: eced6cd14a

Change-Id: I53d0d6755c8e0be34db66da56efa483006e538ac
2017-10-02 10:51:21 +00:00
Hugo Benichi
2a84d1cbcf ConnectivityServiceTest: fix flaky testNetworkRequestMaximum
Registered requests are not keyed by PendingIntents in
ConnectivityService, which means that unregistering a request with a
PendingIntent causes a linear search in all registered requests.

testNetworkRequestMaximum was registering too many PendingIntents
simultaneously, causing the unregistration loop to have n^2
complexity and to take a long time to take effect.

To make the unregistering loop less likely to trigger a timeout on
waitForIdle, this patch changes the test to not register MAX_REQUEST
number of PendingIntent, but instead mixes a small number of
PendingIntents with NetworkCallbacks to reach MAX_REQUEST number of
simultaneously registered requests.

When unregistering these requests, callbacks are unregistered first.

Bug: 32561414
Test: runtest frameworks-net
Change-Id: I48b882c884abe20b388190b7f28baee293446f37
2017-10-02 17:37:57 +09:00
Hugo Benichi
66749201a1 Merge "Fix NPE in NsdServiceTest" am: c30decbfe8 am: a9177b3748
am: a5d620ae92

Change-Id: Ieb299771438fe55566b76271815e52d02da799c8
2017-09-28 12:35:03 +00:00
Hugo Benichi
c30decbfe8 Merge "Fix NPE in NsdServiceTest" 2017-09-28 12:13:18 +00:00
Hugo Benichi
210ab83b77 Fix NPE in NsdServiceTest
Continuous test dashboards report that quit() can crash sometimes
due to mThread being null.

This patch adds a null guard in tearDown().

Bug: 32561414
Test: runtest frameworks-net
Change-Id: If66fb47e31e77d25b4741a786f12eb78f0b9102e
2017-09-28 15:22:13 +09:00
Lorenzo Colitti
f384a58f79 Merge "Delete the legacy framework code for manipulating ND offload." am: 3c0bf71eee am: fc56002707
am: bb21618a86

Change-Id: I07d9753e214af311d3dcab6f8016442f60388700
2017-09-27 11:05:29 +00:00
Lorenzo Colitti
3c0bf71eee Merge "Delete the legacy framework code for manipulating ND offload." 2017-09-27 10:46:36 +00:00
Lorenzo Colitti
d6cc68dab4 Merge "Declare support for Ethernet if the service is running." am: 21fcca6818 am: 5b906e1d11
am: a6648cc90b

Change-Id: Iafd9807ab76ce4e4ab1fd506d7b0e2b2b7017751
2017-09-27 08:51:51 +00:00
Treehugger Robot
21fcca6818 Merge "Declare support for Ethernet if the service is running." 2017-09-27 08:23:34 +00:00
Lorenzo Colitti
19d4cd99f5 Delete the legacy framework code for manipulating ND offload.
This only worked on broadcom devices, and was superseded in
M by a wifi HAL call made by IpManager.

Test: bullhead builds, boots
Change-Id: I711cae7dafe171c2c8b4e84a229adbcad27f3d14
2017-09-27 16:47:36 +09:00
Lorenzo Colitti
23e9afc702 Declare support for Ethernet if the service is running.
On some devices, support for TYPE_ETHERNET is not specified in
the networkAttributes config resource, even though the device is
capable of supporting Ethernet (e.g., via USB host adapters).
This leads to Ethernet working but various connectivity APIs
behaving as if it was not - for example, no CONNECTIVITY_ACTION
broadcasts will be issues when it connects or disconnects.

Ensure that ConnectivityService always treats Ethernet as
available if the service is running. Currently the service is
started if the device supports FEATURE_ETHERNET or
FEATURE_USB_HOST.

Bug: 37359230
Test: bullhead builds, boots
Test: ConnectivityServiceTest passes
Test: Ethernet is available even if removed from networkAttributes resource
Test: ConnectivityManagerTest CTS test passes
Change-Id: I58801bf4f0bbdc3ff6345ec6bfdc911ce045c8ab
2017-09-27 13:03:10 +09:00
Hugo Benichi
883604a9fd Merge changes Ia47e566b,Ib94d79a9 am: d8eae0de70 am: 53eee16439
am: b91bd88c5e

Change-Id: Ied2b31c9d1219b8aebf5fec085ab598b77bede6e
2017-09-26 13:05:41 +00:00
Hugo Benichi
bf737c0a6b Extract RingBuffer class from NetdEventListenerService
This patch takes out the ring buffer array added for NFLOG wakeup packet
events logging and extract it into its own class for reuse. This new
RingBuffer class has the two minimal useful functions append() and
toArray().

Bug: 65164242
Bug: 65700460
Test: runtest frameworks-net, with new unit test
Change-Id: Ib94d79a93f4e99661b7d0fac67117b91d57af980
2017-09-26 14:14:16 +09:00
Erik Kline
0bbe489393 Merge "Also support 464xlat on SUSPENDED networks" am: 995a28d334 am: 698b2ee406
am: 1347ac8109

Change-Id: I83ae39a2e36bc036dce419c80dd476d2358b4537
2017-09-21 12:06:05 +00:00
Erik Kline
0b01b0f191 Also support 464xlat on SUSPENDED networks
Test: as follows
    - built
    - flashed
    - booted
    - runtest frameworks-net passes
Bug: 65684232

Change-Id: I1b10aab01554b1f926ec7157dba78645fdaff90f
2017-09-21 18:06:29 +09:00
Charles He
e25293089d Merge changes from topic "vpn-dialog" am: 85afa50569 am: b692194f38
am: a9f6384b6a

Change-Id: I853f48a75865008ac8b976eec1af56fb1870a1b3
2017-09-19 08:25:16 +00:00
Charles He
85afa50569 Merge changes from topic "vpn-dialog"
* changes:
  Unbreak VPN unit tests.
  Add alert dialog when always-on VPN disconnects.
2017-09-19 07:56:44 +00:00
Charles He
ca55d7bda7 Unbreak VPN unit tests.
VpnTest was broken earlier due to a change to always-on VPN
notifications. This CL adds the corresponding mocks to the unit test to
fix it.

Bug: 36650087
Bug: 65439160
Test: runtest frameworks-net
Change-Id: Icff57c7e927c135d75a7d70ff347a579c5d45134
Merged-In: Icff57c7e927c135d75a7d70ff347a579c5d45134
(cherry picked from commit 5da89994b9)
2017-09-19 07:56:36 +00:00
Charles He
65e8bd2e04 Merge changes from topic "always-on-vpn"
* changes:
  Opt-out for always-on VPN: rename API.
  Opt-out for always-on VPN
2017-09-19 07:50:13 +00:00
Hugo Benichi
17d5101e99 Merge "Wakeup packet events: addressing a few comments" am: efd7e6d7a9 am: ca88876b58
am: 19625788a1

Change-Id: I8ca2a01a95acaaca2599563efd6a21e4372d1f95
2017-09-19 07:36:12 +00:00
Hugo Benichi
d4a29081c1 Wakeup packet events: addressing a few comments
This patch addresses a few post-submit comment for
commits f562ac34a51dc and 60c9f63b66921.

Bug: 34901696
Bug: 62179647
Test: runtest frameworks-net
Change-Id: I4abec57e0c6bc869dc57b5eb54582dd977b64c30
2017-09-19 14:07:47 +09:00
Hugo Benichi
46510068bc Merge changes I4719b4dc,I0308cdf4,I38db1bb7 am: e5090f2547 am: 1cbdfb6460
am: b025492a6b

Change-Id: I5385a3747e039a42e86034f7632edd0f855b2eb1
2017-09-14 18:11:06 +00:00