Commit Graph

1571 Commits

Author SHA1 Message Date
Varun Anand
52ce558fef Revert "NetworkStatsService: Fix getDetailedUidStats to take VPNs into account."
This reverts commit 720133f79d.

Reason for revert: This change has been implicated in 4-way deadlocks as seen in b/134244752.

Bug: 134244752
Change-Id: I37f75c2b243ea548a88ef1dae88287405c6ef55f
Merged-In: I0c00e8f0e30cee987b71b561079a97bf09d4dae4
2019-06-10 16:00:38 -07:00
Varun Anand
2099b09982 Revert "Addressing comments for http://ag/7700679."
This reverts commit 6018f64055.

Reason for revert: This change has been implicated in 4-way deadlocks as seen in b/134244752.

Bug: 134244752
Change-Id: I12ab724e2ef8a5c1b42078330ba74713ff86fdd1
Merged-In: I5fbb3443a39a21fc9d96442726cd10d20e8d61cd
2019-06-10 16:00:28 -07:00
Varun Anand
6018f64055 Addressing comments for http://ag/7700679.
(cherry picked from commit 81e79803de)

Note, that its in a separate CL so we could cherry-pick this CL to aosp.
http://ag/7700679 is already in aosp (http://aosp/865073).

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests

Change-Id: Ic1767bc8bf1460e4223f86465fc72344428e6055
Merged-In: I7cfda226b4ed11b67002b83b38fba0f5caf96718
2019-05-30 15:59:07 +00:00
chen xu
47090f9dd0 NetworkStatAccess Should checkCarrierPrivileges cross all subscriptions
Bug: 133236378
Test: Manual
Change-Id: I49fbde1fe73b33aadcf8fd23ad224f363b137bf3
2019-05-28 23:28:56 -07:00
Treehugger Robot
33e236823f Merge changes Ibff278a6,If6d537a3
* changes:
  Revert "Add NATT keepalive resources and methods into IpSecService"
  Revert "[KA11] Verify fd ownership and allocate resource for NattKeepalive"
2019-05-10 01:42:26 +00:00
Junyu Lai
75eabfeb7c Revert "Add NATT keepalive resources and methods into IpSecService"
This reverts commit 4aac3e9e48.

Reason for revert: Adds dependency between IpSecService and
                   ConnectivityService may lead to future deadlock
		   problems. Uses a simpler approach instead,
		   hence the solution is not needed.
		   See aosp/954040.

Change-Id: Ibff278a6eee666cd85dba81c2bed94d568679b02
2019-05-10 00:58:18 +08:00
Xin Li
e963030676 DO NOT MERGE - Merge Pie Bonito/Sargo into master.
Bug: 131756210
Change-Id: I77a701deda4935526ad452564f9bda77af345f46
2019-05-09 09:27:04 -07:00
Benedict Wong
533559234e Merge "Add EPROTONOSUPPORT to IpSecManager SSE map"
am: 7050ce9434

Change-Id: I9ab4161e2b04615ce782c89cd9e99d98cdbdc92d
2019-04-29 13:35:37 -07:00
Benedict Wong
7e9c1ceadd Add EPROTONOSUPPORT to IpSecManager SSE map
This change maps EPROTONOSUPPORT to the list of error codes that map to
UnsupportedOperationException in IpSecManager.

Bug: 80103456
Test: Compiles, CTS tests ran
Change-Id: Iec3d5fc4a9bcad7c104414afefae775232d46558
2019-04-24 21:31:01 +00:00
Benedict Wong
70e5117542 Merge "Add NATT keepalive resources and methods into IpSecService"
am: c345527430

Change-Id: I97e7451959d619f42d68a5c29cca410bf0740852
2019-04-22 13:31:52 -07:00
Benedict Wong
4aac3e9e48 Add NATT keepalive resources and methods into IpSecService
This change adds a new NATTKeepalive resource type, along with the
associated allocation/deallocation. Additionally, this change allows
ReferenceCountedResource(s) to not be binder-linked, to allow the
ConnectivityService to verify ownership and allocate a NattKeepalive
without double-registering for binder-death notifications.

Bug: 125517194
Test: IpSecService frameworks tests ran
Change-Id: I8293f79940ad57dabb6f2b9de5e334d06b869443
2019-04-19 11:17:21 -07:00
Chalard Jean
2c28ee4cb8 Merge "Move TrafficStats tags for the network stack constants"
am: d2eb7f71b8

Change-Id: I13ba9e3077bb4ec28229a09f2d4747a43c281bcc
2019-04-16 23:08:07 -07:00
Chalard Jean
d2eb7f71b8 Merge "Move TrafficStats tags for the network stack constants" 2019-04-17 05:45:56 +00:00
Chalard Jean
8a93ab8eef Move TrafficStats tags for the network stack constants
As per API council feedback, these constants should live in
a place that is private to the network stack, only with a
range defined in system API.

