Commit Graph

3272 Commits

Author SHA1 Message Date
Aaron Huang
559c51f903 Have buildTemplateMobileWithRatType take metered parameter
To support unmetered 5g, have buildTemplateMobileWithRatType take
metered parameter to build a template which could be used to filter
an unmetered network.

Bug: 183776809
Test: atest FrameworksNetTests:NetworkStatsServiceTest
Change-Id: Ia310d90eceeb572a35ce9518de02b198cae16705
Merged-In: Ia310d90eceeb572a35ce9518de02b198cae16705
2021-10-25 15:10:15 +00:00
Aaron Huang
7cf5cd3044 Respect metered filter in matchesMobile*
In old design, only metered mobile network would be matched,
which means that only metered stats could be read if callers
query the mobile stats.

Currently, the caller in NetworkPolicyManagerService was updated
to use the NetworkTemplate constructor with metered parameter in
aosp/1563312 which means that the template will be created by a
given meteredness. Thus, the hardcode metered can be removed.

Remove the metered check from matches method will cause a
different behavior. Therefore, to keep the original behavior,
if the match rule is MATCH_MOBILE or MATCH_MOBILE_WILDCARD,
it should pass METERED_YES to the constructor to build a
metered template.

Also, if a caller creates a template by calling the constructor
with metered as a parameter, the behavior will also be changed.
Therefore, if the caller expects to get metered stats then it
should change to pass METERED_YES. If the caller expects to get
both metered and unmetered stats then it should remain METERED_ALL
and it would be a bug that been fixed by this patch.

Bug: 183776809
Bug: 202092687
Test: atest FrameworksNetTests:NetworkStatsServiceTest
      manually test by generating traffic and check the data counts
      from "adb shell dumpsys netstats --uid" almost equal to the
      result from "adb shell cmd stats pull-source 10082"
Change-Id: I66dd51b020f6d895cd002acc05bef6b6315cd447
Merged-In: I66dd51b020f6d895cd002acc05bef6b6315cd447
2021-10-25 15:09:21 +00:00
Xin Li
7dacadb1ea [automerger skipped] Merge "Merge Android 12" am: c03b0fa033 -s ours am: c259e66801 -s ours am: bbc8ff259a -s ours
am skip reason: Merged-In Iba1443da42161f4a41830081f2e1985b30444cc0 with SHA-1 ee05ff24d8 is already in history

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

Change-Id: I25a7ef9d68d597dae37704c4b0f4e36b5e34478e
2021-10-08 07:56:37 +00:00
Xin Li
bbc8ff259a [automerger skipped] Merge "Merge Android 12" am: c03b0fa033 -s ours am: c259e66801 -s ours
am skip reason: Merged-In Iba1443da42161f4a41830081f2e1985b30444cc0 with SHA-1 ee05ff24d8 is already in history

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

Change-Id: Ie051fa26cd626cb4d9a5a9e54ca3e42a340dc024
2021-10-08 01:39:21 +00:00
Xin Li
be0b993fae Merge Android 12
Bug: 202323961
Merged-In: Iba1443da42161f4a41830081f2e1985b30444cc0
Change-Id: I2bebe60bb7114706a3ba6af35522268cdf031f41
2021-10-06 22:53:28 +00:00
Luke Huang
2715753fca Merge "Keep the native mdns daemon alive for pre-S application" am: b2d3a48ae8 am: 67584fa3fe am: 260cbdfab6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1763368

Change-Id: Ib6e173d0b68469d596cf8491b729d50ed1f5263a
2021-09-29 04:26:15 +00:00
Luke Huang
260cbdfab6 Merge "Keep the native mdns daemon alive for pre-S application" am: b2d3a48ae8 am: 67584fa3fe
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1763368

Change-Id: I0312c8abb2eb11d8f788ca915a13ba0f23b5430a
2021-09-29 04:10:28 +00:00
Luke Huang
67584fa3fe Merge "Keep the native mdns daemon alive for pre-S application" am: b2d3a48ae8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1763368

