summaryrefslogtreecommitdiff
path: root/core/java/android/net/TrafficStats.java
Commit message (Collapse)AuthorAgeFilesLines
* [MS08] Move NetworkStats files to f/b/package/ConnectivityTJunyu Lai2021-12-101-1032/+0
| | | | | | | | | | | NetworkStatsService is going to be moved into ConnectivityService module. Move all related files to packages/ConnectivityT so that it can be easily migrate these files to connectivity module after clearing the hidden API usages. Bug: 197717846 Test: TH Change-Id: Iead00832b5eb7b1dc40a92027c5a14ae8316b16c
* Expose getTx/RxBytes in TrafficStatsjunyulai2020-11-241-10/+50
| | | | | | | Test: atest FrameworksNetTests TrafficStatsTest atest android.net.cts android.net.wifi.cts Bug: 164965653 Change-Id: I17b9d0bc2404c5727d4c4530ad941439b7b71a54
* Remove legacy style metalava suppressionAurimas Liutikas2020-11-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | @SuppressLint("Doclava125") is a legacy way of suppressing RequiresPermission check. Updating to the new style of suppression so metalava no longer has to support the legacy mode. sed -i "s/@SuppressLint(\"Doclava125/@SuppressLint(\"RequiresPermission/" \ core/java/android/app/admin/DevicePolicyManager.java \ core/java/android/hardware/hdmi/HdmiControlManager.java \ core/java/android/hardware/location/ContextHubManager.java \ core/java/android/hardware/usb/UsbDeviceConnection.java \ core/java/android/net/TrafficStats.java \ core/java/android/os/RecoverySystem.java \ core/java/android/os/storage/StorageManager.java \ core/java/android/service/persistentdata/PersistentDataBlockManager.java \ location/java/android/location/LocationManager.java \ media/java/android/media/AudioManager.java \ telecomm/java/android/telecom/TelecomManager.java \ telephony/java/android/telephony/CarrierConfigManager.java \ telephony/java/android/telephony/TelephonyManager.java \ wifi/java/android/net/wifi/RttManager.java \ wifi/java/android/net/wifi/WifiScanner.java Test: make Exempt-From-Owner-Approval: No-op change Merged-In: I6d5df95cfca2950ea86872d2f0afc1ba828841dc Change-Id: I6d5df95cfca2950ea86872d2f0afc1ba828841dc
* Merge changes I6a48d4db,I6741c41c,Ifec6bde5,Icd0717c5Junyu Lai2020-11-121-7/+13
|\ | | | | | | | | | | | | | | * changes: Remove unused variables Return offloaded traffic when querying from TrafficStats API Add hardware tethering traffic in testTethering test Remove unused getTetherStats
| * Return offloaded traffic when querying from TrafficStats APIjunyulai2020-11-121-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TrafficStats API are being used for querying realtime network statistics for years. However, on certain devices, some network traffic are produced by hardware components and not be able to seen by kernel counters. Thus, include statistics for those missing network traffic is necessary. Note that the included statistics might be stale since polling newest stats from hardware might impact system health and not suitable for TrafficStats API use cases. Test: atest FrameworksNetTests TetheringTests Bug: 16229221 Change-Id: I6741c41cb5145ca8748f9b083b9c15e7e2735681
* | Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-11-041-2/+2
|/ | | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Merged-In: I626caf7c1fe46c5ab1f39c2895b42a34319f771a Change-Id: I54e5ecd11e76ca1de3c5893e3a98b0108e735413
* Enforce permission check in getUidStats functionChenbo Feng2020-04-271-44/+16
| | | | | | | | | | | | | | | | | The NetworkStatsService.getUidStats() currently doesn't have any permission check to make sure unpriviledged apps cannot read the stats of a different uid. It will protentially have security problem since apps with ACCESS_NETWORK_STATS permission can directly calling into NetworkStatsService and bypass the check in TrafficStats. Move the uid check from TrafficStats to NetworkStatsService to fix the problem. Bug: 129151407 Test: atest AppSecurityTests#testAppFailAccessPrivateData_full Test: atest AppSecurityTests#testAppFailAccessPrivateData_instant Test: atest android.app.usage.cts.NetworkUsageStatsTest Test: atest NetworkStatsBinderTest Change-Id: Iae85676cfe5f114da69ec278afc2c904bc907234
* [SP01] Add NetworkStats to system APIjunyulai2020-01-091-1/+1
| | | | | | | | | | In order to let external module report their network stats, expose necessary APIs to construct NetworkStats object. Test: atest FrameworksNetTests CtsUsageStatsTestCases Test: m doc-comment-check-docs Bug: 130855321 Change-Id: Id3ec8aaff3df67948c25eac2319a74cf33a27979
* Use new UnsupportedAppUsage annotation.Artur Satayev2020-01-081-1/+1
| | | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I0c336de56bc4a041dc97ff9b7927f62f0b44b457 Merged-In: I0c336de56bc4a041dc97ff9b7927f62f0b44b457
* Add TrafficStats methods to public APIsAaron Huang2019-12-061-4/+19
| | | | | | | | | | | | | Add methods to public APIs for mainline support. Bug: 139268426 Bug: 135998869 Test: atest FrameworksNetTests ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh atest android.net.cts atest android.net.wifi.cts Change-Id: I21a9c0dbdc79b1f1041fc9e23c6a4e1e97ecde92
* Merge "Move TrafficStats tags for the network stack constants"Chalard Jean2019-04-171-18/+37
|\
| * Move TrafficStats tags for the network stack constantsChalard Jean2019-04-171-18/+37
| | | | | | | | | | | | | | | | | | | | | | | | As per API council feedback, these constants should live in a place that is private to the network stack, only with a range defined in system API. Bug: 129433383 Test: m Change-Id: I84a90f84a9af6fef4667ee4d512ebd0413222086 Merged-In: I4882686a86e7c6d42f4b0619b921d02619ed6d4c Merged-In: I9b648ed6c687d56db61a54570c7880c51c1bae51
* | Restrict access to dangerous methods to <= PChalard Jean2019-04-091-2/+3
|/ | | | | | Test: make Fixes: 130143562 Change-Id: I1a6a472f83cf00a1ab174a9c5e67d3e9357a0c45
* Add SocketUtils for NetworkStackRemi NGUYEN VAN2019-01-281-0/+6
| | | | | | | | | These utilities can only be used for privileged apps. The underlying implementation cannot be @SystemApi. Test: m Bug: 112869080 Change-Id: Idfa90561102e5b03ab2b79486d3ad46457128bf8
* Merge "DO NOT MERGE - Merge pie-platform-release (PPRL.181205.001) into master"Treehugger Robot2018-12-131-0/+8
|\
| * DO NOT MERGE - Merge pie-platform-release (PPRL.181205.001) into masterXin Li2018-12-111-0/+8
| |\ | | | | | | | | | | | | Bug: 120502534 Change-Id: Idc8bfb6d97a869b76cfb87ca1a494201baf9e8bd
| | * docs: added Android P behavior change note to untagSocket referencekopriva2018-07-261-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | staged here: https://android-dot-devsite.googleplex.com/reference/android/net/TrafficStats#untagSocket(java.net.Socket) Test: make ds-docs Exempt-From-Owner-Approval: Docs-only change Bug: 110484513 Change-Id: I24575e6f4451a019b60c5bf60e17e14a928c6cc3
* | | API: Clean up redundant and ineffective usages of SystemApi and TestApiAdrian Roos2018-12-121-2/+0
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Everything that is marked SystemApi or TestApi, but not @hide is still part of the public SDK, it is therefore not sound to have that combination. In the future, specifing such a combination will be considered an error to prevent inadvertently exposing SystemApi and TestApi as public API. Bug: 115333477 Change-Id: Ibd5d6a22862fdbc1e20a1cb3925280f5a682edea Merged-In: Ibd5d6a22862fdbc1e20a1cb3925280f5a682edea Test: METALAVA_PREPEND_ARGS="--error UnhiddenSystemApi" m checkapi Exempt-From-Owner-Approval: API cleanup
* | Add DhcpServerRemi NGUYEN VAN2018-08-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | This first version can serve discover/request/release, although there are some small behavior changes with current implementation which will be addressed later. Also removes final modifiers on start() and stop() in FdEventsReader, to allow mocking the methods in tests with the current mockito lib. Test: Added tests pass, manual: flashed a device using the server Change-Id: I025366ff7d51c4ba31152af50f3dd2b5e280a54d
* | Add @UnsupportedAppUsage annotationsMathew Inwood2018-08-141-0/+7
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For packages: android.net.wimax android.net.wifi.p2p.nsd android.net.wifi.p2p android.net.wifi.hotspot2.pps android.net.wifi.hotspot2.omadm android.net.wifi.hotspot2 android.net.wifi.aware android.net.wifi android.net.util android.net.sip android.net.rtp android.net.nsd android.net.metrics android.net.lowpan android.net.http android.net.captiveportal android.net This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: Ie25423113ee1a8071cd5039382c00de6ce0af7fd Merged-In: I520be7a4c79e68310c12e4f55bf66acaa94145a1
* API council requested tweaks to TrafficStats.Jeff Sharkey2018-03-261-8/+24
| | | | | | Test: atest android.appsecurity.cts.AppSecurityTests#testAppFailAccessPrivateData Bug: 71584606 Change-Id: I4be8a47d54a04f17cbaac735d543ff7d6370376d
* Merge "Return non-negetive value in getMobileStats method" am: bb1d07e681 ↵Chenbo Feng2018-02-021-10/+10
|\ | | | | | | | | | | | | | | am: 515a54a93e am: 7b5487cd0a Change-Id: I304f42d473289ad876f6ceae8d6866e4248686a9
| * Return non-negetive value in getMobileStats methodChenbo Feng2018-01-291-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implementation of getMobileRxBytes and all the similiar method adds up the return values for multiple calls to getRxBytes so if all of them return UNSUPPORTED for any reason, getMobileRxBytes() would return a value such as -3. This behavior is not compliance with the cts TrafficStatsTest which always assume getMobileRxBytes to return a non-negetive value. The method now will check tha stats get from getRxBytes method and add them up only if the stats is valid. Bug: 72473294 Test: run cts -m CtsNetTestCases -t android.net.cts.TrafficStatsTest Change-Id: I656970ebc8f6506cf17c4353ad46c0178bb65cfd
* | Add DataUnit to clarify SI-vs-IEC units.Jeff Sharkey2018-01-071-5/+11
|/ | | | | | | | | | | Mirrors the design of TimeUnit and ChronoUnit which many developers are already familiar with, making it easy to pick up and use. Yes, this is an enum. Bug: 70915728 Test: bit FrameworksCoreTests:android.util.DataUnitTest Change-Id: Id0cfdac5c81ed89c3c9ece23c964acba4a4f8471
* Use NetworkStatsService to get stats for appsChenbo Feng2017-12-191-22/+92
| | | | | | | | | | | | | | Move the native implementation of TrafficStats to NetworkStatsService and apps need to get the NetworkStatsService binder interface from system_server in order to get the network usage stats since boot. This implementation can hide the detail of retrieving network traffic information from apps and the NetworkStatsService can choose which methoed it use to get the data depending on the kernel version of the device. Bug: 30950746 Test: CtsNetTestCases -t android.net.cts.TrafficStatsTest Change-Id: I53bbefd19aa0b783b9b4b42ea4d76db3e9ec07a3
* [ipsec-qtaguid] Tag sockets upon creation of encap socketsBenedict Wong2017-12-181-0/+27
| | | | | | | | | | | Added calls to tag encap sockets to that of the UID for which the encap socket is being created on behalf of. This ensures that all data accounting generated for the UDP-encap-ESP socket is correctly billed to the right UID. Bug: 62994731 Test: New tests added to IpSecServiceTest.java, passing Change-Id: I15365ea9c982fd7b4e3cdeff314ddfba2289c86e
* [CHERRY-PICK] API for apps to tag sockets with their own UID.Jeff Sharkey2017-12-181-2/+37
| | | | | | | | | | | | | | This enables app A to create a socket, pass it to app B, and have app B accept blame for the traffic performed on that socket. Also adds helpful public APIs for tagging raw FileDescriptor sockets instead of making developers go through shady SocketImpl wrappers. Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AppSecurityTests#testAppFailAccessPrivateData Bug: 63932076 Change-Id: I08925c843974675fc82e4080cec2eaab9ab7cd41 Merged-In: I08925c843974675fc82e4080cec2eaab9ab7cd41 (cherry picked from commit 70dc4f4d16082c598cd1774d366c1e60c2016126)
* Rename API to match StorageStats.Jeff Sharkey2017-08-111-7/+7
| | | | | | | | | Since they're both measuring app code (APKs), name this API consistently with StorageStats.getAppBytes(). Bug: 64331226 Test: builds, boots Change-Id: I1b00427b619a78c043b1b5fac2d0e6406b51d454
* Allocate well-known tag for app store updates.Jeff Sharkey2017-06-261-13/+27
| | | | | | | | | | | | | This way an app store can shift blame for update-related network traffic onto the app that is being updated. Using a well-known tag makes it easy for developers to identify that they didn't explicitly request the traffic at runtime, similar to how backup/restore traffic is handled. Bug: 38282350 Test: builds, boots Change-Id: I003dd7c9615d4ab318250f1e44fa5d195ac94d23
* Annotate @SystemApi with required permissions.Jeff Sharkey2017-06-051-0/+3
| | | | | | | | | | | | | | | | | Most @SystemApi methods should be protected with system (or higher) permissions, so annotate common methods with @RequiresPermission to make automatic verification easier. Verification is really only relevant when calling into system services (where permissions checking can happen on the other side of a Binder call), so annotate managers with the new @SystemService annotation, which is now automatically documented. This is purely a docs change; no logic changes are being made. Test: make -j32 update-api && make -j32 offline-sdk-docs Bug: 62263906 Change-Id: I2554227202d84465676aa4ab0dd336b5c45fc651
* StrictMode to detect untagged network traffic.Jeff Sharkey2017-01-191-0/+18
| | | | | | | | | | | | | | | 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
* StrictMode to detect untagged network traffic.Jeff Sharkey2016-11-211-0/+20
| | | | | | | | Define some constants for early use in AOSP code. Test: builds, boots, all common traffic tagged Bug: 30943431 Change-Id: Ia58a8933bccfddbc027afb78c63ae65bd71ce562
* Fix broken javadoc.Jeff Sharkey2016-04-121-2/+0
| | | | Change-Id: I9f2050fd6040234bb1d759ab346f79fc41247aa9
* Update TrafficStats SystemApi docs.Jeff Sharkey2016-03-221-5/+15
| | | | | Bug: 25726690 Change-Id: I221d62eaaf1e0fca8c26e4f19cb25d306710a849
* Restrict TrafficStats due to privacy concerns.Jeff Sharkey2016-03-091-9/+66
| | | | | | | | | | | | | 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
* When system server goes down, crash apps more.Jeff Sharkey2016-02-271-3/+3
| | | | | | | | | | | | | | 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
* Add tagging variants for DatagramSocket.Jeff Sharkey2015-12-041-0/+22
| | | | | | | Oops, we missed these along the way. Bug: 25799174 Change-Id: I4ad368f9faee4b1996d605534dce4c2b23dbe200
* Introduce socket stats tag for restore trafficChristopher Tate2015-11-101-1/+20
| | | | | | As well as system API for emplacing it. Change-Id: If33fbd23552261efe3b00d75c22ff823564f43e6
* Update file size formatting.Jeff Sharkey2015-06-151-0/+2
| | | | | | | | | | | | Per UX, default strings should have space between value and units resulting in "12.3 GB". Add a formatting variant that returns the various components for callers who want to build their own strings. For now there is only one mounted emulated volume at a time, and it's always the primary storage, so give it the default rootId to keep old Uris working. Change-Id: Ifcc72a91a6b397ee65dc92642153286186eb64ac
* Progress towards dynamic storage support.Jeff Sharkey2015-03-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Storage devices are no longer hard-coded, and instead bubble up from whatever Disk and VolumeBase that vold uncovered, turning into sibling Java objects in MountService. We now treat vold events as the source-of-truth for state, and synchronize our state by asking vold to "reset" whenever we reconnect. We've now moved to a model where all storage devices are mounted in the root mount namespace (user boundaries protected with GIDs), so we no longer need app-to-vold path translation. This also means that zygote only needs to bind mount the user-specific /mnt/user/n/ path onto /storage/self/ to make legacy paths like /sdcard work. This grealy simplifies a lot of system code. Many parts of the platform depend on a primary storage device always being present, so we hack together a stub StorageVolume when vold doesn't have a volume ready yet. StorageVolume isn't really a volume anymore; it's the user-specific view onto a volume, so MountService now filters and builds them based on the calling user. StorageVolume is now immutable, making it easier to reason about. Environment now builds all of its paths dynamically based on active volumes. Adds utility methods to turn int types and flags into user-readable strings for debugging purposes. Remove UMS sharing support for now, since no current devices support it; MTP is the recommended solution going forward because it offers better multi-user support. Simplify unmount logic, since vold will now gladly trigger EJECTING broadcast and kill stubborn processes. Bug: 19993667 Change-Id: I9842280e61974c91bae15d764e386969aedcd338
* Make TrafficStats uid attribution @SystemApiChristopher Tate2014-08-071-0/+13
| | | | | | | | | | Anything that runs as a singleton may need to attribute traffic to various client apps; in particular, backup transports need to do this. Apropos of which, introduce a @SystemApi method specifically for that purpose, setThreadStatsTagBackup(). Bug 16661321 Change-Id: Id5d22e28bdc68edb53f2a1fdba80b144fcbc61d2
* Update TrafficStats docs to reflect behavior.Jeff Sharkey2013-03-261-61/+72
| | | | | Bug: 8399623 Change-Id: If9ccd305e8a077f318a09ac1bb160b8efbf903aa
* Add version code constant for JB MR2.Dianne Hackborn2013-02-251-12/+12
| | | | Change-Id: I60fc76bbeb3c5e85d716179e9e3ea5758bafaf69
* Improve TrafficStats UID APIs.Jeff Sharkey2013-02-071-117/+113
| | | | | | | | | | | | Deprecate transport layer statistics, leaving only the summarized network layer statistics. Improve documentation to be clear about layers where measurements occur, and their behavior since boot. Under the hood, move to using xt_qtaguid UID statistics. Bug: 6818637, 7013662 Change-Id: I9f26992e5fcdebd88c671e5765bd91229e7b0016
* Offer parsed TCP interface statistics.Jeff Sharkey2013-02-061-0/+26
| | | | | | | | Also switch to newer iface_stat_fmt numbers, which are measured at XT level instead of dev. Bug: 7903145, 6569689 Change-Id: Ibeb742966b8c89916ea31a49388a5dbe25a5f67f
* Revert "API to adjust network stats."Jeff Sharkey2012-07-311-28/+0
|
* API to adjust network stats. DO NOT MERGE.Jeff Sharkey2012-07-311-0/+28
| | | | | | | | Enables system apps to correctly account network usage performed on behalf of another application. Bug: 6695246 Change-Id: I39e243afd57936b6b30157a6ca511a17b6c55c39
* Move TrafficStats iface counters to xt_qtaguid.Jeff Sharkey2012-04-121-20/+86
| | | | | | | | | | | | | | | | Use xt_qtaguid iface_stat_all counters, which are monotonic during a single boot. Track all ifaces associated with mobile networks since boot, and move TrafficStats to using these ifaces. This will include usage of networks omitted from config_data_usage_network_types, specifically on devices that recycle network interfaces across APNs. Split wildcard template matching, and move NetworkStatsService to use mobile wildcard when logging stats. Bug: 5324515 Change-Id: I2211c374c05d1b598cc647f2f873630538955ffe
* INetworkStatsSession with lifecycle for caching.Jeff Sharkey2012-04-061-0/+13
| | | | | | | | | Users outside system_server now explicitly communicate their lifecycle, which keeps a strong-reference chain to any fully loaded NetworkStatsCollection histories. Bug: 6236498 Change-Id: I8e22739b6e89a626b676967a736d7117fd000778
* Unify shorthand for byte-based units.Jeff Sharkey2012-02-031-0/+7
| | | | Change-Id: If990859dee3f0973e1d4c48f05312c84071b3328