Commit graph android_packages_modules_Co.../services/core/java
Message SHA1
Add debug output for bad wifi avoidance restrictions.
Bug: 31075769
Change-Id: Ibd97f40917c946aa164c13c7e06c4696d21dc203

Lorenzo Colitti   commited 2016-09-20 22:01:39 +09:00
7dabed84b5
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

Lorenzo Colitti   commited 2016-09-20 16:03:53 +09:00
e98557f85a
Update the avoid bad wifi settings on the handler thread.
Currently, every call to avoidBadWifi fetches the current value
of the config variable and setting whenever it is called. This
means that the score of an unvalidated wifi network can
unpredictably change at any time, creating a data race.

Instead, persist the value and only update it when something
changes.

Bug: 31075769
Change-Id: I0f4e0e742c91ef77fabc95d3ebb494338396aca5

Lorenzo Colitti   commited 2016-09-17 00:57:38 +09:00
49d32fe109
Unit tests for avoid bad wifi networks setting.
Bug: 31075769
Change-Id: I21ba20df59ddce5731ef1ebe8846b3f00578a674

Lorenzo Colitti   commited 2016-09-15 23:45:07 +09:00
71b4d66e16
Support displaying a dialog when wifi becomes unvalidated.
Bug: 31075769
Change-Id: I7a6e7580769365bea930f638bd44edcaa28df134

Lorenzo Colitti   commited 2016-09-15 23:33:34 +09:00
477bf5caa9
Support ignoring penalty for bad wifi networks
This patch adds a way to configure devices so that a validated network
that becomes unvalidated is not penalized in the network scoring and
selection logic.

The intent is to prevent devices configured to do so from switching to a
lower scoring network such as cellular networks when a higher scoring
network such as wifi networks loses internet connectivity.

Bug: 31075769
Change-Id: Ie7e0f2607d214a178367fedfbef6c44768fa00a4

Hugo Benichi   commited 2016-09-15 18:34:13 +09:00
4fc79c45d2
Explicitly pass old score to updateCapabilities
This allows simplification of getCurrentScore function in
NetworkAgentInfo and its return value to depend on everValidated and
lastValidated.

Bug: 31075769
Change-Id: I0b3c85e3a61b006733e900e0a231424878317476

Hugo Benichi   commited 2016-09-15 18:33:23 +09:00
810f4917c2
Network switch notifications: rate & daily limits
This patch adds a daily limit to the maximum number of notifications
shown when switching networks.

It also adds a rate limit to prevent rapid successive notifications in
flapping scenarios.

Bug: 31132499
Change-Id: Iccb6d0899646ea6df3cfad32a421922263e0eb85

Lorenzo Colitti   authored and   Hugo Benichi   commited 2016-08-31 00:36:11 +09:00
e5ebb71a81
Network Switching Notifications: add unit tests
BUG: 31132499
Change-Id: I9c50a59fe48efdcb51d2517f0a756691700c3ebe

Hugo Benichi   commited 2016-08-31 00:35:16 +09:00
550ad8d1d0
Don't notify on network switch if source network is validated.
Sometimes we switch away from a network to another (e.g., wifi to
cell data) not because the old network is unvalidated, but
because the score is lowered by a low signal strength.

In this case, don't notify the user of a network switch.

Bug: 31132499
Change-Id: I996a6e00096f8cb864fa9b00b36921725a4edb53

Lorenzo Colitti   commited 2016-08-29 16:30:21 +09:00
673e80f021
Support notifying network switches via notifications and toasts.
Bug: 31025214
Change-Id: If1578f422f38a1dcfaec529882aed01ae5e8d53c

Lorenzo Colitti   commited 2016-08-25 18:14:18 +09:00
b268f9f554
Refactor NetworkNotificationManager.
1. Move from deprecated network types to transport types.
2. Rename and simplify (by passing in a NetworkAgentInfo object)
   the call signature of the method that displays notifications.
3. Add a method to clear notification, and unindent lots of code.
4. Move the legacy DcTracker-issued notification code to
   NetworkNotificationManager.

Bug: 31025214
Change-Id: Ie49c60126d0ed5bac620bc47e84fe038791b2d6c

