Commit Graph

1644 Commits

Author SHA1 Message Date
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
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
Andrei Onea
0fbf072ca6 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
Change-Id: I7489aad1dceeb18ed7ca48a1ed8829a668b3fa04
2019-02-27 13:31:33 +00:00
Xin Li
da46efeb0a [automerger skipped] DO NOT MERGE - Merge pi-dev@5234907 into stage-aosp-master am: 090a80a420 -s ours
am: 030d9f682a -s ours
am skip reason: subject contains skip directive

Change-Id: I2b3cf7ba11fc80010badbb212902a5507d5caae0
2019-02-25 17:16:05 -08:00
Xin Li
030d9f682a [automerger skipped] DO NOT MERGE - Merge pi-dev@5234907 into stage-aosp-master
am: 090a80a420 -s ours
am skip reason: subject contains skip directive

Change-Id: I6c115125bad894bbb597557f2e9c3de3eb2b95b5
2019-02-25 16:13:06 -08:00
Xin Li
090a80a420 DO NOT MERGE - Merge pi-dev@5234907 into stage-aosp-master
Bug: 120848293
Change-Id: I2f9a524f2ba552de3f62e343075cf0abf400bbae
2019-02-21 16:02:06 -08:00
Xin Li
14d4847954 [automerger skipped] DO NOT MERGE - Merge pi-platform-release (PPRL.190205.001) into stage-aosp-master am: 38b1a2d9df -s ours
am: 211356e565 -s ours
am skip reason: subject contains skip directive

Change-Id: I333d887a77e5ff5f0949c02fc460b8d23cded964
2019-02-14 21:02:00 -08:00
Xin Li
211356e565 [automerger skipped] DO NOT MERGE - Merge pi-platform-release (PPRL.190205.001) into stage-aosp-master
am: 38b1a2d9df -s ours
am skip reason: subject contains skip directive

Change-Id: I49505ddfda138f983dd8a75361f270549254f4f8
2019-02-14 14:33:10 -08:00
Xin Li
38b1a2d9df DO NOT MERGE - Merge pi-platform-release (PPRL.190205.001) into
stage-aosp-master

Bug: 124234733
Change-Id: Ic4f67fde0835da0b1c363906cccef0d244e38393
2019-02-14 09:48:06 -08:00
android-build-team Robot
4a44ee4a83 Snap for 5180536 from 1fc6d8adf1 to pi-platform-release
Change-Id: I7c5a9c9e96572c32eadd97448c4886f9c9150a19
2019-02-09 02:33:11 +00:00
Remi NGUYEN VAN
a618134a1e Merge "Remove last NetworkStack usage of hidden APIs" am: 16ec5d038c am: e4675dcaab
am: ba3b82db1e

Change-Id: I2059d9cfa3015388301a74828255354b6dc23c23
2019-01-29 21:42:29 -08:00
Remi NGUYEN VAN
ba3b82db1e Merge "Remove last NetworkStack usage of hidden APIs" am: 16ec5d038c
am: e4675dcaab

Change-Id: I488fc028b8fd2aa5a09464082c65a4889a8a6b62
2019-01-29 21:27:50 -08:00
Remi NGUYEN VAN
e4675dcaab Merge "Remove last NetworkStack usage of hidden APIs"
am: 16ec5d038c

Change-Id: I27c78d09938f672a4428a17436d5ed0541170d0d
2019-01-29 21:13:46 -08:00
Remi NGUYEN VAN
5db0919a0d Remove last NetworkStack usage of hidden APIs
Includes various small changes to stop using hidden APIs

Test: make NetworkStack
Test: flashed, booted, WiFi and tethering working
Bug: 112869080
Change-Id: Id2830795a444f484b377ed6437435a1cd833697a
2019-01-30 10:23:24 +09:00
Remi NGUYEN VAN
83bde292f1 Merge "Add SocketUtils for NetworkStack" am: d9cc11e8bd am: 4d301b8d85
am: d3030bf5b4

Change-Id: I6d059f9cd1a694659bfd7ac09a32022d29c03f85
2019-01-28 23:47:36 -08:00