Commit Graph

2238 Commits

Author SHA1 Message Date
TreeHugger Robot
03db8e4b58 Merge changes I1a544a8d,Ie78d3fb0
* changes:
  IpConnectivityMetrics: rate limit ApfProgramEvents
  IpConnectivityMetrics reads buffer size in settings
2016-10-24 14:45:46 +00:00
Hugo Benichi
e1c173d224 IpConnectivityMetrics: rate limit ApfProgramEvents
This patch uses the previously introduced TokenBucket to rate limit
ApfProgramEvents, still allowing for burst of ApfProgramEvents when a
new interface is set up (due to ipv4 provisioning, multicast lock, ipv6 RAs
triggering new APF program events in short amounts of time).

Test: new test in IpConnectivityMetricsTest
Bug: 1550402
Change-Id: I1a544a8d62e6b02f0ed0088ab76c4bad338d2f44
2016-10-24 21:54:37 +09:00
TreeHugger Robot
8d48570f45 Merge "ConnectivityManager: use ConnectivityThread looper" 2016-10-21 01:49:46 +00:00
Hugo Benichi
7724cdd8b9 ConnectivityManager: use ConnectivityThread looper
This patch removes the static singleton looper used by
ConnectivityManager and instead uses the common ConnectivityThread.

This allows to removes the static atomic counter used to track
the number of registered NetworkCallback in ConnectivityManager, because
the looper is not turned off anymore when no callbacks are registered.

Also an overloaded version of sendRequestForNetwork is added taking as a
new parameter a Handler. This will allow to overload various callback
and request related API calls with user provided Handlers.

Test: ConnectivityServiceTest passes
Bug: 26749700
Bug: 28537383
Bug: 32130437
Change-Id: I431afcee7c7155bd7bac23a2e1e97fd5d6520c74
2016-10-21 08:54:34 +09:00
Hugo Benichi
c9eb24ceab Merge "ConnectivityThread: use lazy holder idiom" 2016-10-20 23:49:03 +00:00
Hugo Benichi
5cc311774d Merge "ConnectivityManager: a simpler CallbackHandler" 2016-10-20 23:46:30 +00:00
Hugo Benichi
c4fe5d373c ConnectivityThread: use lazy holder idiom
This patch changes the way that the ConnectivityThread is lazily
instantiated by using the "lazy initialization holder class idiom".

The first code point that tries to obtain a reference to the unique
ConnectivityThread instance will trigger the creation of the Singleton
class, which will guarantee a thread-safe initialization of the static
INSTANCE field inside Singleton according to the language specs.

This is the Item #71 of Effective Java.

The unique static instance of ConnectivityThread is not stored directly
inside ConnectivityThread class but is stored in a static nested class.
This is to avoid triggering the creation of that unique instance when
Zygote does class preloading at phone startup. Otherwise this would lead
to Zygote creating a new OS thread during preloading, which is a fatal
error.

Test: frameworks-wifi tests pass
Bug: 26749700
Bug: 28537383
Bug: 32130437

Change-Id: I4d5672a3195d3af9a0a2c85f871695257abe782b
2016-10-20 09:30:13 +09:00
Hugo Benichi
d42650faaa ConnectivityManager: a simpler CallbackHandler
This patch simplifies CallbackHandler in the following way:
  - CallbackHandler directly uses the static references to
    sNetworkCallback and sCallbackRefCount. This allows to remove
    instance fields in CallbackHandler.
  - CallbackHandler does not have a reference to ConnectivityManager
    anymore
  - CallbackHandler.getObject() is now generic in a type-safe way.

Test: ConnectivityServiceTest passes
Bug: 28537383
Bug: 32130437
Change-Id: I5004da5b91498e6ff7f8b05057a9e24b975bb56e
2016-10-20 09:09:02 +09:00
Christopher Wiley
bfe052cb73 Merge "Use this.isUp() inside InterfaceConfiguration" am: 239df3cc5a am: c6e72b30c7
am: 31ac117bef

Change-Id: If2c93c4affbdb3c1f27f874c509147f2cf50337f
2016-10-19 19:53:15 +00:00
Christopher Wiley
c6e72b30c7 Merge "Use this.isUp() inside InterfaceConfiguration"
am: 239df3cc5a

Change-Id: Id6f064d7a74e41d757de2499653671fc830d217b
2016-10-19 19:31:57 +00:00
Christopher Wiley
87100cce39 Use this.isUp() inside InterfaceConfiguration
Bug: 31337216
Test: Compiles
Change-Id: I968a739f9ada47b1357932d2da76451eb26c3d5f
2016-10-17 10:32:40 -07:00
Christopher Wiley
7566520f7b Merge "Add InterfaceConfiguration.isUp()" am: c7ea99a63c am: 281d7490bf
am: 39c3166710

