Commit Graph

3137 Commits

Author SHA1 Message Date
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
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
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
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
5f4a585110 Merge "Make NsdService only start the native daemon when needed and automatically clean it up." into sc-dev 2021-06-15 04:52:43 +00:00
Les Lee
fee2cf470d Fix: query TYPE_WIFI usage with empty string
Starting with API level 31, the subscriberId is applicable
for the wifi network. Considering applications may use
null or an empty string as subscriberId (for instance, cts),
frameworks create MATCH_WIFI_WILDCARD NetworkTemplate when querying
wifi network with null or an empty string which is the behavior before
API level 31.

Bug: 188915450
Test: atest -c NetworkStatsManagerTest
Test: atest -c NetworkUsageStatsTest
Merged-In: I084b69903f8ba7a6225b312560752e8508938714
Change-Id: I084b69903f8ba7a6225b312560752e8508938714
2021-06-15 10:52:49 +08:00
Luke Huang
0529858b9c Make NsdService only start the native daemon when needed and automatically clean it up.
Currently, NsdService starts the native mdnsresponder daemon if any
NsdManager connect to it, which results in that when any constant
service holds the NsdManager connection, the device would always be
in the mdns multicast group whatever the connection is not used or not.
This is because mdnsresponder will join the multicast group when it
starts.

To solve this problem, start the native daemon only when needed, and
clean it up after the given idle timeout.

1. Start the native daemon when a new request come.
2. If there is no pending request, clean up the daemon after 3 seconds
of idle time.

Bug: 181810560
Test: atest NsdManagerTest NsdServiceTest
Original-Change: https://android-review.googlesource.com/1717479
Merged-In: I3eb04552f6cf6c0c68c07abffe751bb4d0669215
Change-Id: I3eb04552f6cf6c0c68c07abffe751bb4d0669215
2021-06-14 06:54:52 +00:00
lesl
22d53be4f7 carrier data usage: Use carrier template as default policy
The carrier network means any network which linked with sepcific
subscriberId (for instances: merged Wifi or mobile).
Update default policy to use carrier network template to replace mobile
template.

No impact for current AOSP user because no any wifi network is merged
wifi. (Because the merged wifi network requires to support from the wifi module).

Also this change convert all of the old policies which template is
TYEP_MOBILE to TYPE_CARRIER to match the default policy.

Bug: 176396812
Test: atest -c NetworkPolicyManagerServiceTest
Test: atest -c CtsHostsideNetworkTests
Test: Manual Test with test code (Force wifi to merged wifi).
      The data will limit when using merged wifi.
      And mobile policy also work normally.

Merged-In: I33c10f7549e713c52ce9afd5b8c4cce2abbda616
Change-Id: I33c10f7549e713c52ce9afd5b8c4cce2abbda616
2021-06-01 18:12:56 +08:00
Treehugger Robot
683c9918c9 Improve documentation of IpSecTunnelInterface#setUnderlyingNetwork
Clarify the consequence of adding IpSecTunnelInterface to the
underlying network.

Bug: 169855650
Test: builds
Change-Id: I2e3c4fe735b3374b2ff6d23850970e36c0aafda5
Merged-In: I2e3c4fe735b3374b2ff6d23850970e36c0aafda5
2021-05-20 21:56:26 +00:00
Les Lee
8d16935478 Merge "Support to query TYPE_WIFI usage with subscriberId" into sc-dev 2021-05-20 08:55:59 +00:00
Les Lee
f00bbae424 Merge "Add metered filter for API: buildTemplateCarrier" into sc-dev 2021-05-19 14:32:29 +00:00
lesl
43e738951b Add metered filter for API: buildTemplateCarrier
This CL modifies NetworkTemplate#buildTemplateCarrier to force on
metered carrier network and rename to buildTemplateCarrierMetered.
This method was introduced recently and has no callers.

This method will be used in Settings and NetworkPolicyManagerService
to display and manage data usage on carrier metered networks.

Settings/NetworkPolicyManagerService will use it instead of the existing
method buildTemplateMobileAll method, which only matches metered networks.
That code will change from matching metered mobile networks to matching
metered carrier networks.

Note: The carrier metered network includes metered mobile network and
metered "merged carrier wifi network" that is a specific cerrier wifi network
which provides the same user experience as mobile.

Bug: 176396812
Test: atest -c NetworkTemplateTest
Change-Id: I7196d62bb60844458a6c4b1d94e2baccb71e15cd
Merged-In: I7196d62bb60844458a6c4b1d94e2baccb71e15cd
2021-05-19 02:53:39 +00:00
lesl
9156aa122f Support to query TYPE_WIFI usage with subscriberId
Previous the API ignores subscriberId when network type is WIFI.
Allow caller to call querySummaryXXXX with TYPE: WIFI
+ subscriberId: IMSI to get carrier merged wifi usage which matches the wifi
network with the given IMSI.