Bug: 129433383
Test: m
Change-Id: I84a90f84a9af6fef4667ee4d512ebd0413222086
Merged-In: I4882686a86e7c6d42f4b0619b921d02619ed6d4c
Merged-In: I9b648ed6c687d56db61a54570c7880c51c1bae51
2019-04-17 05:45:40 +00:00
Chalard Jean
af8f384985 Merge "Restrict access to dangerous methods to <= P"
am: a1c9270562

Change-Id: I3c1271e00e026518e9c4ddafc931a2cac87dcee0
2019-04-15 22:29:28 -07:00
Chalard Jean
a1c9270562 Merge "Restrict access to dangerous methods to <= P" 2019-04-16 05:17:20 +00:00
Chenbo Feng
3878f31aff Merge "Ask netd to swap stats map before reading"
am: f8b251fd28

Change-Id: I7a683e479fe7631a167138314bcf5948e72386ec
2019-04-12 16:06:30 -07:00
Treehugger Robot
f8b251fd28 Merge "Ask netd to swap stats map before reading" 2019-04-12 22:35:52 +00:00
Chenbo Feng
57f207b1c7 Merge "Add a lock to protect persistent stats snapshot"
am: f31face531

Change-Id: I73851336452110afb74d6dd1ca5e50047d5b3d4a
2019-04-11 18:44:45 -07:00
Treehugger Robot
f31face531 Merge "Add a lock to protect persistent stats snapshot" 2019-04-12 01:33:00 +00:00
Chenbo Feng
876218abcb Ask netd to swap stats map before reading
To avoid protentail race problem between netd and system_server when
reading the network stats map. Always inform netd before reading the
stats and let netd to do a swap between active stats map and inactive
stats map. So the system_server can safely remove the stats after
reading.

Bug: 126620214
Test: android.app.usage.cts.NetworkUsageStatsTest
      android.net.cts.TrafficStatsTest

Change-Id: I8fa37c26bec23ffca0b29b679e72ba1189f557f1
2019-04-10 12:59:38 -07:00
Chenbo Feng
0c419ca9eb Add a lock to protect persistent stats snapshot
Since the network stats could be polled from multiple services at
runtime, it is not thread safe for networkStatsFactory to hold a
persistent stats snapshot without any protection. Use a internal lock to
prevent concurrent modification on mPersistentSnapshot to fix the
problem.

Bug: 124764595
Test: android.app.usage.cts.NetworkUsageStatsTest
      android.net.cts.TrafficStatsTest

Change-Id: I22afb46f17697e8b6359d4f593802e0f4b95db8b
2019-04-10 12:59:18 -07:00
Chiachang Wang
a1a994c7eb Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces"
am: 41c49d1a8e

Change-Id: Id5922a41d07c95958090f88a65d22ef5883aefff
2019-04-09 19:37:20 -07:00
Chiachang Wang
41c49d1a8e Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces" 2019-04-10 02:27:30 +00:00
Benedict Wong
47fa5b0f7f Merge "Fix remove-before-add for IpSecService RefcountedResource"
am: dcd06394d4

Change-Id: Ief286a54a93efd731deeff9fc32815663ab7695d
2019-04-09 10:39:16 -07:00
Benedict Wong
dcd06394d4 Merge "Fix remove-before-add for IpSecService RefcountedResource" 2019-04-09 17:22:56 +00:00
Chiachang Wang
f04137e99e Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces
ConnectivityManager and its usages are removed from
NetworkStatsService. After that, forceUpdateIfaces requires
information that only ConnectivityService has, hence
restricting the calling permission to NETWORK_STACK or
MAINLINE_NETWORK_STACK permission. The required permission
will be changed from READ_NETWORK_USAGE_HISTORY to
NETWORK_STACK or MAINLINE_NETWORK_STACK. This change would make
it impossible to call outside the system.

Bug: 126830974
Test: atest FrameworksNetTests
Change-Id: I776484921b2dbb6735d7940c558fb5e4baed6d1e
2019-04-09 19:42:52 +08:00
Chalard Jean
3cfb4991eb Restrict access to dangerous methods to <= P
Test: make
Fixes: 130143562
Change-Id: I1a6a472f83cf00a1ab174a9c5e67d3e9357a0c45
2019-04-09 15:47:25 +09:00
Benedict Wong
04738f5b07 Fix remove-before-add for IpSecService RefcountedResource
This patch fixes a bug where if a binder dies before the linkToDeath
call, the cleanup will be performed before the entry is added to the
array. While it is safe in that quotas and tracking performs as per
normal, the RefcountedRecord may not be cleaned up.

