Commit Graph

4071 Commits

Author SHA1 Message Date
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
0d4a1ae642 Merge "Return a port from bindToPort() in IpSecService"
am: 51de41dea2

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

Change-Id: Ic099206a28c4f21fa796969c953a8d4e81e8495b
2017-10-19 17:14:53 +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
a5ea707a44 Merge "Fix ConnectivityServiceTest#testNetworkCallbackMaximum"
am: f7929f37b9

Change-Id: I1cbe45eb339903630675713d287e3375c7c98e62
2017-10-15 02:24:52 +00:00
Hugo Benichi
f7929f37b9 Merge "Fix ConnectivityServiceTest#testNetworkCallbackMaximum" 2017-10-13 01:44:36 +00: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
bf80e2f376 Merge "Import a few android.net unit tests into frameworks-net"
am: f851fef87f

Change-Id: I41655938d6d1df19130847210437f047c8b65cdf
2017-10-12 12:13:20 +00:00
Hugo Benichi
f851fef87f Merge "Import a few android.net unit tests into frameworks-net" 2017-10-12 11:58:32 +00:00
Hugo Benichi
06cfeaf51f Merge "Migrate most of core networking tests to junit4"
am: 649a997437

Change-Id: Ib124efb327bfbacd5a637753f9c9724e27a218cb
2017-10-12 09:24:40 +00:00
Treehugger Robot
649a997437 Merge "Migrate most of core networking tests to junit4" 2017-10-12 09:06:24 +00:00
Hugo Benichi
87d306b45f Import a few android.net unit tests into frameworks-net
Bug: 62918393
Test: runtest frameworks-net
Change-Id: I3c7c60bcfeffec5c5ec287810312349237a2868a
2017-10-12 15:55:22 +09: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
Hugo Benichi
2d91ade1d8 Merge "LinkProperties: fix some indentation issues"
am: 4dea4936c7

Change-Id: If9bc7cf980aa14880dbf6cc43bc86cc269d306cb
2017-10-10 14:13:45 +00:00
Treehugger Robot
4dea4936c7 Merge "LinkProperties: fix some indentation issues" 2017-10-10 14:02:35 +00:00
Hugo Benichi
875e9a419c LinkProperties: fix some indentation issues
Test: no functional change
Change-Id: I469bba154feb382156e56043d83f066a5bd658aa
2017-10-10 18:25:50 +09:00
Chalard Jean
316bc4e19c Merge "Add some useful helpers and constants."
am: ed8d236319

Change-Id: I3a934e19ece91bf5957e4c5fa289bbc1a6242915
2017-10-06 09:48:32 +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
83d7776121 Merge changes from topic "ipsec-svc-cleanup"
am: 9778c7884f

Change-Id: Ide81ae76bd05ba3a2cc7c06c072306d30a489057
2017-10-04 20:24:10 +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
4f4459d8c3 Add equals() for IpSecAlgorithm and IpSecConfig
Add equality testing methods to support tests
for parceling and un-parceling IpSecConfig.

Bug: 38397094
Test: runtest -x IpSecConfigTest.java
Change-Id: I31e318334d39ed6e9daf5ec8f3be7dcec75e12ad
2017-10-03 19:45:58 -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
ca67954314 Merge "ConnectivityServiceTest: fix flaky testNetworkRequestMaximum"
am: 1211941aa0

Change-Id: I169e1d48bffab3326dd61011b7747c1400b9bc74
2017-10-02 10:36:22 +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
a9177b3748 Merge "Fix NPE in NsdServiceTest"
am: c30decbfe8

Change-Id: Ic9b7aaec14066d18247cc1efbdc06be1e6a79f29
2017-09-28 12:22:34 +00:00
Hugo Benichi
c30decbfe8 Merge "Fix NPE in NsdServiceTest" 2017-09-28 12:13:18 +00:00
Jean Chalard
38a3b1cda1 Merge "Do not throw on call to isTetheringSupported w/o permission"
am: 9f04f7a609