Bug: 176396812
Test: atest -c NetworkStatsServiceTest
Change-Id: Ia033521a24e2bb56182d74a41bb2b39710571782
Merged-In: Ia033521a24e2bb56182d74a41bb2b39710571782
2021-05-19 02:53:16 +00:00
junyulai
d8d50e6c8f [FUI27] Fix internal naming of notifyNetworkStatus
Test: TH
Bug: 174123988
Merged-In: I970ee365ca221956ee85788005d331374b5fa71a
Change-Id: I970ee365ca221956ee85788005d331374b5fa71a
  (cherry-picked from aosp/1620539)
2021-05-17 14:07:00 +08:00
Aaron Huang
da35346611 [automerger skipped] Merge "Rename *Iface* APIs to *Interface*" am: f281058618 am: 5ff38f7c0d am: 1750ceafb8 -s ours
am skip reason: Merged-In I38b476e762fb57fa88c4a789092d0af6f5330d80 with SHA-1 c6e149a977 is already in history

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

Change-Id: I39709941a1770435d9a2e221025b46eed5d32ea0
2021-05-14 10:07:18 +00:00
Aaron Huang
1750ceafb8 Merge "Rename *Iface* APIs to *Interface*" am: f281058618 am: 5ff38f7c0d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1693585

Change-Id: I9aa62677f52ac78916c518d1378a05bda143f676
2021-05-14 09:44:33 +00:00
Aaron Huang
5ff38f7c0d Merge "Rename *Iface* APIs to *Interface*" am: f281058618
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1693585

Change-Id: I62fa0403c8b2d78e7e7a90be8ac804576ec27456
2021-05-14 09:36:36 +00:00
Aaron Huang
a266a9855c Rename *Iface* APIs to *Interface*
Address API review feedback, other APIs have been refering to
these as "interface" instead of "iface" so migrate the APIs named
*Iface* to *Interface*.

(cherry-picked from ag/14326779)
Bug: 183972554
Test: atest android.net.UnderlyingNetworkInfoTest
Merged-In: I38b476e762fb57fa88c4a789092d0af6f5330d80
Change-Id: I38b476e762fb57fa88c4a789092d0af6f5330d80
2021-05-14 11:05:22 +08:00
Aaron Huang
2ed83a71ee Merge "Add return type javadoc to NetworkStateSnapshot#getLegacyType" into sc-dev 2021-05-12 05:11:45 +00:00
Benedict Wong
974cd14755 Merge "Add clarifying comments on for IPsec forward policies" am: 1a88665f3c am: df1dcf78f2 am: 3f397e3f6e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1702525

Change-Id: I77e806ab3e76307dfc6456b210f691027aaeec66
2021-05-11 18:13:01 +00:00
Benedict Wong
3f397e3f6e Merge "Add clarifying comments on for IPsec forward policies" am: 1a88665f3c am: df1dcf78f2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1702525

Change-Id: Ifef0b1d3a1def9dfcf995fb5ddc79c0a88658ad0
2021-05-11 17:48:00 +00:00
Benedict Wong
df1dcf78f2 Merge "Add clarifying comments on for IPsec forward policies" am: 1a88665f3c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1702525

Change-Id: I7267d331065ceadb830a14170920810f053eacb8
2021-05-11 17:17:53 +00:00
Benedict Wong
70f1aab8c7 Merge changes from topic "vcn-fwd" am: d7d2d2a15b am: fc14eeaf35 am: 07806ad6be
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1682047

Change-Id: I745687f69366657dc33bfdacd878e06affd6a8ec
2021-05-11 06:10:32 +00:00
Benedict Wong
07806ad6be Merge changes from topic "vcn-fwd" am: d7d2d2a15b am: fc14eeaf35
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1682047

Change-Id: I4e11bdfa3e887103673a354aad7f9b5fa746ac9e
2021-05-11 05:52:26 +00:00
Benedict Wong
fc14eeaf35 Merge changes from topic "vcn-fwd" am: d7d2d2a15b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1682047

Change-Id: I7f02785727c73c27ac498ad4663f25252242c6e0
2021-05-11 05:26:46 +00:00
Benedict Wong
47b528cfe7 Add clarifying comments on for IPsec forward policies
This change adds clarifying comments for the usage of the forward
policies in IPsec, and corrects a comment to properly specify the
permissions allowed.

Bug: 185495453
Test: Comment-only changes
Change-Id: I6d36522c344c41b0ebd90d46b216d115b678dd31
2021-05-10 18:26:02 -07:00
Aaron Huang
ba8093a22e Add return type javadoc to NetworkStateSnapshot#getLegacyType
Add javadoc to document the return type is the legacy network
type in getLegacyType.

