Commit Graph

770 Commits

Author SHA1 Message Date
Nathan Harold
909d66e80a Change reserveSecurityParameterIndex() to take a remoteAddress
To make the SPI reservation more semantically consistent with the
transform creation API, and to ensure that we always create SPI
reservations relative to a well-known remote, we should take the
SPI request relative to a remote (rather than to a destination).
This necessitates that we now consider direction separately, which
is used for keying the SA-Id.

Bug: 36073210
Test: compilation
Change-Id: I81e955c20128c1f8e04fd68eb26669561f827a78
2017-03-29 17:46:47 -07:00
Nathan Harold
7e854f1b82 Merge commit 'e45e328821ba' into oc-dev-plus-aosp
Change-Id: I30ad9038be8faee57e5d6b1391d9e70a966a9a77
2017-03-29 17:05:10 -07:00
Nathan Harold
d2a1dad9a8 Add a Skeleton IpSecService
-Add IpSecService with the necessary glue to connect to netd
-Add code to retrieve IpSecService from System Server

Bug: 34811227
Test: Service boots (and dumpsys works), more via b/34811227
Merged-In: I4cdcb643421141202f77a0e2f87a37012de0cd92
Change-Id: I4cdcb643421141202f77a0e2f87a37012de0cd92
2017-03-29 11:31:27 -07:00
Nathan Harold
fab5eff9a6 Merge "Add API Surface for creating IpSec Transforms" am: 7645fa2816 am: 5466fbdc27
am: 3ddaf3e6b0

Change-Id: Idceae0e5a1af2f357378b03fc0d257dab605b217
2017-03-01 14:22:57 +00:00
Nathan Harold
b1f605fc33 Add API Surface for creating IpSec Transforms
This CL adds an API to set up an IPSec Security Association
and Security Policy to perform Transport-Mode and Tunnel-Mode encapuslation
of IP Packets.

Bug: 30984788
Bug: 34811752
Test: 34812052, 34811227
Change-Id: Ic9f63c7bb366302a24baa3e1b79020210910ac0a
2017-02-28 22:01:20 -08:00
Jeff Sharkey
289eac11a2 StrictMode to detect untagged network traffic.
Network usage is tracked by the kernel at the UID level, which is
granular enough for normal apps, but large components (such as the
system server) are impossible to debug without adding additional
socket tagging to help identify subsystems within a UID.

To help ensure that system components tag all their network traffic,
this change offers a new StrictMode option to detect and report
untagged sockets.

Test: builds, boots, all common traffic tagged
Bug: 30943431, 30414041
Change-Id: I825c7941076054732264690247de2863342638e2
2017-01-19 20:52:05 -07:00
Makoto Onuki
feb5df9814 Support protofied dumpsys for NetStats
Bug 34228873
Test: manual tests with "incident_report netstats"

Change-Id: I359b364c64d9798fd4229018a905658d5d46ea5c
2017-01-17 14:16:01 -08:00
Stephen Chen
92b6175069 DO NOT MERGE: Implement metered tracking for NetworkStats summary queries.
Dependent on ag/1550196 where API is defined.

Bug: 31015360
Bug: 26545374
Test: runtest --path
frameworks/base/core/tests/coretests/src/android/net/NetworkStatsTest.java,
other test classes.

(cherry picked from commit 357f8fabc8)

Change-Id: I46da93ba4afa968facf98f7c3d844fd0c469095a
2016-12-09 13:59:33 +09:00
Stephen Chen
ebace40092 DO NOT MERGE: Define API for metering network stats buckets.
This is a continuation of b/26545374, since now we can also set the
metered bit with NetworkScorer. The tracking of metered state changes
will be implemented in a seperate CL.

Bug: 31015360
Bug: 26545374
Test: N/A

(cherry picked from commit ed7fcb4d26)

Change-Id: I6a2fcc8577d62daa8823dff9e0128a5cf39ede7b
2016-12-09 13:59:17 +09:00
Jeremy Joslin
b135f1d5a8 DO NOT MERGE: VPN network stat accounting changes.
Properly account for VPN apps that make heavy use of the tun
interface. Prior to this change a VPN app could be incorrectly charged
for more data than it actually used if it sent more traffic through
the tun interface than the underlying interface.

