Commit Graph

3295 Commits

Author SHA1 Message Date
paulhu
c047d9a273 Replace @hide APIs
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
2021-12-01 22:31:50 +08:00
paulhu
9dbe49f954 Centralize nsd associated files
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
2021-11-29 23:08:06 +08:00
Chalard Jean
be3cc2a0de Merge "net: fix NPE when reading IP configurations" am: 53cf445e6a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1879657

Change-Id: I9ad5d7bdb2c9aa08bcfeca78c0a4858101f28444
2021-11-26 07:23:37 +00:00
Chalard Jean
53cf445e6a Merge "net: fix NPE when reading IP configurations" 2021-11-26 07:04:34 +00:00
Treehugger Robot
4f6833fee4 Merge "[MS06] Add carrier template fields into cloud backup/restore" am: bf7cc5b5d7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1892336

Change-Id: I65e9824a56727bd6a2386b2c6407fe407060d43c
2021-11-26 05:26:27 +00:00
Treehugger Robot
bf7cc5b5d7 Merge "[MS06] Add carrier template fields into cloud backup/restore" 2021-11-26 05:07:26 +00:00
Treehugger Robot
3095a50185 Merge "Clear calling identity when notifying alert/limit reached" am: f12063e60e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1896540

Change-Id: If2b8b6e8b8856d6db2aa167484c71163e06828c2
2021-11-26 03:47:01 +00:00
Treehugger Robot
f12063e60e Merge "Clear calling identity when notifying alert/limit reached" 2021-11-26 03:28:58 +00:00
Junyu Lai
d622cde7ee [MS06] Add carrier template fields into cloud backup/restore
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
2021-11-26 03:04:37 +00:00
gary-wzl77
4d7813dacc net: fix NPE when reading IP configurations
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>
2021-11-25 22:05:31 +08:00
Junyu Lai
575e81496c Clear calling identity when notifying alert/limit reached
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
2021-11-25 06:53:52 +00:00
Remi NGUYEN VAN
5f27f80c9a Merge "Remove AsyncChannel usage in NsdManager" am: 16d3da63f7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1823015

