Commit Graph

82 Commits

Author SHA1 Message Date
Lorenzo Colitti
ca25ad3567 Merge changes from topic "ms52-movenetstats"
* 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
2022-02-28 05:32:23 +00:00
markchien
2616b49c70 Fix system_server crash while iterating CookieTagMap
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
2022-02-18 10:11:15 +00:00
Remi NGUYEN VAN
63d42a25bb Move networkstats JNI to connectivity module
Reorganize networkstats JNI so it can be included in the connectivity
module.

Bug: 197717846
Test: m
Change-Id: I815ea379f3d9915041c80ac5e743ce62e05f4cf8
Merged-In: I815ea379f3d9915041c80ac5e743ce62e05f4cf8
2022-02-18 16:20:47 +08:00
Junyu Lai
63627bce56 [MS54.1] Move NetworkStats to updatable sources
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
2022-02-18 16:20:47 +08:00
Patrick Rohr
397799787d Merge "Replace qtaguid_deleteTagData with java implementation" 2022-02-16 19:59:14 +00:00
markchien
336d3c71b3 Replace qtaguid_deleteTagData with java implementation
Copies the behavior of TrafficController::deleteTagData.

Test: atest NetworkStatsServiceTest
Change-Id: I436ce514108486db712b455f1b5fd8dca345c65c
2022-02-11 14:51:09 +08:00
Aaron Huang
83400b6b3b Split out the ipsec API surface and use framework-connectivity-tiramisu
(cherry picked from commit 131a866384)
Bug: 204153604
Test: TH
Change-Id: I6cc8aef6a0ab9ce4bcef2797196b1d1b3687acca
Merged-In: I6cc8aef6a0ab9ce4bcef2797196b1d1b3687acca
2022-02-10 19:01:00 +09:00
Chiachang Wang
531889a993 Correct typo in the year of copyright
Test: m
Change-Id: I68e9925b5b6deb7c5c9d57aa4a397c80f8b8d869
2022-02-09 11:38:37 +00:00
Treehugger Robot
4a53677d10 Merge "Add key / value data structures for IBpfMaps" 2022-02-04 23:39:29 +00:00
Patrick Rohr
fc3b420236 Add key / value data structures for IBpfMaps
Add key / value structures for CookieTagMap, StatsMap, and UidStatsMap.
This will be used for deleteTagData.

Test: m
Change-Id: I955ae7f7745d4c5f37eccbad80cdb841ef55ff56
2022-02-04 13:13:02 +01:00
Remi NGUYEN VAN
bca7618ded Support discover/resolve on specific networks
This adds a Network member to NsdServiceInfo, allowing discovered
services to report which network they were discovered on, and clients to
specify which network to resolve the service on. If clients use the
discovered NsdServiceInfo to resolve a service, it will be resolved on
the network where it was discovered instead of an unspecified network.

Also add a network parameter to a new overload of
NsdManager#discoverServices, so that clients can discover on specific
networks.

Bug: 190249673
Test: atest NsdManagerTest

Change-Id: Idc4bf9fde0f4b0328204a8cd2eedc12fffbbbdba
2022-02-03 13:04:08 +09:00
hepengtao
271548c96d NSD: Specify on what interface to getAddrInfo
When discover two different host with same host name
from different network interface, specify on what
 interface to getAddrInfo.

Bug: 203453164
Test: build & manual

Signed-off-by: hepengtao <hept.hept.hept@gmail.com>
Change-Id: Ifaccb7f3fac6b1dd789cc9ce7c8d964102754508
2022-02-02 17:50:50 +09:00
Lorenzo Colitti
a6bc0e1373 Merge changes from topics "move-kerneltotag", "move-socket-tagging-to-mainline"
* changes:
  Move socket tagging implementation to mainline.
  Move kernelToTag to NetworkStatsFactory.
2022-01-31 13:35:30 +00:00
Lorenzo Colitti
adab7b1cc3 Move kernelToTag to NetworkStatsFactory.
... to prepare for the deletion of NetworkManagementSocketTagger.

