Commit Graph

2392 Commits

Author SHA1 Message Date
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
android-build-team Robot
6dd7ce6793 Snap for 6450912 from 6b639d3eb3fc417ba2279b2265255b9e8c1d1157 to mainline-release
Change-Id: Ica89f4b346997c4a37ab5664a54383ac4c63c472
2020-05-01 07:00:38 +00:00
android-build-team Robot
6161ae6324 Snap for 6449986 from 4b42462c25f53a0b2738d4266d704b42d1f211a1 to rvc-release
Change-Id: Iab2ba4cf22c235596383b7cf8b505af0104603ec
2020-05-01 01:13:46 +00: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
TreeHugger Robot
eacbdf80e7 [automerger skipped] Merge "Filter debug entries for each vpn" into rvc-dev am: 1913e1d29b -s ours
am skip reason: Change-Id I3525edc385b07858b48c7add2d331c4b5a2e84ad with SHA-1 87ba308377 is in history

Change-Id: I89ff9147f99b03c5bd1e7f5aa34c5968cfbfc18e
2020-04-30 04:20:28 +00:00
Chiachang Wang
abfadbefef Filter debug entries for each vpn
NetworkStats calculation needs to filter out debug entries to
prevent over counting. While NetworkStatsFactory migrates data
usage over a VPN to the TUN network, NetworkStatsFactory does
not filter out debug entries per vpn which will cause debug
entries left and cause exception.

Bug: 152678151
Test: atest com.android.server.net.NetworkStatsFactoryTest
      and verify no exception
Change-Id: I3525edc385b07858b48c7add2d331c4b5a2e84ad
Merged-In: I3525edc385b07858b48c7add2d331c4b5a2e84ad
2020-04-30 02:39:15 +00:00
Chiachang Wang
c16df4f73f Merge changes I3525edc3,I6e18915e am: c861b10841 am: fa9d473f26
Change-Id: I85b8798fc82873d22c338937bb61092fbde259e6
2020-04-29 09:24:10 +00:00
Chiachang Wang
fa9d473f26 Merge changes I3525edc3,I6e18915e am: c861b10841
Change-Id: Ie298cd37fdaa8d638298e8326c6f1db7a5d5b7b4
2020-04-29 09:08:45 +00:00
android-build-team Robot
f12ae56815 Snap for 6441286 from 014b5e780901cd622855bb889ebd423d6efeeb7f to mainline-release
Change-Id: I7d17005e20e06ea6b6f497952d8fab33c45e1bcc
2020-04-29 07:09:39 +00:00
Chiachang Wang
87ba308377 Filter debug entries for each vpn
NetworkStats calculation needs to filter out debug entries to
prevent over counting. While NetworkStatsFactory migrates data
usage over a VPN to the TUN network, NetworkStatsFactory does
not filter out debug entries per vpn which will cause debug
entries left and cause exception.

Bug: 152678151
Test: atest com.android.server.net.NetworkStatsFactoryTest
      and verify no exception
Change-Id: I3525edc385b07858b48c7add2d331c4b5a2e84ad
2020-04-29 15:07:45 +08:00
android-build-team Robot
2e3e72d638 Snap for 6440900 from 144788b5bb46b8ef52e9cd53b4d50e558e3d52e7 to rvc-release
Change-Id: I70cfc31e85c8497a91825a099852573d42aff086
2020-04-29 01:14:26 +00:00
TreeHugger Robot
913f69a8c2 Merge "Enforce permission check in getUidStats function" into rvc-dev am: 0f3164c79d
Change-Id: I2b7c846497690bfca7b12ad70aa778c785c416a2
2020-04-28 09:30:09 +00:00
TreeHugger Robot
0f3164c79d Merge "Enforce permission check in getUidStats function" into rvc-dev 2020-04-28 09:13:32 +00:00
Chenbo Feng
d80a6ed9e2 Enforce permission check in getUidStats function
The NetworkStatsService.getUidStats() currently doesn't have any
permission check to make sure unpriviledged apps cannot read the stats
of a different uid. It will protentially have security problem since
apps with ACCESS_NETWORK_STATS permission can directly calling into
NetworkStatsService and bypass the check in TrafficStats. Move the uid
check from TrafficStats to NetworkStatsService to fix the problem.

Bug: 129151407
Test: atest AppSecurityTests#testAppFailAccessPrivateData_full
Test: atest AppSecurityTests#testAppFailAccessPrivateData_instant
Test: atest android.app.usage.cts.NetworkUsageStatsTest
Test: atest NetworkStatsBinderTest

