Commit Graph

2398 Commits

Author SHA1 Message Date
Jeff Davidson
5210fa503f Implement roaming tracking in NetworkStats summary queries.
Whether a network is deemed roaming or not was already being tracked
as part of the NetworkIdentitySet, so the underlying data store
already tracks roaming and native data separately. However, this data
was being aggregated together in NetworkStatsCollection#getSummary,
since the NetworkIdentitySet is converted to an iface name for the
purposes of matching, and the iface name will be identical whether or
not the iface is considered roaming. Now it is separated.

Also fixes a long-standing bug in NetworkIdentitySet where an identity
read from a saved file would always be considered roaming == false,
even if it wasn't at the time it was written.

Bug: 25813438
Change-Id: I11ab5b51182ed8da7af8fde468df065f9fdc3dad
2016-01-19 16:57:51 -08:00
Jeremy Klein
0486333736 Add a TETHER_PRIVILEGED permission and use it where needed.
BUG: 26247383
Change-Id: I73f7227d77926faa9081e83eccb83c8ddee33e08
2016-01-07 10:11:24 -08:00
Alex Cheung
cd858e2dbd Use "merge -s ours origin/mirror-partner-mm-wireless-dev" as described in b/26154276 2015-12-23 14:48:52 -08:00
Jeff Davidson
e993bb4c8e Merge "Relax permissions around NetworkStatsManager APIs." 2015-12-15 19:04:25 +00:00
Jeff Davidson
7b376e8c8e Merge "Fix bit-rotted NetworkStatsServiceTest." 2015-12-15 17:48:46 +00:00
Lorenzo Colitti
50461077fe Merge "Remove defunct EVENT_SEND_STICKY_BROADCAST_INTENT." 2015-12-15 13:24:52 +00:00
Jeff Davidson
1046856083 Relax permissions around NetworkStatsManager APIs.
Currently, access to network usage history and statistics requires a
signature|privileged permission, an AppOps bit (associated with the
PACKAGE_USAGE_STATS permission), or device/profile ownership. Once
access is granted via one of these mechanisms, it generally applies to
any UID running in the same user as the caller.

This CL expands access as follows:

-Any app can access its own usage history with no extra requirements.
-Carrier-privileged applications can access usage history for the
entire device.
-Device owners can access per-UID breakdowns for usage. Previously
they could access the summary for the whole device, but not the
individual breakdowns.

We simplify the permission model by defining three access levels -
DEFAULT (own app only), USER (all apps in the same user), and DEVICE
(all apps on the device), and propagate these levels throughout.

Finally, this CL fixes an apparent bug in
NetworkStatsSerice#hasAppOpsPermissions - if the AppOp bit was in
MODE_DEFAULT, hasAppOpsPermission would always return false instead of
falling back to the PackageManager permission check.

Bug: 25812859
Bug: 25813856
Change-Id: Ic96e0776e2a4215a400163872acea1ededfaced9
2015-12-14 17:16:37 -08:00
Jeff Davidson
86bc22e37f Fix bit-rotted NetworkStatsServiceTest.
Breakages:

-ag/574873 - Renders testReportXtOverDev obsolete as this is no longer
             a supported mode. Test has been removed.
-ag/600223 - Tests were sending a CONNECTIVITY_ACTION bcast to trigger
             a call to updateIfaces(), but the listener was removed.
             Tests now call forceUpdateIfaces() directly.
-ag/648284 - Calls to get VPN info were not mocked.