Test: atest FrameworksNetTests
Change-Id: Id3ad67fa640ddb9ab446e10dcf8e6a588d661dd9
2022-01-29 21:54:15 +09:00
Junyu Lai
8de5088578 Merge "[MS59.3] Expose NetworkStatsDataMigrationUtils" 2022-01-29 03:55:41 +00:00
junyulai
aa6eed54a7 [MS59.3] Expose NetworkStatsDataMigrationUtils
Test: TH
Bug: 204830222
Change-Id: I15a45fbadeb69b70a0e983b00de9e934d29749d6
2022-01-28 11:03:53 +00:00
Lorenzo Colitti
bf254864a4 Clear counters and delete tag data from NetworkStatsService.
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
2022-01-28 13:02:48 +09:00
Frank
de9b4def5f [DU12]Remove NetworkType Annotation
Bug: 216619447
Test: atest NetworkTemplateTest NetworkStatsCollectionTest
            NetworkStatsSubscriptionsMonitorTest
Change-Id: I58689201a684f581a4b88df058a5e0683da61926
2022-01-27 22:28:20 +08:00
Mark Chien
b68a9f0972 Merge "Update UidCounterSetMap directly from NetworkStatsService" 2022-01-27 10:02:35 +00:00
Aaron Huang
1618171b38 Move the implement of getAllCollapsedRatTypes to StatsPullAtomService
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
2022-01-27 12:27:20 +08:00
Aaron Huang
0bfd365a4f Move NETWORK_TYPE_5G_NSA from NetworkTemplate to NetworkStatsManager
Move NETWORK_TYPE_5G_NSA to NetworkStatsManager. Also expose it as
module API so that it can be used out of module.

Bug: 210073043
Test: builds, FrameworksNetTests
Change-Id: I670c7e1405107bbe30b92fe1a8d81652c46de6d9
2022-01-27 12:23:56 +08:00
markchien
ad9ee7d926 Update UidCounterSetMap directly from NetworkStatsService
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
2022-01-26 22:50:27 +08:00
Junyu Lai
0534b453bc Merge "[MS68.1] Register usage callback from NetworkPolicyManagerService" 2022-01-25 13:30:57 +00:00
Mark Chien
121c4fc872 Merge "Replace INetd#trafficSwapActiveStatsMap with ConnectivityManager API" 2022-01-25 03:34:14 +00:00
Junyu Lai
a88cab0f1f Merge "[MS67.1] Expose registerUsageCallback with template" 2022-01-25 01:23:45 +00:00
Maciej Żenczykowski
8036c626b2 Merge "Monitor interface added and update bpf interface map" 2022-01-24 19:05:27 +00:00
Junyu Lai
546ae74ab9 Merge changes I54c2258c,I47b2d3ac
* changes:
  [MS38] Remove android.os.HandlerExecutor dependencies
  [MS58] Expose Apis which will be used by data migration utility
2022-01-24 14:08:56 +00:00
junyulai
f6487fb3c1 [MS68.1] Register usage callback from NetworkPolicyManagerService
Use usage callback to replace the need of intent receiver.

Test: atest TrafficStatsTest NetworkUsageStatsTest FrameworksNetTests
Bug: 204830222
Change-Id: I40967c2b6c86d25c7db93e6d3a4908b72ed76154
2022-01-24 21:07:04 +08:00
junyulai
18a2105afa [MS67.1] Expose registerUsageCallback with template
Test: atest FrameworksNetTests
Bug: 204830222
Change-Id: I643e2d96144210852fc8916ec9c483f2b207a48b
2022-01-24 19:38:06 +08:00
junyulai
c28dd15332 [MS38] Remove android.os.HandlerExecutor dependencies
Mainline module can't use internal HandlerExecutor, so inline
the implementation instead.

