Commit Graph

2249 Commits

Author SHA1 Message Date
Michael Groover
c356bf7394 Merge "Update docs for methods that require subscriberId" into rvc-dev am: 3e045d41e1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11932150

Change-Id: I627d3015c0e2cad832a8fd9926fc2079241bd9cd
2020-06-22 19:31:31 +00:00
Michael Groover
3e045d41e1 Merge "Update docs for methods that require subscriberId" into rvc-dev 2020-06-22 19:30:10 +00:00
Michael Groover
3dae8b1b41 Update docs for methods that require subscriberId
In Android 10 additional restrictions were required to access the
subscriberId. The NetworkStatsManager has several methods that accept
a subscriberId of the mobile network for which usage should be queried.
This commit updates the docs for these methods to reference the new
access restrictions and offer null as an option to obtain the usage
for all mobile networks.

Fixes: 157871064
Test: m docs
Change-Id: I95c730c9418fced6312eb3ba4e0d69e6299f3ded
2020-06-19 19:48:07 -07:00
Aaron Huang
e9d35cc556 Merge "Address comments from aosp/1298476" am: 72b4ffad5c am: eb276cb5b3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1340040

Change-Id: I7b119758ac7cd65defdec77692957287af17566d
2020-06-18 10:47:47 +00:00
Aaron Huang
72b4ffad5c Merge "Address comments from aosp/1298476" 2020-06-18 10:18:57 +00:00
Aaron Huang
cf854996a6 Address comments from aosp/1298476
This patch addresses the followings,
- Pass Looper to NetworkStatsSubscriptionsMonitor constructor
- Replace Looper with TestLooper in unit test
- Assert fail if result of condition check is not expected.

Bug: 154080205
Test: atest FrameworksNetTests:com.android.server.net.NetworkStatsServiceTest
      atest FrameworksNetTests:com.android.server.net.NetworkStatsSubscriptionsMonitorTest
Change-Id: Ibcaba2b38af80cc0ec9a4e428a3b3a1538bc4325
2020-06-18 15:05:19 +08:00
Aaron Huang
eb1a7159b0 Merge "Dynamically enable/disable watch for RAT type changes" am: 04baaeb973 am: abc4648d47
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1315574

Change-Id: I5a96774ad2104a6b03c9abab2b105b97195edea8
2020-06-18 04:22:21 +00:00
Aaron Huang
04baaeb973 Merge "Dynamically enable/disable watch for RAT type changes" 2020-06-18 03:51:51 +00:00
Aaron Huang
2d1e20a07b [automerger skipped] Merge "Add unit test for NetworkStatsSubscriptionsMonitor" am: ad9a0e7713 am: 4535e1ddca -s ours
am skip reason: Change-Id I4ef3f1ab2e5ea1322133edd80db3ccd0022e9c91 with SHA-1 da12e7f732 is in history

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1298476

Change-Id: I11b25c0832d6959e77bbabbfce53cdedce922279
2020-06-17 09:21:52 +00:00
Aaron Huang
e436804466 Dynamically enable/disable watch for RAT type changes
Add ContentObserver to observe the status of
NETSTATS_COMBINE_SUBTYPE_ENABLED to determine that
NetworkStatsSubscriptionsMonitor start or stop
monitoring data usage per RAT type changes.

Bug: 154080515
Test: atest NetworkStatsServiceTest#testDynamicWatchForNetworkRatTypeChanges
Change-Id: I272d589633c9186b45753228b05aa0b40b7c7b89
2020-06-17 17:09:10 +09:00
Aaron Huang
86bb429959 Add unit test for NetworkStatsSubscriptionsMonitor
Bug: 154080205
Test: atest FrameworksNetTests:com.android.server.net.NetworkStatsSubscriptionsMonitorTest
(copy from ag/11788484 but getActiveAndHiddenSubscriptionIdList() since it's renamed
in internal)
Change-Id: Ia162f36efe96d90b2f6f70190d9fa855bba34484
Merged-In: I4ef3f1ab2e5ea1322133edd80db3ccd0022e9c91
2020-06-15 07:05:19 +00:00
Aaron Huang
2ef30014fe Merge "Add unit test for NetworkStatsSubscriptionsMonitor" into rvc-dev am: 32f8a56636
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11788484

