Commit Graph

1982 Commits

Author SHA1 Message Date
Robin Lee
7ec93a1ee2 Merge "Add lockdownEnabled parameter to always-on VPN API" into nyc-dev 2016-05-04 18:38:30 +00:00
Robin Lee
dc67971a99 Add lockdownEnabled parameter to always-on VPN API
Allows callers to opt-out of blockading network traffic during boot and
on VPN app failure.

Bug: 26694104
Change-Id: Ibfbd43ad09a25f2e38053fcd6306df3711f8bde2
2016-05-03 13:24:42 +01:00
Jeff Sharkey
1b6519bd87 Flag to mark foreground jobs, fix data saver.
When a job will eventually run in the foreground, the internal
scheduling needs to ignore any background network restrictions when
satisfying constraints.  This also means the job should ignore the
current device doze state, since the requesting app could get the
same behavior by starting their own foreground service.

Always dispatch network policy changes to ConnectivityService first
to ensure that it has up-to-date information.  Fix bugs around data
saver that were causing networks to not be marked as BLOCKED for
background apps; before this fix apps would have been spinning in
internal connectivity loops, thinking that the network was actually
connected when the kernel was actually blocking their traffic.

Offer new ConnectivityService method overloads to ignore the blocked
state for a specific UID.

Print unsatisfied job constraints to aid debugging.

Bug: 26571724
Change-Id: Iaaa17933e6dc1bf6d3dff26d0bfc12222e51e241
2016-04-29 13:44:07 -06:00
Lorenzo Colitti
c5be12e7ac Make isCaptivePortal perform both HTTP and HTTPS probes.
Also a couple of minor cleanups and logging tweaks.

Bug: 26075613
Change-Id: I67b09e96d72764179339b616072bb2ce06aabf33
2016-04-28 11:23:10 +09:00
TreeHugger Robot
0db93cea0f Merge "Tethering and Data Saver: There Can Be Only One!" into nyc-dev 2016-04-27 22:41:13 +00:00
TreeHugger Robot
24b6e2bcc8 Merge changes I8de95add,Ia6f4ccfd into nyc-dev
* changes:
  Remove unused event tags of IpConnectivityEvent
  Better ConnectivityMetricsEvent printing
2016-04-27 01:49:53 +00:00
Hugo Benichi
61cbccc2bf Remove unused event tags of IpConnectivityEvent
Bug: 28204408
Change-Id: I8de95add30cdf5c35c8129ee1b95d2d648b3316d
2016-04-27 09:12:40 +09:00
Hugo Benichi
5df9d729f6 Better ConnectivityMetricsEvent printing
This patch adds more information printing for IpConnectivity event
classes in android.net.metrics.

example:

ConnectivityMetricsEvent(14:36:35.799, 0, 1026): DhcpClientEvent(wlan0, DhcpRequestingState)
ConnectivityMetricsEvent(14:36:35.805, 0, 1026): DhcpClientEvent(wlan0, DhcpHaveAddressState)
ConnectivityMetricsEvent(14:36:35.809, 0, 4096): IpManagerEvent(wlan0, PROVISIONING_OK, 155ms)
ConnectivityMetricsEvent(14:36:35.810, 0, 1026): DhcpClientEvent(wlan0, DhcpBoundState)
ConnectivityMetricsEvent(14:36:35.871, 0, 2048): NetworkEvent(101, NETWORK_CONNECTED, 0ms)
ConnectivityMetricsEvent(14:36:35.874, 0, 2051): ValidationProbeEvent(101, PROBE_HTTP:599, 3ms)
ConnectivityMetricsEvent(14:36:35.874, 0, 2048): NetworkEvent(101, NETWORK_VALIDATION_FAILED, 0ms)
ConnectivityMetricsEvent(14:36:35.928, 0, 3072): DefaultNetworkEvent(0 -> 101, [WIFI], IPv4: false, IPv6: false)
ConnectivityMetricsEvent(14:36:37.008, 0, 2051): ValidationProbeEvent(101, PROBE_HTTP:204, 134ms)
ConnectivityMetricsEvent(14:36:37.008, 0, 2050): NetworkEvent(101, NETWORK_VALIDATED, 1137ms)

Also fixes a couple of event logging issues:
  - do no record spurious receive DhcpErrorEvent when a network goes down.
  - add an eventType field to IpManagerEvent instead of using the
    loggger component tag.