Change-Id: Id0f1e097c9903897a35846e0ec6026d29228a39a
2021-09-29 03:50:49 +00:00
Luke Huang
b2d3a48ae8 Merge "Keep the native mdns daemon alive for pre-S application" 2021-09-29 03:35:20 +00:00
Aaron Huang
049dc2d23d Merge "Remove forceAllNetworkTypes from test" am: bc48cdaf46 am: 478733ce72 am: 5e54c22073
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1824613

Change-Id: I3cf9ca855b0a98c1bd65772e6617809a8c7194bb
2021-09-17 12:53:36 +00:00
Aaron Huang
5e54c22073 Merge "Remove forceAllNetworkTypes from test" am: bc48cdaf46 am: 478733ce72
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1824613

Change-Id: I3271a1dacea9e99c70b4d23d0cb2aea9a82a4678
2021-09-17 12:44:27 +00:00
Aaron Huang
478733ce72 Merge "Remove forceAllNetworkTypes from test" am: bc48cdaf46
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1824613

Change-Id: I460b93a1a9d04ecdf687761eea3461ecf0346860
2021-09-17 12:25:04 +00:00
Aaron Huang
dcd181914c Remove forceAllNetworkTypes from test
A test should test the actual behavior as much as possible.
However, if the flag is true, matchesMobile/matchesMobileWildcard
will always return true regardless of the network type and metered.
Thus, remove this flag would be closer to the actual behavior.

Bug: 183776809
Test: atest FrameworksNetTests
Change-Id: I0907a08ca1dd8a14a738db4057ea5ff6a0cd925a
2021-09-15 18:30:09 +08:00
Aaron Huang
b309f23e7f [automerger skipped] Merge "NetworkStats: Avoid Division By 0" into sc-qpr1-dev am: c98d5a9d97 -s ours
am skip reason: Merged-In I4e5ac9da7adf707d7f991483555ab5c6d0cc3245 with SHA-1 8b9f10e93c is already in history

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

Change-Id: I32041742d029c9ce5d91e5006978e7debd9375d9
2021-09-10 06:06:52 +00:00
Junyu Lai
f5ddb61923 NetworkStats: Avoid Division By 0
RawBytes should always be at least 1 to avoid division by 0 and
ArithmeticException resulting in Settings crash.

Bug: 197292638
Change-Id: I4e5ac9da7adf707d7f991483555ab5c6d0cc3245
Merged-In: I4e5ac9da7adf707d7f991483555ab5c6d0cc3245
(cherry picked from commit 49fb7e6da2ba08ead42d625b1aafa41a06fa45c2)
2021-09-08 04:12:31 +00:00
Junyu Lai
b346e2d12a Merge "NetworkStats: Avoid Division By 0" am: e22278838e am: dddf70e9c8 am: f08493be2f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1810678

Change-Id: I0b98a671be9c649f8e0d0655e2820b2430d0a3ef
2021-09-01 07:09:35 +00:00
Junyu Lai
f08493be2f Merge "NetworkStats: Avoid Division By 0" am: e22278838e am: dddf70e9c8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1810678

Change-Id: I579026d3e4b1f4ee03f156089d16047f0fc2f77c
2021-09-01 06:53:37 +00:00
Junyu Lai
dddf70e9c8 Merge "NetworkStats: Avoid Division By 0" am: e22278838e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1810678

Change-Id: I5bdeb5bba3613bc4891ff2c1e108d6f1a334eaad
2021-09-01 06:19:57 +00:00
Tyler Wear
8b9f10e93c NetworkStats: Avoid Division By 0
RawBytes should always be at least 1 to avoid division by 0 and
ArithmeticException resulting in Settings crash.