Change-Id: I06087e1d4828f4fee7a1b9a42e8bb2596e22684c
2021-11-22 06:19:18 +00:00
Remi NGUYEN VAN
16d3da63f7 Merge "Remove AsyncChannel usage in NsdManager" 2021-11-22 05:58:15 +00:00
Xin Li
c598c3f69d Merge sc-qpr1-dev-plus-aosp-without-vendor@7810918
Bug: 205056467
Merged-In: I13199bc39e9445929195f3d15579cbffe94e92b0
Change-Id: I35fa3c6c2abf679c51033f1395a08d511ed8739f
2021-11-18 17:00:37 +00:00
Maciej Żenczykowski
79237fad47 bpf is required so /sys/fs/bpf/map_netd_app_uid_stats_map always exists
(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
2021-11-18 06:11:00 +00:00
Maciej Żenczykowski
a2343dcbcc bpf is required - remove mUseBpfTrafficStats field
Test: git grep mUseBpfTrafficStats
  TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0be3b802e2ebd175b2a58061bf821aba02a8ec8a
2021-11-18 06:10:46 +00:00
Maciej Żenczykowski
6976b5996e bpf is required - remove checkBpfStatsEnable()
Test: git grep 'nativeGetTotalStat|nativeGetIfaceStat|nativeGetUidStat'
    - shows all locations have been updated
  git grep 'checkBpfStatsEnable'
    - find nothings relevant (just services/art-profile)
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib584ea57c39d5ab0605787b05133097fd2c82a39
2021-11-18 06:10:35 +00:00
Maciej Żenczykowski
0b99c46bcd remove qtaguid parsing
This removes the legacy (and untested) xt_qtaguid
non-ebpf code path (ie. dead code).

Test: git grep 'QTAGUID_IFACE_STATS|QTAGUID_UID_STATS|parseIfaceStats|parseUidStats'
  finds nothing
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I922910238474f2cfb74eba19b219bc792ce4abc3
2021-11-18 06:10:14 +00:00
Maciej Żenczykowski
6516893555 replace R + 1 with S
Test: TreeHugger
Bug: 170424293
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic28aa1a568bbd0b6d4f06abb7294415afd695fff
2021-11-10 18:16:42 -08:00
Remi NGUYEN VAN
3d30b93d60 Remove AsyncChannel usage in NsdManager
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
2021-11-04 17:59:51 +09:00
Les Lee
1e1cd496f6 Fix normalize doesn't work on carrier template
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
2021-11-04 14:12:09 +08:00
paulhu
927a6a7fdc Replace @hide APIs in IpSecService
- Replace Slog with Log
- Replace Binder.withCleanCallingIdentity with
  BinderUtils.withCleanCallingIdentity

Bug: 204153604
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I63083b3a4e50afe5154b4e8585d0eee46da819c6
2021-10-28 06:39:38 +00:00
Aaron Huang
0aed3102da Adapt NET_CAPABILITY_TEMPORARILY_NOT_METERED in NetworkIdentity
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
2021-10-26 05:57:24 +00:00
Aaron Huang
faf2c9e5d6 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
88c9babd37 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
cc9b7c0dea [automerger skipped] Merge "Merge Android 12" am: c03b0fa033 -s ours am: c259e66801 -s ours am: 86f6be8db8 -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
86f6be8db8 [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
6ce1b49048 Merge Android 12
Bug: 202323961
Merged-In: Iba1443da42161f4a41830081f2e1985b30444cc0
Change-Id: I2bebe60bb7114706a3ba6af35522268cdf031f41
2021-10-06 22:53:28 +00:00
Luke Huang
9cf857f7c0 Merge "Keep the native mdns daemon alive for pre-S application" am: 5e2f17f209 am: e0106f0acd am: 8facf2115d
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
8facf2115d Merge "Keep the native mdns daemon alive for pre-S application" am: 5e2f17f209 am: e0106f0acd
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
e0106f0acd Merge "Keep the native mdns daemon alive for pre-S application" am: 5e2f17f209
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
5e2f17f209 Merge "Keep the native mdns daemon alive for pre-S application" 2021-09-29 03:35:20 +00:00
Aaron Huang
9c536d1f59 Merge "Remove forceAllNetworkTypes from test" am: bc48cdaf46 am: 15503f12d6 am: 76ef313646
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
76ef313646 Merge "Remove forceAllNetworkTypes from test" am: bc48cdaf46 am: 15503f12d6
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
15503f12d6 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
da213c052e 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
560cc96a86 [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 162b047e74 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
5a5866cd0b 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 93581a0347)
2021-09-08 04:12:31 +00:00
Junyu Lai
de8e38379e Merge "NetworkStats: Avoid Division By 0" am: e22278838e am: 46b4720a18 am: 3672fe156e
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
3672fe156e Merge "NetworkStats: Avoid Division By 0" am: e22278838e am: 46b4720a18
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
46b4720a18 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
162b047e74 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
960761e3fd Merge "[automerger skipped] Merge "Merge stage-aosp-sc-ts-dev before making it an upstream" into sc-dev am: 30a1c99c1b -s ours am: a841e9ba73 -s ours" into sc-qpr1-dev-plus-aosp 2021-08-13 21:32:15 +00:00
Xin Li
448ae481b2 [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
a841e9ba73 [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
d970a9ad7e Merge ab/7633965
Bug: 169893837
Merged-In: I3ef19b77bc33546a3e80bca75532d017b4712054
Change-Id: I595fb801f4519177825f3fdc0021fb874a36aa31
2021-08-12 22:30:48 +00:00
Junyu Lai
2cfeeda796 [automerger skipped] Add debug log for tracking NPE of mMobileIfaces am: 10f9bde239 -s ours
am skip reason: Merged-In Ib048c18b1c64627de5a9d2b04d10e084a014ff64 with SHA-1 f6f1066532 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
1abbfe9361 [automerger skipped] Fix mMobileIfaces is not protected by lock am: fe1b6f90d7 -s ours
am skip reason: Merged-In Ie7694a63f5203ee7c83830ca13d97219b7949fd7 with SHA-1 1bdf075964 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
10f9bde239 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
fe1b6f90d7 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