Change-Id: I309f2b5d006549104cb1d3cb83e99363dd6dac16
2015-12-14 13:05:30 -08:00
Baligh Uddin
7f18ef2523 empty commit to trigger build
Change-Id: I3ec926126a0d9ee7d64ffc70ca7aa7c6c9e2a9c6
2015-12-13 18:01:17 +00:00
Tyler Gunn
6c194d9014 Merge commit 'da131290ae5e476691e05e5eb4ac6d507012a0ac' into mncvtdev-to-mmwirelessdev-merge-2015-12-10 2015-12-10 20:05:46 -08:00
Tyler Gunn
5ab5b554ab Merge commit '70da83381f77e0ee9ada47eafaae395038ff77ad' into mncvtdev-to-mmwirelessdev-merge-2015-12-10 2015-12-10 20:04:17 -08:00
Tyler Gunn
92d8863f70 Merge commit '98bd72181e176cdc5536b9709127a71cca082bbf' into mncvtdev-to-mmwirelessdev-merge-2015-12-10 2015-12-10 19:59:27 -08:00
Christopher Tate
75fb864e80 DO NOT MERGE Introduce direct listener API for alarm delivery
The Alarm Manager now supports a set() variant that takes a listener
callback to invoke at alarm trigger time rather than a PendingIntent.
This is much lower overhead and has guaranteed low delivery latency
from the trigger time.  The tradeoff is that the app must be running
*continuously* from the time the alarm is set to the time it is
delivered.  If the app exits for any reason before the alarm fires,
the listener becomes invalid and the alarm will be dropped.  This is
more or less equivalent to setting an alarm with a broadcast
PendingIntent that matches only a runtime-registered receiver.

The app's alarm listener can be any object that implements the new
AlarmManager.OnAlarmListener interface and implements its onAlarm()
method.  There is no data delivered at alarm trigger time: whatever
state needs to be associated with the specific alarm instance should
simply be packaged inside the OnAlarmListener instance.

An alarm using OnAlarmListener can request that the onAlarm() method
be called on an arbitrary handler.  If the program passes 'null' for
this parameter when setting the alarm, the callback occurs on the
application's main Looper thread.

Cherry-picked from b481a892d2
Bug 20157436

Change-Id: I2eb030a24efdd466a2eee1666c5231201b43684b
2015-12-10 16:06:50 -08:00
Jan Nordqvist
5dbd59feb2 DO NOT MERGE Hotspot 2.0 relase 2 first cut.
CP mods to take a URL as a parameter, and new ScanInfo object.

Cherry-picked from 0f3b4449b0
Change-Id: Idbb2d4751c575ba07a56942771e2b2955b624635
2015-12-10 16:06:50 -08:00
Dianne Hackborn
6782e22930 Add new target SDK filtering feature to BroadcastOptions.
You can now control the range of target SDKs that receivers
will be need to have in order to receive your broadcast.

Use this for CONNECTIVITY_ACTION to not allow N+ applications
to receive these broadcasts through their manifest.

Also tweak the broadcast debug output code to now include the
disposition of each receiver in the list.  This is becoming
important as skipping receivers is becoming a more common
thing to have happen.

Change-Id: I251daf68575c07cbb447536286ab4e68b7015148
2015-12-10 12:12:00 -08:00
Lorenzo Colitti
048896e466 Remove defunct EVENT_SEND_STICKY_BROADCAST_INTENT.
http://ag/572619 , which removed the 3-second CONNECTIVITY_ACTION delay,
removed its only caller, but missed removing the message declaration
and processing code.

Bug: 20013379
Change-Id: Ice573569715ba424b8bf66d1dd08184d2b4a60f1
2015-12-10 13:08:35 +00:00
Tyler Gunn
18d1c7d77a Merge commit 'da131290ae5e476691e05e5eb4ac6d507012a0ac' into tgunn-mncvtdev-to-master-2015-12-04 2015-12-04 21:05:15 -08:00
Tyler Gunn
83223f9090 Merge commit '70da83381f77e0ee9ada47eafaae395038ff77ad' into tgunn-mncvtdev-to-master-2015-12-04 2015-12-04 21:04:44 -08:00
Tyler Gunn
a603141563 Merge commit '98bd72181e176cdc5536b9709127a71cca082bbf' into tgunn-mncvtdev-to-master-2015-12-04 2015-12-04 21:00:51 -08:00
Lorenzo Colitti
5cce267ba3 Don't match network requests to legacy API requests.
Currently, we look at network requests that are created by the
current requestNetwork API to see if they look like requests
that could have been created using the legacy
startUsingNetworkFeature API.

