Commit Graph

2120 Commits

Author SHA1 Message Date
Jeremy Joslin
807102d7ff VPN network stat accounting changes. am: 3f0d75afe8
am: 0d309b7a47

Change-Id: I797ac586581f83ada0e94639dd435122c987f1c1
2016-10-21 23:43:06 +00:00
Jeremy Joslin
3f0d75afe8 VPN network stat accounting changes.
Properly account for VPN apps that make heavy use of the tun
interface. Prior to this change a VPN app could be incorrectly charged
for more data than it actually used if it sent more traffic through
the tun interface than the underlying interface.

This change excludes VPN app traffic on the tun interface from the
adjustment pool and doesn't redistribute traffic to the VPN app.
Instead all of the redistributed traffic is deducted from the VPN app
which effectively represents any overhead incurred by the VPN app.

BUG: 30557871
Change-Id: I62a75a0c0c0111e052b7903baa9f5d6d94ef57fd
2016-10-21 18:47:57 +09: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
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
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
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
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
Michal Karpinski
d82fccd368 Rename DnsEventListenerServiceTest to NetdEventListenerServiceTest
Change-Id: I67e645306444938a4675e91a9db5d716c0bd4881
2016-09-21 18:48:57 +09: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
81493a9fef Support displaying a dialog when wifi becomes unvalidated. am: 9be58c5580 am: d660913b0b
am: 56e32083b5

Change-Id: Id908683dce15ffbafc042d506a38ec26d5e9a6ee
2016-09-15 16:18:42 +00:00
Lorenzo Colitti
d660913b0b Support displaying a dialog when wifi becomes unvalidated.
am: 9be58c5580

Change-Id: I8b8e2b652510ca75407a9ad3c29ed111367941e0
2016-09-15 16:04:03 +00:00
Lorenzo Colitti
9be58c5580 Support displaying a dialog when wifi becomes unvalidated.
Bug: 31075769
Change-Id: I7a6e7580769365bea930f638bd44edcaa28df134
2016-09-15 23:33:34 +09:00
Lorenzo Colitti
9ba472d619 Add a NET_CAPABILITY_FOREGROUND capability. am: f0e9a33435
am: aaec66110d

Change-Id: I78d6aa21f8e4c6bbd9cefb4a36f1b77f4bbe4104
2016-09-13 16:23:10 +00:00
Lorenzo Colitti
f0e9a33435 Add a NET_CAPABILITY_FOREGROUND capability.
Bug: 23113288
Change-Id: I90cb9ffb5751f0d9ec822933f37680c401e49966
2016-09-13 12:02:13 +09:00
Lorenzo Colitti
4c698d3eed Add a background NetworkRequest type for mobile data always on. am: 3d4a10617c
am: 9396da4e10

Change-Id: I4b0e05e8bb87e37bf2564fd255b8be7a2b20118a
2016-09-12 13:48:53 +00:00
Lorenzo Colitti
3d4a10617c Add a background NetworkRequest type for mobile data always on.
Like a normal (foreground) request, a background request is only
satisfied by one network and will keep that network up. Unlike a
foreground request, when a network only has background requests,
it will linger, and after lingering is complete, it will become
a background network.

Future CLs will cause the system to treat background networks
differently, e.g., by requiring different permissions.

Bug: 23113288
Change-Id: I40f735269dad1042eb04fea15e64584fc903ccb3
2016-09-09 18:49:24 +09:00
Etan Cohen
bd9fdbe022 [NAN] Add transport type for NAN. [DO NOT MERGE]
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)

Bug: 26564277
Change-Id: I975ebc72d8f97a592d18038b3d6465b7a40efa75
2016-09-06 15:54:10 -07:00
Neil Fuller
8d5ec8d7db Fix receive timeout on LocalSocket
The receive timeout stopped being set incorrect due to commit
c80af6d8. There is an associated CTS regression test in cts/.

Test: Ran CTS test android.net.cts.LocalSocketTest
Bug: 31205169
(cherry picked from commit a8280a5d34)

Change-Id: I28924df45abb687bcca6f4b731ed8b6f741e96da
2016-08-31 18:15:52 +01:00
Neil Fuller
0aa7d4bb3f Merge "Fix receive timeout on LocalSocket" am: 7a9c0cd854 am: 680ec020a1
am: ef1fb4889a

Change-Id: Ie4befe516f369d903a61f22aab15e40ac09193a3
2016-08-31 16:47:33 +00:00
Neil Fuller
a8280a5d34 Fix receive timeout on LocalSocket
The receive timeout stopped being set incorrect due to commit
c80af6d8. There is an associated CTS regression test in cts/.

Test: Ran CTS test android.net.cts.LocalSocketTest
Bug: 31205169
Change-Id: I99808478946f8eae502c49d2cb83465648b9c904
2016-08-31 11:32:17 +01:00
Felipe Leme
bd1a93a721 Fixed statuses on Battery Saver column.
BUG: 30139400

Change-Id: I1798607af13c9be5e1f21212fd7078f7152562bd
(cherry picked from commit 9e325706f4)
2016-08-29 11:27:16 -07:00
Jack Yu
cc2b91697f Do not print misleading debug messages in some scenarios. am: bfd1d6ed49
am: d330f0ccc4

Change-Id: Ia264715fe843b1b272da6ca909edc3be6fd57b28
2016-08-24 20:54:08 +00:00
Jack Yu
bfd1d6ed49 Do not print misleading debug messages in some scenarios.
When the mobile network is not active, querying the network
information might trigger the misleading debug messages. Added
some condition checks to prevent this.

bug: 30850733
Change-Id: Ice6d548a56f98bac7fe2ca6a06148350b505533d
2016-08-23 16:09:36 -07:00
Jack Yu
c92cb8b816 Added todo items for a potential metrics issue am: dc5a63bdd1
am: 94f2fe22b4

Change-Id: Id3a4f8985536f312c35718a1c992ecb505dbbebf
2016-07-30 23:34:10 +00:00
Jack Yu
94f2fe22b4 Added todo items for a potential metrics issue
am: dc5a63bdd1

Change-Id: Ibf846f026d137db2c10fd076a408f2702cab5eaf
2016-07-30 06:41:29 +00:00
Jack Yu
a4e616e0dc Merge "Added todo items for a potential metrics issue" into nyc-mr1-dev 2016-07-30 02:07:53 +00:00
Jack Yu
dc5a63bdd1 Added todo items for a potential metrics issue
bug: 29390529
Change-Id: I15826d5f513748a423eb4cc103f1b010ddad2126
2016-07-29 15:01:18 -07:00
Hugo Benichi
9ecb72151b Fix missing IpConnectivity metrics am: 90cbc5b444
am: 384818b99d

Change-Id: I62f174cc615f40e450ba72f8c6f86d46ed5fc096
2016-07-29 09:47:21 +00:00
Hugo Benichi
90cbc5b444 Fix missing IpConnectivity metrics
The IpConnectivityLog class looks up MetricsLoggerService once only
at creation. If a IpConnectivityLog user instantiates this class too
early during the boot process, the MetricsLoggerService is not found
and no event can be recorded.

This patch makes IpConnectivityLog attempt to look up
MetricsLoggerService as long as it hasn't found it yet.

This allows IpManager and ConnectivityService to upload
android.net.metrics events.

Bug: 30490301
Change-Id: I97102b95a775ea9e90351b9887ae4661fddc2af9
2016-07-29 17:07:38 +09:00