Rethrowing this exception is safe, since the only paths that would hit
this are all on binder threads coming from applications. Further, it
seems there is only one real way of this getting hit - if the app that
called the creation died during the binder call.

Bug: 126802451
Test: Compiled, CTS tests passing
Change-Id: I6db75853da9f29e1573512e26351623f22770c5d
2019-04-08 18:51:50 -07:00
Chenbo Feng
1c3e46628c Merge "Move NetworkStatsFactory into service directory"
am: c452cbf496

Change-Id: If92f556cbf3badcb057a3b6e43bb3ef74d0c9ac0
2019-04-05 13:26:28 -07:00
Treehugger Robot
c452cbf496 Merge "Move NetworkStatsFactory into service directory" 2019-04-05 19:27:22 +00:00
Lorenzo Colitti
53e2f98e65 Merge "Fix flaky UdpEncapsulationSocket test"
am: 066b321400

Change-Id: I4d6cc85fcd539a38674fc3daff1af57fa1bdd2f7
2019-04-04 01:38:02 -07:00
Lorenzo Colitti
066b321400 Merge "Fix flaky UdpEncapsulationSocket test" 2019-04-04 08:09:06 +00:00
Benedict Wong
29c3077ce0 Fix flaky UdpEncapsulationSocket test
This commit reduces the flakiness of the
testOpenAndCloseUdpEncapsulationSocket by retrying up to three times.
Unfortunately, testing port-selected socket creation is racy against
other applications. This helps to handle the same race condition as done
in IpSecService#bindToRandomPort

Bug: 128024100
Test: 200x runs of testOpenAndCloseUdpEncapsulationSocket
Change-Id: I7e036ce821019dbac6c50899bd0894e89d2fe82a
2019-04-03 17:52:03 -07:00
Chenbo Feng
45fff45471 Move NetworkStatsFactory into service directory
In order to notify netd to swap eBPF maps before pulling the
networkStats from eBPF maps, NetworkStatsFactory need to use the
NetdServices to issue binder calls. So it need to be moved from
framework/base/core to framework/base/service since object in
framework/base/core cannot get any system services. This change is also
necessary for setting up a lock inside NetworkStatsFactory to prevent
racing between two netstats caller since the lock need to be hold before
netd trigger the map swap.

Also fix the compile problem caused by moving the NetworkStatsFactory
and the related tests. Rename the packages and the jni functions to a
more proper name.

Bug: 124764595
Bug: 128900919
Test: NetworkStatsFactoryTest
      android.app.usage.cts.NetworkUsageStatsTest
      android.net.cts.TrafficStatsTest

Merged-In: Ifcfe4df81caf8ede2e4e66a76552cb3200378fa8
Change-Id: Ifcfe4df81caf8ede2e4e66a76552cb3200378fa8
2019-04-03 11:33:40 -07:00
Varun Anand
6f365c4ad5 Merge changes from topic "vpn_data_accounting"
am: ed2eb961e8

Change-Id: Iaa4b2dd9be2fc6e9833c6c846b6858aab507ca8b
2019-03-28 18:06:12 -07:00
Varun Anand
ed2eb961e8 Merge changes from topic "vpn_data_accounting"
* changes:
  Move BatteryStats and StatsCompanionService to use NetworkStatsService.
  NetworkStatsService: Fix getDetailedUidStats to take VPNs into account.
  Take all VPN underlying networks into account when migrating traffic for VPN uid.
2019-03-29 00:40:53 +00:00
Varun Anand
720133f79d NetworkStatsService: Fix getDetailedUidStats to take VPNs into account.
This API is similar to one provided by NetworkStatsFactory with the
difference that NSS also migrates traffic from VPN UID to other apps.

Since traffic can only be migrated over NetworkStats delta, NSS
therefore maintains NetworkStats snapshot across all UIDs/ifaces/tags.

This snapshot gets updated whenever NSS records a new snapshot
(based on various hooks such as VPN updating its underlying networks,
network getting lost, etc.), or getDetailedUidStats API is invoked by
one of its callers.

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests
Test: manually verified that battery stats are migrating traffic off of
TUN (after patching above CL where we point BatteryStats to use this
API).
Change-Id: Ib0f0c2d4d41ee1d7a027ea9da457baaf198d649e
2019-03-28 10:31:51 -07:00
Varun Anand
c8dbdf35de Take all VPN underlying networks into account when migrating traffic for
VPN uid.

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests
Test: Manually verified on device that stats from VPN UID are moved
      appropriately based on its declared underlying network set.