Bug: 183972826
Test: only update javadoc
Change-Id: I7757253af5955f7d489d6349c090dcba146cfd7f
2021-05-10 23:18:41 +08:00
Benedict Wong
908d34edcb Add internal support for IPsec forward policies
This change adds support for IPsec forward policies, which are necessary
for packets to be allowed to be forwarded to another interface, as is
the case with tethering. This is necessary and useful only within the
system server, and as such is not exposed as a public API.

This change is safe, since the addition of a FWD policy on IPsec tunnel
interfaces will by default block forwarded traffic (as would be the case
without this patch). In the event that the (system) owner of the tunnel
requires support for forwarded packets (eg tethering), this patch allows
application of transforms in the FWD direction as well.

This will be used to ensure that the VCN can be used as the underlying
network for the purposes of tethering.

Bug: 185495453
Test: atest IpSecServiceTest
Test: atest IpSecServiceParameterizedTest
Test: manual testing with tethering over VCN
Change-Id: I74ecea71f1954029f6fbdbe34598c82e0aac386b
2021-05-07 15:09:42 -07:00
TreeHugger Robot
0ccd2aceaf [automerger skipped] Merge "[SP31] Expose onSetWarningAndLimit System API" into mainline-prod am: 0bc22e9ff7 -s ours
am skip reason: Merged-In I6f5e22e3a7b80a38cae9f3c5d7296a1dff34facf with SHA-1 e6e90d34a2 is already in history

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

Change-Id: Ic7a9537554cbd290393111086ed8a691744cb33c
2021-05-07 04:10:53 +00:00
Junyu Lai
118833dff6 [automerger skipped] Merge changes I6c486303,I073934f3,I6ee66149,Ibbb4325c into mainline-prod am: d05921c661 -s ours
am skip reason: Merged-In I6c4863030c36328db571294fd12a40e59864def5 with SHA-1 df6726cac7 is already in history

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

Change-Id: If3ff5c4a714f3c4947a158a2b4e921c8bbc15eee
2021-05-03 14:38:47 +00:00
Treehugger Robot
72ca24d3d0 [automerger skipped] Merge "Add getters to NetworkStateSnapshot" am: 3bcc77078c am: df180e412e am: 74a82f6f39 -s ours
am skip reason: Merged-In Id1707753b42ae88d2b95e4bd00a792609434e4f5 with SHA-1 444fcb9d56 is already in history

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

Change-Id: Ice81dc86428db24ce535ad052e5b594e18d401b8
2021-04-29 10:26:50 +00:00
Treehugger Robot
74a82f6f39 Merge "Add getters to NetworkStateSnapshot" am: 3bcc77078c am: df180e412e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1684649

Change-Id: Ia6047f77624d6be82dc2528f52f7c77bf5b29c17
2021-04-29 10:02:43 +00:00
Treehugger Robot
df180e412e Merge "Add getters to NetworkStateSnapshot" am: 3bcc77078c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1684649

Change-Id: I3263514a5d75141c81e5f9d7389603ed369e95df
2021-04-29 09:39:19 +00:00
Treehugger Robot
bcbb1eac77 [automerger skipped] Merge "Add getters to UnderlyingNetworkInfo" am: 05d884470a am: b560e885f7 am: a93cae0ec7 -s ours
am skip reason: Merged-In Id59744097208d91298a25ef110ade91a9cf291a1 with SHA-1 8a74c1ff1d is already in history

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

Change-Id: I9ac1f63c16debb8269b240380257bffd934021d1
2021-04-29 09:23:49 +00:00
Treehugger Robot
3bcc77078c Merge "Add getters to NetworkStateSnapshot" 2021-04-29 09:20:34 +00:00
Treehugger Robot
a93cae0ec7 Merge "Add getters to UnderlyingNetworkInfo" am: 05d884470a am: b560e885f7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1684651

Change-Id: I33d2bbca5a72ab8500a7886073c9f4c4d1b84925
2021-04-29 08:57:50 +00:00
Treehugger Robot
b560e885f7 Merge "Add getters to UnderlyingNetworkInfo" am: 05d884470a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1684651

Change-Id: I97222bb04bdea78178741245016658cad7f082dc
2021-04-29 08:16:36 +00:00
Treehugger Robot
05d884470a Merge "Add getters to UnderlyingNetworkInfo" 2021-04-29 07:29:08 +00:00
Aaron Huang
c6e149a977 Rename *Iface* APIs to *Interface*
Address API review feedback, other APIs have been refering to
these as "interface" instead of "iface" so migrate the APIs named
*Iface* to *Interface*.

Bug: 183972554
Test: atest android.net.UnderlyingNetworkInfoTest
Change-Id: I38b476e762fb57fa88c4a789092d0af6f5330d80
2021-04-28 17:57:32 +08:00
Les Lee
3f3865873d Merge "wifi data usage: support to get carrier merged wifi network." am: bef2f5be94 am: e0f1f83446 am: 1f366a8365
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1538743