Bug: 28204408
Change-Id: Ia6f4ccfd7a0c63a5ccec18825f226c0b5781217b
2016-04-27 09:11:29 +09:00
TreeHugger Robot
396c590c42 Merge "Frameworks/base: Make debug helper lazy in ConnectivityManager" into nyc-dev 2016-04-26 15:25:44 +00:00
Lorenzo Colitti
e4860f0256 Merge "When dumping connectivity metrics events, print data as well." into nyc-dev 2016-04-26 03:22:26 +00:00
Felipe Leme
70c8b9b660 Tethering and Data Saver: There Can Be Only One!
If tethering is on when Data Saver mode is turned on, tethering should
be disabled, and vice-versa.

BUG: 28313291
Change-Id: I7f3dadbd97ea1492ab76b41043dea7487c1db02d
2016-04-25 15:36:25 -07:00
Andreas Gampe
3480213054 Frameworks/base: Make debug helper lazy in ConnectivityManager
Place helper map for callback field names into a holder. This avoids
the reflective calls in static initialization of ConnectivityManager
in the common (non-debug) case, which means the class can be
compile-time initialized. Also saves the storage necessary (both
the storage array as well as the reflection metadata).

Follow-up to fcfa7d921a.

Bug: 27265238
Change-Id: Ib4bfaf27acd234a035a5d198458340099a156a4c
2016-04-25 10:30:53 -07:00
Lorenzo Colitti
0a082e2c38 When dumping connectivity metrics events, print data as well.
Currently the output is not very interesting, looking like:

ConnectivityMetricsEvent(1461591945223, 4, 5): Bundle[mParcelledData.dataSize=340]
ConnectivityMetricsEvent(1461591945289, 0, 2048): android.net.metrics.NetworkEvent@b76cd61
ConnectivityMetricsEvent(1461591945296, 4, 5): Bundle[mParcelledData.dataSize=340]
ConnectivityMetricsEvent(1461591945299, 0, 3072): android.net.metrics.DefaultNetworkEvent@e2f3086
ConnectivityMetricsEvent(1461591945527, 0, 2051): android.net.metrics.ValidationProbeEvent@884ad47

but at least it's better than nothing, and event logger users can
always implement a better toString method on their events.

This is only enabled if --events is passed into the dump.

Bug: 28204408
Change-Id: Ife96b8d54e5e91317d86b622d5efc29724969f63
2016-04-25 22:55:09 +09:00
Jeff Sharkey
f07c7b9fd0 API changes for DownloadManager and JobScheduler.
To support moving DownloadManager, add new JobScheduler network type
constraint that matches "any network except roaming."  Also add an
API to get a specific JobInfo by ID.

Since the default network can be different on a per-app basis, and
individual apps may be blocked due to app standby, evaluate job
connectivity constraints on a per-UID basis.  To implement this
cleanly, add NetworkInfo.isMetered() to match the isRoaming() API.

Add new DownloadManager APIs to support charging and device idle
constraints, which are plumbed through to JobScheduler under the
hood when scheduled.

Add filtering to JobScheduler dumpsys to omit noisy details for
packages the caller isn't interested in.

Bug: 28098882, 26571724, 19821935
Change-Id: I09ca7184ef7ce6adba399f579d415a5fb2ea6110
2016-04-24 14:39:34 -06:00
Hugo Benichi
cc92c6e877 Split network monitoring and portal probe events
This patches changes how captive portal tests and network lifecycle
events are logged as connectivity events:
  - it splits NetworkMonitorEvent into two event classes:
      - ValidationProbeEvent for logging individual probe events.
      - NetworkEvent for logging network connection, validation,
        lingering, and disconnection.
  - it removes the redundant CaptivePortalCheckResultEvent class.
    The information logged in CaptivePortalCheckResultEvent was already
    logged by NetworkMonitorEvent, but missing the evaluation durations.
    It is now logged by ValidationProbeEvent.
  - it removes the CaptivePortalStateChangeEvent class, which is now
    redundant with NetworkEvent, but missing evaluation durations.

In addition, it adds event logging when ConnectivityService puts a
network into lingering or removes a network from lingering.

Bug: 28204408
Change-Id: I8f9752e4d36175ecfcbd1545a01a41bad6e06ea4
2016-04-22 17:08:56 +09:00
TreeHugger Robot
b99d6af3ab Merge "Expand NetworkMonitor metrics" into nyc-dev 2016-04-21 05:24:40 +00:00
Hugo Benichi
7261fb27de Merge "Some fixes in ConnectivityService event logging" into nyc-dev 2016-04-21 04:02:55 +00:00
Erik Kline
a488c23dd5 Expand NetworkMonitor metrics
- add netid to CaptivePortalStateChangeEvent
    - add NetworkMonitorEvent for simple duration measurements