Lorenzo Colitti   commited 2016-08-23 17:57:46 +09:00
eb166f447b
Move notification code out of ConnectivityService.
Bug: 31025214
Change-Id: I4190be6b57f92298b79bea8868f1876ecbfd2d75

Lorenzo Colitti   commited 2016-08-23 15:31:59 +09:00
7d31cc0021
IpConnectivityMetrics: no metrics upload in tests
Similarly to ApfTest, this patch changes ConnectivityServiceTest to use
a mock object instead of IpConnectivityLog so that running
ConnectivityServiceTest does not generate android.net.metrics events.

Bug: 30450301
Change-Id: Ibc0479f381f26e60baefbae15407c62aecbf6666

Hugo Benichi   commited 2016-07-29 16:58:35 +09:00
638621a1f9
Add CONNECTIVITY_USE_RESTRICTED_NETWORKS permission
This patch creates a new permission used by ConnectivityService to give
access to restricted networks without the NET_CAPABILITY_NOT_RESTRICTED
capability bit on.

Bug: 24497316
Change-Id: I5b6c8a9ef14395b2f1ab26cb17b24d7876ec79f1

Hugo Benichi   commited 2016-07-25 10:24:42 +09:00
c4899354b0
Add an isListen method to NetworkRequests.
This allows simplification of the ConnectivityService code.

Bug: 23113288
Change-Id: I124544b99c5a920124e9a3d31cda8c6d2abc21fd

Lorenzo Colitti   commited 2016-07-18 18:42:26 +09:00
6737b64741
ConnectivityService dump: add apps blocked logs
This patch adds NetworkInfo BLOCKED/UNBLOCKED status of apps to
ConnectivityService's dump logs.

The BLOCKED or UNBLOCKED status of an app is logged with the app uid
when the app calls getActiveNetworkInfo().

Examples:
mNetworkInfoBlockingLogs (most recent first):
  07-11 11:04:43.139 - BLOCKED 10060
  07-11 11:04:39.056 - UNBLOCKED 10061
  07-11 11:04:38.851 - BLOCKED 10061

Bug: 29981766
Change-Id: I6e2fde446702b92b0964ed894409b5d733d8f8a7

Hugo Benichi   commited 2016-07-12 11:39:48 +09:00
7b3bf37ac3
Support requesting async LinkProperties/NetworkCapabilities updates
Bug: 9580643
Change-Id: I1d7ba7645c20d7d53f6eef777dfce43727940f13

Erik Kline   commited 2016-07-11 19:17:41 +09:00
aec3f5ef5b
Rewrite lingering.
The two major changes here are:

- Move lingering out of NetworkMonitor. The fact that lingering
  is currently its own state in NetworkMonitor complicates the
  logic there: while a network is lingering it cannot be in any
  other state, we have to take care not to leave LingeringState
  for the wrong reason, etc.
- Instead of keeping a single per-network boolean to indicate
  whether a network is lingered or not, keep a linger timer for
  every request. This allows us to fix various corner-case bugs
  in lingering.

The changes in behaviour compared to the current code can be seen
in the unit test changes. Specifically:

1. Bug fix: when a network is lingered, and a request is added
   and removed to it, the existing code tears the network down
   immediately. The new code just sends another CALLBACK_LOSING
   and resumes lingering with the original timeout.
2. Bug fix: if cell is unvalidated and wifi comes up and
   validates before cell does (as might happen on boot), the
   existing code immediately tears down cell. The new code
   lingers cell, which is correct because unvalidated cell was
   the default network, so an app might have been using it.
3. Correctness improvement: always send CALLBACK_AVAILABLE for
   the new network before sending CALLBACK_LOSING. This was not
   really an issue in practice, because the usual flow is:
    - Network A is the default.
    - Network B connects, CALLBACK_AVAILABLE.
    - Network B validates, CALLBACK_LOSING.

Bug: 23113288
Change-Id: I2f1e779ff6eb869e62921a95aa9d356f380cf30a

Lorenzo Colitti   commited 2016-07-07 16:18:57 +09:00
70c70fa7e2
Prepare to delete useless loop in handleReleaseNetworkRequest.
As explained in the TODO, the loop serves no purpose since only
one network can be satisfying a given request at a time.