Change-Id: Iac633487b359d751206e06b2352a2a9cb475811e
2020-06-12 02:11:29 +00:00
Aaron Huang
da12e7f732 Add unit test for NetworkStatsSubscriptionsMonitor
Bug: 154080205
Test: atest FrameworksNetTests:com.android.server.net.NetworkStatsSubscriptionsMonitorTest
Change-Id: I4ef3f1ab2e5ea1322133edd80db3ccd0022e9c91
2020-06-09 00:40:36 +08:00
TreeHugger Robot
9b4412d7f4 [automerger skipped] Merge changes I289d935f,I0121a4ac,Ie73ba058,I4393afcb,Ifebd946e, ... into rvc-dev am: c119ee1ed2 -s ours
am skip reason: Change-Id I289d935f84b616ed857ef4c5a7427d57c282d00c with SHA-1 e454f35a39 is in history

Change-Id: I9e2e5b2862a2a381c437669427c0ef02a3905dc4
2020-05-28 13:31:18 +00:00
Treehugger Robot
4d03a1c408 Merge changes I289d935f,I0121a4ac am: 8366a33efa am: fc00838335
Change-Id: If3c25f5a373e96fc007698ad2c5cdef5af92804a
2020-05-28 11:08:56 +00:00
Treehugger Robot
fc00838335 Merge changes I289d935f,I0121a4ac am: 8366a33efa
Change-Id: I7c413c9e1f2efc3aba55453c6b98bf682f3d4116
2020-05-28 10:55:48 +00:00
Treehugger Robot
8366a33efa Merge changes I289d935f,I0121a4ac
* changes:
  NetworkStats: apply464xlatAdjustments - don't remove CLAT_UID
  NetworkStats: apply464xlatAdjustments - remove useBpfStats parameter.
2020-05-28 10:34:01 +00:00
Maciej Żenczykowski
9d862381bb NetworkStats: apply464xlatAdjustments - don't remove CLAT_UID
This should no longer be needed after all the cleanups.

Test: atest NetworkStatsTest NetworkStatsFactoryTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I289d935f84b616ed857ef4c5a7427d57c282d00c
Merged-In: I289d935f84b616ed857ef4c5a7427d57c282d00c
2020-05-28 02:44:20 -07:00
Maciej Żenczykowski
c7d0224c75 NetworkStats: apply464xlatAdjustments - remove useBpfStats parameter.
Test: atest NetworkStatsTest NetworkStatsFactoryTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0121a4ac7ee824adc5930bab786d550b2f00b05b
Merged-In: I0121a4ac7ee824adc5930bab786d550b2f00b05b
2020-05-28 02:44:10 -07:00
Maciej Żenczykowski
5c9097c9e0 NetworkStats - no need for xt_qtaguid clat bw fixups
This is due to the previous addition of the ip6tables raw PREROUTING
drop rules for incoming ipv6 clat traffic pre-translation to ipv4.

Since we no longer double account, we no longer need these fixups.

Test: atest bpf_module_test clatd_test libbpf_android_test libnetdbpf_test
  netd_integration_test netd_unit_test netdutils_test
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia171b7797cdc99367064d0649bf1293c71579941
Merged-In: Ia171b7797cdc99367064d0649bf1293c71579941
2020-05-28 02:43:22 -07:00
Maciej Żenczykowski
fc30c1b04b Merge changes Ie73ba058,I4393afcb,Ifebd946e,Ib12ee882,Ia171b779 am: 8eb57183e9 am: 394c0003a1
Change-Id: If8abb4247759462532cbac6b43bfb8d3202c6e34
2020-05-28 09:36:05 +00:00
Maciej Żenczykowski
394c0003a1 Merge changes Ie73ba058,I4393afcb,Ifebd946e,Ib12ee882,Ia171b779 am: 8eb57183e9
Change-Id: I7b9ae6590c67f89b023417e511fa823b79ad53b1
2020-05-28 09:18:16 +00:00
Maciej Żenczykowski
8eb57183e9 Merge changes Ie73ba058,I4393afcb,Ifebd946e,Ib12ee882,Ia171b779
* changes:
  fix com.android.server.net.NetworkStatsFactoryTest#testDoubleClatAccounting100MBDownload
  fix com.android.server.net.NetworkStatsFactoryTest#testDoubleClatAccounting
  fix com.android.server.net.NetworkStatsFactoryTest#testDoubleClatAccountingSimple
  fix android.net.NetworkStatsTest#testApply464xlatAdjustments
  NetworkStats - no need for xt_qtaguid clat bw fixups