Bug: 28204408
Change-Id: I62035e07d64013878a0bce30c67c929c2c7e7a85
2016-04-21 13:02:55 +09:00
Hugo Benichi
5f16f760ad Some fixes in ConnectivityService event logging
Bug: 28204408
Change-Id: I44ed9539bb213a845c2bcc2861c947af7c3c9ef4
2016-04-21 11:03:08 +09:00
Hugo Benichi
25bf8f5d56 Various fixes in IpReachability event logging
- fold IpReachabilityMonitor* classes into a single IpReachabilityEvent.
- only log an event for NUD_FAILED Netlink answers.
- distinguish between NUD_FAILED with or without lost of provisioning.
- do not record host ip addresses.
- record interface name instead of interface index when losing
  provisioning.

- also return an error code when probeNeighbor fails, and log this error
  code in IpReachability events.

Bug: 28204408
Change-Id: I5f0def0ab1ace7e467a0c69b3b82d07ef2252307
2016-04-21 09:18:50 +09:00
TreeHugger Robot
9724fba835 Merge "Added onRestrictBackgroundWhitelistChanged callback." into nyc-dev 2016-04-20 17:44:56 +00:00
Robin Lee
c6184685d8 Merge "Move UidRange aidl declaration to system/netd" into nyc-dev 2016-04-19 19:19:43 +00:00
Felipe Leme
019fcd2bec Added onRestrictBackgroundWhitelistChanged callback.
When users add or remove an app to the Data Saver Mode whitelist, the
app is notified through a
ConnectivityManager.ACTION_RESTRICT_BACKGROUND_CHANGED. But besides this
broadcast, it's also necessary to notify internal apps such Settings,
hence a new method is being added to INetworkPolicyListener.

BUG: 27481520
Change-Id: I1537a77becf6b7da1535ed5faabdc894fd9f7084
2016-04-19 12:06:00 -07:00
Pavel Zhamaitsiak
6e08a629c4 Merge "Add wrappers for IConnectivityMetricsLogger functions" into nyc-dev 2016-04-19 17:41:42 +00:00
Hugo Benichi
23e0e805c5 Remove unused DHCP timeout event tag.
DHCP timeouts should not be logged at DHCPClient level but as a timeout
event in IpManager.

Bug: 28204408
Change-Id: Ia12619e3bf71102cf289cbbcdec53fd5e7e8efff
2016-04-19 14:26:53 +09:00
Pavel Zhamaitsiak
c2c39e28f3 Add wrappers for IConnectivityMetricsLogger functions
Bug: 25691077
Change-Id: I51fa34a4815fb04e33d3b02f0134e3555afc3900
2016-04-18 17:41:19 -07:00
Robin Lee
106069412d Move UidRange aidl declaration to system/netd
Which owns the native UidRange.cpp, so it makes more sense for the
declaration to live there since frameworks/base depends on netd but not
vice versa.

Bug: 26694104
Change-Id: I0efda77713ee6f0ec8070fb0e09a694b95f6cd25
2016-04-18 15:26:47 +01:00
Hugo Benichi
4b6dfc2ef5 Make android.net.metrics Event classes @SystemApi
Bug: 28204408
Change-Id: I8ffe833213bbc03a7f70c51789f4899ee08f6e08
2016-04-18 11:36:42 +09:00
Hugo Benichi
627b42494d Fixes fatal linter errors in android.net.metrics
This patch changes how Event classes are organized:
 - Base IpConnectivityEvent class does not implement Parcelable because
   it cannot be final (has children). It also becomes abstract because
   it is not supposed to be instantiated and logged directly.
 - All children classes becomes final because they are Parcelable.
 - All constructors of all children classes become private, because they
   are supposed to be instantiated with their associated logEvent()
   methods.
 - All instance fields of all children classes become public final.
      Rational: if private, the ConnectivityMetrics app cannot read
      their data.

Bug: 28204408
Change-Id: I1a4689c422230c6ed034307dec54a61daf8a6598
2016-04-18 11:29:03 +09:00
Hugo Benichi
2677b1957b Fix spurious DHCP parse error logging.
This patch moves the event logging of DHCP response packet parse errors
to DHCPClient in a single place. It also logs receive IO errors as
DHCPErrors instead of DHCPClientEvents.

BUG=28197345

Change-Id: I7ad666cff4d8b97915880477347fbb3f588fdb2a
2016-04-18 11:27:35 +09:00
Pavel Zhamaitsiak
74870c441f Merge "Make ConnectivityMetricsLogger and related classes @SystemApi" into nyc-dev 2016-04-15 18:45:06 +00:00
Lorenzo Colitti
43724734d7 Metrics logging for DNS queries.
Bug: 28204408
Change-Id: I05fc9b580aa20d99e8766057e17a38b5eb6267e8
2016-04-15 16:54:39 +09:00
Lorenzo Colitti
88bc0bbb13 Disambiguate NetworkCallback JavaDoc.
The JavaDoc for many of the requestNetwork and
[un]registerNetworkCallback APIs incorrectly mentions the
PendingIntent version of the APIs instead of the NetworkCallback
version.