This change excludes VPN app traffic on the tun interface from the
adjustment pool and doesn't redistribute traffic to the VPN app.
Instead all of the redistributed traffic is deducted from the VPN app
which effectively represents any overhead incurred by the VPN app.

BUG: 30557871

(cherry picked from commit 12255e3655)

Change-Id: I06f01aa8fe5fdc06b2d36cfb9c68feb244c2e5de
2016-12-09 13:42:29 +09:00
Philip P. Moltmann
2838d9bb56 DO NOT MERGE: Indicate the NsdServiceInfo attributes are only filled in for a resolved service.
Fixes: 28530428

(cherry picked from commit 79a3c031a0)

Change-Id: If2bfc06589adb361f11b89cd5923cb5c255cb680
2016-12-09 13:42:09 +09:00
Jeff Sharkey
931afb110d Merge "StrictMode to detect untagged network traffic." am: 0bb7880e77 am: bc9c6a91b9 am: 8cbc5e3eac
am: 55727aaede

Change-Id: I272964fc9c2a9e350bacc0586dd6b2d4a23c5f51
2016-11-21 23:05:12 +00:00
Jeff Sharkey
8cbc5e3eac Merge "StrictMode to detect untagged network traffic." am: 0bb7880e77
am: bc9c6a91b9

Change-Id: Id6ce5cfedab250f25c0eb8b0c49971e9e20cbeb2
2016-11-21 21:48:31 +00:00
Jeff Sharkey
bc9c6a91b9 Merge "StrictMode to detect untagged network traffic."
am: 0bb7880e77

Change-Id: I52cdce87d87ec503294e431c8f22e87235bdbf79
2016-11-21 21:43:58 +00:00
Jeff Sharkey
66dca17fe7 StrictMode to detect untagged network traffic.
Define some constants for early use in AOSP code.

Test: builds, boots, all common traffic tagged
Bug: 30943431
Change-Id: Ia58a8933bccfddbc027afb78c63ae65bd71ce562
2016-11-21 12:15:16 -07:00
Stephen Chen
4f1700dd16 Fix documentation for NetworkStatsManager methods.
Test: N/A
Change-Id: I054ce104e561ece8e414c7ddad718665e51a692e
2016-11-07 11:31:24 -08:00
Stephen Chen
357f8fabc8 Implement metered tracking for NetworkStats summary queries.
Dependent on ag/1550196 where API is defined.

Bug: 31015360
Bug: 26545374
Test: runtest --path
frameworks/base/core/tests/coretests/src/android/net/NetworkStatsTest.java,
other test classes.

Change-Id: I968b9e3352d7880e3fc438f12de628a2da057e0a
2016-11-04 09:55:21 -07:00
Stephen Chen
ed7fcb4d26 Define API for metering network stats buckets.
This is a continuation of b/26545374, since now we can also set the
metered bit with NetworkScorer. The tracking of metered state changes
will be implemented in a seperate CL.

Bug: 31015360
Bug: 26545374
Test: N/A
Change-Id: I0eccd10c0316357abb03af4d9cf0c4191a66abfb
2016-10-25 18:16:15 -07:00
Jeremy Joslin
218bfe7a33 VPN network stat accounting changes.
Properly account for VPN apps that make heavy use of the tun
interface. Prior to this change a VPN app could be incorrectly charged
for more data than it actually used if it sent more traffic through
the tun interface than the underlying interface.

This change excludes VPN app traffic on the tun interface from the
adjustment pool and doesn't redistribute traffic to the VPN app.
Instead all of the redistributed traffic is deducted from the VPN app
which effectively represents any overhead incurred by the VPN app.

BUG: 30557871
Change-Id: I62a75a0c0c0111e052b7903baa9f5d6d94ef57fd
2016-10-21 18:47:57 +09:00
Jack Yu
eb0b6630bb Do not print misleading debug messages in some scenarios. am: 05cca1a4cb am: d330f0ccc4
am: cc2b91697f