Test: vogar --mode app_process --benchmark NetworkStatsBenchmark.java

Change-Id: I9d8d0cc58d18002c1c96f8ddff780ef8dc452d21
2019-03-28 10:31:49 -07:00
Andrei-Valentin Onea
b70a65df0f Merge "Add @UnsupportedAppUsage annotations"
am: 60eacd60d1

Change-Id: I63ae22279aa46522b652cdc9329567a04a7ef136
2019-03-22 06:25:44 -07:00
Andrei-Valentin Onea
60eacd60d1 Merge "Add @UnsupportedAppUsage annotations" 2019-03-22 13:12:41 +00:00
Andrei Onea
8841fd2f13 Add @UnsupportedAppUsage annotations
For packages:
  android.companion
  android.filterfw
  android.hardware.camera2.utils
  android.inputmethodservice
  android.net.nsd
  android.os
  android.preference
  android.security.keymaster
  android.service.dreams
  android.telecom
  android.telephony.ims.compat.feature
  android.telephony
  android.util
  android.view.accessibility
  android.media.effect

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Merged-In: I9c2f8347952f3cc65759472b0e1a2717b285e44e
Change-Id: I14793863cf815fa3383fec6c6bf5a9365c2e17eb
2019-03-22 11:43:11 +00:00
Varun Anand
dd9d8de53b Merge "Add unit tests related to data accounting for VPNs with one underlying network."
am: 289759e0d2

Change-Id: I91971112870c7a3a2d4786c25125204de7e008f5
2019-03-19 09:28:22 -07:00
Varun Anand
d8fdea1c6e Add unit tests related to data accounting for VPNs with one underlying
network.

This is to establish a baseline for the existing behavior, and to ensure
that following changes are not causing a regression in existing
behavior.

This CL is also adding missing cleanup for NetworkStatsCollectionTest
which was forcing all network types in NetworkTemplate that was causing
NetworkStatsService related tests to fail.

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests
Change-Id: I285f186cfb16bc9fa704c797996b1e4f8a73dee4
2019-03-15 17:23:28 -07:00
Andrei-Valentin Onea
6a9a136f6a Merge "Add @UnsupportedAppUsage annotations"
am: cdf8d71a9f

Change-Id: Ib760897a2d3de2672b4f19d66e238ebee9bfb239
2019-03-06 09:41:34 -08:00
Andrei-Valentin Onea
cdf8d71a9f Merge "Add @UnsupportedAppUsage annotations" 2019-03-06 17:18:05 +00:00
Brett Chabot
a28860fbbd resolve merge conflicts of 18900c462c16c0e3784b8bb6959426caa93cb8cb to stage-aosp-master
Bug: None
Test: I solemnly swear I tested this conflict resolution.
Change-Id: I8ad986d06195bcd2861023e943c4ea7d0e2be729
Merged-In: Ib04d80954bd8536914d88c66b28e6632e60a6245
2019-03-01 22:18:04 +00:00
Brett Chabot
97342bd4e5 Migrate frameworks/base/tests/testables and its users to androidx.test
See go/jetpack-test-android-migration

Test: atest TestablesTests NetworkStackTests FrameworksServicesTests SystemUITests FrameworksUiServicesTests ExtServicesUnitTests
Exempt-From-Owner-Approval: already reviewed
Change-Id: I083fcdaa71b503535aa2b3c257740f3ecf055373
Merged-In: Ib04d80954bd8536914d88c66b28e6632e60a6245
2019-03-01 17:23:42 +00:00
Varun Anand
c2a6f8af78 Merge "Remove ConnectivityManager and its usages from NetworkStatsService."
am: 93dfa10da4

Change-Id: I2a2809d3a2ee4106cc131d61ace401f31c187844
2019-02-28 19:18:33 -08:00
Varun Anand
10fe088231 Remove ConnectivityManager and its usages from NetworkStatsService.
NSS needed it for getting VpnInfo[], NetworkState[] and
activeLinkProperties which it used to query via ConnectivityManager.

For VpnInfo[], this was racy as NSS may ignore intermediate changes to a
VPN's underlying networks. See http://b/123961098 for more context.

It may also lead to deadlocks b/w ConnectivityService and
NetworkStatsService. See http://b/126245192 for more info.

This change will ensure that NSS is never contending on any of
ConnectivityService locks.

Bug: 123961098
Bug: 126245192
Bug: 120145746
Test: atest FrameworksNetTests
Change-Id: Id1da446b54d95ee68ed14079107b1a10318bcf8b
Merged-In: I57e117bb4e9efe491b19d6b5a479f2d58d1c58e6
2019-03-01 00:10:52 +00:00