Change-Id: Iae85676cfe5f114da69ec278afc2c904bc907234
2020-04-27 18:38:56 +08:00
Benedict Wong
d9c923b26d Merge "Use TransformRecord to get SPI instead of SpiRecord" am: ba714fa495 am: ff540abc9f
Change-Id: Ibc3090627699aecb4ab5e183219b5848005d0412
2020-04-24 23:27:36 +00:00
Benedict Wong
ff540abc9f Merge "Use TransformRecord to get SPI instead of SpiRecord" am: ba714fa495
Change-Id: If9d23537009ea1359d7dc198ba4662c85f8f4b0c
2020-04-24 23:12:27 +00:00
Benedict Wong
ba714fa495 Merge "Use TransformRecord to get SPI instead of SpiRecord" 2020-04-24 22:32:41 +00:00
android-build-team Robot
5036472f72 Snap for 6410067 from 23b52c4f47eced4dca86093f5c48419bef3103f5 to mainline-release
Change-Id: Ic8cf0fcd7ffdfd54385982bb890d0ebd3c485181
2020-04-20 07:15:41 +00:00
android-build-team Robot
704eca30df Snap for 6408188 from ff9701f94856b114a1e74e3bb6591c1e18413763 to rvc-release
Change-Id: I0eb357db7408b3e7596c74efa9d4bd4d3b09486c
2020-04-18 23:15:12 +00:00
TreeHugger Robot
44603228fc Merge "Narrow access to getDataLayerSnapshotForUid()." into rvc-dev am: fdbc50b386
Change-Id: Id800ea9c8fd9462c362afc35fde5ab06c5615696
2020-04-18 01:07:02 +00:00
TreeHugger Robot
fdbc50b386 Merge "Narrow access to getDataLayerSnapshotForUid()." into rvc-dev 2020-04-18 00:42:17 +00:00
android-build-team Robot
3f84f5d9d7 Snap for 6399349 from d1f82dd3d84c78f230177d0c8935f03b6e7df3dc to mainline-release
Change-Id: Iab1e25b6719b5aeec2027b7e86413e42fc65ce9e
2020-04-16 07:12:34 +00:00
android-build-team Robot
1be2fb4bdc Snap for 6398428 from bcb2d73e48ca3d4b1c14b85b055ba20103211896 to rvc-release
Change-Id: I0b5a894f5adc4f7fa731ce128432391d01cbe556
2020-04-16 01:02:25 +00:00
Junyu Lai
f4c980e3ec Merge "[SM10] Adopt helper class to monitor RAT type change per sub" into rvc-dev am: cdd7c94ec0
Change-Id: I5dd2e734cd8ce6637c39e57a6b302447bc0f295f
2020-04-15 17:26:19 +00:00
junyulai
f0fcc339c3 [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 219faff07bdc58c14fe58fc525e86383db1f8167)
2020-04-15 10:30:49 +00:00
Jeff Sharkey
7bab8e86df Narrow access to getDataLayerSnapshotForUid().
This method is used in TrafficStats to obtain the snapshot for the
calling UID, so narrow it to only return data for that specific case.

We might be tempted to throw an exception or adjust the method
signature, but apps are using the raw AIDL in the greylist, so we
return them an empty NetworkStats if they ask about other UIDs.

Bug: 119672472
Test: manual
Change-Id: I3064630039f1d8473d6425dd663f17813a4ae3a1
2020-04-10 13:54:45 -06:00
Xin Li
b82e17d4ae [automerger skipped] Merge "DO NOT MERGE - Merge qt-qpr1-dev-plus-aosp@6382244 into stag-aosp-master" into stage-aosp-master am: f68e6a03f1 -s ours
am skip reason: subject contains skip directive

Change-Id: I99ef66bbbf796a104bedf3da2909e47cbe023f6f
2020-04-10 19:07:11 +00:00
Automerger Merge Worker
5a316e581e Merge "Merge "[SM09] Add helper class to monitor RAT type change per sub" am: 64ccb88948 am: 57aa3c8c94" into qt-qpr1-dev-plus-aosp 2020-04-09 11:06:06 +00:00
Treehugger Robot
49e6672c9b Merge "[SM09] Add helper class to monitor RAT type change per sub" am: 64ccb88948 am: 57aa3c8c94
Change-Id: I182886d7fd1e9dad96c43c339bda7acf1c749397
2020-04-09 11:05:45 +00:00
Treehugger Robot
dabeb3d324 [automerger skipped] Merge "[SM09] Add helper class to monitor RAT type change per sub" am: 64ccb88948 am: 57aa3c8c94 -s ours
am skip reason: Change-Id I0055f6b55c209a073ce997fc7a144477f9db7069 with SHA-1 5d0d638f54 is in history

Change-Id: I7ebe73a3ffffaae14a1f557a9f15136e460b2969
2020-04-09 10:30:33 +00:00
Treehugger Robot
e8bbe6d329 Merge "[SM09] Add helper class to monitor RAT type change per sub" am: 64ccb88948 am: 57aa3c8c94
Change-Id: Ic269c912268a9c8cd6a4fc9f9e3f2a28a54d88be
2020-04-09 10:23:17 +00:00
Treehugger Robot
57aa3c8c94 Merge "[SM09] Add helper class to monitor RAT type change per sub" am: 64ccb88948
Change-Id: I27acccfe6e8c892090a979dd3c2f96970627fdac
2020-04-09 08:21:21 +00:00
junyulai
af1b5c3f4f [SM09] Add helper class to monitor RAT type change per sub
In current design, Rat type change in NSS is only for default
subscription. This is only correct for single sim project.
However, it does not correct for multi-sim scenarios such as
CBRS or DSDS, given that all data usage will be attributed
to the Rat type of default sub.

