summaryrefslogtreecommitdiff
path: root/framework-t/src/android/net/NetworkStatsHistory.java
Commit message (Collapse)AuthorAgeFilesLines
* Return sorted NetworkStatsHistoryJunyu Lai2022-05-261-65/+61
| | | | | | | | | | | | | | | | | | NetworkStatsHistory internally assumes that bucketStart is sorted at all times. However, in the fields, we've found there are some buckets of NetworkStatsHistory do not preserve the order of timestamp, which is caught by the IAE when addEntry is called. In order to provide backward compatibility, return sorted items instead of throwing IAE when adding entry into NetworkStatsHistory instance. Ignore-AOSP-First: Base change not in AOSP, will cherry-pick immediately after Test: atest android.net.netstats.NetworkStatsHistoryTest#testBuilder Bug: 233825704 Change-Id: If3187384bd1e90770ca5873b8ec73e852fff543d
* Don't clobber existing history entries.Lorenzo Colitti2022-05-181-1/+31
| | | | | | | | | | | | | | | | | | Currently, adding a history to a NetworkStatsCollection.Builder will overwrite any history that was previously passed in with the same key. This breaks the importer (which is the primary/only caller of this code), because the importer re-uses the same NetworkStatsCollection object to import multiple files. Instead, simply add any passed-in entries after the ones that were already there. Require the caller to pass in entries in order, because NetworkStatsHistory internally assumes that entris are always sorted. Ignore-AOSP-First: in a topic with internal-only changes Bug: 230289468 Test: manually verified this unbreaks the importer Change-Id: Ic8647ff28fca78d579d5f759f96a864877f8158b
* Ensure NetworkStats migrated snapshot is identicalRemi NGUYEN VAN2022-05-181-0/+20
| | | | | | | | | | | | | | 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
* [MS81] Support remove history before cutoff timestampJunyu Lai2022-05-161-6/+8
| | | | | | | | | | | This is needed to ensure corrupted data can be clean up if the data migration process dones't go well. Test: NetworkStatsCollectionTest Bug: 197717846 Change-Id: Ic76ad6f3e96f03791b48988fb2622c9c647ffc7c (cherry picked from commit 306a00316cac03a0c61f995316c9c5682bec2a19) Merged-In: Ic76ad6f3e96f03791b48988fb2622c9c647ffc7c
* Fix proto invalid write typeAaron Huang2022-03-041-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
* [MS54.1] Move NetworkStats to updatable sourcesJunyu Lai2022-02-071-9/+10
| | | | | | | | | | | | | | | 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
* [MS58] Expose Apis which will be used by data migration utilityJunyu Lai2022-01-241-1/+3
| | | | | | | | | | | | | This includes: 1. NetworkIdentity 2. NetworkIdentitySet 3. NetworkStatsHistory NetworkStatsCollection Apis will be exposed in a separate CL. Test: TH Bug: 204830222 Change-Id: I47b2d3ac3b86cb4e6879afaae34326ca3c050ffa
* [MS56.1] Add NetworkStatsHistory#BuilderJunyu Lai2022-01-231-1/+229
| | | | | | | | | | | NetworkStatsHistory will need to be exposed and constructed from the data migration tool in the follow-up changes. Add a Builder class to prevent from exposing internal array structures. Test: atest NetworkStatsHistoryTest#testBuilder Bug: 204830222 Change-Id: I5f8ea1c825d601de0aac8623034ef896999fc1a0
* [MS57.1] Prepare APIs for data migration utilityJunyu Lai2022-01-201-5/+49
| | | | | | | | | | | | | | This includes: 1. Move PREFIX_* constants to NetworkStatsManager to expose in later changes. 2. Rename networkId to wifiNetworkKey. 3. Rename subType to ratType. 4. Replace SUBTYPE_COMBINED with NETWORK_TYPE_ALL 5. Fix lint errors when exposing system api. Test: TH Bug: 204830222 Change-Id: I2b7c34958bc59c3225c96f12abba008b83101585
* [MS19.1] Fix several hidden API dependenciesJunyu Lai2021-12-281-7/+13
| | | | | | | | | | | | | | | | This includes: 1. Use android.util.IndentingPrintWriter instead of the deprecated internal one. 2. Replace usages of IntArray with CollectionUtils and ArrayList. 3. Replace usages of ArrayUtils with CollectionUtils. 4. Refactor MathUtils.constrain functions into NetworkStatsUtils. 5. Replace Maps.newHashMap and Lists.newArrayList with public class constructors. 6. Replace Slog with Log. Test: FrameworksNetTests NetworkStaticLibTests Bug: 204830222 Change-Id: If009194ad5668a6d48dd341ea6d325028ce56d42
* [MS10.1] Move multiplySafeByRational to NetworkStatsUtilsJunyu Lai2021-12-201-1/+1
| | | | | | | | | | | | Since NetworkStats related code will be moved to the module. multiplySafeByRational in the NetworkUtilsInternal cannot be accessed after that. Thus, create another utils class that will be moved with NetworkStats code and put the function into it. Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.NetworkStatsUtilsTest Bug: 204830222 Change-Id: I96f3ac02e57b7325ed53988285770f478dee529e
* [MS08] Move NetworkStats files to f/b/package/ConnectivityTJunyu Lai2021-12-101-0/+881
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