Bug: 197292638
Change-Id: I4e5ac9da7adf707d7f991483555ab5c6d0cc3245
2021-08-26 10:06:28 -07:00
Automerger Merge Worker
0879ec6150 Merge "[automerger skipped] Merge "Merge stage-aosp-sc-ts-dev before making it an upstream" into sc-dev am: 30a1c99c1b -s ours am: 8f7b3b1789 -s ours" into sc-qpr1-dev-plus-aosp 2021-08-13 21:32:15 +00:00
Xin Li
f6171a743a [automerger skipped] Merge "Merge stage-aosp-sc-ts-dev before making it an upstream" into sc-dev am: 30a1c99c1b -s ours am: 78e68f78c7 -s ours
am skip reason: Merged-In I35aae96e4ebb0c13bc567bb926f2e7a549f554ba with SHA-1 6c582e973d is already in history

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

Change-Id: I6162e93e7f80a6662e9a953883a2e02372c26009
2021-08-13 21:30:42 +00:00
Xin Li
8f7b3b1789 [automerger skipped] Merge "Merge stage-aosp-sc-ts-dev before making it an upstream" into sc-dev am: 30a1c99c1b -s ours
am skip reason: Merged-In I35aae96e4ebb0c13bc567bb926f2e7a549f554ba with SHA-1 6c582e973d is already in history

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

Change-Id: I4e344aae0efb943414ee16aa5d054d3c7232c723
2021-08-13 20:51:42 +00:00
The Android Open Source Project
0c4bbd7b01 Merge ab/7633965
Bug: 169893837
Merged-In: I3ef19b77bc33546a3e80bca75532d017b4712054
Change-Id: I595fb801f4519177825f3fdc0021fb874a36aa31
2021-08-12 22:30:48 +00:00
Junyu Lai
3b14a82156 [automerger skipped] Add debug log for tracking NPE of mMobileIfaces am: 9ec09dce94 -s ours
am skip reason: Merged-In Ib048c18b1c64627de5a9d2b04d10e084a014ff64 with SHA-1 73993fbb68 is already in history

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

Change-Id: Ib9cd4a658271786a0d75ee6f035dbace944624f1
2021-07-30 08:16:51 +00:00
Junyu Lai
b573ae43fc [automerger skipped] Fix mMobileIfaces is not protected by lock am: 67df85ea36 -s ours
am skip reason: Merged-In Ie7694a63f5203ee7c83830ca13d97219b7949fd7 with SHA-1 3a7f671f45 is already in history

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

Change-Id: I4d2c4e0af9137e380ab0ca71008721d95907cf3c
2021-07-30 08:16:38 +00:00
Junyu Lai
9ec09dce94 Add debug log for tracking NPE of mMobileIfaces
Test: TH
Bug: 192758557
Original-Change: https://android-review.googlesource.com/1777887
Merged-In: Ib048c18b1c64627de5a9d2b04d10e084a014ff64
Change-Id: Ib048c18b1c64627de5a9d2b04d10e084a014ff64
2021-07-30 06:08:30 +00:00
Junyu Lai
67df85ea36 Fix mMobileIfaces is not protected by lock
Currently, mMobileIfaces is accessed from multiple threads, and
should be protected from concurrent accessing. However, since the
variable could be accessed frequently, holding the mStatsLock
would make this be blocked by network stats I/O operations.
Thus, protect the variable by making it volatile.

Test: Wifi on/off stress test
Bug: 192758557
Original-Change: https://android-review.googlesource.com/1765686
Merged-In: Ie7694a63f5203ee7c83830ca13d97219b7949fd7
Change-Id: Ie7694a63f5203ee7c83830ca13d97219b7949fd7
2021-07-30 05:59:21 +00:00
Junyu Lai
beb6aa0fc0 Merge changes Ib048c18b,Ie7694a63 am: 06fd5a94ac am: 76ba518dcc
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1777887

Change-Id: I047a95bbf6d70f1a03e35782a36a98f34f51ca9c
2021-07-30 02:45:18 +00:00
Junyu Lai
06fd5a94ac Merge changes Ib048c18b,Ie7694a63
* changes:
  Add debug log for tracking NPE of mMobileIfaces
  Fix mMobileIfaces is not protected by lock