Change-Id: Ie2ed67525e719104cef1537568f944b77d5f5e4e
2017-09-28 07:47:30 +00:00
Jean Chalard
9f04f7a609 Merge "Do not throw on call to isTetheringSupported w/o permission" 2017-09-28 07:39:14 +00:00
Chalard Jean
eb137aebc9 Do not throw on call to isTetheringSupported w/o permission
...just return false instead.

Test: Made an app to test this. Made sure it doesn't have
Test: the required permission. Checked it crashes with
Test: SecurityException without this change. Checked that it
Test: doesn't with it.

Merged-In: Ib5b17a7f68c1327f47fe1f54c0454c51f4226907
Change-Id: Id20d3c240ec5d70d085e0366b92ab3a514f3e7c8
(cherry picked from commit ffacaef813)
2017-09-28 16:34:39 +09: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
fc56002707 Merge "Delete the legacy framework code for manipulating ND offload."
am: 3c0bf71eee

Change-Id: I060bd7632b809d89224d250c697ac9d2e89d5c2d
2017-09-27 10:53:05 +00:00
Lorenzo Colitti
3c0bf71eee Merge "Delete the legacy framework code for manipulating ND offload." 2017-09-27 10:46:36 +00:00
Jean Chalard
f79e177f1f Merge "Adds necessary permissions to system apis"
am: efb7b861d3

Change-Id: Ifa5d94cdd883c3e1b983c985c0c17fe61e864352
2017-09-27 09:58:51 +00:00
Jean Chalard
efb7b861d3 Merge "Adds necessary permissions to system apis" 2017-09-27 09:50:42 +00:00
Lorenzo Colitti
5b906e1d11 Merge "Declare support for Ethernet if the service is running."
am: 21fcca6818

Change-Id: Ie0a0190da53571c6f4b466840b7878eb54b5e136
2017-09-27 08:32:43 +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
Udam Saini
b4f31a2f56 Adds necessary permissions to system apis
adds privileged permission for getCaptivePortalServerUrl
adds tether privileged permission for
startTethering,isTetheringSupported

bug:62348162

Test: make and manual testing
Change-Id: I8eb8e3c9dcd7201abe9ea303ee57fe99073d67eb
2017-09-27 12:14:37 +09:00
Hugo Benichi
53eee16439 Merge changes Ia47e566b,Ib94d79a9
am: d8eae0de70

Change-Id: I0cac456f778db78d76d2225b79ce42526a6d2d19
2017-09-26 11:46:30 +00:00
Hugo Benichi
d8eae0de70 Merge changes Ia47e566b,Ib94d79a9
* changes:
  Separate connectivity event buffer for bug reports
  Extract RingBuffer class from NetdEventListenerService
2017-09-26 09:48:10 +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
Hugo Benichi
a25440dfc8 Merge "Implement ConnectivityService TODO and fix many race conditions"
am: 864746862b

Change-Id: I2011e23c9f894c079ab66cd7cc5c14af572a956d
2017-09-21 12:08:45 +00:00
Hugo Benichi
864746862b Merge "Implement ConnectivityService TODO and fix many race conditions" 2017-09-21 12:00:48 +00:00
Erik Kline
698b2ee406 Merge "Also support 464xlat on SUSPENDED networks"
am: 995a28d334

Change-Id: Iab87bfcb66e7932d61beec38bcbda366262eab46
2017-09-21 11:55:35 +00:00
Hugo Benichi
53e6fd54e6 Implement ConnectivityService TODO and fix many race conditions
This patch implements an outstanding TODO in ConnectivityService to add
synchronization over the map of network request ids to network agent
info objects.

This structure is accessed from multiple threads:
 - Binder thread on public aidl methods, most notably via
   getDefaultNetwork().
 - Internal handler.

This leads to many race conditions that can crash the system server and
reboot the phone if getDefaultNetwork() is called on a Binder thread to
service a public ConnectivityManager api while the default network state
is being updated on the internal handler after losing the default
network.

Bug: 65911184
Test: runtest frameworks-net
Change-Id: I86c830ebd559e31d4576a7606705a056afb064ac
2017-09-21 18:50:27 +09: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