Test: atest FrameworksNetTests NetworkPolicyManagerServiceTest
Bug: 204830222
Change-Id: I54c2258cb3cee5fb862409441de293d6fed6b32c
2022-01-24 15:53:42 +08:00
Xiao Ma
ed76c1b8ea Move Ethernet related files to f/b/packages/ConnectivityT.
ethernet-service is going to be moved into Connectivity mainline module.
Notice that below sources are also only used in the ethernet framework
during compiling the filegroup: framework-connectivity-ethernet-sources.
Move them from f/b to f/b/packages/ConnectivityT as well.

Ethernet framework only related files:
    - IInternalNetworkManagementListener.aidl
    - InternalNetworkManagementException.java
    - InternalNetworkManagementException.aidl
    - InternalNetworkUpdateRequest.java
    - InternalNetworkUpdateRequest.aidl

Ethernet service only related files:
    - DelayedDiskWrite.java(IpConfigStore imports this class)

Bug: 210586283
Test: build pass
      atest FrameworksNetTests
      atest EthernetServiceTests
Change-Id: I1ec2d1d182c04f3f2acc9b757d5061ca749a4a3c
2022-01-24 04:15:14 +00:00
markchien
debfc4015b Monitor interface added and update bpf interface map
Have BpfInterfaceMapUpdater to update bpf interface map: adding
the interface and index mapping to bpf interface map when interface
added.

Bug: 215095957
Test: atest FrameworkNetTests

Change-Id: I2189a50c4869cfc0c33fc6f0228f40ee9f3ac1d4
2022-01-21 23:34:57 +08:00
markchien
9703eb291c Replace INetd#trafficSwapActiveStatsMap with ConnectivityManager API
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
2022-01-21 19:24:08 +08:00
Junyu Lai
6dcaf9dee4 Merge changes from topic "ms65-identity"
* changes:
  [MS65.1] Add NetworkIdentity#Builder
  [MS46] Remove INetworkStatsSession usage from NetworkCycleDataLoader
2022-01-21 09:36:08 +00:00
lifr
02eb422cb4 [DU03-1]Remove INetworkStatsService from BatteryStatsImpl
Expose systemapi NetworkStats.getDetailedUidStats for use by
BatteryStats.

BatteryStatsImpl is using INetworkStatsService APIs, which
cannot be accessed after moving into the mainline module. So, replace
and remove those hidden API usages.

Bug: 210066922
Test: atest BatteryStatsImplTest WifiPowerCalculatorTest
            MobileRadioPowerCalculatorTest NetworkStatsServiceTest
CTS-Coverage-Bug: 213437796
Change-Id: I40d713923278f4654d67bb4d12155cea85c10447
2022-01-21 13:52:41 +08:00
Junyu Lai
717c22831a Merge changes from topic "ms57-migrationapi"
* changes:
  [MS57.1] Prepare APIs for data migration utility
  [MS45] Expose SystemApis to query summary and history with template
2022-01-21 04:26:57 +00:00
Frank Li
b45f4fb06d Merge "[DU05]Remove the android.provider.Settings.Global in NetworkStatsService" 2022-01-21 03:03:51 +00:00
Junyu Lai
86377eba46 [MS65.1] Add NetworkIdentity#Builder
Test: atest NetworkIdentityTest#testBuilder
Bug: 204830222

Change-Id: Ifdb6482a54fb1e6999c82647d2710cb833c78d02
2022-01-20 17:12:14 +00:00
Junyu Lai
a8dc50de05 [MS57.1] Prepare APIs for data migration utility
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
2022-01-20 13:10:36 +00:00
Junyu Lai
bb459aeaba [MS41.1] Prepare for APIs for querying usage with template
This CL includes:
1. Prepare for queryDetailsForDevice which allows callers
   to query history of networks that matches the given template.
2. Prepare for queryDetailsForUidTagState, which allows
   callers to query history uid stats with the given template,
   uid and other conditions.
3. Enforce fine location permission if the caller is querying
   data usage with a template which contains wifi network keys.