2021-07-30 02:13:25 +00:00
Junyu Lai
73993fbb68 Add debug log for tracking NPE of mMobileIfaces
Test: TH
Bug: 192758557
Change-Id: Ib048c18b1c64627de5a9d2b04d10e084a014ff64
2021-07-26 09:16:59 +00:00
Junyu Lai
3a7f671f45 Fix mMobileIfaces is not protected by lock
Currently, mMobileIfaces is accessed from multiple threads, and
should be protected from concurrent accessing. However, since the
variable could be accessed frequently, holding the mStatsLock
would make this be blocked by network stats I/O operations.
Thus, protect the variable by making it volatile.

Test: Wifi on/off stress test
Bug: 192758557
Change-Id: Ie7694a63f5203ee7c83830ca13d97219b7949fd7
2021-07-26 09:16:35 +00:00
Luke Huang
5ae199899f Merge "Keep the native mdns daemon alive for pre-S application" into sc-dev am: 5978eb6eb4
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15320524

Change-Id: I18b5ab0a0d332167db75d97b8d35595dedc56567
2021-07-22 03:26:43 +00:00
Luke Huang
f7277ed3c4 Keep the native mdns daemon alive for pre-S application
Roll back the behavior changes by checking the target SDK to ensure that
there are no compatibility issues with the pre-S application.
If the target SDK of the application <S, NsdManager will actively send a
cmd to start the native daemon, and NsdService will keep the daemon
until the last client with the target SDK <S disconnects.

Test: atest NsdManagerTest NsdServiceTest
Bug: 191844585
Change-Id: Ie93d5d585e126fe220ae865bbc7274f21a925984
2021-07-21 06:21:42 +00:00
Luke Huang
7a1fbd7463 Keep the native mdns daemon alive for pre-S application
Roll back the behavior changes by checking the target SDK to ensure that
there are no compatibility issues with the pre-S application.
If the target SDK of the application <S, NsdManager will actively send a
cmd to start the native daemon, and NsdService will keep the daemon
until the last client with the target SDK <S disconnects.

Test: atest NsdManagerTest NsdServiceTest
Bug: 191844585
Change-Id: Ie93d5d585e126fe220ae865bbc7274f21a925984
2021-07-21 06:08:35 +00:00
Treehugger Robot
024a50d574 Merge "Gracefully handle integer overflows." am: 424d3965d2 am: d4909b9aa9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1714119

Change-Id: I95ef9e71987fc39250e6edd107fe2ec597b1ea17
2021-07-20 08:15:13 +00:00
Treehugger Robot
424d3965d2 Merge "Gracefully handle integer overflows." 2021-07-20 07:36:56 +00:00
Remi NGUYEN VAN
c518ac6478 [automerger skipped] Merge "Rename FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT" am: ad9b865843 am: 8565e71426 -s ours
am skip reason: Merged-In I72660959cb4e638a8e80fcf2f4e96ea172969f44 with SHA-1 f7633ac09c is already in history

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

Change-Id: I2644d387bb1667ed5c1153646a78946b68c27301
2021-07-19 10:25:48 +00:00
Remi NGUYEN VAN
ad9b865843 Merge "Rename FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT" 2021-07-19 09:47:21 +00:00
paulhu
c6c8f46cc2 Rename FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT
As API review feedback, rename Build#VERSION#FIRST_SDK_INT to
Build#VERSION#DEVICE_INITIAL_SDK_INT. As well as update all usage
in frameworks and tests.

Bug: 184735771
Test: m
Merged-In: I72660959cb4e638a8e80fcf2f4e96ea172969f44
(cherry-pick with minor conflicts)

Change-Id: I72660959cb4e638a8e80fcf2f4e96ea172969f44
2021-07-05 14:10:16 +09:00
TreeHugger Robot
7643e201e4 [automerger skipped] Merge "Add support for app data accounting for in-kernel dataplanes" into sc-dev am: 836927f24b -s ours
am skip reason: Merged-In I768907cd3dd2028c7040cddd81fc71a5ce69bbdb with SHA-1 f5eca660c5 is already in history

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

