NSD associated files are going to move into connectivity
mainline module in T, so need convert all hidden APIs to formal
API surfaces.
- Replace Slog with Log
- Remove useless implements Watchdog.Monitor
- Replace Build.IS_DEBUGGABLE with Build.isDebuggable()
- Replace Preconditions.checkState90 by checking null directly.
- Replace Lists.newArrayList() by new ArrayList<>()
- Replace DumpUtils.checkDumpPermission() by checking DUMP
permission directly.
Bug: 206702844
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I6bc478b852c10591959d9e0615af63e675532abe
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
When the default gateway is not used in IP configurations,
for example the gateway info in ip configurations was fed with
custom gateway address
```
out.writeUTF(GATEWAY_KEY);
out.writeInt(0); // Default route.
out.writeInt(1); // Have a gateway.
out.writeUTF(staticIpConfiguration.getGateway().getHostAddress());
```
A NPE occurred.
When there is no destination, assume it is default route and use
the gateway address in all cases.
Test: manual
Change-Id: I5904efad5d277de6724f81d99e62c21ff8347caa
Signed-off-by: gary-wzl77 <gary.wang@canonical.com>
When the NetworkStatsProvider reports alert/limit reached,
NetworkStatsService will relay the event to other services
such as NPMS or NMS. The identity should be cleared before
calling into other services.
Test: TH
Bug: 181106917
Change-Id: I2a7b273dc30156a84b30566319894ec3a42d4429
(we cannot just remove the argument, since the test code path still
goes via the legacy xt_qtaguid code paths with sample data)
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I044d0363aaab0dbbb90c40ca466cc48f169d649a
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
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 93581a0347)
RawBytes should always be at least 1 to avoid division by 0 and
ArithmeticException resulting in Settings crash.
Bug: 197292638
Change-Id: I4e5ac9da7adf707d7f991483555ab5c6d0cc3245
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