Instead of looping, look up the nai in the mNetworkForRequestId
array that exists for this purpose.

Keep the loop around with an Slog.wtf statement on it so we can
see if we ever hit it, and add a TODO to delete it if we don't.

Bug: 23113288
Change-Id: I173de4bd45c5a4169b7a062a981f2ecccaa44143

Lorenzo Colitti   commited 2016-07-07 14:50:12 +09:00
daeb6109e1
Merge "Unbreak unregisterNetworkCallback." into nyc-mr1-dev
Lorenzo Colitti   authored and   Android (Google) Code Review   commited 2016-07-05 02:07:06 +00:00
04401f0e0f
Unbreak unregisterNetworkCallback.
http://ag/1194313 broke unregisterNetworkCallback because the
system does not parcel the type of the request back to the app.
So when the app calls unregisterNetworkCallback, the
NetworkRequest that's passed in does not have a type and thus
doesn't match the request in mNetworkRequests.

Fix this by parceling over the type as well.

This was not caught by the unit test because the unit test all
runs in the same process with no parceling.

Bug: 23113288
Change-Id: I58b2ed651b9bf5cbdcca5b25c3ca24db53cffdf1

Lorenzo Colitti   commited 2016-07-05 01:59:49 +09:00
cef9c490ad
Merge "Annotate public methods in ConnectivityService." into nyc-mr1-dev
TreeHugger Robot   authored and   Android (Google) Code Review   commited 2016-07-04 16:07:33 +00:00
ad7755209c
Make registerDefaultNetwork work on metered networks.
Bug: 29927488
Change-Id: I3b705c2ab0d1493546ffa5185bb5b07d5e25c897

Lorenzo Colitti   commited 2016-07-04 23:18:12 +09:00
34eda2aa6f
Annotate public methods in ConnectivityService.
Ensure every public method is annotated with why it's public.
This can be either an @Override or @VisibleForTesting annotation
or a comment explaining why it's public.

Bug: 29927488
Change-Id: I3582aef7997dc0d723718ca5e3dd115647d22979

Lorenzo Colitti   commited 2016-07-04 12:58:29 +09:00
10e796c35d
Make the NetworkRequest list private to NetworkAgentInfo.
This allows us to keep track of how many live requests a network
is satisfying without having to count them every time.

Bug: 23113288
Change-Id: Ic4756676491e09071dbf80b7c48da3be028d68eb

Lorenzo Colitti   commited 2016-07-01 21:14:26 +09:00
e0d1a03d4e
Move the request type from NetworkRequestInfo to NetworkRequest.
This will allow us to simplify code that deals with
NetworkRequests outside ConnectivityService.

Bug: 23113288
Change-Id: I9b3a859d0c68cad73d7f6baa4b584d13ffd2ae36

Lorenzo Colitti   commited 2016-07-01 20:15:19 +09:00
a4505cafab
Refactor IP connectivity event logging
This patch removes static methods for logging IP connectivity events
defined in android.net.metrics and replaces them with a single log()
instance method defined on IpConnectivityLog. Event constructors are
now public also. Every classes logging such events now create an
instance of IpConnectivityLog for logging event objects directly
instantiated with new.

Removing static dependencies allow straightforward testing of logging.

This patch also removes the base IpConnectivityEvent class which is not
needed any more.

Bug: 29035129
Change-Id: I3de700f93f46deaa48a759f938f7d00e1d8bff98

Hugo Benichi   commited 2016-06-29 14:28:51 +09:00
3bdc8357fe
Fix unsafe concurrent access in LegacyTypeTracker
This patch adds synchronization inside LegacyTypeTracker so that
getNetworkForType() can safely run concurrently with remove().

Without synchronization if remove() removes the last network for a
given type while getNetworkForType() runs for the same type, it is
possible that getNetworkForType tries to access the head of an empty
list, resulting in a runtime exception.

This issue was found by zoran.jovanovic@sonymobile.com who proposed a
fix in AOSP (Change-Id: Ia963662edb9d643790e8d9439e4dbdcac4c2187b).

This patch differs from the fix proposed by the bug reporter and tries
instead to do the minimum amount of locking to make getNetworkForType
safe.