Change-Id: I18d2899cf7ac747a1789e17a2b9786aa9c49c002
2016-08-26 18:55:06 +00:00
Jack Yu
05cca1a4cb Do not print misleading debug messages in some scenarios.
When the mobile network is not active, querying the network
information might trigger the misleading debug messages. Added
some condition checks to prevent this.

bug: 30850733
Change-Id: Ice6d548a56f98bac7fe2ca6a06148350b505533d
2016-08-23 16:09:36 -07:00
Jeremy Joslin
12255e3655 VPN network stat accounting changes.
Properly account for VPN apps that make heavy use of the tun
interface. Prior to this change a VPN app could be incorrectly charged
for more data than it actually used if it sent more traffic through
the tun interface than the underlying interface.

This change excludes VPN app traffic on the tun interface from the
adjustment pool and doesn't redistribute traffic to the VPN app.
Instead all of the redistributed traffic is deducted from the VPN app
which effectively represents any overhead incurred by the VPN app.

BUG: 30557871
Change-Id: I62a75a0c0c0111e052b7903baa9f5d6d94ef57fd
2016-08-16 15:53:57 -07:00
Jeff Sharkey
bed14ecfc5 Avoid caching services with missing binders.
When fetching system services early during boot, if the underlying
binder interface hasn't been published yet, we end up caching a
manager class that is broken for the remainder of the process
lifetime, and innocent downstream callers end up using the broken
cached manager.

Fix this by using an explicit exception to quickly abort manager
creation when the underlying binder is missing.  The exception is
only used to skip the remainder of the manager creation, and it
doesn't actually crash the process.

Bug: 28634953
Change-Id: I0cb62261e6d6833660704b93a11185aa11a2ac97
2016-08-11 09:44:30 -06:00
Antonio Cansado
02f3b13b51 Merge \\\"Fix infinite loop when registering data usage callback.\\\" into nyc-dev am: 55e82ab60f am: 13cf0e7d54
am: 1d4fd3ed27

Change-Id: I5140373d930726e0b93fa62ac03315a37c581b5b
2016-06-20 22:44:51 +00:00
Antonio Cansado
320e313d2c Fix infinite loop when registering data usage callback.
Trivial fix is to call the method that takes the handler as a param.

Bug: 29508547
Change-Id: I75ba30a1663be265eed56b24deda82e83fd47a43
2016-06-20 15:03:03 -07:00
Antonio Cansado
dccb76c3de Merge "Cleaning up NetworkStatsManager." into nyc-dev am: c45f0aea71 am: f49cbec84c
am: cc1524eded

* commit 'cc1524edede07e2139cd072d6256fa96952f4004':
  Cleaning up NetworkStatsManager.

Change-Id: I3f669191e7c7739870dc098d5d6357d1d3ceb6dd
2016-05-25 22:43:26 +00:00
Antonio Cansado
bfd4e42c8d Cleaning up NetworkStatsManager.
- Throwing SecurityExceptionand and IllegalArgumentException instead of null for new APIs
- removing @removed APIs

Bug:27530098,27379882
Change-Id: Ifbe65bfc5051aa33aff2baa22cfa8e67b0f7c358
2016-05-25 11:07:41 -07:00
Antonio Cansado
e68d6ff96b Merge "Addressing API council comments on NetworkStatsManager." into nyc-dev am: dc5f558640 am: 7598ac2aa7
am: 8b2dd44f2f

* commit '8b2dd44f2f30a9dd22799ee30dd4b9c5a093aae5':
  Addressing API council comments on NetworkStatsManager.

Change-Id: Ie6455799758f0bdb67440f72c266effaf412e22f
2016-05-10 21:14:09 +00:00
Antonio Cansado
fe78ecbb2c Addressing API council comments on NetworkStatsManager.
Callbacks
 - DataUsageCallback renamed to UsageCallback
 - DataUsagePolicy removed; passing in params directly to register method
 - making it an abstract class
 - passing in (networkType, subscriberId) that reached its threshold
 - renaming onLimitReached to onThresholdReached to match existing naming
 - only monitor single network,subscriberId
 - no monitoring of specific uids; using device or user wide instead