This causes those networks to be added to LegacyTypeTracker,
and so cause CONNECTIVITY_ACTION broadcasts, be accessible
using getNetworkInfo(int type), etc. This was done in the L
timeframe so that apps could request networks using the
then-new requestNetwork APIs and still use them using legacy
APIs such as requestRouteToHost.

However, the resulting CONNECTIVITY_ACTION broadcasts are
expensive. requestRouteToHost has been deprecated since L, and
mixing the old and new APIs was never recommended, so it's time
to delete this hack.

Bug: 22513439
Bug: 23350688
Bug: 25295964
Change-Id: Id867058446e5ee44396743d126d26fa57da0c990
2015-11-27 11:46:19 +09:00
Lorenzo Colitti
eb3e2c47a3 Fix one of the breakages of ConnectivityServiceTest in master.
Change-Id: I31c7a019383fa589beb1572486700e54edfb97e8
2015-11-27 11:46:18 +09:00
Lorenzo Colitti
bbb3607bec Merge "Fix javadoc for the NetworkRequest version of requestNetwork." 2015-11-26 08:16:51 +00:00
Lorenzo Colitti
4c9cc847f7 Fix javadoc for the NetworkRequest version of requestNetwork.
The documentation for this method says that the request can be
released using releaseNetworkRequest, but that's not true.
releaseNetworkRequest only takes a PendingIntent, and can only be
used to release a request filed with a PendingIntent.

Fix the docs to say that the request needs to be released using
unregisterNetworkCallback.

Change-Id: If044fd2d463ab8d09874172d5d56946251057a3c
2015-11-26 17:06:20 +09:00
Lorenzo Colitti
716c073e63 Make the new NetworkRequest flavour consistent with the others.
Change-Id: I491eb0b6d2fa0f1c472c97ef403488407e71803e
2015-11-25 15:47:14 +09:00
Lorenzo Colitti
508689c5e2 Merge "Temporarily add a requestNetwork flavour that takes a legacy type" 2015-11-25 06:37:25 +00:00
Lorenzo Colitti
873f7bb0b7 Temporarily add a requestNetwork flavour that takes a legacy type
This method is public @hide to support progressive refactoring of
tethering away from startUsingNetworkFeature to requestNetwork,
without getting in the way of the CONNECTIVITY_ACTION cleanup in
b/22513439 .

Bug: 9580643
Bug: 22513439
Change-Id: I9053ec746cc8f415a2d5849f044667eeb14e1b19
2015-11-25 12:00:52 +09:00
Sreeram Ramachandran
0844e31d96 Don\'t use framework permission strings for netd permissions. am: 2c4e4c95e0 am: a40a3e6bf4 am: e55b156581 am: d3b6e2d790 am: 934b45022a am: 8b05ea51ad am: 4d2ed63c65 am: 6d983179a0 am: 5d41bd8d1a am: c1552f0caf am: 38a3b2154c
am: d6832351c9

* commit 'd6832351c9516926d021045417750c175c5cf4c5':
  Don't use framework permission strings for netd permissions.
2015-11-20 03:52:20 +00:00
Sreeram Ramachandran
d6832351c9 Don\'t use framework permission strings for netd permissions. am: 2c4e4c95e0 am: a40a3e6bf4 am: e55b156581 am: d3b6e2d790 am: 934b45022a am: 8b05ea51ad am: 4d2ed63c65 am: 6d983179a0 am: 5d41bd8d1a am: c1552f0caf
am: 38a3b2154c

* commit '38a3b2154c7ee5d75b5670abaa4c154edd3c36eb':
  Don't use framework permission strings for netd permissions.
2015-11-20 01:52:25 +00:00
Sreeram Ramachandran
84376d950f Don\'t use framework permission strings for netd permissions. am: 2c4e4c95e0 am: a40a3e6bf4 am: e55b156581 am: d3b6e2d790 am: 934b45022a am: 8b05ea51ad am: 4d2ed63c65 am: 6d983179a0
am: 5d41bd8d1a