Bug: 29030387
Change-Id: I915aac527fc8828b32bf35fee870add2dfb11d8d

Hugo Benichi   commited 2016-06-27 15:04:27 +09:00
9c807fdcd4
resolve merge conflicts of fa2715e to nyc-mr1-dev
Change-Id: If0a1e7e70aa33e99f05694a37c2a54c567449507

Felipe Leme   commited 2016-06-21 13:12:53 -07:00
7d0177d5d7
Ignore system apps on enforceMeteredApnPolicy().
BUG: 29514913
Fixes: 29448383
Change-Id: I19eb004c937e1c872bbf82caa7a919e43d48a259

Felipe Leme   commited 2016-06-20 17:15:46 -07:00
ff76014fe8
Merge \"Move \'is already always-on\' check into Vpn.java\" into nyc-dev
am: 6a58c98cef

Change-Id: I6532f2e654cfd9df8ee6c649344b0b915a8381c1

Robin Lee   authored and   android-build-merger   commited 2016-06-16 10:10:23 +00:00
f062d0b193
Merge "Move 'is already always-on' check into Vpn.java" into nyc-dev
Robin Lee   authored and   Android (Google) Code Review   commited 2016-06-16 10:06:11 +00:00
6a58c98cef
Move 'is already always-on' check into Vpn.java
It's with the rest of the logic now and allows checking whether the
lockdown state matches, too, which led to a lot of misunderstandings.

Fix: 29199431
Change-Id: I94a2c38c4837f9c33b5b9c2becb52eeb7e2a2534

Robin Lee   commited 2016-06-14 13:24:17 +00:00
a4325d282c
Merge \"Show sign-in to network notification to all users, not just owner.\" into nyc-dev
am: 634bd0eb4e

Change-Id: I4522f765c6166bd1c8216088b1605eac4c69d869

Paul Jensen   authored and   android-build-merger   commited 2016-06-14 11:16:12 +00:00
6715499061
Merge "Show sign-in to network notification to all users, not just owner." into nyc-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2016-06-14 11:05:32 +00:00
634bd0eb4e
Show sign-in to network notification to all users, not just owner.
All users should be made aware a captive portal is in place and be
given the opportunity to sign into the network.  Without this fix
other users are not notified and given a chance to sign-in.

Change-Id: I1bf823d5f6a36f391dca4be5f6a584e8562a72a7
Fixes: 23079964

Paul Jensen   commited 2016-06-13 09:39:28 -04:00
efffb79661
Merge \"Package changed/removed listeners for always-on VPN\" into nyc-dev
am: ee5e4cc836

Change-Id: I8f7054b5a2ac69677a0e124e9a616b3d58b604af

Robin Lee   authored and   android-build-merger   commited 2016-06-08 10:50:42 +00:00
198d78012d
Merge changes Ic98e3bcb,Idb0c55fc,Ia8649061,I5e7e5a87 into nyc-mr1-dev
* changes:
  Give WakeupMessage the ability to transport an object as well.
  Don't treat the lingerExpired broadcast specially.
  Add a test for mobile data always on.
  Add a FakeSettingsProvider and use it in ConnectivityServiceTest.

TreeHugger Robot   authored and   Android (Google) Code Review   commited 2016-06-08 06:35:32 +00:00
ec79b10313
Add a test for mobile data always on.
Bug: 23113288
Change-Id: Ia8649061a797367d135bb5576600a7cdc85a822e

Lorenzo Colitti   commited 2016-06-08 14:08:59 +09:00
6caa9fe143
Package changed/removed listeners for always-on VPN
Fix 2 problems of always-on vpn after always-on package is removed
1. Prevent network being locked down (blocking all network traffic)
   Otherwise, user has no way to download the vpn app from Play Store,
   and never be able to gain control of the network again.
2. Allow user to connect other vpn app.

Implementation
1. Switch off always-on mode if the package gets removed.
2. Restart always-on mode if the package gets replaced/upgraded.

Bug: 29050764
Change-Id: Id3e389ae0b11c6002a5167919292d9634c2014cb

Robin Lee   commited 2016-06-06 15:42:50 +00:00
2073a5c734
Merge "Include network name in validation logs for dumpsys" into nyc-dev
am: daef5224d1