Change-Id: I2937f320ccc3ab521fa5d1683048f96d05defedc
2016-10-17 16:58:50 +00:00
Christopher Wiley
281d7490bf Merge "Add InterfaceConfiguration.isUp()"
am: c7ea99a63c

Change-Id: Id0bc63c82f8ffd6ad411769ab012efd8bbdfa3ce
2016-10-17 16:41:52 +00:00
Christopher Wiley
08395dce6a Add InterfaceConfiguration.isUp()
Bug: 31337216
Test: None
Change-Id: Ifd83b069472fc50c9517fc69306e7938a9e9628c
2016-10-11 16:47:44 -07:00
Hugo Benichi
d0f9bc1a52 Reject DHCP packets with no magic cookie am: 006e061301 am: 1ade34dd76
am: 7720c01fcf

Change-Id: Id6c52e0e8819ab70c21939519b617da1b25da255
2016-10-08 19:05:17 +00:00
Hugo Benichi
88bcf2f65e Catch runtime exceptions when parsing DHCP packets am: e0ea7fecd6 am: c4a13afe92
am: 9f713864ca

Change-Id: I41b2576f5e944e4d52160570b60bb53315cb7009
2016-10-08 18:48:55 +00:00
Hugo Benichi
7720c01fcf Reject DHCP packets with no magic cookie am: 006e061301
am: 1ade34dd76

Change-Id: Idc93ed44260f9e2dd3343dda57b790d3efa87a18
2016-10-07 02:36:53 +00:00
Hugo Benichi
9f713864ca Catch runtime exceptions when parsing DHCP packets am: e0ea7fecd6
am: c4a13afe92

Change-Id: I53cb258a3b04f2bd8b31e15794b2fcd3ae295ce6
2016-10-06 21:45:08 +00:00
Hugo Benichi
006e061301 Reject DHCP packets with no magic cookie
This patch adds an explicit check in the DHCP packet parser for
rejecting packets without a magic cookie, instead of relying on the
top-level try-catch-all in the parser.

This allows to add to DHCP error metrics this specific error.

It also allows to add two poor man's fuzzing tests that tries to find
additional gaps in the DHCP packet parser by
 - trying to parse all subslices of a valid offer packet.
 - trying to parse random byte arrays.

Test: covered by previously introduced malformed DHCP packet unit tests
      + additional fuzzing tests.
Bug: 31850211
Change-Id: If53c9ba9df78d7604ec018c9d67c237ae59c4833
2016-10-06 21:22:29 +09:00
Hugo Benichi
e0ea7fecd6 Catch runtime exceptions when parsing DHCP packets
This patch adds a try catch all to DHCP packet parsing so that
DhcpClient does not choke on malformed packets, brinding down with it
the whole framework.

Test: added new unit tests catching the issue fixed in this patch.
Bug: 31850211
Change-Id: I3c50a149fed6b2cbc4f40bb4f0e5bb2b56859b44
2016-10-05 21:58:26 +09:00
Hugo Benichi
d7c7f5b3f3 Captive portal detection uses 3rd fallback probe am: d953bf853d am: bc739d0bbc
am: 2b04d1234b

Change-Id: I221cf47aa43105d4094ec724f8d6f4f6c98d0757
2016-09-29 06:07:53 +00:00
Hugo Benichi
2b04d1234b Captive portal detection uses 3rd fallback probe am: d953bf853d
am: bc739d0bbc

Change-Id: Iec8ccdbcd433d8b2f5538d7b4bed5c945b5b688a
2016-09-29 01:22:01 +00:00
Hugo Benichi
d953bf853d Captive portal detection uses 3rd fallback probe
This patch adds the possitibility to send a 3rd fallback validation
probe in sendParallelHttpProbes when neither the 1st http probe nor the
https probe came back with a conclusive answer.

This 3rd probe is only used for trying again captive portal detection
and does not return success, so that network validation always fails if
the https probe fails.

In addition, the url reveals a captive portal is now sent to the
CaptivePortalLoginActivity so that all three probes can use different
urls.

Bug: 29367974

Change-Id: I7385fde1aa1316d94aac350af0e956cb193aa4ee
2016-09-28 23:12:31 +09:00
Alex Klyubin
5e86d951a7 Remove android.net.PskKeyManager
android.net.PskKeyManager does not work with upcoming TLS 1.3.
The class does not appear to be used by any Android apps and is thus
likely to be completely removed in the future.

Bug: 30978706
Test: make && make cts
Change-Id: Id9bae20362c5909e4621cdb00102bfee09d970ec
2016-09-27 11:24:32 -07:00
Hugo Benichi
8472efa087 resolve merge conflicts of 00f07be to nyc-mr1-dev-plus-aosp
am: e69608f864