Change-Id: I91d095347ced6a4d16af91371ebefdf68577b724
2021-07-03 02:12:25 +00:00
Benedict Wong
8002fe63f4 Add support for app data accounting for in-kernel dataplanes
This change ensures that app data accounting works correctly within the
confines of in-kernel dataplanes, as used by platform VPNs and the VCN.

Notably, the VCN MUST NOT specify the IMSI, as that would lead to double
counting of the interface statistics.

Bug: 175853498
Bug: 190620024
Test: atest NetworkStatsTest FrameworksVcnTests
Original-Change: https://android-review.googlesource.com/1749070
Merged-In: I768907cd3dd2028c7040cddd81fc71a5ce69bbdb
Change-Id: I768907cd3dd2028c7040cddd81fc71a5ce69bbdb
2021-07-02 19:28:45 +00:00
Benedict Wong
e8e6c62f7b Merge "Add support for app data accounting for in-kernel dataplanes" am: 75669e5311 am: cdb9503af4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1749070

Change-Id: I583a872bcb18f1b749f4ab0b49cbc9323920f048
2021-07-02 19:12:24 +00:00
Benedict Wong
75669e5311 Merge "Add support for app data accounting for in-kernel dataplanes" 2021-07-02 18:42:15 +00:00
Benedict Wong
f5eca660c5 Add support for app data accounting for in-kernel dataplanes
This change ensures that app data accounting works correctly within the
confines of in-kernel dataplanes, as used by platform VPNs and the VCN.

Notably, the VCN MUST NOT specify the IMSI, as that would lead to double
counting of the interface statistics.

Bug: 175853498
Bug: 190620024
Test: atest NetworkStatsTest FrameworksVcnTests
Change-Id: I768907cd3dd2028c7040cddd81fc71a5ce69bbdb
2021-07-01 19:49:50 -07:00
Luke Huang
0f212d8297 [automerger skipped] Merge "Fix the comments from aosp/1717479." into sc-dev am: e39eddcafb -s ours
am skip reason: Merged-In I71ebdd011574bd96de16a4248b0e15636418e87c with SHA-1 9fd7f864f4 is already in history

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

Change-Id: Id83bb07c1fb58995581d335968c7fb39abf7ffcb
2021-07-01 10:27:02 +00:00
Luke Huang
92860f9ea0 Fix the comments from aosp/1717479.
1. Increase the cleanup delay from 3s to 10s.
2. Fix the comments from aosp/1717479.

Bug: 181810560
Test: atest NsdManagerTest NsdServiceTest
Original-Change: https://android-review.googlesource.com/1730170
Merged-In: I71ebdd011574bd96de16a4248b0e15636418e87c
Change-Id: I71ebdd011574bd96de16a4248b0e15636418e87c
2021-06-23 09:54:50 +00:00
Luke Huang
9fa68e4c23 Merge "Fix the comments from aosp/1717479." am: 5955bb19cb am: 2d1ccbfd91
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1730170

Change-Id: I5c8869f627eb8f65ab7193991da0796dd682e8d4
2021-06-23 06:29:30 +00:00
Luke Huang
5955bb19cb Merge "Fix the comments from aosp/1717479." 2021-06-23 03:36:02 +00:00
TreeHugger Robot
0d5838ffd6 [automerger skipped] Merge "DO NOT MERGE - Merge ab/7272582" into stage-aosp-master am: 58175ace73 -s ours
am skip reason: Merged-In I81c036a8484d14683db9450b55bd379c7a728d73 with SHA-1 56f7a93793 is already in history

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

Change-Id: I86d96f38851361be3083c8a7fdf2e74dbbc35267
2021-06-18 00:51:57 +00:00
Xin Li
1ce52a9c5e DO NOT MERGE - Merge ab/7272582
Bug: 190855093
Merged-In: I81c036a8484d14683db9450b55bd379c7a728d73
Change-Id: I71fe9744d88740a8d95235ddb4c8ab91881473ce
2021-06-14 22:01:46 -07:00