Commit Graph

2224 Commits

Author SHA1 Message Date
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
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
ae747eb76f Add a NET_CAPABILITY_FOREGROUND capability. am: f0e9a33435 am: aaec66110d
am: 9ba472d619

Change-Id: I08ca73666668ddc6c9bfe002844a9d2e0ecb28e4
2016-09-14 19:22:54 +00:00
Lorenzo Colitti
786a4b8300 Add a background NetworkRequest type for mobile data always on. am: 3d4a10617c am: 9396da4e10
am: 4c698d3eed

Change-Id: I9e11b75fe0af8a116593394b151c7fb4d1e167f8
2016-09-14 05:02:12 +00: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
Felipe Leme
0ecfcd1e3a Refactored INetworkPolicyListener callbacks.
Methods onRestrictBackgroundWhitelistChanged() and
onRestrictBackgroundBlacklistChanged() were replaced by a more generic
onUidPoliciesChanged().

Test: m javac-check RUN_ERROR_PRONE=true
Test: m -j32 FrameworksServicesTests && adb install -r -g ${ANDROID_PRODUCT_OUT}/data/app/FrameworksServicesTests/FrameworksServicesTests.apk && adb shell am instrument -e class "com.android.server.NetworkPolicyManagerServiceTest" -w "com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner"

BUG: 28791717
Change-Id: I18b2ee4af06802e0d23822b153d1be9b429d5811
2016-09-06 12:49:48 -07:00
Felipe Leme
57e3d31091 Removed deprecated methods from INetworkPolicyManager.
Removed the following methods:

- addRestrictBackgroundWhitelistedUid(int uid)
- removeRestrictBackgroundWhitelistedUid(int uid);
- getRestrictBackgroundWhitelistedUids();

They've been replaced by getUidsWithPolicy() and setUidPolicy().

Test: m -j32 FrameworksServicesTests && adb install -r -g ${ANDROID_PRODUCT_OUT}/data/app/FrameworksServicesTests/FrameworksServicesTests.apk && adb shell am instrument -e class "com.android.server.NetworkPolicyManagerServiceTest" -w "com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner"

BUG: 28791717

Change-Id: I8f6a569cef84c2be60e3277756283026c0fb5b29
2016-09-02 16:26:35 -07:00
Neil Fuller
4e4f9a24e0 Merge "Fix receive timeout on LocalSocket" am: 7a9c0cd854 am: 680ec020a1 am: ef1fb4889a
am: 0aa7d4bb3f

Change-Id: I35b4ff81c9263a3a2d3052602fe43bc37377c733
2016-09-01 01:18:32 +00: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