Move all nsd associated files include framework, service and test
to package/Nsd first. After clear all hidden API dependencies, we
can easily migrate these files into connectivity mainline module.
Bug: 206893064
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Id26f471a10fe7882e31ccc2dbb73219461f00dbd
NetworkTemplate with MATCH_CARRIER can be created in NPMS,
and can be backup by SettingsBackupAgent. However, since
the meteredness is not stored in the backup. After incorrectly
deducing from match rule, meteredness always becomes
METERED_ALL after restoring from backup.
This change also adds debug log if any non-persistable template
is being backed up.
Test: TH, dedicated test is included in the follow-up CL.
Bug: 204830222
Change-Id: I865b1d6e571ed998a75b776f01afc7c2534af2dc
Replace AsyncChannel with two AIDL interfaces: INsdManagerCallback and
INsdServiceConnector.
This will be helpful to move NsdManager into a module, avoiding the
dependency on the hidden AsyncChannel utility.
Bug: 190249673
Test: atest FrameworksNetTests CtsNetTestCases:NsdManagerTest
Change-Id: Id9e8feb95cbb5ba16f00893f6c3f37fced3358c1
From android 12, the subscriberId is being used for different network
types. For instances:
The TYPE_WIFI with subscriberId means that it is a merged wifi network.
The TYPE_CARRIER means that the network associate to specific carrier
network (subscriberId).
So remove the check "isMatchRuleMobile" and only check whether subscriberId
is being used in NetworkTemplate or not.
Bug: 194939211
Test: atest -c NetworkTemplateTest
Change-Id: I80c9f887cf8b4714716d657da92ed273a532ce27
NET_CAPABILITY_TEMPORARILY_NOT_METERED is a capability indicates
networks are generally metered, but are currently unmetered.
NetworkIdentity currently did not consider it which will cause
Settings shows high data usage. To exclude unmetered 5g from the
metered usage, NetworkIdentity should consider a network with
NET_CAPABILITY_TEMPORARILY_NOT_METERED capabilities as not metered.
Bug: 183776809
Test: FrameworksNetTests:NetworkIdentityTest
Change-Id: Iadbc082b52f16708207e8aecf0904356bc0898ab
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
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
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
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
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
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
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
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
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
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
Change-Id: I084b69903f8ba7a6225b312560752e8508938714
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
Change-Id: I3eb04552f6cf6c0c68c07abffe751bb4d0669215
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
Avoid recording negative data by doing integer-based
math as much as possible, but switch to double-based
math if we detect that we'd end up causing an overflow.
Test :
- Builds, Boots
- High data throughput scenarios
- NetworkStatsHistoryTest, NetworkStatsCollectionTest,
NetworkStatsTest
Bug: 119527458
Change-Id: I355fc9bd127da83c1dc70ab3b1261346d4fa5de0
Clarify the consequence of adding IpSecTunnelInterface to the
underlying network.
Bug: 169855650
Test: builds
Change-Id: I2e3c4fe735b3374b2ff6d23850970e36c0aafda5
Merged-In: I2e3c4fe735b3374b2ff6d23850970e36c0aafda5
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.
Change-Id: I33c10f7549e713c52ce9afd5b8c4cce2abbda616
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
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
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