* commit '5d41bd8d1acd894cef1aff9018614194df6f95ab':
  Don't use framework permission strings for netd permissions.
2015-11-19 17:20:14 +00:00
Sreeram Ramachandran
4d2ed63c65 Don\'t use framework permission strings for netd permissions. am: 2c4e4c95e0 am: a40a3e6bf4 am: e55b156581 am: d3b6e2d790 am: 934b45022a
am: 8b05ea51ad

* commit '8b05ea51adab2a057ed0367472d194c2dc29a0bc':
  Don't use framework permission strings for netd permissions.
2015-11-19 16:50:11 +00:00
Sreeram Ramachandran
8b05ea51ad Don\'t use framework permission strings for netd permissions. am: 2c4e4c95e0 am: a40a3e6bf4 am: e55b156581 am: d3b6e2d790
am: 934b45022a

* commit '934b45022aaaee96a43768ac1c498c6a49f7b2cd':
  Don't use framework permission strings for netd permissions.
2015-11-19 16:40:35 +00:00
Sreeram Ramachandran
934b45022a Don\'t use framework permission strings for netd permissions. am: 2c4e4c95e0 am: a40a3e6bf4 am: e55b156581
am: d3b6e2d790

* commit 'd3b6e2d790f95f2fb3d85f0993b90bb8708a6114':
  Don't use framework permission strings for netd permissions.
2015-11-19 16:30:59 +00:00
Sreeram Ramachandran
e55b156581 Don\'t use framework permission strings for netd permissions. am: 2c4e4c95e0
am: a40a3e6bf4

* commit 'a40a3e6bf4c3de9119812d854bf53923a68131ed':
  Don't use framework permission strings for netd permissions.
2015-11-19 16:10:19 +00:00
Sreeram Ramachandran
a40a3e6bf4 Don\'t use framework permission strings for netd permissions.
am: 2c4e4c95e0

* commit '2c4e4c95e011bc4dd54c71c341b1f7ff83a53842':
  Don't use framework permission strings for netd permissions.
2015-11-19 15:59:42 +00:00
Sreeram Ramachandran
2c4e4c95e0 Don't use framework permission strings for netd permissions.
These framework permission strings were being used as arbitrary labels
that mapped to netd permissions that have completely different meaning.
This leads to confusion, so use different strings.

This is being cherry picked from lmp-mr1-dev to lmp-dev to fix failures
when creating restricted networks due to prior back-port e46a802.

Bug: 21900139
Bug: 18194858
Change-Id: Ib3ec377ab26ce904d3d4678f04edec6cb1260517
(cherry picked from commit d84f7f863c)
2015-11-18 17:04:18 +00:00
Christopher Tate
b481a892d2 Introduce direct listener API for alarm delivery
The Alarm Manager now supports a set() variant that takes a listener
callback to invoke at alarm trigger time rather than a PendingIntent.
This is much lower overhead and has guaranteed low delivery latency
from the trigger time.  The tradeoff is that the app must be running
*continuously* from the time the alarm is set to the time it is
delivered.  If the app exits for any reason before the alarm fires,
the listener becomes invalid and the alarm will be dropped.  This is
more or less equivalent to setting an alarm with a broadcast
PendingIntent that matches only a runtime-registered receiver.

The app's alarm listener can be any object that implements the new
AlarmManager.OnAlarmListener interface and implements its onAlarm()
method.  There is no data delivered at alarm trigger time: whatever
state needs to be associated with the specific alarm instance should
simply be packaged inside the OnAlarmListener instance.

An alarm using OnAlarmListener can request that the onAlarm() method
be called on an arbitrary handler.  If the program passes 'null' for
this parameter when setting the alarm, the callback occurs on the
application's main Looper thread.

Bug 20157436