* commit 'daef5224d1':
  Include network name in validation logs for dumpsys

Change-Id: Ic5345cb7f309e509c7b9d7cb7b7ec4b95b8f1102

Paul Jensen   authored and   android-build-merger   commited 2016-06-06 11:23:51 +00:00
8a3ecc71d8
Merge "Include network name in validation logs for dumpsys" into nyc-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2016-06-06 11:08:45 +00:00
daef5224d1
Merge "Fix that fail to setup any vpn after Network Settings reset and always-on vpn is on" into nyc-dev
am: 265f4113ee

* commit '265f4113ee42e89f324b087a81044a9f1dab457e':
  Fix that fail to setup any vpn after Network Settings reset and always-on vpn is on

Change-Id: I86a8f5c9b2dbd8ea71bdc8fb6268f3d9dc7e329d

Victor Chang   authored and   android-build-merger   commited 2016-06-06 10:30:42 +00:00
0ca903017c
cold sim clean up
- add a new field: provisioningNotificationEnabled from NetworkMisc. set
  to false if we want to hide "sign in" notification and placed
  carrier-specific notification instead. it is set on connect, once set,
  it is carrier-app's responsibility to post new UI to users
- rework on the interaction between carrier app and framework
- code cleanup
- unit test support

Bug: 28567303
Change-Id: Ic84db7ffbb920d15344717f104496d3cb82e1a85

fionaxu   commited 2016-06-03 11:45:12 -07:00
5447c49f01
Include network name in validation logs for dumpsys
Previously this was included in the log messages from NetworkMonitor
but that has been removed (ag/944107), making it frequently impossible
to know what network the logs apply to as there may be no way to
correlate NetIDs to WiFi SSIDs or Cellular networks if the log has wrapped.

Bug: 26075613
Change-Id: I2e3cd41fffb616ab9f855cb16790360bd3414793

Paul Jensen   commited 2016-06-03 13:51:21 -04:00
72b24b1b5b
Fix that fail to setup any vpn after Network Settings reset and always-on vpn is on
Cause: It revoked the user consent of the vpn app without reseting always-on vpn.
In addition, prepareVpn sets legacy vpn as the current package, the state in
Vpn.class is broken, as it thought the current always-on package is legacy vpn,
(mAlwaysOn is only for app vpn, not for legacy vpn). As a result, prepareVpn rejects
all VpnService.prepare.

Bug: 29031820
Change-Id: Id6bf1d6f38cf134a872811806301b8a602fb5725

Victor Chang   commited 2016-06-03 17:14:32 +01:00
4754f8d47f
Merge "Return legacy VPN info regardless of lockdown mode" into nyc-dev
Robin Lee   authored and   Android (Google) Code Review   commited 2016-05-25 21:05:55 +00:00
ca9615bb20
Merge "Fix default network transition event recording" into nyc-dev
Hugo Benichi   authored and   Android (Google) Code Review   commited 2016-05-25 03:22:32 +00:00
3cd6a8b85d
Fix default network transition event recording
When disconnecting from a default network X and falling back on another
connected network Y as the new default, ConnectivityService was
attempting to record this event as a X -> Y "atomic" transition.

In practice the default network connectivity is actually lost and
recovering default network takes some non-zero time.

This patch changes the event recording to always record disconnection as
X -> 0 events. At the same time, if there is a fallback network that is
elected as the new default ConnectivityService will also record a 0 -> Y
event.

This patch also improves pretty-printing of DefaultNetworkEvent.

Extract from $ adb shell dumpsys connectivity_metrics_logger --events
17:51:00.086: DefaultNetworkEvent(0 -> 100:CELLULAR)
17:51:25.232: DefaultNetworkEvent(100:IPv4 -> 101:WIFI) # wifi goes on
17:51:44.064: DefaultNetworkEvent(101:DUAL -> 0)        # wifi goes off
17:51:44.187: DefaultNetworkEvent(0 -> 100:CELLULAR)

Bug: 28204408
Change-Id: I63252633235bf6ba833b9ac431a80dda75a93e67

Hugo Benichi   commited 2016-05-25 10:03:38 +09:00
3f34b66e47