Commit Graph

128 Commits

Author SHA1 Message Date
Aaron Huang
d99dc72c93 Merge "Have NetworkStats implements iterable" 2022-01-20 04:09:00 +00:00
Paul Hu
0e3adda802 Merge "Split out the nsd API surface and use framework-connectivity-tiramisu" 2022-01-20 03:02:56 +00:00
Treehugger Robot
bfcf6325ee Merge "[MS64] Remove subscriberId and NetworkId in proto" 2022-01-20 02:32:59 +00:00
Junyu Lai
11169e3da7 [MS64] Remove subscriberId and NetworkId in proto
netstats.proto is about to move into mainline module.
And it can no longer see privacy.proto definition.
Thus, this change remove PII data that is not very useful
when debugging and any reference to privacy.proto.

Test: adb bugreport and check output at transponder
Bug: 204830222
Change-Id: I755530f356d2c16b336d62785c4c17c557f792db
2022-01-19 16:08:40 +00:00
paulhu
66f61acfec 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
Treehugger Robot
41fe9f7e31 Merge "Remove ServiceManager usage from IpSecTransform" 2022-01-19 07:59:56 +00:00
Aaron Huang
874d4076a7 Have NetworkStats implements iterable
Make NetworkStats be iterable and expose iterator as system API
which is better than expose size() and getValues().
This API could be used by the caller who needs to get entry
from NetworkStats.