2020-05-28 09:04:42 +00:00
Maciej Żenczykowski
e454f35a39 NetworkStats: apply464xlatAdjustments - don't remove CLAT_UID
This should no longer be needed after all the cleanups.

Test: atest NetworkStatsTest NetworkStatsFactoryTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I289d935f84b616ed857ef4c5a7427d57c282d00c
2020-05-28 01:47:30 -07:00
Maciej Żenczykowski
bfaed04795 NetworkStats: apply464xlatAdjustments - remove useBpfStats parameter.
Test: atest NetworkStatsTest NetworkStatsFactoryTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0121a4ac7ee824adc5930bab786d550b2f00b05b
2020-05-28 01:33:25 -07:00
Maciej Żenczykowski
28aed515f0 NetworkStats - no need for xt_qtaguid clat bw fixups
This is due to the previous addition of the ip6tables raw PREROUTING
drop rules for incoming ipv6 clat traffic pre-translation to ipv4.

Since we no longer double account, we no longer need these fixups.

Test: atest bpf_module_test clatd_test libbpf_android_test libnetdbpf_test
  netd_integration_test netd_unit_test netdutils_test
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia171b7797cdc99367064d0649bf1293c71579941
2020-05-28 00:26:17 -07:00
TreeHugger Robot
45a9ef6383 [automerger skipped] Merge "NetworkStatsService - xt_qtaguid non-ebpf - account stacked interface stats" into rvc-dev am: f2b96fb045 -s ours
am skip reason: Change-Id I297fcad0a83bd8c32c0fa6c6a77d83b42cd8c428 with SHA-1 7e81d01799 is in history

Change-Id: I28154da3f37d182efd5b65c4c1169690f50e5731
2020-05-28 06:52:33 +00:00
Maciej Żenczykowski
d4ce044ad1 NetworkStatsService - xt_qtaguid non-ebpf - account stacked interface stats
Test: atest bpf_module_test clatd_test libbpf_android_test libnetdbpf_test
  netd_integration_test netd_unit_test netdutils_test
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I297fcad0a83bd8c32c0fa6c6a77d83b42cd8c428
Merged-In: I297fcad0a83bd8c32c0fa6c6a77d83b42cd8c428
2020-05-28 01:57:37 +00:00
Maciej Żenczykowski
d5d0cff90c Merge "NetworkStatsService - xt_qtaguid non-ebpf - account stacked interface stats" am: 3febc2c0d0 am: f9c7d0b463
Change-Id: I89254b745961a6372985cc6cc651756d41a9c1b7
2020-05-28 01:11:29 +00:00
Maciej Żenczykowski
f9c7d0b463 Merge "NetworkStatsService - xt_qtaguid non-ebpf - account stacked interface stats" am: 3febc2c0d0
Change-Id: I66ee156163937fd9dad330a51f73c09eb0fe76b6
2020-05-28 00:58:07 +00:00
Maciej Żenczykowski
3febc2c0d0 Merge "NetworkStatsService - xt_qtaguid non-ebpf - account stacked interface stats" 2020-05-28 00:42:17 +00:00
Maciej Żenczykowski
7e81d01799 NetworkStatsService - xt_qtaguid non-ebpf - account stacked interface stats
Test: atest bpf_module_test clatd_test libbpf_android_test libnetdbpf_test
  netd_integration_test netd_unit_test netdutils_test
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I297fcad0a83bd8c32c0fa6c6a77d83b42cd8c428
2020-05-27 23:26:26 +00:00
Junyu Lai
64ee3d39fa [automerger skipped] Merge "Use CopyOnWriteArrayList to store list of NetworkStatsProviderCb" into rvc-dev am: 358fe14bce -s ours
am skip reason: Change-Id If74e9f2ea597a0d5ae4668c3358bc687f342bbb5 with SHA-1 a6880d0037 is in history

Change-Id: I2ee29a01a22b0299993b99835fe8a18a6c1f364c
2020-05-13 00:49:16 +00:00
Junyu Lai
358fe14bce Merge "Use CopyOnWriteArrayList to store list of NetworkStatsProviderCb" into rvc-dev 2020-05-13 00:42:42 +00:00
TreeHugger Robot
bd38d29054 [automerger skipped] Merge changes I37dd459d,I1959f308 into rvc-dev am: d7aa055b61 -s ours
am skip reason: Change-Id I37dd459d08b57b14f72f3b28ea80fa231b152f10 with SHA-1 4d3f871a94 is in history