Change-Id: Ie55770f885bf3c917ad485d2bd8c025b676f12b6
2021-04-27 06:00:48 +00:00
Les Lee
1f366a8365 Merge "wifi data usage: support to get carrier merged wifi network." am: bef2f5be94 am: e0f1f83446
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1538743

Change-Id: Ia115b6c8fe536d77071744374f5d42390cc50dbd
2021-04-27 04:13:08 +00:00
Les Lee
e0f1f83446 Merge "wifi data usage: support to get carrier merged wifi network." am: bef2f5be94
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1538743

Change-Id: I01b6790de48a514256f51ebb85226e56c6e2f59b
2021-04-27 03:26:31 +00:00
Aaron Huang
433fb498b5 Add getters to UnderlyingNetworkInfo
Address API review feedback, add getters to UnderlyingNetworkInfo
instead of exposing fields.

Instead of wasting memory by converting this into an array, have
migrateTun take a List<String>. In turn, tunAdjustmentInit should
also take a List<String>.

(cherry picked from ag/14211075)
Bug: 183972554
Test: atest android.net.UnderlyingNetworkInfoTest
Merged-In: Id59744097208d91298a25ef110ade91a9cf291a1
Change-Id: Id59744097208d91298a25ef110ade91a9cf291a1
2021-04-22 22:30:42 +08:00
Aaron Huang
955a1a50df Add getters to NetworkStateSnapshot
Address API council feedback, add getters to NetworkStateSnapshot
instead of exposing the bare fields directly.

(cherry picked from ag/14233655)
Bug: 183972826
Test: FrameworksNetTests
Merged-In: Id1707753b42ae88d2b95e4bd00a792609434e4f5
Change-Id: Id1707753b42ae88d2b95e4bd00a792609434e4f5
2021-04-22 18:21:00 +08:00
junyulai
8c6fdf886e [SP31] Expose onSetWarningAndLimit System API
Test: atest NetworkPolicyManagerServiceTest NetworkStatsServiceTest
Bug: 149467454
CTS-Coverage-Bug: 183598414
Merged-In: I6f5e22e3a7b80a38cae9f3c5d7296a1dff34facf
Change-Id: I6f5e22e3a7b80a38cae9f3c5d7296a1dff34facf
  (cherry-picked from ag/13981689 with fixed merged conflict)
2021-04-22 12:07:13 +08:00
junyulai
bfce074c44 [SP29] Send interface warning bytes to NetworkStatsProvider
This change contains necessary modification in NPMS and NSS
to send warning bytes to NetworkStatsProvider. But since
no any provider has been upgraded to handle such parameter.
Thus, no behavior change is made in this patch.

Test: atest NetworkPolicyManagerServiceTest NetworkStatsServiceTest
Test: atest NetworkPolicyManagerServiceTest#testStatsProviderWarningAndLimitReached
Bug: 149467454
Bug: 170699770
Bug: 170179169
Merged-In: I6c4863030c36328db571294fd12a40e59864def5
Change-Id: I6c4863030c36328db571294fd12a40e59864def5
  (cherry-picked from ag/13982166)
2021-04-22 12:07:12 +08:00
junyulai
7ead7c5101 [SP28] Add API for set data warning
To have better control and race-free of set data warning
to tether offload hardware, an interface of set warning and
limit at the same time in the NetworkStatsProvider is needed.

This is a no-op change which expose such interface with minimum
changes in service side to get build pass. The implementation
would be included in follow-up patches.

Test: atest NetworkStatsServiceTest
Test: atest NetworkPolicyManagerServiceTest
Test: atest GtsNetworkStackHostTestCases
Test: m doc-comment-check-docs
Bug: 149467454
Bug: 170699770
Bug: 170179169
Merged-In: I6ee661497f7dedb871c85786d1950cab951d8aa2
Change-Id: I6ee661497f7dedb871c85786d1950cab951d8aa2
  (cherry-picked from ag/13959436)
2021-04-22 12:07:12 +08:00
Aaron Huang
360973e00a Merge "Add getters to UnderlyingNetworkInfo" into sc-dev 2021-04-22 03:09:41 +00:00
Nazanin Bakhshi
35c18e14f9 Merge "Security fix: enforce read privilege permission to check package privileges in TelephonyManager" into sc-dev 2021-04-21 22:04:04 +00:00
Nazanin
6468b0d17e Security fix: enforce read privilege permission to check package
privileges in TelephonyManager

Bug: 180938364
Test: cts
Change-Id: I08c346c46b9e87dceaa1faf35fa36b954d88f9b0
2021-04-20 14:27:20 -07:00