Bug: 210073043
CTS-Coverage-Bug: 215061403
Test: build, TH
Change-Id: I6cb4c8f63d7067133f2722b2be7e16b4098a697d
2022-01-19 15:54:17 +08:00
Junyu Lai
54eb405c64 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
6fbf3ee9f5 [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
Xiao Ma
c19bac5292 Merge "Fix the Preconditions dependency in EthernetNetworkSpecifier." 2022-01-19 03:23:17 +00:00
Treehugger Robot
2b10dcdec0 Merge "[MS63.1] Remove TrafficStats.TAG_SYSTEM_DOWNLOAD dependency" 2022-01-18 13:04:35 +00:00
Xiao Ma
abdbab01cc Fix the Preconditions dependency in EthernetNetworkSpecifier.
Ethernet service related files are going to be moved into Connectivity
module. Replace the Preconditions class in the EthernetNetworkSpecifier,
either add modules-utils-preconditions static lib dependency to fix it,
however, notice that will result in the duplicate class import when
moving ethernet stuff to p/m/Connectivity.

Bug: 210586283
Test: atest FrameworksNetTests EthernetServiceTests
Change-Id: I6163699be4126ef1b95dfb87ec9a6aba2c01195a
2022-01-18 04:50:41 +00:00
Junyu Lai
ab2c35e440 [MS63.1] Remove TrafficStats.TAG_SYSTEM_DOWNLOAD dependency
Replace with system Api.

Test: TH
Bug: 204830222
CTS-Coverage-Bug: 215043101
Change-Id: Ic14b26d2862f6fe8bee18fe0c9eaf183052452ee
2022-01-18 02:54:27 +00:00
Treehugger Robot
dfb7be30d1 Merge "[MS30] Remove ServiceManager#getService dependency" 2022-01-17 15:28:46 +00:00
Junyu Lai
3f7bb338bd [MS30] Remove ServiceManager#getService dependency
Since TrafficStats is moving into the mainline module,
ServiceManager#getService can no longer be accessed.

This change use reflection to access getService, since
there is no offical way to get the service binder,
and TrafficStats is a static utility that doesn't have
the context to invoke Context#getSystemService.

This change also fixes minor lint errors.

Test: atest CtsNetTestCases:TrafficStatsTest
Bug: 204830222
Change-Id: I5caec42a71431b39f747fc791b8511d92e5cf7cc
2022-01-17 13:54:06 +00:00
Aaron Huang
8843680f9a Merge "Add getter for the fields of NetworkStats.Entry" 2022-01-17 09:31:55 +00:00
Junyu Lai
dbc0da139c 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
Aaron Huang
6b9248ea6e Add getter for the fields of NetworkStats.Entry
NetworkStats is going to be moved into mainline module and
there're some external callers have dependencies on it.
To replace those hidden APIs with formal APIs, NetworkStats
needs to expose some getter methods to eliminate the dependencies
on hidden API.

Bug: 210073043
Bug: 204830222
CTS-Coverage-Bug: 214881138
Test: FrameworksNetTests
Change-Id: I85bb6b27bd17bad16c9693d95b569d0ec5fbb785
2022-01-17 06:32:21 +00:00
Treehugger Robot
71b890a440 Merge "Revert "Pivot network statistics to use DataInput/Output."" 2022-01-15 13:25:40 +00:00
Junyu Lai
6e782c7ad3 [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
5e3545fc7f [MS35] Remove getNetwork[Total|Uid]Bytes dependencies from NPMS
1. getNetworkTotalBytes was used for querying overall statistics
   that regards of the NetworkPolicy to calculate the remaining
   data warning/limit quota that needs to be send to the lower layer.
2. getNetworkUidBytes was used for querying overall statistics of
   apps to find out the rapid traffic that caused by an abnormal
   app behavior.

This change replaces getNetwork[Total|Uid]Bytes with APIs that are
about to expose, and introduces a dependencies object for better
unit test injection.

Test: atest NetworkPolicyManagerServiceTest
Bug: 204830222

Change-Id: I802d2316fb22886e951456df0941c09176c981f8
2022-01-15 08:34:35 +00:00
Junyu Lai
d7045d6fa1 Revert "Pivot network statistics to use DataInput/Output."
This reverts commit daa23607be.

Reason for revert: FastDataInput/Output is hidden and cannot be used in mainline module.

Test: TH
Bug: 204830222
Change-Id: I8cfa435bb6233818adb9cc99dadeeb06a03443d5
2022-01-15 08:16:25 +00:00
Aaron Huang
17856061fa Merge "Add PolicyDirection InfDef annotation to IpSecManager" 2022-01-15 06:08:32 +00:00
Junyu Lai
6c83653cbb Merge "[MS44.1] Add API to query tagged UID summary" 2022-01-13 11:25:15 +00:00
Aaron Huang
ca9c1df504 Add PolicyDirection InfDef annotation to IpSecManager
IpSec is going to be moved into Connectivity module and it needs to
use PolicyDirection annotation. Add PolicyDirection IntDef annotation
so that it can be used in the module.

Bug: 204153604
Test: FrameworksNetTests
Change-Id: Ib411d8c436d67574bfaf7f3aba43e5f31e7487e2
2022-01-13 10:43:54 +08:00
Junyu Lai
f577b2248b [MS44.1] Add API to query tagged UID summary
Query tagged UID summary is currently needed by
StatsPullAtomService to collect tagged traffic statistics.
Add an Api via NetworkStatsManager to support this
functionality.

Test: atest NetworkStatsManagerTest
Bug: 204830222
Change-Id: Iaa54482a8109b56e66e829c5bec5a8a8f466641a
2022-01-13 01:01:46 +00:00
Aaron Huang
e17a9d4536 Check iface by TextUtils.equals
In current equals method, if iface is null then it will cause
null object reference when checking iface.
Thus, use TextUtils.equals to check iface so that it can compare
null iface.

Bug: 210073043
Test: FrameworksNetTests, NetworkStaticLibTests
Change-Id: I2bd8127cb030ea54438382ee89961590fffbc31a
2022-01-12 23:30:43 +08:00
lifr
d686e2dd2d [DU03]Remove INetworkStatsService from BatteryStatsImpl
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
CTS-Coverage-Bug: 213437796

  (cherry-picked from ag/16548638)

Change-Id: I584897ff8ba303c717a9df3756c9f6778c1cfb10
Merged-In: I584897ff8ba303c717a9df3756c9f6778c1cfb10
2022-01-12 07:28:55 +00:00
Junyu Lai
61ebc2fc7f [MS22] Move NetworkManagementSocketTagger into the module
This is heavily used by TrafficStats, and no other modules
are using it. Hence it should be moved to the module as well.

Test: TH
Bug: 204830222

Change-Id: I7ea1ccb916e796c786c29d53e4ecf3970a8af6dd
2022-01-07 09:57:15 +00:00
Junyu Lai
6ba0487c91 [MS09] Expose NetworkTemplate APIs which are needed by NetworkPolicy
This change also remove getWifiNetworkKey which should not be exposed
as system API.

Test: atest NetworkTemplateTest
Bug: 204830222
Change-Id: I924f62025a8672167f778ff790cd208c74eed878
2022-01-06 09:22:52 +00:00
Treehugger Robot
e10a94f740 Merge changes from topics "ms25-appops", "ms28-service-fix"
* changes:
  [MS25.1] Remove AppOpsManager.OP_GET_USAGE_STATS dependency
  [MS28.1] Fix several hidden API dependencies
2022-01-03 22:41:07 +00:00
Les Lee
b0493845c3 Merge "wifi data usage: replaced Wi-Fi SSID with a Wi-Fi network key" 2022-01-03 12:36:49 +00:00
Les Lee
03bc782031 wifi data usage: replaced Wi-Fi SSID with a Wi-Fi network key
1. Used SSID to be a wifi network identity can't separate wifi
data usage when there are two different network with same SSID.
Use a new usage key from WifiInfo to replace wifi SSID to solve
this issue.

2. To support to query wifi usage per configured Wifi network.
Adding matchWifiNetworkKeys in NetworkTemplate to support querying
multi networkKeys wifi data usage since each configured Wifi
network configuration might be used to connect different Wifi
network. (Replace mNetworkId with mMatchWifiNetworkKeys)

3. Updated callers who were using NetworkTemplate constructor.

4. Fixed SortedSet null order case. The null subscriberId is a
valid input for matchSubscriberIds.

5. Replaced ArrayUtils with CollectionUtils.

Bug: 197520752
Bug: 126299427
Test: atest -c NetworkTemplateTest
Test: atest -c NetworkStatsServiceTest
Test: atest -c NetworkPolicyManagerServiceTest
Test: atest -c NetworkPolicyTest
Change-Id: Ie20e7fb56597817901be4ce1d2a7afcbc9ded0c6
2022-01-03 15:13:00 +08:00
Treehugger Robot
400e4dff51 Merge "[MS23] Remove UserHandle.getUserId dependencies" 2021-12-30 15:45:03 +00:00
Treehugger Robot
08af91950f Merge "[MS26.1] Remove Process.NETWORK_STACK_UID dependency" 2021-12-30 12:43:39 +00:00
Junyu Lai
7a6dbd4394 [MS25.1] Remove AppOpsManager.OP_GET_USAGE_STATS dependency
Replaced by public interface.

Test: TH
Bug: 204830222
Change-Id: If7d17879b0ffdb6300373bc581cb07252fccfc7a
2021-12-30 10:00:19 +00:00
Junyu Lai
f81e323a23 [MS23] Remove UserHandle.getUserId dependencies
Replaced with SystemApi.

Test: TH
Bug: 204830222
Change-Id: Ibc834489428c2036cd4ccd3284ba06c4c9e792b7
2021-12-30 10:00:19 +00:00
Treehugger Robot
22c616d261 Merge "[MS21] Remove DataUnit dependency" 2021-12-29 13:24:49 +00:00
Treehugger Robot
9e3c325be4 Merge "[MS19.1] Fix several hidden API dependencies" 2021-12-29 05:16:58 +00:00
Junyu Lai
8b46180814 [MS26.1] Remove Process.NETWORK_STACK_UID dependency
Check NetworkStack permission instead.

Test: NetworkStatsAccessTest
Bug: 204830222
Change-Id: I052a1422d145af533b036b0f017ace485b67cbfe
2021-12-29 01:43:54 +00:00
Junyu Lai
1d3ce85882 [MS21] Remove DataUnit dependency
DataUnit is a hidden class, remove the references to
it from files that about to be moved into the module.

Test: TH
Bug: 204830222

Change-Id: Ibfb82ab74f283686fb2af6c3a550d541440c890d
2021-12-29 01:43:53 +00:00
Junyu Lai
7ad3d346b2 [MS19.1] Fix several hidden API dependencies
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
2021-12-28 09:16:33 +00:00
Aaron Huang
80a73fd6cc Remove ServiceManager usage from IpSecTransform
Remove ServiceManager hidden API dependency because this class
is going to be moved into mainline module. Thus have IpSecTransform
calls createTransform and deleteTransform through IpSecManager to
remove the ServiceManager usage.

Bug: 204153604
Test: FrameworksNetTests
Change-Id: Iba48da4aecac1080684d5a7e7e7ca2e31219591a
2021-12-28 02:59:26 +08:00
Junyu Lai
40e4fc8326 [MS18] Augment data usage by default
Follow-up from ag/2815797, callers who uses the hidden API
will have their data augmented by default, and the public
API offers a way to opt-into augmentation.

However, since the data usage is going to the module.
All the hidden API usage must be eliminated. Also, from user
perspective, it is better for UI and API to have aligned
behavior.

Thus, enable augment data usage for public API callers.

Test: atest FrameworksNetTests \
      android.app.usage.cts.NetworkUsageStatsTest
Bug: 204830222
Change-Id: Ida254fac8d44c32d388f1886a866f7324a41ce75
2021-12-24 09:55:22 +00:00
Junyu Lai
4aaf65aa86 [MS16.1] Prepare APIs for replacing getNetwork[Total|Uid]Bytes
These internal methods are used in MultipathPolicyTracker and
NetworkPolicyManagementService. getNetworkTotalBytes is used
to query total bytes regarding to the specified NetworkPolicy,
to see how much data quota is used. getNetworkUidBytes is used
to find the app to blame for rapid data usage.

These methods needs to be replaced by public APIs in follow-up
patches.

Test: TH
Bug: 204830222
Change-Id: Iec9cc7a07397ec2bbc6c3d2559fc3680b149cb8a
2021-12-24 08:50:29 +00:00
Junyu Lai
03cbe3f73b Merge "[MS15.1] Remove get/setSubscriberIdMatchRule dependencies" 2021-12-23 01:35:00 +00:00
James Mattis
407ea1dfc3 eth manager updates for network management APIs
Private methods added to EthernetManager for network management to be
made public when ready.

Bug: 210485380
Test: make, flash and boot
Change-Id: I7f484d373e05225c98bf0e6111afdc12be31764f
2021-12-22 11:11:01 -08:00
Frank Li
6129e19e41 Merge "[DU02]Remove DevicePolicyManagerInternal from NetworkStatsAccess" 2021-12-22 14:13:55 +00:00
Treehugger Robot
dae874959a Merge "Replace Preconditions.checkNotNull with Objects.requireNonNull" 2021-12-22 11:37:42 +00:00
Junyu Lai
e33b61eed1 [MS15.1] Remove get/setSubscriberIdMatchRule dependencies
Subscriber Id Match Rule won't be exposed as system Api.
Callers should use Builder#setSubscriberIds or
NetworkTemplate#getSubscriberIds to set/get the Subscriber
Ids filter. An empty set in the paremter or return value
represents the intention of matching any Subscriber Ids.

Test: atest NetworkPolicyManagerServiceTest \
      FrameworksNetTests
Bug: 204830222

Change-Id: I12c54280b44c71e4737e82859dfe869794cc9c29
2021-12-22 09:50:44 +00:00