Commit Graph

1807 Commits

Author SHA1 Message Date
Lorenzo Colitti
b2dc0fca0b 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
Merged-In: Idf040a67e53d9b9ec6e6c647ce24f8ada501d355
Merged-In: Iad9aea4b42cd8b31a5a2659bb9cb54dd1c64e8b7
(cherry picked from commit 614ab3dd4e49e9b664f5065983fb9067148fef12)
2019-04-09 06:44:32 +00: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
1577bee1c0 [automerger skipped] Merge "Move NetworkStatsFactory into service directory" am: c452cbf496
am: 1c3e46628c -s ours
am skip reason: change_id Ifcfe4df81caf8ede2e4e66a76552cb3200378fa8 with SHA1 c1b3fc8712 is in history

Change-Id: I419ae9923a510c9691c8c88911ac45fe76846166
2019-04-08 12:06:35 -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
4be55d08d9 Merge "Fix flaky UdpEncapsulationSocket test" am: 066b321400
am: 53e2f98e65

Change-Id: Idf040a67e53d9b9ec6e6c647ce24f8ada501d355
2019-04-04 09:18:29 -07: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
TreeHugger Robot
db81a2a52e Merge "Move NetworkStatsFactory into service directory" 2019-04-03 23:44:26 +00:00
Bill Rassieur
ce7f239c76 Merge master@5406228 into git_qt-dev-plus-aosp.
am: 79e158a59b

Change-Id: I684e995988f5a8ef330fbbf55da7ae9230f0cfc2
2019-04-03 16:41:27 -07:00
Chenbo Feng
c1b3fc8712 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

Change-Id: Ifcfe4df81caf8ede2e4e66a76552cb3200378fa8
2019-04-03 14:28:41 -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
Bill Rassieur
79e158a59b Merge master@5406228 into git_qt-dev-plus-aosp.
Change-Id: I6ec4d7ef40a971744cbc14ebf3a9ec1071c0bb0a
BUG: 129345239
2019-03-29 04:16:19 +00:00
Varun Anand
27e72f7dac [automerger skipped] Merge changes from topic "vpn_data_accounting" am: ed2eb961e8 am: 6f365c4ad5
am: 96c32b6802 -s ours
am skip reason: change_id I230c1edbf64cfeb3dbb560db368b5e420f7b79a4 with SHA1 e62e287511 is in history

Change-Id: I193b9d8190a4cda863d89d9babb680201fa3f125
2019-03-28 18:25:59 -07:00
Varun Anand
96c32b6802 Merge changes from topic "vpn_data_accounting" am: ed2eb961e8
am: 6f365c4ad5

Change-Id: If4fff1b4d14e80e024ce7b1aa85ebd3afcb1ecc2
2019-03-28 18:16:37 -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
Varun Anand
692797ade0 [automerger skipped] Merge "Remove ConnectivityManager and its usages from NetworkStatsService." into pi-dev am: a24113f030 -s ours
am: a189e1fb1a -s ours
am skip reason: change_id I57e117bb4e9efe491b19d6b5a479f2d58d1c58e6 with SHA1 6cfd15e33e is in history

Change-Id: I34c36c55ba985118ffc2210b2e05daab2a0ea8e8
2019-03-22 12:02:12 -07:00
Varun Anand
a189e1fb1a [automerger skipped] Merge "Remove ConnectivityManager and its usages from NetworkStatsService." into pi-dev
am: a24113f030 -s ours
am skip reason: SHA1 a24113f030 skipped by user vaanand

Change-Id: Ieee5f28f6d10b0d2b8a7b3eb0272297f148ef03f
2019-03-22 11:39:41 -07:00
Andrei-Valentin Onea
b912fe2d4a [automerger skipped] Merge "Add @UnsupportedAppUsage annotations" am: 60eacd60d1 am: b70a65df0f
am: bdae83e8b7 -s ours
am skip reason: change_id I9c2f8347952f3cc65759472b0e1a2717b285e44e with SHA1 c5965f1f41 is in history

Change-Id: Ibaf1e8320f8603c5eb6d33a4a4c862e9dbc2559f
2019-03-22 06:44:40 -07:00
Andrei-Valentin Onea
bdae83e8b7 Merge "Add @UnsupportedAppUsage annotations" am: 60eacd60d1
am: b70a65df0f

Change-Id: Id5e95d173ab7c2595ae148f73d3d7381b0ea8226
2019-03-22 06:35:02 -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
Andrei Onea
c5965f1f41 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
Change-Id: I9c2f8347952f3cc65759472b0e1a2717b285e44e
2019-03-21 14:04:57 +00:00
Varun Anand
1a96a9997c Merge "Add unit tests related to data accounting for VPNs with one underlying network." am: 289759e0d2 am: dd9d8de53b
am: cf038bfcd1