Test: atest NetworkStatsServiceTest NetworkStatsManagerTest
Bug: 204830222
Bug: 200768422
Change-Id: I6783d6bfd6e075e0b3ec8a3c91836377f1d71c7a
2022-01-20 13:03:35 +00:00
Frank
878641336d [DU05]Remove the android.provider.Settings.Global in NetworkStatsService
Replace android.provider.Settings.Global methods that return the default
value and hardcoding them inside the methods.

Bug: 213329727
Test: atest NetworkStatsServiceTest
Change-Id: I51d686222f983c8deb71d4b32f9e443e87a5e53e
2022-01-20 16:45:13 +08:00
Paul Hu
64f906a06a Merge "Split out the nsd API surface and use framework-connectivity-tiramisu" 2022-01-20 03:02:56 +00:00
paulhu
172aa68e5d Split out the nsd API surface and use framework-connectivity-tiramisu
- Split out nsd APIs and hidden APIs to Connectivity module.
- Keep the all files in f/b/packages/Connectivity-T and add
  framework-connectivity-tiramisu library on p/m/Connectivity.
  Then make framework to use this module library.
- Remove NsdService from SystemServer which will register from
  ConnectivityServiceInitializer

Bug: 206893064
Test: m online-sdk-dev-docs
Test: atest FrameworksNetTests CtsNetTestCases
CTS-Coverage-Bug: 207804007
Merged-In: I72c7de124b9cc53f2263bd452ecd5f39e88e485b
Change-Id: I72c7de124b9cc53f2263bd452ecd5f39e88e485b
2022-01-19 18:47:45 +08:00
Junyu Lai
a079336270 Merge changes I16418791,I210f5ddc
* changes:
  [MS37.1] Expose APIs which is used by NPMS
  [MS55] Remove INetworkStats dependency from DataIdleTest
2022-01-19 07:08:15 +00:00
Junyu Lai
ba8efd5c84 [MS37.1] Expose APIs which is used by NPMS
Test: TH
Bug: 204830222
CTS-Coverage-Bug: 213124616
Change-Id: I16418791246b12fc3da7348ed36b58274e20db54
2022-01-19 07:07:34 +00:00
lifr
69e220ccd8 [DU04-1]Remove NetworkPolicyManagerInternal from NetworkStatsService
Expose system APIs for use by NetworkStatsService.

Bug: 211843446
Test: atest NetworkStatsServiceTest NetworkPolicyManagerTest
            NetworkPolicyManagerServiceTest
Change-Id: I56a066b7f4b4c2c8fefdd185c2e50de63b1e2629
2022-01-18 03:16:51 +08:00
Junyu Lai
ada2a7fb3a Merge changes If51b6676,Ia6863a70,I802d2316
* changes:
  [MS37] Replace NetworkStatsManagerInternal usages in NPMS
  [MS36] Remove unused getNetwork[Total|Uid]Bytes
  [MS35] Remove getNetwork[Total|Uid]Bytes dependencies from NPMS
2022-01-17 08:15:14 +00:00
Frank Li
5479b9dd88 Merge "[DU04]Remove NetworkPolicyManagerInternal from NetworkStatsService" 2022-01-15 23:14:16 +00:00
Junyu Lai
4161a04033 [MS37] Replace NetworkStatsManagerInternal usages in NPMS
This is done by:
1. Add NetworkStatsManagerInternal APIs directly from
   NetworkStatsManager, these APIs are needed by NPMS.
2. Replace all usages with these APIs.
3. Delete NetworkStatsManagerInternal implementation.

Test: atest FrameworksNetTests NetworkPolicyManagerServiceTest
Bug: 204830222
CTS-Coverage-Bug: 213124616
Change-Id: If51b6676915e3a0a8a9f95221d735306911442fc
2022-01-15 08:34:35 +00:00
Junyu Lai
3715b37705 [MS36] Remove unused getNetwork[Total|Uid]Bytes
Since the usages are all removed, clean up the
unused code accordingly.

Test: TH
Bug: 204830222
Change-Id: Ia6863a7098632580b411bd79550754e511ea2543
2022-01-15 08:34:35 +00:00