Commit Graph

3459 Commits

Author SHA1 Message Date
Aaron Huang
3b5180d80e 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
Frank Li
5479b9dd88 Merge "[DU04]Remove NetworkPolicyManagerInternal from NetworkStatsService" 2022-01-15 23:14:16 +00:00
Treehugger Robot
362c825b3a Merge "Revert "Pivot network statistics to use DataInput/Output."" 2022-01-15 13:25:40 +00:00
Junyu Lai
5d46aecf45 Merge "[MS43] Remove EventLogTags depdendency" 2022-01-15 08:37:54 +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
Junyu Lai
638f6667e9 [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
4c0b80f6f1 Revert "Pivot network statistics to use DataInput/Output."
This reverts commit 1b4f0a409d.

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
Junyu Lai
86adedf565 [MS43] Remove EventLogTags depdendency
Inline functions and copy constants to the service.

Test: TH
Bug: 204830222
Change-Id: Idf5c8ff7c7fec39530269b3c6b24475407198fbc
2022-01-15 08:16:25 +00:00
Aaron Huang
5f70655025 Merge "Add PolicyDirection InfDef annotation to IpSecManager" 2022-01-15 06:08:32 +00:00
lifr
5f631cf00b [DU04]Remove NetworkPolicyManagerInternal from NetworkStatsService
NetworkStatsService is using NetworkPolicyManagerInternal APIs, which
cannot be accessed after moving into the mainline module. So, replace
and remove those hidden API usages.

Bug: 211843446
Test: atest NetworkStatsServiceTest NetworkPolicyManagerTest
            NetworkPolicyManagerServiceTest
Change-Id: I0f3f02d1dc014967fab27ffcf37dd1918dbef5e0
2022-01-15 14:06:31 +08:00
Junyu Lai
0a0c20df11 Merge "[MS44.1] Add API to query tagged UID summary" 2022-01-13 11:25:15 +00:00
Frank Li
bd80c9db17 Merge "[DU01]Remove INetworkManagementService from NetworkStatsService" 2022-01-13 05:45:42 +00:00
Aaron Huang
595dc3b96e 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
7577deee21 [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
Treehugger Robot
cc32b705b3 Merge "[DU03]Remove INetworkStatsService from BatteryStatsImpl" 2022-01-12 19:33:52 +00:00
James Mattis
d038933790 Merge "Making NetworkCapabilities @NonNull" 2022-01-12 17:43:22 +00:00
Aaron Huang
7742218754 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
c9dedfbe95 [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
5366b82996 Merge "[MS42.1] Replace PhoneStateListener with DisplayInfoListener" 2022-01-10 11:43:58 +00:00
Junyu Lai
c44e042f07 [MS42.1] Replace PhoneStateListener with DisplayInfoListener
Several methods and constants are hidden in PhoneStateListener
and ServiceState to track Radio Access Technology(RAT) types.
Replace them with public API instead.

Test: atest NetworkStatsSubscriptionsMonitorTest
Fix: 213021103
Change-Id: I588398da7f2b031910a8350a7d84405ff101232d
2022-01-10 11:43:17 +00:00
James Mattis
e75b506df2 Making NetworkCapabilities @NonNull
Updating InternalNetworkUpdateRequest to require non-null network
capabilities.

Bug: 210485380
Test: atest EthernetServiceTests
Change-Id: I660d039166451c22ffe5b5e603c649a43b71ebf1
2022-01-08 17:16:24 -08:00
Bill Yi
aa301c6fc8 Merge "Merge sc-qpr1 to aosp-master - DO NOT MERGE" 2022-01-07 17:29:10 +00:00
lifr
14a3baf244 [DU01]Remove INetworkManagementService from NetworkStatsService
NetworkStatsService is using INetworkManagementService APIs, which
cannot be accessed after moving into the mainline module. So, replace
and remove those hidden API usages.

Bug: 209738761
Test: atest NetworkStatsServiceTest
Change-Id: I5740f6d8a54e9a06c6dbb93203cb4c954383c3c8
2022-01-08 01:27:35 +08:00
Treehugger Robot
27bcf7b6ed Merge "[MS39.1] Remove the looper from NetworkStatsSubscriptionMonitor" 2022-01-07 14:42:52 +00:00
Junyu Lai
30eb3cc54a [MS39.1] Remove the looper from NetworkStatsSubscriptionMonitor
OnSubscriptionsChangedListenerHandler(Looper looper) is
hidden, there is no way to pass a looper to it in the test.
This change partially revert aosp/1340040 to fix hidden
API dependency. And will use a different approach to address
this problem in later stages.

Test: atest NetworkStatsSubscriptionMonitorTest
Bug: 204830222
Bug: 213280079
Change-Id: I429be3578d599de9a5a3f78b02387c20744b37d3
2022-01-07 12:55:02 +00:00
Treehugger Robot
50d02a33ad Merge "[MS22] Move NetworkManagementSocketTagger into the module" 2022-01-07 12:07:53 +00:00
Junyu Lai
19332960f6 [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
Bill Yi
57dd741ea7 Merge sc-qpr1 to aosp-master - DO NOT MERGE
Merged-In: I90ca5ccbf686a975f479c2488ff34f82af12946a
Merged-In: I128f5ed6c1bad350ea449bba5da21123de3ea31b
Change-Id: Ib18c8042f735dceeee5e6ab9f1c963cf630913a6
2022-01-06 18:38:32 -08:00
Junyu Lai
c94e128c24 Merge "[MS32.1] Remove TetheringManager#ACTION_TETHER_STATE_CHANGED usage" 2022-01-06 13:57:12 +00:00
Junyu Lai
a3c2578644 Merge changes from topics "ms34-tm", "ms40-clock"
* changes:
  [MS09] Expose NetworkTemplate APIs which are needed by NetworkPolicy
  [MS34.1] Replace TelephonyManager#getSubscriberId(subId) with public API
  [MS40.1] Remove Clock dependencies from NetworkStatsService
  [MS27] Expose noteUntaggedSocket SystemApi
2022-01-06 13:56:39 +00:00
Aaron Huang
76b8f88428 Remove ParcelFileDescriptor hidden API usage from IpSecService
IpSec service is going to be a part of Connectivity mainline module
and ParcelFileDescriptor(FileDescriptor) is a hidden API that cannot
be used by mainline module.

Therefore, use ParcelFileDescriptor.dup(FileDescriptor) to get a
ParcelFileDescriptor instead.

Bug: 204153604
Test: FrameworksNetTests
Change-Id: I0ccabdfc5060f4b635e9a7009a67fbd5d32002fd
2022-01-06 19:16:43 +08:00
Junyu Lai
1ea62cdab4 [MS32.1] Remove TetheringManager#ACTION_TETHER_STATE_CHANGED usage
Replace intent receiver with callback listener.

Test: atest com.android.server.net.NetworkStatsServiceTest
Bug: 204830222
Change-Id: I585b2bb471b59cbca3cce1c01ce527dff87f42da
2022-01-06 09:22:53 +00:00
Junyu Lai
e7c835b3ad [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
Junyu Lai
5bef63756c [MS34.1] Replace TelephonyManager#getSubscriberId(subId) with public API
Test: atest com.android.server.net.NetworkStatsSubscriptionsMonitorTest
Bug: 204830222
Change-Id: I57aa4470aea1715217fa7d74f2c9067b096d1bae
2022-01-06 09:22:52 +00:00
Junyu Lai
0dbd0c8d26 [MS40.1] Remove Clock dependencies from NetworkStatsService
This includes:
1. Re-implement the BestClock in the static library.
2. Expose SystemClock#currentNetworkTimeClock as public Api

Test: TH
Bug: 204830222
CTS-Coverage-Bug: 213393821
Exempt-From-Owner-Approval: 1. Owner approved the change with
  explicitly granted submission after adderessing the
  straight-forward comment. 2. Owner is OOO for 3 months.
Change-Id: I08c0162a7101cc6184f3eca3d4a59211183fb843
2022-01-06 08:49:59 +00:00
Junyu Lai
1d1c2d22c7 [MS33.1] Remove NetdService dependency
This change pass INetd to NetworkStatsFactory to replace
NetdService#getNetdInstance.

Test: atest FrameworksNetTests
Bug: 204830222
Change-Id: I39b278989cea06dd316f21214380b5c4b54d2d50
2022-01-05 05:29:46 +00:00
Treehugger Robot
6613c924d2 Merge "[MS31] Fix several hidden API usages" 2022-01-04 03:56:23 +00:00
Treehugger Robot
bbb36e91ee 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
Junyu Lai
9426a6f034 [MS31] Fix several hidden API usages
This includes:
1. Replace UserHandle.getUid(userId, appId) with public API
2. Remove Preconditions.checkArgument
3. Replace MathUtil.constrain with the one in NetworkStatsUtils
4. Remove Sets
5. Replace NetworkStack.checkNetworkStackPermission with the
   one in the PermissionUtils
6. Replace internal CollectionUtils with the one in the module
7. Inline ProtoOutputStream(fd)
8. Replace Intent.EXTRA_USER_HANDLE with Intent.EXTRA_USER

Test: atest NetworkStatsSubscriptionsMonitorTest \
      NetworkStatsServiceTest
Bug: 204830222

Change-Id: If06a27b04ad15c29052b670eefc2f6dc0d199420
2022-01-03 15:15:05 +00:00
Les Lee
a0f6ce8fab Merge "wifi data usage: replaced Wi-Fi SSID with a Wi-Fi network key" 2022-01-03 12:36:49 +00:00
Les Lee
c70871f60a 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
b68d04b7bb Merge "[MS23] Remove UserHandle.getUserId dependencies" 2021-12-30 15:45:03 +00:00
Treehugger Robot
6b86e4a59f Merge "[MS26.1] Remove Process.NETWORK_STACK_UID dependency" 2021-12-30 12:43:39 +00:00
Junyu Lai
67b95e049e [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
978ef03a6c [MS23] Remove UserHandle.getUserId dependencies
Replaced with SystemApi.

Test: TH
Bug: 204830222
Change-Id: Ibc834489428c2036cd4ccd3284ba06c4c9e792b7
2021-12-30 10:00:19 +00:00
Junyu Lai
04a367ebc1 [MS28.1] Fix several hidden API dependencies
This includes:
1. Replace Slog with Log
2. Use android.util.IndentingPrintWriter instead of the
   deprecated internal one.
3. Replace usages of ArrayUtils with CollectionUtils.
4. Reimplement DumpUtils#checkDumpPermission in PermissionUtils.
5. Replace MathUtils.constrain with NetworkStatsUtils.constrain

Test: FrameworksNetTests
Bug: 204830222
Change-Id: I2b064fc25497288d66018584e66da98c79bd208d
2021-12-30 10:00:19 +00:00
Treehugger Robot
1fb56a8f11 Merge "[MS21] Remove DataUnit dependency" 2021-12-29 13:24:49 +00:00
Treehugger Robot
94990d335e Merge "[MS19.1] Fix several hidden API dependencies" 2021-12-29 05:16:58 +00:00
Junyu Lai
4f84ff3709 [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