Tags
 - only owner uid can read its tags
 - exposing only TAG_NONE to match service side

BUG: 27530098

Change-Id: I2b2664da71806868a1e937d2bf4d1f234637509b
2016-05-10 13:24:16 -07:00
Philip P. Moltmann
79a3c031a0 Indicate the NsdServiceInfo attributes are only filled in for a resolved service.
Fixes: 28530428
Change-Id: Ic90bcf4eec10c7db0fd4a4acc8436dda6bab4ba8
2016-05-05 22:34:00 +00:00
Antonio Cansado
84a92fd256 Fixing network tags.
- History was not populating the tag, so all of them appeared as tag 0x0.

Bug: 28345240
Change-Id: I9c898695bbe8d18531f7ea432ebb8f02d72e5d27
2016-04-26 22:18:52 +00:00
Robin Lee
8bad0f4646 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
Jeff Sharkey
3616d5e826 Fix broken javadoc.
Change-Id: I9f2050fd6040234bb1d759ab346f79fc41247aa9
2016-04-12 15:22:57 -06:00
Jack Yu
7e3859251f Excluded certain APNs (e.g. IMS) from mobile data usage.
Added not_metered capability to a mobile network if none
of its associated APN types are metered. Also used not_metered
capability to determine if a network should be accounted for
data usage or not instead of using network type, which is
always MOBILE after refactoring. Will add VT usage support
in next phase.

bug: 20888836
Change-Id: Id692cb856be9a47d0e918371112630128965b1bb
2016-04-07 10:07:31 -07:00
Philip P. Moltmann
bbb41dd3bd Parse and validate txt records.
Bug: 27696905
Change-Id: I9affcf02a51c92a2be1c2bfc5efbd09065e100bc
2016-03-30 20:33:31 -07:00
Sharvil Nanavati
74895614da Add a NetworkTemplate matcher for ConnectivityManager#TYPE_PROXY.
Change-Id: I48c0a7bc39e2efcc5b4120a4fa2ecf6dfd54ac27
2016-03-23 16:19:34 -07:00
Jeff Sharkey
f759159b62 Update TrafficStats SystemApi docs.
Bug: 25726690
Change-Id: I221d62eaaf1e0fca8c26e4f19cb25d306710a849
2016-03-22 10:20:35 -06:00
Jeff Sharkey
f28f2820ab Ignore wildcard network policies.
They never should have been persisted to disk in the first place.

Bug: 24972775
Change-Id: If9254f74455823f9fda9545fdf543fc7250a4016
2016-03-21 13:13:28 -06:00
Jeff Davidson
082ceb1679 NetworkStats.Bucket API polish.
-Add @IntDef constants for STATE_ and ROAMING_.
-Expand docs for ROAMING_ constants.
-Use ROAMING_NO/YES instead of ROAMING_DEFAULT/ROAMING.

Bug: 27531260
Change-Id: I54ecfb4148caa549214df0bee9983036ffa4cb55
2016-03-14 11:24:12 -07:00
Jeff Sharkey
27c8a07be6 Restrict TrafficStats due to privacy concerns.
Granular per-UID network statistics can be used to infer user
behavior over time, so they fall under the umbrella of the
PACKAGE_USAGE_STATS permission.

Since we can't check app-ops based permissions in the kernel, the
best we can do is redirect users to the NetworkStatsManager class,
which offers a much more robust historical data set.

Bug: 27577101
Change-Id: I696bdc5e0b3d7e24acf35f388d0ab13617ed8af3
2016-03-09 16:49:45 -07:00
Jeff Sharkey
f713828f74 When system server goes down, crash apps more.
Apps making calls into the system server may end up persisting
internal state or making security decisions based on the perceived
success or failure of a call, or the default values returned.

The reality is that if the system process just died, init will be
along shortly to kill all running apps, so we should have no problem
rethrowing the RemoteException as a RuntimeException.