Thus, add a helper class to monitor subscription change event,
and register/unregister dynamically for Rat type change for
every subscription.

Note that unit test of the helper class will be addressed
in follow-up patch.

Test: m -j
Bug: 146415925
Change-Id: I0055f6b55c209a073ce997fc7a144477f9db7069
Merged-In: I0055f6b55c209a073ce997fc7a144477f9db7069
(cherry picked from ag/10977156 and fixed conflict)
2020-04-09 07:11:17 +00:00
android-build-team Robot
a260c33fe5 Snap for 6379507 from c14806197cb453e8e26558adf8c02db9567c036a to mainline-release
Change-Id: I2ddc68634a691db6c6321d47e2ac69e6f6637ead
2020-04-09 07:10:02 +00:00
android-build-team Robot
4caf0b45ef Snap for 6378851 from a23f461e1b75c50692c41e5eb4cb41e1922c9608 to rvc-release
Change-Id: I95095b7a4b626e3119f61e68a3e9de5355b740a3
2020-04-09 02:11:07 +00:00
Junyu Lai
7aaca95d10 Merge "[SM09] Add helper class to monitor RAT type change per sub" into rvc-dev am: cc0c65dbb5
Change-Id: I95d1a1c1931c194c7f751a444e669adc16a65897
2020-04-08 10:35:10 +00:00
junyulai
5d0d638f54 [SM09] Add helper class to monitor RAT type change per sub
In current design, Rat type change in NSS is only for default
subscription. This is only correct for single sim project.
However, it does not correct for multi-sim scenarios such as
CBRS or DSDS, given that all data usage will be attributed
to the Rat type of default sub.

Thus, add a helper class to monitor subscription change event,
and register/unregister dynamically for Rat type change for
every subscription.

Note that unit test of the helper class will be addressed
in follow-up patch.

Test: m -j
Bug: 146415925
Change-Id: I0055f6b55c209a073ce997fc7a144477f9db7069
Merged-In: I0055f6b55c209a073ce997fc7a144477f9db7069
(cherry picked from commit 306de26c138ec135846f2a74a952464cf00dce54)
2020-04-08 08:50:22 +00:00
android-build-team Robot
2f8d37e38b Snap for 6371019 from 6f2fc99fbd543302f40049fd6c493a676cda4406 to mainline-release
Change-Id: I077942e37c7aa4ca802240ecbe1b0237249b97ba
2020-04-07 07:12:22 +00:00
android-build-team Robot
de7df19396 Snap for 6370344 from d5729ebc66f333af206c96e81f9e1c18129d7f83 to rvc-release
Change-Id: Ia051ce889de0ccce3eb4d428daee4e33d7f23046
2020-04-07 02:05:37 +00:00
Junyu Lai
1d29cc9ca2 [automerger skipped] Merge changes from topic "am-5ce58db354ac494a84904378ca35c013-rvc-dev" into rvc-dev am: ae9a901cbb -s ours
am skip reason: Change-Id I690704b43cfd16de70c4c83916f6d750cf613f67 with SHA-1 863f390810 is in history

Change-Id: I1a97a8cb46302c29425781b9252640c1eec4b50b
2020-04-06 04:27:56 +00:00
junyulai
d81034383d [SP26.2] add a method in NetworkStats that removes empty entries
In current design, entries with zeros are preserved after
addition/subtraction. These entries are not very useful
and lead to difficulty of verifying the result of
addition/subtraction.

However, change the behavior in the original NetworkStats
is considered risky in current stage.

Thus, this change provide a function that could remove these
empty entries in tests.

Test: atest FrameworksNetTests
Bug: 152827872
Bug: 150644692

Change-Id: I40a76935d55712b8083ee1e17e137a8a4ef5e029
Merged-In: I40a76935d55712b8083ee1e17e137a8a4ef5e029
(cherry picked from commit 6c7bef3064dbe949b7b213036b8e70c125ddd343)
2020-04-06 02:18:50 +00:00
android-build-team Robot
6170705614 Snap for 6357740 from 4c6e6b9c5a4fb640da0daf20bb42cfa158d961aa to mainline-release
Change-Id: I8e3b3b8da0b0dac54ffc8c632d75ea2261968136
2020-04-02 07:10:37 +00:00
Junyu Lai
c5c5992227 Merge changes from topic "sp26-networkstats-cts" am: 4d4ddc78cf am: d9074a21fc
Change-Id: Icd22765bf76b3b37935928169722afed65469105
2020-04-02 02:41:02 +00:00
junyulai
aa5c856269 [SP26.2] add a method in NetworkStats that removes empty entries am: 5d9bc0c75e am: ba57ab6eb9
Change-Id: I99eef67c05afb7d6432d5dbf32494d2f5b56b1a5
2020-04-02 02:41:00 +00:00