Change-Id: I80e3ebb556ac0b6bff5d232b881f7d869cb74f00
2019-03-19 09:47:04 -07:00
Varun Anand
cf038bfcd1 Merge "Add unit tests related to data accounting for VPNs with one underlying network." am: 289759e0d2
am: dd9d8de53b

Change-Id: I7ab73884266bc4b64d1914557a29e84fc4de431e
2019-03-19 09:37:37 -07: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
07500d5d6f [automerger skipped] Merge "Add @UnsupportedAppUsage annotations" am: cdf8d71a9f am: 6a9a136f6a
am: 93ecd3ea25 -s ours
am skip reason: change_id I7489aad1dceeb18ed7ca48a1ed8829a668b3fa04 with SHA1 0fbf072ca6 is in history

Change-Id: Ic26a760f7e86a4f8e2911bc4d57509bfb574f447
2019-03-06 10:26:13 -08:00
Andrei-Valentin Onea
93ecd3ea25 Merge "Add @UnsupportedAppUsage annotations" am: cdf8d71a9f
am: 6a9a136f6a

Change-Id: Id5ba379057d3874b78391c312cfb903799617d81
2019-03-06 09:57:27 -08: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
83ade26f75 [automerger skipped] resolve merge conflicts of 18900c462c16c0e3784b8bb6959426caa93cb8cb to stage-aosp-master am: a28860fbbd
am: 79ba26366d -s ours
am skip reason: change_id Ib04d80954bd8536914d88c66b28e6632e60a6245 with SHA1 84151d91f7 is in history

Change-Id: I03bf03af566a1508a6d9c68ed09d1027b40b4c4a
2019-03-01 16:33:39 -08:00
Brett Chabot
79ba26366d resolve merge conflicts of 18900c462c16c0e3784b8bb6959426caa93cb8cb to stage-aosp-master
am: a28860fbbd

Change-Id: I02998fc243f8d26aa3badda3c32cb65c237d317e
2019-03-01 16:23:54 -08: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
Jeff Sharkey
08a1c3662a All Parcelable CREATOR fields are @NonNull.
If they were null, then the Parcelable would fail to work.

Bug: 126726802
Test: manual
Change-Id: I7929ffa2f20e5de1c8e68e8263cca99496e9d014
Exempt-From-Owner-Approval: Trivial API annotations
2019-02-28 23:29:04 -07:00
Varun Anand
2c72944ddc [automerger skipped] Merge "Remove ConnectivityManager and its usages from NetworkStatsService." am: 93dfa10da4 am: c2a6f8af78
am: 56f915acaa -s ours
am skip reason: change_id I57e117bb4e9efe491b19d6b5a479f2d58d1c58e6 with SHA1 6cfd15e33e is in history

Change-Id: I3ddc59f7abb5e3c0a2f4f54bb68632578948ee89
2019-02-28 19:35:07 -08:00
Varun Anand
687d8bd094 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.

This change also is cherry-picking cleanup made to NSS in
http://aosp/628368.

Bug: 123961098
Bug: 126245192
Bug: 120145746
Test: atest FrameworksNetTests
Change-Id: Ia687845888434c8ddd24bdf44b4c70dfe80e03f5
Merged-In: I57e117bb4e9efe491b19d6b5a479f2d58d1c58e6
2019-03-01 03:32:23 +00:00
Varun Anand
56f915acaa Merge "Remove ConnectivityManager and its usages from NetworkStatsService." am: 93dfa10da4
am: c2a6f8af78

Change-Id: Ieb10b88344dd4436913426961e6999577a469f36
2019-02-28 19:25:53 -08: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
bc0dd9b3c7 Merge "Remove ConnectivityManager and its usages from NetworkStatsService." 2019-03-01 01:14:34 +00: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
Varun Anand
6cfd15e33e 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: I57e117bb4e9efe491b19d6b5a479f2d58d1c58e6
2019-02-28 13:43:02 -08:00
Andrei Onea
2a71a3d814 Add @UnsupportedAppUsage annotations
For packages:
  android.net
  android.net.wifi
  android.nfc

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: I7489aad1dceeb18ed7ca48a1ed8829a668b3fa04
Change-Id: I16570aef456b45a5543bf889dddc7a0d25441928
2019-02-28 14:39:20 +00:00
Andrei-Valentin Onea
647bdf562b Merge "Add @UnsupportedAppUsage annotations" 2019-02-28 13:50:19 +00:00