summaryrefslogtreecommitdiff
path: root/service-t/src/com/android/server/net/NetworkStatsService.java
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Disable comparison in user release builds" into tm-devRemi NGUYEN VAN2022-06-211-3/+1
|\
| * Disable comparison in user release buildsJunyu Lai2022-06-211-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL disable the comparison mechanism introduced in previous beta releases to stop receiving log.wtf signals from beta users. This CL only affects logging on user release builds. Ignore-AOSP-First: Parent CLs are not in aosp yet Test: 1. NetworkStatsServiceTest 2. manual test with script Bug: 233752318 Change-Id: I7047106b1019c29460d6633b148f501ffa62f139
* | Merge "Increase fallbacks counter when comparison result is different" into ↵Junyu Lai2022-06-211-0/+2
|\ \ | | | | | | | | | tm-dev
| * | Increase fallbacks counter when comparison result is differentJunyu Lai2022-06-211-0/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | In current code, the fallbacks counter does not increase when comparison result is different. This will not impact how we print log.wtf but will impact the dry run process for debugging in next every later boots. Ignore-AOSP-First: Parent CLs are not in aosp yet Test: 1. NetworkStatsServiceTest 2. manual test with script Bug: 233752318 Change-Id: Ib152cec2ee0f21d59ccfe4669b31f26b3db71a97
* / Add wipeOnError flag to NetworkStatsRecorderAaron Huang2022-06-171-11/+20
|/ | | | | | | | | | | | | | | If reading data happens exception while doing data migration, the file will be deleted by legacy recorders. This would cause legacy persistent data being lost and cannot be retrieved by any method. To avoid the files being deleted, add a wipeOnError flag to recorder which indicates this recorder will wipe on error or not . If the flag is set to true then deletes all files when it throws, otherwise keeps all files. Ignore-AOSP-First: urgent fix and will cherry-pick immediately after. Bug: 233828210 Test: FrameworksNetTests:NetworkStatsRecorderTest Change-Id: Id7a3d8bebf8a00d814f9e84bf4c10d927e6ff749
* Disable fallback when comparison result is differentJunyu Lai2022-06-151-59/+117
| | | | | | | | | | | | | | | | | | | | Follow-up from ag/18452103, where we add fallback code that runs with the importer to make sure they are identical. When the result is different, we'll take the result from fallback code to minimize the rollout risk. However, since the OEMs might change the importer implementation. The fallback code would no longer valid and that makes OEM modified code not working. Hence the fallback code must be disabled before release. This change keeps comparison enabled for all cases to keep getting signals from beta users. And will switch it to read overlay value for OEM to debug their solution. Ignore-AOSP-First: Parent CLs are not in aosp yet Test: 1. NetworkStatsServiceTest 2. Test all datasets with script Bug: 233752318 Change-Id: I869ff05297149bde6e13a204bd8c5a4fece75de0
* Hold wifi and mobile interfaces since boot in NetworkStatsServiceAaron Huang2022-06-031-15/+56
| | | | | | | | | | | | | | | In current design, the interface will be removed from the list if the network disconnected which will cause getUidStatsForTransport() returns unexpected snapshot to caller since the list is empty. This change also remove interface name from all entries before the method returns the result. Ignore-AOSP-First: non-AOSP CL is included in the same topic Bug: 231514741 Test: FrameworksNetTests manual test Change-Id: Ie60829a65d0d9b5b63ad353695a820c0586e3665
* Merge changes from topic "increment-crash" into tm-devJunyu Lai2022-06-011-2/+2
|\ | | | | | | | | | | * changes: Fix get summary does not include the latest bucket Add unit test for MultipathPolicyTracker
| * Fix get summary does not include the latest bucketJunyu Lai2022-06-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In internalGetSummaryForNetwork, the history object will not include the latest bucket because of the logic in NetworkStatsHistory#recordHistory would only include buckets that atomically occur in the inclusive time range. This makes querySummaryForDevice callers who are also sensitive to the latest bucket fails. This CL revert the behavior back to S, in T this is temporarily changed after aosp/1937268. Also, for test purpose, this CL change System.currentTimeMillis to use mClock when querying. Ignore-AOSP-First: Urgent fix Test: NetworkStatsServiceTest#testGetLatestSummary Bug: 233733267 Change-Id: I55e2a5d953622b68da36a9b8d3e57c88d57543b0
* | Use fallback method if the importer throwsJunyu Lai2022-05-261-11/+24
|/ | | | | | | | | | This prevent users from seeing empty data usage if the importer throws. Ignore-AOSP-First: in a topic with internal-only changes Test: Manual Bug: 233825704 Change-Id: Iab27e8eb6f2ed406f932507100aaf74abb997c83
* Address comment at ag/18491259 and ag/18486388Junyu Lai2022-05-251-30/+15
| | | | | | | Ignore-AOSP-First: in a topic with internal-only changes Test: TH Bug: 230289468 Change-Id: Id91fabb47b542d8526d6aa787b5947238c3934fb
* Run comparison code if the data migration finished with fallbackJunyu Lai2022-05-231-3/+15
| | | | | | | | | | | | | | | | If the data migration process runs finished with fallback, that means we might get some unknown data that cannot be handled by importing code. If that happens, the CL runs the problematic code whenever device boot-up but doesn't do the actual import process. This improves the debuggability since the current log disappears after device reboot, which will show up in every boot-up log after this CL. Ignore-AOSP-First: in a topic with internal-only changes Test: manual Bug: 230289468 Change-Id: I6d117032d47f21c7cb49bbab916668058060f2f8
* Persisting status int on the device if fallback happenedJunyu Lai2022-05-231-13/+32
| | | | | | | | | | This CL also stop from incresing "successes" counter if the importer finishes with fallback. Ignore-AOSP-First: in a topic with internal-only changes Test: manual Bug: 230289468 Change-Id: I88fce1b2d0dea3772a8b31df8f8fa93bf13bffad
* Merge changes from topic "stats-migration" into tm-devJunyu Lai2022-05-191-41/+418
|\ | | | | | | | | | | | | | | | | * changes: Skip PersistentIntTest on S- device Don't clobber existing history entries. Ensure NetworkStats migrated snapshot is identical [MS82.1] Support network stats data migration process Add a PersistentInt class.
| * Ensure NetworkStats migrated snapshot is identicalRemi NGUYEN VAN2022-05-181-12/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Read migration snapshot both from the platform API and the legacy method, and Log.wtf if they are different. Use the legacy method data if they are. This ensures that using the migration API is a no-op, and that errors are reported (through Log.wtf) if it would not have been if used as-is. Ignore-AOSP-First: in a topic with internal-only changes Test: NetworkStatsServiceTest Bug: 230289468 Change-Id: I857ad18183d63d1aa16e89f89eb24009648720a2
| * [MS82.1] Support network stats data migration processJunyu Lai2022-05-181-36/+268
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This includes: 1. Provide NetworkStatsRecorder#importCollectionLocked to allow caller to write a NetworkStatsCollection object to a standalone file. 2. Do not clear the collection in NetworkStatsRecorder# CombiningRewriter, this is safe since pending set will still be cleared during forcePersistLocked. 3. Implement the migration process, including recovery and safety measures. Test: NetworkStatsServiceTest NetworkStatsCollectionTest Test: manual test with adb shell device_config put tethering \ netstats_store_files_in_apexdata true adb shell device_config put tethering \ netstats_import_legacy_target_attempts 1 Ignore-AOSP-First: in a topic with internal-only changes Bug: 230289468 Change-Id: Ic2002cbfd5a6b3c2226fa8dab22481f8ce656574
* | move netd maps and progs into /sys/fs/bpf/netd_shared/...Maciej Żenczykowski2022-05-191-5/+5
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | (out of current /sys/fs/bpf/net_shared/...) This will allow genfscon regexp changes in a followup selinux commit. Note that this has a hard dependency on system/bpf change 'bpfloader: add support for netd_shared and net_private subdirs' which also bumps bpfloader to v0.13. This was merged May 12, 2022 (into both aosp/master and tm-dev) and it is in Android T starting with Beta 3 release. This isn't really an issue since amusingly T Beta 2 is already incompatible with current mainline releases due to the snap reverting a previous required bpfloader system/bpf change: move net_shared bpf programs into net_shared subdirectory See: http://b/232050459#comment14 So this doesn't break T Beta1/2, since they already don't work, and Beta3 will work. Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Id5f14d6e3f11cfe35d9d8a9496548a2bc4d022ec (cherry picked from commit 6d116d0f38196625d205e8c76a17b01b61fff246) Merged-In: Id5f14d6e3f11cfe35d9d8a9496548a2bc4d022ec
* Merge changes from topic ↵TreeHugger Robot2022-05-131-30/+92
|\ | | | | | | | | | | | | | | "cherrypicker-L63700000954424743:N16900001262878041" into tm-dev * changes: Exclude PID for rate-limited Improve count of openSession callers in dumpsys
| * Exclude PID for rate-limitedAaron Huang2022-05-131-26/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rate-limited would include PID in current design, which means that an app can ignore the rate-limits by creating a process (a new PID) every time. Thus, maintain mOpenSessionCallsPerUid for rate-limits and OpenSessionKey for debugging. Also, there's no rate-limit for SYSTEM_UID so if the uid is SYSTEM_UID, the mLastStatsSessionPoll should not be updated. Otherwise, it may cause an app to be rate-limited to do a query after a system user polled. Test: adb shell dumpsys netstats and check the output Bug: 228081549 Change-Id: I69cc1f3990c9960347691256ed4cb500f9bb48b2 (cherry picked from commit 8d5907fc13bd6238a2eaa56c1d80488c42a2d564) Merged-In: I69cc1f3990c9960347691256ed4cb500f9bb48b2
| * Improve count of openSession callers in dumpsysAaron Huang2022-05-131-31/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, it's only uid=count in dumpsys, however, the call may also come from system but there is no such information in dumpsys. If the call came from system, it's hard to know who is the caller. So, this patch makes pid, uid and package as a key to record the count of the caller. The output will look like, Top openSession callers: {pid=1787,uid=1000,package=android}=26 {pid=2931,uid=1000,package=com.android.settings}=4 Test: adb shell dumpsys netstats and check the output Bug: 228081549 Change-Id: Id2dfdd4480aa5b1ece51e46de6efe30a46629811 (cherry picked from commit b87b5e5d0a4f08f58d85ff11d39a64e2c4e4646b) Merged-In: Id2dfdd4480aa5b1ece51e46de6efe30a46629811
* | Improve logging for NetworkStatsObserversJunyu Lai2022-05-101-2/+10
|/ | | | | | | | | | | | | | | | | | | In order to have better logging to gather information about the callers. This change includes: 1. Add pid and package name into RequestInfo for better logging. 2. Print current observers in dumpsys section. 3. Enable register/unregister usage request logging by default. The log added in the dumpsys section looks like: Stats Observers: RequestInfo from pid/uid:2001/1000(android) for DataUsageRequest [...] accessLevel:3 ... Test: NetworkStatsObserversTest Bug: 229103088 Change-Id: Ide68776dc279610e8dee0efd924b59a1fac2b7b6 (cherry picked from commit c259e615e68aacc3bc47b729de03449b5798a1b4) Merged-In: Ide68776dc279610e8dee0efd924b59a1fac2b7b6
* adjust for new T bpfloader net_shared locationMaciej Żenczykowski2022-04-231-6/+5
| | | | | | | | | | (this is safe because on pre-T none of these maps and programs are mainlined and thus safe to access from mainline code anyway) Test: TreeHugger, manual Bug: 218408035 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I23e565d665247f33e084978890a1ee8ffe0fe568
* Merge "Fix proto invalid write type"Aaron Huang2022-03-221-8/+8
|\
| * Fix proto invalid write typeAaron Huang2022-03-071-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While dumpProtoLocked is called, InvalidProtocolBufferException occurred because types are mismatched between platform side and module side. netstats.proto was moved into connectivity module, both the platform(incident.proto) and the module uses protoc-gen-javastream to generate the Java classes from it. It should be fine since platform includes the source of the proto, and jarjar the generated classess in the module to avoid conflict with platform. Bug: 218566849 Test: adb shell incident 3001 adb shell dumpsys netstats --proto atest CtsIncidentHostTestCases:IncidentdTest#testIncidentReportDumpAuto Change-Id: I4654350a59dc1ca1a925785ad37f34aa7b481235 Merged-In: I4654350a59dc1ca1a925785ad37f34aa7b481235
* | Merge "[DU04-2]Appropriate changes to the NetworkPolicyManager API"Frank Li2022-03-161-3/+10
|\ \
| * | [DU04-2]Appropriate changes to the NetworkPolicyManager APIFrank2022-03-161-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Divide the NetworkPolicyManager API notifyStatsProviderWarningOrLimitReached into the following two APIs: 1. notifyStatsProviderWarningReached() 2. notifyStatsProviderLimitReached() Bug: 216474563 Test: atest NetworkStatsServiceTest NetworkPolicyManagerTest NetworkPolicyManagerServiceTest OffloadControllerTest Change-Id: Ic413eb532b5e24d4a7e2afabdcf643ab6607b1ed
* | | Merge "Rename setUidForeground to noteUidForeground"Lorenzo Colitti2022-03-151-1/+1
|\ \ \ | |/ / |/| |
| * | Rename setUidForeground to noteUidForegroundAaron Huang2022-03-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch addresses API review about the naming of NetworkStatsManager#setUidForeground and it would be more appropriate to rename it to noteUidForeground. Bug: 222291301 Test: atest FrameworksNetTests Change-Id: I952762872850889609c9808aa6e3cdfc04317806
* | | Fix log message when failing to open bpf mapsPatrick Rohr2022-03-081-5/+5
|/ / | | | | | | | | | | | | s/create/open/ Test: TH Change-Id: I7fd1b280ab15aaa0757cfb3afcc20bf377a3bcef
* | Merge "[MS68.3] Address comments at aosp/1958144"Frank Li2022-03-031-1/+1
|\ \
| * | [MS68.3] Address comments at aosp/1958144Frank2022-03-021-1/+1
| |/ | | | | | | | | | | | | | | | | | | Test: atest TrafficStatsTest NetworkUsageStatsTest FrameworksNetTests Bug: 204830222 (cherry-picked from ag/16813003) Change-Id: I5a54b44294021d64d8506eeb570db0db8544472a Merged-In: I5a54b44294021d64d8506eeb570db0db8544472a
* | Merge "[SUBID01-0]Grow NetworkIdentity to include a new mSubId field"Frank Li2022-03-021-4/+9
|\ \
| * | [SUBID01-0]Grow NetworkIdentity to include a new mSubId fieldlifr2022-03-021-4/+9
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the previous design of NSS and NPMS, those only had IMSI to identify the cell network. Now the telephony has created the "subId" handle, which is the preferred mechanism for identifying subscribers. This commit adds NetworkStats support for subscriberId as a part of the network identity key Bug: 80526261 Test: atest NetworkTemplateTest NetworkStatsCollectionTest NetworkStatsServiceTest NetworkIdentityTest NetworkStatsDataMigrationUtilsTest (cherry-picked from ag/16825721) Change-Id: Ie1fe81006555dbcca4b62457fa6c319f04b4576d Merged-In: Ie1fe81006555dbcca4b62457fa6c319f04b4576d
* / [DU03-4]Add NETWORK_STACK Permission check for NetworkStatsService APIFrank2022-03-021-1/+1
|/ | | | | | | | | | | | | 1. getUidStatsForTransport API Bug: 210066922 Test: atest BatteryStatsImplTest WifiPowerCalculatorTest MobileRadioPowerCalculatorTest NetworkStatsServiceTest (cherry-picked from ag/16816095) Change-Id: I022c34b5af87fe3ff6857ea264bac2f7098eaed4 Merged-In: I022c34b5af87fe3ff6857ea264bac2f7098eaed4
* Merge changes from topic "ms52-movenetstats"Lorenzo Colitti2022-02-281-8/+18
|\ | | | | | | | | | | | | | | | | * changes: Expose MATCH_PROXY as a module-lib API. Add setPollForce to module API Move networkstats JNI to connectivity module [MS54.1] Move NetworkStats to updatable sources [MS62.1] Start NetworkStatsService from the module
| * Move networkstats JNI to connectivity moduleRemi NGUYEN VAN2022-02-181-0/+4
| | | | | | | | | | | | | | | | | | | | Reorganize networkstats JNI so it can be included in the connectivity module. Bug: 197717846 Test: m Change-Id: I815ea379f3d9915041c80ac5e743ce62e05f4cf8 Merged-In: I815ea379f3d9915041c80ac5e743ce62e05f4cf8
| * [MS54.1] Move NetworkStats to updatable sourcesJunyu Lai2022-02-181-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL builds NetworkStats related code with the connectivity module instead of platform. This includes: 1. Add netstats.proto to the module. 2. Add lib dependencies for all callers. 3. Include several source files in platform and add jarjar rule to it. Modify callers accordingly. Test: TH Bug: 197717846 Change-Id: I244693aebe1782d9e67502638ff8145c51462e1e Merged-In: I244693aebe1782d9e67502638ff8145c51462e1e
* | Fix system_server crash while iterating CookieTagMapmarkchien2022-02-181-1/+7
|/ | | | | | | | | | | | | | | When uid is removed, NetworkStatsService will iterate CookieTagMap and delete the corresponded uid socketTag value. But not only NetworkStatsService would detete CookieTagMap entries. There are other threads may also delete CookieTagMap entries such as #unTagSocket in bpfHandler and desctroy socket listener in TrafficController. System server crash as NPE because the CookieTagMap entry it iterate just be removed by other threads at the same time. This is just a simple fix to prevent the crash. Will have follow up CL for formal fix. Bug: 220084230 Test: m Change-Id: I08cad87f537fb09499faf1ff5cfd443fcb8ce436
* Replace qtaguid_deleteTagData with java implementationmarkchien2022-02-111-15/+117
| | | | | | | Copies the behavior of TrafficController::deleteTagData. Test: atest NetworkStatsServiceTest Change-Id: I436ce514108486db712b455f1b5fd8dca345c65c
* Merge "[MS59.3] Expose NetworkStatsDataMigrationUtils"Junyu Lai2022-01-291-3/+3
|\
| * [MS59.3] Expose NetworkStatsDataMigrationUtilsjunyulai2022-01-281-3/+3
| | | | | | | | | | | | Test: TH Bug: 204830222 Change-Id: I15a45fbadeb69b70a0e983b00de9e934d29749d6
* | Clear counters and delete tag data from NetworkStatsService.Lorenzo Colitti2022-01-281-2/+17
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, NetworkStatsService deletes tag data by calling NetworkManagementSocketTagger, which then calls into libcutils "qtaguid" code. Instead, make NetworkStatsService call into libcutils directly and delete the NetworkManagementSocketTagger code. In the future, this will make it easier for NetworkStatsService to perform this operation by calling directly into BpfNetMaps. Because the unit test does not yet have working JNI code, provide an internal TagStatsDeleter interface that can be mocked out via the Dependencies class. This is a bit ugly but it will be deleted as soon as the code uses BpfNetMaps directly. Delete NetworkManagementSocketTagger#setKernelCounterSet since it was replaced in aosp/1958917. Also remove unused includes and make formatting changes suggested by clang-format. Test: m Test: atest NetworkStatsServiceTest Test: atest NetworkUsageStatsTest Test: atest TrafficStatsTest Test: stats deleted when CtsUsageStatsTestCases completes and test APK is uninstalled Change-Id: I62987000afc185199821580232bfb7668c8e301e
* Merge "Update UidCounterSetMap directly from NetworkStatsService"Mark Chien2022-01-271-2/+51
|\
| * Update UidCounterSetMap directly from NetworkStatsServicemarkchien2022-01-261-2/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently NetworkStatsService call NetworkManagementSocketTagger#setKernelCounterSet which would call into netd to update UidCounterSet bpf map. This change let NetworkStatsService get UidCounterSetMap and update it directly. After this change, NetworkManagementSocketTagger#setKernelCounterSet could be removed because NetworkStatsService is the only caller. Test: dump UidCounterSetMap to ensure it still have value after removing netd code. Change-Id: I7ae14106ded4fa55122e93e76c3057052a2fa33e
* | Move the implement of getAllCollapsedRatTypes to StatsPullAtomServiceAaron Huang2022-01-271-1/+1
|/ | | | | | | | | | | To make data usage as a mainline module, move getAllCollapsedRatTypes to StatsPullAtomService since currently it is the only user. Also, the method needs to call getCollapsedRatType, thus move getCollapsedRatType to NetworkStatsManager and expose it as module API. Bug: 210073043 Test: builds, FrameworksNetTests Change-Id: Ibe41b50f173464694c21dd22841552bdb69a6a14
* Merge "Replace INetd#trafficSwapActiveStatsMap with ConnectivityManager API"Mark Chien2022-01-251-3/+12
|\
| * Replace INetd#trafficSwapActiveStatsMap with ConnectivityManager APImarkchien2022-01-211-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | INetd#trafficSwapActiveStatsMap is deprecated and the implementaion is moved into tethering (connectivity) mainline module. A new ConnectivityManager API swapActiveStatsMap is temprary exposed for NetworkStatsFactory. Once NetworkStatsFactory move into tethering module, swapActiveStatsMap API would be removed and NetworkStatsFactory should could call the implemeneted inside the module directly. This should happen before T sdk finalization. Bug: 209935649 Test: atest NetworkStatsFactoryTest Change-Id: I6685fe513511e7af9fa6521601891c66d1297da0
* | Merge "[MS67.1] Expose registerUsageCallback with template"Junyu Lai2022-01-251-7/+6
|\ \
| * | [MS67.1] Expose registerUsageCallback with templatejunyulai2022-01-241-7/+6
| | | | | | | | | | | | | | | | | | Test: atest FrameworksNetTests Bug: 204830222 Change-Id: I643e2d96144210852fc8916ec9c483f2b207a48b
* | | Merge "Monitor interface added and update bpf interface map"Maciej Żenczykowski2022-01-241-0/+12
|\ \ \ | |/ / |/| |