Change-Id: I0b5556bcaa27ca0a379f910bfba80aec506348c9
2020-05-12 20:41:03 +00:00
TreeHugger Robot
d7aa055b61 Merge changes I37dd459d,I1959f308 into rvc-dev
* changes:
  Add tests for Tunnel, Transport mode application with released SPIs
  Use TransformRecord to get SPI instead of SpiRecord
2020-05-12 20:30:03 +00:00
Treehugger Robot
1d4d01a8a8 Use CopyOnWriteArrayList to store list of NetworkStatsProviderCb
In NetworkStatsService, mStatsLock will be held when
iterating through the provider list. This is to protect the list
from concurrent broadcast that triggered by
NetworkPolicyManagerService. This is not good since the binder
call is oneway, it does not make sense to block every
access to the providers.

This change also remove unuse variable and reduce verbose log.

Test: atest FrameworksNetTests TetheringTests
Bug: 150418178
Change-Id: If74e9f2ea597a0d5ae4668c3358bc687f342bbb5
Merged-In: If74e9f2ea597a0d5ae4668c3358bc687f342bbb5
(cherry picked from commit 5d8f96c6967d5b1a42ba374521078e75a9e6f187)
2020-05-12 11:36:03 +00:00
Treehugger Robot
c146edd88a Merge "Use CopyOnWriteArrayList to store list of NetworkStatsProviderCb" am: 9aa60f31da am: 23289b2670
Change-Id: Ie188a72163f70c5efc964c03acdae9dac2bbe6cf
2020-05-12 10:26:04 +00:00
Treehugger Robot
23289b2670 Merge "Use CopyOnWriteArrayList to store list of NetworkStatsProviderCb" am: 9aa60f31da
Change-Id: I51dfa3882e33db89d40b9e912d5178096c724de6
2020-05-12 10:12:56 +00:00
Treehugger Robot
9aa60f31da Merge "Use CopyOnWriteArrayList to store list of NetworkStatsProviderCb" 2020-05-12 09:51:35 +00:00
Benedict Wong
003c5c9807 Use TransformRecord to get SPI instead of SpiRecord
IpSecService.applyTunnelModeTransform() currently does not take an
SpiRecord instance, yet implicitly requires that the SpiRecord instance
is still alive based on the stored SpiRecord resourceId in
the TransformRecord's IpSecConfig.

This check is unnecessary, as the SpiRecord has been subsumed into the
TransformRecord, and the kernel resources are kept alive whether or
not the SpiRecord is still held by the user.

This allows users of the IpSecManager API to allocate short-lived SPIs
during the creation of an IpSecTransform, without having to keep track
of both of them (even though the SPI is no longer usable).

The TransformRecord.getSpiRecord() call is already used in
multiple other places in the same method.

Bug: 142072071
Test: New tests added, passing.
Change-Id: I1959f3080946267243564459ff4207647922566e
Merged-In: I1959f3080946267243564459ff4207647922566e
(cherry picked from commit 5258b1b82f39bf17e0751bcb94479464250aaec5)
2020-05-08 00:01:45 -07:00
Lucas Lin
b9560fc6ef [automerger skipped] Merge "Broadcast ACTION_NETWORK_STATS_UPDATED in NetworkStatsHandler" into rvc-dev am: 9257482629 -s ours
am skip reason: Change-Id Icf88d3e7a38562ab15187f6c71bc8fb0486d37c0 with SHA-1 3648f0a35d is in history

Change-Id: Iac39289cb5a7d912131cd056a702a3bf8d361681
2020-05-08 05:37:43 +00:00
Lucas Lin
55119e823e Broadcast ACTION_NETWORK_STATS_UPDATED in NetworkStatsHandler
There is a corner case which may cause the deadlock:
When NetworkStatsService tried to broadcast the intent,
NetworkStatsService was waiting for a lock which was hold by
ActivityManagerService. In the same time, ActivityManagerService
was waiting for ActiveService#startServiceInnerLocked() to get a
lock which was hold by ConnectivityService. ConnectivityService
was waiting for a lock which was hold by BatteryStatsImpl.
BatteryStatsImpl was waiting for a lock which was hold by
NetworkStatsService, and the lock was locked by
NetworkStatsService when NetworkStatsService tried to broadcast
the intent.