Bug: 27364859
Change-Id: Ife0bcb079636c88d54c44d17eb580409fd79028b
2016-03-01 19:29:16 -07:00
Jeff Sharkey
89a344fe60 Parcelable classes should always be final.
Also hide ConnectivityMetricsEvent which isn't being used yet.

Bug: 27415331
Change-Id: Iacdccddda504f3f669185f807b4f35b8dc2b0212
2016-02-29 16:46:09 -07:00
Jeff Sharkey
bc08d071ba When system server goes down, crash apps more.
Similar to first patch, but now using new "rethrowFromSystemServer()"
method which internally translates DeadObjectException into
DeadSystemException.  New logic over in Log.printlns() now
suppresses the DeadSystemException stack traces, since they're
misleading and just added pressure to the precious log buffer space.

Add some extra RuntimeInit checks to suppress logging-about-logging
when the system server is dead.

Bug: 27364859
Change-Id: I05316b3e8e42416b30a56a76c09cd3113a018123
2016-02-27 17:17:01 -07:00
Antonio Cansado
7a6536383d Implementation of data usage callbacks.
NetworkStatsService will register data usage requests
and keep data usage stats scoped to the request.

There are different types of data usage requests
- scoped to a set of NetworkTemplate; these are restrictred to
device owners and carrier apps and allow the caller to monitor
all activity on the specified interfaces.
- scoped to all uids visible to the user, if the user has
android.Manifest.permission#PACKAGE_USAGE_STATS permission.
The set of uids may change over time, so we keep track of that.
- scoped to a set of uids given by the caller, granted that
the caller has access to those uids.
- scoped to the caller's own data usage. This doesn't require
PACKAGE_USAGE_STATS.

Bug: 25812785
Change-Id: Ie11f35fc1f29d0dbe82f7fc924b169bb55c76708
2016-02-17 18:43:53 -08:00
Ritesh Reddy
118b392565 Merge "Enabled Network Policy Backup/Restore." into mm-wireless-dev
am: d9c4bc0c4d

* commit 'd9c4bc0c4db7a8b16d8ea0f58ed0615efc167f47':
  Enabled Network Policy Backup/Restore.
2016-02-10 19:46:20 +00:00
Ritesh Reddy
ca9d62d08d Enabled Network Policy Backup/Restore.
Added Backup Restore specific NetworkPolicySerializer
to NetworkPolicy Class and related classes.

Change-Id: I2a11e2afae8dd9e0ee0c3356e669a73f6a1361af
2016-02-08 10:41:21 +00:00
Antonio Cansado
fb502108b4 Adding a callback to notify data usage.
Allow holders of android.Manifest.permission#PACKAGE_USAGE_STATS
to be notified when data usage has exceeded a given threshold.
This allows an app to update its data usage metrics without
polling.

Bug: 25812785
Change-Id: I3a4904a97f3c7fbaf8071b460f9ee6ca9c1ba4ed
2016-02-02 15:18:41 -08:00
Antonio Cansado
2bb66f5d48 Retuning tag information through NetworkStatsManager.
Network tags could be set since ICS but was not exposed
through the SDK. This CL extends existing functionality
of NetworkStatsManager to return network tags.

Bug: 25813338
Change-Id: I414b98193249ba88a3f2d64cb2e0d2633f64fa3f
2016-02-01 14:13:20 -08:00
Jeff Davidson
3bbf8f320d Revert Network Stats API stub for tracking of metered networks.
Bug: 25813958
Change-Id: I9d2835b7bacfffef05b1588f1301afc70f5f582f
2016-01-29 10:36:52 -08:00
Zoltan Szatmary-Ban
4ff8b948b0 Introduce DEVICESUMMARY access level to NetworkStatsAccess.
Apps with PACKAGE_USAGE_STATS app op or READ_NETWORK_USAGE_HISTORY
granted can query the summarized device data usage (but not individual
uids running in other users or profiles).

Bug:26677052
Change-Id: Id51631638f338a8cf48172c9b41746228a335084
2016-01-26 13:59:52 +00:00