Change-Id: I4bfd7a9bc5ef4c3c5a30bed63b92eaef90b1a30e
2016-09-25 20:18:16 +00:00
Lorenzo Colitti
420ca6f96b Restrict access to background networks to CHANGE_NETWORK_STATE. am: fbe9b1ad6f am: 8bfa4053c2
am: c411ec9e35

Change-Id: I49bc23dcb5f36654c61a7aa76c41cebda81349f5
2016-09-25 20:11:52 +00:00
Hugo Benichi
8389d6f0e1 New IpConnectivityMetrics service am: eab511b582 am: 3a353a2044
am: 0daeac5dd4

Change-Id: Id08f9c8426780578c0edde7a69cf118fac232177
2016-09-25 20:09:46 +00:00
Hugo Benichi
e69608f864 resolve merge conflicts of 00f07be to nyc-mr1-dev-plus-aosp
Change-Id: I82865b2847c584f8a1d728ef76113e3969f222ca
2016-09-23 14:48:01 +09:00
Hugo Benichi
00f07beff9 IpConnectivityLog uses new metrics service
am: 00a42d4c88

Change-Id: I1e3b611eeec448e333e83cb8d630f0e9906b7f14
2016-09-23 04:48:49 +00:00
Hugo Benichi
417748f064 Merge "IpConnectivityLog uses new metrics service" into nyc-mr1-dev 2016-09-23 04:43:23 +00:00
Lorenzo Colitti
c411ec9e35 Restrict access to background networks to CHANGE_NETWORK_STATE. am: fbe9b1ad6f
am: 8bfa4053c2

Change-Id: Ie4179344aa12e38d2e2a5fab43e028ca0c97150d
2016-09-23 04:01:07 +00:00
Lorenzo Colitti
8bfa4053c2 Restrict access to background networks to CHANGE_NETWORK_STATE.
am: fbe9b1ad6f

Change-Id: Iaf4ccd24298f680cab39bf9b87604eb16bc53aa5
2016-09-23 03:57:32 +00:00
Hugo Benichi
0daeac5dd4 New IpConnectivityMetrics service am: eab511b582
am: 3a353a2044

Change-Id: I5cf485edd3ab1ebb81a2a9d35dfb8bd6d8bcc305
2016-09-23 03:54:06 +00:00
TreeHugger Robot
a703ecdd0c Merge "Restrict access to background networks to CHANGE_NETWORK_STATE." into nyc-mr1-dev 2016-09-23 03:51:15 +00:00
Lorenzo Colitti
fbe9b1ad6f Restrict access to background networks to CHANGE_NETWORK_STATE.
When a network goes into the background, tell netd to set the
network's permission to NETWORK. Also, close all TCP sockets on
that network, to prevent long-lived TCP connections from staying
on it and possibly continuing to use metered data.

Bug: 23113288
Change-Id: Ie89c1940b6739160e25c6e9022b8b977afb3e16e
2016-09-23 11:27:13 +09:00
Hugo Benichi
00a42d4c88 IpConnectivityLog uses new metrics service
This patch connects existing IpConnectivityLog to the new
IpConnectivityMetrics service:
  - IpConnectivityLog is now an independent class that pushes events
    directly to the new IpConnectivityMetrics service.
  - DnsEventListenerService is moved from MetricsLoggerService to
    IpConnectivityMetrics.
  - this patch also features end to end tests from IpConnectivityLog to
    IpConnectivityMetrics dumpsys output.

Bug: 31254800
Change-Id: I4fe4a209eedde2814d5f13c574a1a0d854bd05c9
2016-09-22 23:08:37 +09:00
Hugo Benichi
eab511b582 New IpConnectivityMetrics service
This patch defines a new metrics service for IpConnectivity events
defined in android.net.metrics, separate from currently existing
MetricsLoggerService.

Similarly to MetricsLoggerService, the new service has an event buffer.
It also implements a dumpsys interface that can be used to flush events
and output a serialized proto.

Bug: 31254800
Change-Id: I0c3faeb4008b283f85d9ba9460371fa68956ea3b
2016-09-22 22:25:27 +09:00
John Reck
aa67f684ff Fix a bunch of repeated reads of a ro.* property
SystemProperties.get() is not particularly fast,
especially if a string is returned. Since ro.* values
are unable to be changed, there's no need to
continously re-query them. Cache the value at
static init time to trivially fix this.