To prevent deadlock when broadcasting the intent in
performPollLocked(), move the intent broadcasting from
performPollLocked() to NetworkStatsHandler.

Bug: 150418178
Bug: 155155473
Test: 1. Create the second user and see if the device will
         do factory reset or not.
      2. Factory reset manually and see if there is a deadlock.

Change-Id: I80569cb4388beb3fd6cbf64a7885bccee8b1c53c
Merged-In: Icf88d3e7a38562ab15187f6c71bc8fb0486d37c0
(cherry picked from commit 3f8ab0350450202910ea702799570c538e96d5cd)
2020-05-08 02:59:28 +00:00
Lucas Lin
3f8ccb072e Merge "Broadcast ACTION_NETWORK_STATS_UPDATED in NetworkStatsHandler" am: 61fbce1bde am: 5ecaf8f36b
Change-Id: I47f46d61c0cc9dacf24efc28ec900b35289eef5f
2020-05-07 09:37:17 +00:00
Lucas Lin
5ecaf8f36b Merge "Broadcast ACTION_NETWORK_STATS_UPDATED in NetworkStatsHandler" am: 61fbce1bde
Change-Id: I8996b46bbd71ddc27ef313e3d9d329faf56ac580
2020-05-07 09:21:25 +00:00
lucaslin
3648f0a35d Broadcast ACTION_NETWORK_STATS_UPDATED in NetworkStatsHandler
There is a corner case which may cause the deadlock:
When NetworkStatsService tried to broadcast the intent,
NetworkStatsService was waiting for a lock which was hold by
ActivityManagerService. In the same time, ActivityManagerService
was waiting for ActiveService#startServiceInnerLocked() to get a
lock which was hold by ConnectivityService. ConnectivityService
was waiting for a lock which was hold by BatteryStatsImpl.
BatteryStatsImpl was waiting for a lock which was hold by
NetworkStatsService, and the lock was locked by
NetworkStatsService when NetworkStatsService tried to broadcast
the intent.

To prevent deadlock when broadcasting the intent in
performPollLocked(), move the intent broadcasting from
performPollLocked() to NetworkStatsHandler.

Bug: 150418178
Bug: 155155473
Test: 1. Create the second user and see if the device will
         do factory reset or not.
      2. Factory reset manually and see if there is a deadlock.
Change-Id: Icf88d3e7a38562ab15187f6c71bc8fb0486d37c0
2020-05-07 08:49:39 +00:00
Treehugger Robot
a2de22278f [automerger skipped] Merge "[SM10] Adopt helper class to monitor RAT type change per sub" am: f4a8f1f21e am: b4451fba20 -s ours
am skip reason: Change-Id I45c3aa9046b316c8cd0943543d620a22e4afefd1 with SHA-1 f0fcc339c3 is in history

Change-Id: I44a2ee47f6a88286b28d5165c67cfd4fdbdd0152
2020-05-05 11:54:36 +00:00
Treehugger Robot
b4451fba20 Merge "[SM10] Adopt helper class to monitor RAT type change per sub" am: f4a8f1f21e
Change-Id: Ifadf4ad62820c6cbf536a3984b1cf4a0b78cbc31
2020-05-05 11:32:31 +00:00
junyulai
53c97ec4cf [SM10] Adopt helper class to monitor RAT type change per sub
Test: atest NetworkStatsServiceTest
Bug: 146415925
Change-Id: I45c3aa9046b316c8cd0943543d620a22e4afefd1
Merged-In: I45c3aa9046b316c8cd0943543d620a22e4afefd1
(cherry picked from commit ab1eb887a6)
2020-05-05 18:37:29 +08:00
junyulai
a6880d0037 Use CopyOnWriteArrayList to store list of NetworkStatsProviderCb
In NetworkStatsService, mStatsLock will be held when
iterating through the provider list. This is to protect the list
from concurrent broadcast that triggered by
NetworkPolicyManagerService. This is not good since the binder
call is oneway, it does not make sense to block every
access to the providers.

This change also remove unuse variable and reduce verbose log.

Test: atest FrameworksNetTests TetheringTests
Bug: 150418178
Change-Id: If74e9f2ea597a0d5ae4668c3358bc687f342bbb5
2020-04-30 05:57:44 +00:00