Commit graph android_packages_modules_Co.../services/core/java
Message SHA1
Expose measurement results to interested callers.
With this it's possible for callers to:

    Network network = ...
    LinkProperties lp = ...

    NetworkDiagnostics netdiag = new NetworkDiagnostics(network, lp, 5000);
    netdiag.startMeasurements();
    netdiag.waitForMeasurements();

    boolean result = true;
    for (Measurement m : netdiag.getMeasurements()) {
        if (!m.checkSucceeded()) {
            result = false;
            // Additional error handling here.
        }
    }

    return result;

Bug: 21832299
Bug: 26780890
Change-Id: Iaf7ff029e2c6a998b574c23d0dcde8d57a467a22

Erik Kline   commited 2016-02-11 00:28:27 +09:00
41e3340ade
Allow NetworkFactories to match any network specifier on a request
Current usage of NetworkSpecifier: network factory will match a request
if the request has either a (1) empty network specifier, or (2) a
network specifier which is identical to that of the network factory.
Note: 'matching' w.r.t. network specifier - all other matching rules
are still in effect.

Change: add rule (3) or the network specifier of the network factory
is the special string (which is defined as "*" and which user-facing
network requests aren't allowed to use).

Rationale: allows on-demand network creation.

Example:
- Can specify a Wi-Fi NetworkRequest with NetworkSpecifier="ssid"
- It will match a Wi-Fi network factory specifying NetworkSpecifier="*"
- That network factory will bring up a Wi-Fi network, connecting to the
  specified SSID.
- Once the network is created it will create a NetworkAgent which will
  now have a NetworkSpecifier matching that of the request (not the
  match-all special string!)

That final step of making sure that the NetworkAgent matches the request
and not the match-all is critical to delivering any subsequent callbacks
correctly. I.e. your network will only get callbacks which match it.

Bug: 26192833
Change-Id: I49e3b492e0bb48a3f6e9a34e3f94f0e1cf89741f

Etan Cohen   commited 2015-12-15 08:06:54 -08:00
d988de60d7
Reinstate CHANGE_NETWORK_STATE as a normal permission.
This is a partial revert of http://ag/738523 , but not a full
revert because M apps that have gone through the WRITE_SETTINGS
route to obtain permission to change network state should
continue to have permission to do so.

Specifically:

1. Change the protection level of CHANGE_NETWORK_STATE back from
   "signature|preinstalled|appop|pre23" to "normal". This allows
   apps that declare CHANGE_NETWORK_STATE in their manifest to
   acquire it, even if they target the M SDK or above.
2. Change the ConnectivityManager permission checks so that they
   first check CHANGE_NETWORK_STATE, and then ask Settings
   if the app has the WRITE_SETTINGS runtime permission.
3. Slightly simplify the code in the Settings provider code that
   deals specifically with the ability to change network state.
4. Make the ConnectivityService permissions checks use the
   ConnectivityManager code to avoid code duplication.
5. Update the ConnectivityManager public Javadoc to list both
   CHANGE_NETWORK_STATE and WRITE_SETTINGS.

Bug: 21588539
Bug: 23597341
Change-Id: Ic06a26517c95f9ad94183f6d126fd0de45de346e

Lorenzo Colitti   commited 2015-10-22 08:33:45 +09:00
91de63b074
Don't buzz when automatically connecting to captive portals
Play a sound and vibrate (by setting DEFAULT_ALL) only if the
user manually selected the network. This applies to both captive
portals and networks with no Internet access.

Bug: 24126143
Change-Id: Idf075d5c85f9f4b07a3431a25d1a3f7089cf1ee2

Lorenzo Colitti   commited 2015-10-21 09:59:31 +09:00
c22996447c
Merge "Don't crash if an invalid always-on VPN profile is configured." into mnc-dr-dev
Erik Kline   authored and   Android (Google) Code Review   commited 2015-10-14 17:37:57 +00:00
f90627d40b
Don't crash if an invalid always-on VPN profile is configured.
This is currently being hit because Settings does not clear the
always-on VPN configuration when the corresponding VPN profile is
deleted. This will be fixed in Settings, but there's no harm in
being robust to invalid configurations here.

Bug: 23625458
Change-Id: Id185a54d5892339197cd40026df5174debd957cf

Lorenzo Colitti   commited 2015-10-13 15:29:14 +09:00
f5e2883d41
Merge "Push firewall rules up to ConnectivityService." into mnc-dr-dev
Jeff Sharkey   authored and   Android (Google) Code Review   commited 2015-10-12 16:34:19 +00:00
22d9b51ce0
Framework fixes for RSSI offload.
1. When registering a NetworkCallback, only update RSSI
   thresholds if the request specifies a signal strength.
2. When releasing a NetworkCallback, only update RSSI
   thresholds if the request specified a signal strength.
3. Add logging.

Add logging.
Bug: 21405941
Bug: 23679346
Bug: 23815756
Change-Id: I4bc42d0ab02285a7a9d14e09f8a1cd868f4d9d7f

Lorenzo Colitti   commited 2015-09-15 16:00:39 +09:00
71ec67ddf7
Push firewall rules up to ConnectivityService.
getActiveNetworkInfo() and friends already know how to augment their
results to help apps detect when network access is blocked.  This
change wires up the new app-idle and device-idle firewall rules to
be reported through these APIs.

This also causes other platform tools like DownloadManager and
SyncManager to respect these new policies.

Bug: 24050462
Change-Id: Id9517b0b70be7e3ca2ab27bed8049db916e4d829

Jeff Sharkey   commited 2015-09-14 15:49:36 -07:00
baefe062f7
NetworkDiagnostics: ping default router from all global addreses.
This will hopefully allow us to determine if the router does not
have our global addresses in its neighbour cache.

Bug: 23661687
Change-Id: I46734c3c719003939cfccf038457ec309a9ff967

Lorenzo Colitti   commited 2015-09-10 15:49:54 +09:00
db30ceba87
Require the new PACKET_KEEPALIVE_OFFLOAD permission.
Bug: 23884210
Change-Id: I50a1a647a69deaba92e73021ee7d6cc0f3eb1eee

Lorenzo Colitti   commited 2015-09-09 00:16:57 +09:00
520287e881
Fix bugs and crashes in PacketKeepalive API.
Bug: 22606153
Bug: 23820819
Bug: 23884210
Change-Id: I1bf82094ec664baed345e9fb137fada0cbf4b7a0

Lorenzo Colitti   commited 2015-09-09 00:16:56 +09:00
f99389f155
Add tests for the PacketKeepalive API.
This currently fails in many different ways, but it tells us what
to fix.

Bug: 22606153
Bug: 23884210
Change-Id: If2e5ee0a8d7b26cad67d3d566ed5b1383e0db096

Lorenzo Colitti   commited 2015-09-09 00:16:56 +09:00
b793d607a5
Get rid of shortSleep() in ConnectivityServiceTest.
Instead, use IdleHandler to wait for things to become idle.

Bug: 22606153
Change-Id: Ic6ab93ad4d336b40962f9be1096629a44b63ee2f

Lorenzo Colitti   commited 2015-09-08 16:41:47 +09:00
1b8b5cdfad
Cut down some logs.
bug:23623327
Change-Id: I737d4e6c384bf4da62c65ad2abe0c9b5dca0067a

Robert Greenwalt   commited 2015-09-03 17:53:42 -07:00
9b33077561
Add SUPL-specific network bcast
Move SUPL CONNECTIVITY_ACTION bcasts to a different, hidden intent
to reduce the churn of apps when SUPL comes/goes.

Short term hack until SUPL moves to use the new APIs and there's
no bcast.

bug:23350688
Change-Id: I3dc14b42afa72465260aa41ccedfe1df27baabd9

Robert Greenwalt   commited 2015-09-01 15:06:04 -07:00
e577c8181d
am 886e7a63: Merge "Change default cellular activity timeout to 10" into mnc-dev
* commit '886e7a63b122a30c69c663d32e3e5f880a07593e':
  Change default cellular activity timeout to 10

Adam Lesinski   authored and   Android Git Automerger   commited 2015-08-19 00:53:35 +00:00
01ed50f414
Change default cellular activity timeout to 10
LTE radios take 10 seconds to power down, so we should set the
activity timeout to 10 seconds.

Bug:23294704
Change-Id: I7478b77f134b0fe2d82e39acd5c370add12735ca

Adam Lesinski   commited 2015-08-18 11:47:07 -07:00
3961c0efb7
am 746d1e33: Merge "Bug: 21588539 Move CHANGE_NETWORK_STATE to be in SYSTEM_SETTINGS" into mnc-dev
* commit '746d1e3321':
  Bug: 21588539 Move CHANGE_NETWORK_STATE to be in SYSTEM_SETTINGS

Billy Lau   authored and   Android Git Automerger   commited 2015-08-07 22:22:24 +00:00
29ea9fd5c4
Merge "Bug: 21588539 Move CHANGE_NETWORK_STATE to be in SYSTEM_SETTINGS" into mnc-dev
Billy Lau   authored and   Android (Google) Code Review   commited 2015-08-07 22:16:03 +00:00
746d1e3321
Bug: 21588539 Move CHANGE_NETWORK_STATE to be in SYSTEM_SETTINGS
Merge the CHANGE_NETWORK_STATE permission with WRITE_SETTINGS.

AndroidManifest.xml:
Raised the protection level of CHANGE_NETWORK_STATE permission from
normal to signature|appops and pre23|preinstall for compatibility

provider/Settings:
Wrote new helper methods to check if app is allowed to change network
state.

ConnectivityManager.java & ConnectivityService.java:
Replace enforcement checks for CHANGE_NETWORK_STATE with
checkAndNoteChangeNetworkStateOperations instead.

Change-Id: If8c2dd3c76a5324ca43f1d90fa17973216c2bcc5

Billy Lau   commited 2015-08-07 19:29:51 +01:00
16c5d9a6a7
resolved conflicts for merge of 32380993 to mnc-dr-dev
Change-Id: I3a8624b2b375e0d174983d7690082e0e6932c4de

Paul Jensen   commited 2015-08-05 07:07:24 -04:00
41027a921c
Merge "Fix NOT_RESTRICTED network capability and enforce it." into mnc-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2015-08-05 10:03:47 +00:00
3238099342
Fix NOT_RESTRICTED network capability and enforce it.
With this change:
1. NOT_RESTRICTED should be removed from NetworkRequests that bring up
   special restricted carrier networks (e.g. IMS, FOTA).
2. NetworkRequests without NOT_RESTRICTED require CONNECTIVITY_INTERNAL
   permission to register
3. Binding sockets to networks without NOT_RESTRICTED requires
   CONNECTIVITY_INTERNAL permission

Bug:21637535
Change-Id: I5991d39facaa6b690e969fe15dcbeec52e918321

Paul Jensen   commited 2015-08-04 07:24:24 -04:00
bc99fc7d96
am d7208c5c: Merge "Revise lockdown check in getLegacyVpnInfo()" into mnc-dev
* commit 'd7208c5c4a':
  Revise lockdown check in getLegacyVpnInfo()

Hung-ying Tyan   authored and   Android Git Automerger   commited 2015-07-31 02:57:19 +00:00
ce009dd426
Merge "Revise lockdown check in getLegacyVpnInfo()" into mnc-dev
Hung-ying Tyan   authored and   Android (Google) Code Review   commited 2015-07-31 02:51:32 +00:00
d7208c5c4a
Revise lockdown check in getLegacyVpnInfo()
Return null instead of raising exception in lockdown mode.

BUG=22749146

Change-Id: I0e9e3ded0d189e3fa9e872b7af9fe363799c85d6

Hung-ying Tyan   commited 2015-07-30 10:52:25 +08:00
5b36cd3f37
am 7dffaafc: Merge "Fix missing onLost NetworkCallbacks when network loses capability" into mnc-dev
* commit '7dffaafc0d':
  Fix missing onLost NetworkCallbacks when network loses capability

Paul Jensen   authored and   Android Git Automerger   commited 2015-07-30 02:20:49 +00:00
225466b363
Merge "Fix missing onLost NetworkCallbacks when network loses capability" into mnc-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2015-07-30 02:10:50 +00:00
7dffaafc0d
resolved conflicts for merge of 951aabb4 to mnc-dr-dev
Change-Id: I8b33797528f16596f0d350ad38458baa51fcacf6

Paul Jensen   commited 2015-07-29 11:31:53 -04:00
d0b0b466d0
Merge "Disable WiFi autojoin when user decides via "Stay connected?" dialog" into mnc-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2015-07-29 13:52:02 +00:00
951aabb4a7
Fix missing onLost NetworkCallbacks when network loses capability
If a network no longer satisfies a NetworkRequest, send the onLost
NetworkCallback.  If it was a real request (not listen) then update
the NetworkFactories.

To test this change I created a little infrastructure to fake
different Internet connectivity probe results during tests.  This
allowed me to rewrite some of ConnectivityServiceTest's logic for
validating networks.  This brought to light a couple issues that
I had to address to keep tests passing:
1. testUnlingeringDoesNotValidate was relying on a bad side-effect
   of my old method of ConnectivityServiceTest's logic for
   validating networks, so I rewrote the test.
2. ConnectivityService was not sending out NetworkCallbacks for
   WiFi when Cellular was validated.  I'm including a fix for this
   in this CL also.

Bug:22220234
Change-Id: I29314f38189817f8b2561a213c4f9e8522696663

Paul Jensen   commited 2015-07-28 12:19:32 -04:00
8c23d5f652
am e288b3af: Merge changes I5c994de5,I6cb0dd84 into mnc-dev
* commit 'e288b3af14421731d8f477b97e8d77588f20498b':
  Add a test for public bugs 2111 and 2136.
  Always check off-link connectivity in NetworkDiagnostics.

Lorenzo Colitti   authored and   Android Git Automerger   commited 2015-07-28 01:20:16 +00:00
b5f86615b6
Always check off-link connectivity in NetworkDiagnostics.
Currently, NetworkDiagnostics only checks off-link connectivity if
one of the DNS servers is off-link. Make it check off-link
connectivity in all cases by sending probes to Google Public DNS
if off-link DNS servers are not specified.

Bug: 22569331
Bug: 22641669
Bug: 22748900
Change-Id: I6cb0dd8491bc0c1a488631deca56722b9c1d2b3f

Lorenzo Colitti   commited 2015-07-27 16:41:44 +09:00
994ba7343f
Pass signal strength thresholds inside a Bundle
Bug: 21407651
Change-Id: I2c80e89441e2eb15a246cb1fa9347f886cefa80f

Erik Kline   authored and   Prerepa Viswanadham   commited 2015-07-18 17:28:52 +00:00
2308195d12
Support NetworkCallbacks based on signal strength.
Bug: 21405941
Change-Id: I2ed8a5aeb8dac464a4305671ed22abcacb485bc9

Lorenzo Colitti   authored and   Prerepa Viswanadham   commited 2015-07-18 17:28:26 +00:00
87f93fe6f4
ConnectivityManager API for for packet keepalives.
Bug: 21405946
Change-Id: Ie1f8f8bee684fe2bb1092a9f1bc9f5dc29b1defc

Lorenzo Colitti   authored and   Prerepa Viswanadham   commited 2015-07-18 17:00:13 +00:00
d1039d1731
Make immutable NetworkCapabilities more explicit.
Bug: 21405941
Change-Id: Iafd738c31747b0f5f9356bed1c97f5f282830af1

Lorenzo Colitti   authored and   Prerepa Viswanadham   commited 2015-07-18 16:59:47 +00:00
6d71af1f53
Disable WiFi autojoin when user decides via "Stay connected?" dialog
If the user selects "No" in the "Stay connected?" dialog box:
1. Disable autojoining that network in the future, and
2. Disassociate from that network.

Bug:22187193
Change-Id: I14dc9236c57e3ab7d3ec95edc906787cbfbf3c9f

Paul Jensen   commited 2015-07-16 14:41:18 +00:00
4afac2378d
Merge "Log NetworkRequestInfo to get more detailed history" into mnc-dev
Erik Kline   authored and   Android (Google) Code Review   commited 2015-07-14 04:09:29 +00:00
c2ce3ff6dd
Log NetworkRequestInfo to get more detailed history
Bug: 21641983
Bug: 22235775
Bug: 22299819
Bug: 22358164
Change-Id: I48a2d162dd499a3590f06d805267a63822856969

Erik Kline   commited 2015-07-14 11:46:51 +09:00
47401fa30e
Fix filter on CONNECTIVITY_ACTION updates
Only send for network types which the network supports.

bug:22411968
Change-Id: I97765544eb653caf0ea4fc5d3feec5742d5d88dc

Robert Greenwalt   commited 2015-07-10 16:26:40 -07:00
dd1e223ce9
Merge "Legacy VPN calls to require a userID" into mnc-dev
Robin Lee   authored and   Android (Google) Code Review   commited 2015-07-10 19:05:38 +00:00
90a455062e
Fix build break.
Automatic merge commit caused breakage due to someone else's
intervening change adding a call site of a function whose last
parameter I removed.  Function in question is
ConnectivityService.rematchAllNetworksAndRequests.
Changes that merged badly are ece7dfa and 41c19a0.

Change-Id: I8fd32e1a187236a65c1b7c0ecdf17b817d108fd0

Paul Jensen   commited 2015-07-10 12:29:23 -04:00
823ea71ef3
Merge "Fallback to Cellular if WiFi fails to validate" into mnc-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2015-07-10 15:51:38 +00:00
9eb4dd2df9
Merge "Prepare some ConnectivityService logic for fallback to Cellular change" into mnc-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2015-07-10 15:51:23 +00:00
36d8b23b1e
Merge "Add android.net.CaptivePortal class for captive-portal-handling-app callbacks" into mnc-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2015-07-10 14:57:13 +00:00
86599d6a2a
Add android.net.CaptivePortal class for captive-portal-handling-app callbacks
This new class replaces the awkward string token and ConnectivityManager APIs
used by apps handling captive portals.

Bug:21343774
Change-Id: I1a2c69edb17322715bf8422bb4216b0ea60bfd59

Paul Jensen   commited 2015-07-09 10:47:34 -04:00
4173cceaea
Fallback to Cellular if WiFi fails to validate
Previously, once a network validated, for the purposes of comparing networks
to select the default network, we always considered it validated.
With this change if a network later fails to validate, we'll take this latest
validation result into account.  This means if WiFi and cellular are up
(e.g. if we recently switched from cellular->WiFi, and cellular is now
lingering) and both are validated, but for some reason WiFi fails a validation,
cellular will become the default network connection.

Bug:20896761
Change-Id: I858aa10c1aaec5cd9032067f960963409107bdb1

Paul Jensen   commited 2015-07-09 10:26:17 -04:00
25eb5fd97e
Prepare some ConnectivityService logic for fallback to Cellular change
Reduce the duplication of some logic so when falling back to Cellular
when WiFi fails to validate is enabled, there's less chance for bugs
and failures:
1. De-duplicate several Network vs NetworkRequest matching functions
2. Remove the very tricky nascent logic by adding a simple "lingering" bit.

Bug:20896761
Change-Id: I21da9e827eec9cfd6835fcaa650192b9186ed053

Paul Jensen   commited 2015-07-09 10:26:08 -04:00
ece7dfac67