Test: refactoring CL.
Change-Id: Iccb021d3cb2ba3a4a1d0048ddec6811bb7409eec
2016-09-21 16:10:54 -07:00
Michal Karpinski
a2d5860a5f Rename DnsEventListenerServiceTest to NetdEventListenerServiceTest
Change-Id: I67e645306444938a4675e91a9db5d716c0bd4881
(cherry picked from commit d82fccd368)
2016-09-21 14:33:56 +00:00
Michal Karpinski
d82fccd368 Rename DnsEventListenerServiceTest to NetdEventListenerServiceTest
Change-Id: I67e645306444938a4675e91a9db5d716c0bd4881
2016-09-21 18:48:57 +09:00
Christopher Wiley
6cb1c65efd Merge "Allow WiFi components to manage interface up state" am: dfa6e6f186 am: b666aa899d am: c185893e9c
am: f6547e9afa

Change-Id: If2b5214b7ba65976ba5e3db0ecf0e85d471b5cf9
2016-09-21 06:58:02 +00:00
Lorenzo Colitti
f700a6e87f Support "don't ask again" in the avoid bad wifi dialog. am: 165c51c0eb am: aab02df195 am: 63275aba54
am: 3f67cbec46

Change-Id: I60ebe27ec892658c5a051457b13506e59ba33824
2016-09-21 06:04:15 +00:00
Christopher Wiley
f6547e9afa Merge "Allow WiFi components to manage interface up state" am: dfa6e6f186 am: b666aa899d
am: c185893e9c

Change-Id: Ic864a64414f47a9058e4cffaf477a76ab09d9dba
2016-09-20 22:05:41 +00:00
Lorenzo Colitti
3f67cbec46 Support "don't ask again" in the avoid bad wifi dialog. am: 165c51c0eb am: aab02df195
am: 63275aba54

Change-Id: I7d8d9f91208bcbe3ff625acf20d943b13f813d8e
2016-09-20 17:39:19 +00:00
Lorenzo Colitti
aab02df195 Support "don't ask again" in the avoid bad wifi dialog.
am: 165c51c0eb

Change-Id: Ic6a1917a83e2d847bd673790e2c36f7316ca7acd
2016-09-20 17:14:50 +00:00
Lorenzo Colitti
165c51c0eb Support "don't ask again" in the avoid bad wifi dialog.
This contains the following changes:

1. Make NETWORK_AVOID_BAD_WIFI a tristate: 0 means never avoid
   bad wifi, unset means prompt the user, 1 means always avoid.
2. Look at NETWORK_AVOID_BAD_WIFI only if the carrier restricts
   avoiding bad wifi (previously, we relied on the setting being
   null and defaulting to the value of the config variable).
3. Add an avoidUnvalidated bit to NetworkAgentInfo to track
   whether the user has requested switching away from this
   unvalidated network even though avoiding bad wifi is generally
   disabled. This is set to true when the user selects "switch"
   in the dialog without setting the "Don't ask again" checkbox.
4. Add a hidden setAvoidUnvalidated API to ConnectivityManager to
   set the avoidUnvalidated bit.
5. Additional unit test coverage.

Bug: 31075769
Change-Id: I1be60c3016c8095df3c4752330149ce638bd0ce1
2016-09-20 16:03:53 +09:00
Christopher Wiley
ce5d913387 Allow WiFi components to manage interface up state
Setting the WiFi network interface up or down is racy because it
is not synchronized with the WiFi components managing the interface.

This causes a problem for hostapd when the interface is marked down
before hostapd starts because it causes the driver to enter the
de-initialization process.  hostapd does not know how to react to this
change of events.

Bug: 31205821
Test: bug no longer reproduces on upcoming devices, unit tests pass

Change-Id: I96938e2aef89b400593d42ce1b0a6ccc2d2e5754
2016-09-19 14:12:38 -07:00
Etan Cohen
51a6ca483f reolve merge conflicts of 4e3d827 to nyc-mr1-dev-plus-aosp
Change-Id: Idb6cca34536fdbb94876d5cde0b2309462840da1
2016-09-16 12:40:03 -07:00
Etan Cohen
305ea28a43 [NAN] Add transport type for NAN.
Add TRANSPORT_WIFI_NAN - specifies a peer-to-peer Wi-Fi NAN data
connectivity request.

While NAN uses Wi-Fi L1 PHY and part of the MAC - it is a different
protocol and constitutes a different transport.

(cherry-pick of commit 7b84987a6a)
(cherry-pick of commit bd9fdbe022)

Bug: 26564277
Change-Id: I975ebc72d8f97a592d18038b3d6465b7a40efa75
2016-09-16 10:21:51 -07:00
Lorenzo Colitti
8d4d235a06 resolve merge conflicts of b97129e to master
Change-Id: Ib09134090aa135d88bb807034b262a23c8b40e5f
2016-09-16 01:45:15 +09:00