Also fix a minor issue in the registerDefaultNetworkCallback
JavaDoc: the default network request is an implementation detail,
so don't mention it. Instead, talk about the "system default
network".

Change-Id: Id94d98261daa2bd768c10e033cb8092729b21c91
2016-04-15 16:24:13 +09:00
Pavel Zhamaitsiak
f6f24c03f3 Make ConnectivityMetricsLogger and related classes @SystemApi
Bug: 25691077
Change-Id: Ia98d0a52a9541d9ae773be2b0e962d609f9dd7ee
2016-04-14 19:15:23 -07:00
Chad Brubaker
439525a993 Merge "Fix isUserAddedCertificate" into nyc-dev 2016-04-14 20:48:53 +00:00
TreeHugger Robot
0628d324d0 Merge "Also log IPv4 and IPv6 connectivity of any previous default network" into nyc-dev 2016-04-14 10:14:20 +00:00
Erik Kline
48f12f2ad6 Also log IPv4 and IPv6 connectivity of any previous default network
Change-Id: I07595c0a131fea21914f524949cd64af87403b88
2016-04-14 17:54:46 +09:00
Hugo Benichi
fc18b6f360 Merge "Add DHCP error event class and record DHCP errors." into nyc-dev 2016-04-14 08:01:31 +00:00
Pierre Imai
1feca76bd4 Merge changes Ia71865a9,I40b6de54 into nyc-dev
* changes:
  Log an event whenever we lose the default network.
  Record the transport types for connectivity events.
2016-04-14 07:25:34 +00:00
Hugo Benichi
6241874355 Add DHCP error event class and record DHCP errors.
This patch adds an event class derived from IpConnectivityEvent that
records parsing errors of DHCP response packets.

Change-Id: I19516cf05e3419c4262e3236899e52987e5f2264
2016-04-14 15:40:10 +09:00
Pierre Imai
6b4e15b155 Record the transport types for connectivity events.
BUG: 25691077
Change-Id: I40b6de5446325e717c0356603fd66cd395db9acb
2016-04-14 15:38:17 +09:00
Erik Kline
5b25a0f796 Add some more metrics: IpManager, IpReachabilityMonitor
Change-Id: Ibb7150c849715a42fc2c879589eaaf86e8a007e7
2016-04-14 10:53:30 +09:00
Chad Brubaker
00a4e29969 Fix isUserAddedCertificate
Check if the CA is in the user store directly instead of delegating to
the TrustManager. This removes one more reflection dependency between
X509TrustManagerExtensions and the default X509TrustManager.

Bug: 28138736
Change-Id: I16c17bf6230becdc0a1948b1d184212f83ee25f0
2016-04-13 10:20:08 -07:00
Pierre Imai
11a888faaf Merge "Fix a memory leak in ConnectivityManager." into nyc-dev 2016-04-13 06:37:33 +00:00
Paul Jensen
3e6a6fc60e Merge "If Internet probe is redirected, pass redirect destination to NetworkAgent." into nyc-dev 2016-04-13 01:33:37 +00:00
Jeff Sharkey
cadfc77d03 Merge "Fix broken javadoc." into nyc-dev 2016-04-12 23:37:38 +00:00
Jeff Sharkey
f82c2f0854 Fix broken javadoc.
Change-Id: I9f2050fd6040234bb1d759ab346f79fc41247aa9
2016-04-12 15:22:57 -06:00
Chad Brubaker
5116ac0d22 Add implemention for isSameTrustConfiguration
Bug: 27672565
Change-Id: Id5291a4a5f2ca75fdf84db4d51363735f1a76845
2016-04-12 13:04:43 -07:00
Paul Jensen
2324373124 If Internet probe is redirected, pass redirect destination to NetworkAgent.
Transport may use the redirect to make additional determination about network
state.

Bug: 25203607
Change-Id: I07d8918f13fdcbe0b6fd757536bfc1850a2a244f
2016-04-12 08:54:36 -04:00
Pierre Imai
b290c0a2cb Fix a memory leak in ConnectivityManager.
Remove callbacks from the internal storage when they are being unregistered.

Change-Id: Ia42ed7aefaebd8caf3eada8e42b6cb7a940d7647
2016-04-12 15:00:28 +09:00