Change-Id: I2eb030a24efdd466a2eee1666c5231201b43684b
2015-10-30 12:14:15 -07:00
Erik Kline
bb2024b595 Also treat loss of IPv6 as a loss of provisioning.
Bug: 23226635
Change-Id: Icebb7d83ed5b3b796901b9f023909a02eb461941
2015-10-27 17:11:27 +09:00
Lorenzo Colitti
93a2f99192 Merge "Reinstate CHANGE_NETWORK_STATE as a normal permission." into mnc-dr-dev am: 809dcade99 am: bdc458048a am: bb8f652372
am: c41cfe3335

* commit 'c41cfe3335d4f82952e056d6a961e7b9fb91bd95':
  Reinstate CHANGE_NETWORK_STATE as a normal permission.
2015-10-22 06:33:09 +00:00
Lorenzo Colitti
c41cfe3335 Merge "Reinstate CHANGE_NETWORK_STATE as a normal permission." into mnc-dr-dev am: 809dcade99 am: bdc458048a
am: bb8f652372

* commit 'bb8f652372f261edd2083103d4300a9173993706':
  Reinstate CHANGE_NETWORK_STATE as a normal permission.
2015-10-22 06:28:24 +00:00
Lorenzo Colitti
0289a5eac4 Merge "Reinstate CHANGE_NETWORK_STATE as a normal permission." into mnc-dr-dev
am: 809dcade99

* commit '809dcade9906001f6aa51a68aa783e20bb1d7c0d':
  Reinstate CHANGE_NETWORK_STATE as a normal permission.
2015-10-22 06:18:45 +00:00
Lorenzo Colitti
91de63b074 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
2015-10-22 08:33:45 +09:00
Lorenzo Colitti
d1023e8476 Merge "Don\'t buzz when automatically connecting to captive portals" into mnc-dr-dev am: d214496319 am: 5c09f31e49 am: 18ec0b5187
am: aea9258396

* commit 'aea9258396724c9fc75247ce332aeaff6524cf6a':
  Don't buzz when automatically connecting to captive portals
2015-10-21 02:28:06 +00:00
Lorenzo Colitti
aea9258396 Merge "Don\'t buzz when automatically connecting to captive portals" into mnc-dr-dev am: d214496319 am: 5c09f31e49
am: 18ec0b5187

* commit '18ec0b518741dc5ac32c52ae9681efec3e73a23c':
  Don't buzz when automatically connecting to captive portals
2015-10-21 02:19:15 +00:00
Lorenzo Colitti
a2a1919f8e Merge "Don\'t buzz when automatically connecting to captive portals" into mnc-dr-dev
am: d214496319

* commit 'd214496319785311f99f8415b7c8be3189420488':
  Don't buzz when automatically connecting to captive portals
2015-10-21 01:15:27 +00:00
Lorenzo Colitti
c22996447c 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
2015-10-21 09:59:31 +09:00
Erik Kline
818b1622e7 am bc68bc37: am 9c8abd1d: am f23eece2: am f90627d4: Merge "Don\'t crash if an invalid always-on VPN profile is configured." into mnc-dr-dev
* commit 'bc68bc37c4174eed4cc92de7135b5b2c45a4ec00':
  Don't crash if an invalid always-on VPN profile is configured.
2015-10-14 18:01:48 +00:00
Erik Kline
bc68bc37c4 am 9c8abd1d: am f23eece2: am f90627d4: Merge "Don\'t crash if an invalid always-on VPN profile is configured." into mnc-dr-dev
* commit '9c8abd1d7ab205047a7e0f131eca24b2f3019d5d':
  Don't crash if an invalid always-on VPN profile is configured.
2015-10-14 17:55:13 +00:00
Erik Kline
002149d821 am f90627d4: Merge "Don\'t crash if an invalid always-on VPN profile is configured." into mnc-dr-dev
* commit 'f90627d40bb987dbfebba781d0c1a88436555863':
  Don't crash if an invalid always-on VPN profile is configured.
2015-10-14 17:42:31 +00:00
Erik Kline
f90627d40b Merge "Don't crash if an invalid always-on VPN profile is configured." into mnc-dr-dev 2015-10-14 17:37:57 +00:00
Lorenzo Colitti
f5e2883d41 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
2015-10-13 15:29:14 +09:00