Commit Graph

3459 Commits

Author SHA1 Message Date
Junyu Lai
8074ed308b [MS08] Move NetworkStats files to f/b/package/ConnectivityT
NetworkStatsService is going to be moved into ConnectivityService
module. Move all related files to packages/ConnectivityT so that
it can be easily migrate these files to connectivity module
after clearing the hidden API usages.

Bug: 197717846
Test: TH
Change-Id: Iead00832b5eb7b1dc40a92027c5a14ae8316b16c
2021-12-10 16:11:08 +00:00
Zhomart Mukhamejanov
cfd6585d9d Merge "Add javadoc to NetworkStats related classes." am: b69c56683c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1917019

Change-Id: Ic92ff264664e714cdcf0a8deadf0e9a254ce752e
2021-12-10 15:39:26 +00:00
Zhomart Mukhamejanov
b69c56683c Merge "Add javadoc to NetworkStats related classes." 2021-12-10 15:21:07 +00:00
Zhomart Mukhamejanov
635e46a2a0 Add javadoc to NetworkStats related classes.
Bug: n/a
Test: n/a
Change-Id: If7f4d68ea89adbcbc02c1e0a06a11f6330f5d8f3
2021-12-09 21:28:05 -08:00
Aaron Huang
aa29ed6ebb Merge "Move f/b/packages/Nsd files to f/b/packages/ConnectivityT" am: 610b585502
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1914528

Change-Id: I9675aa02c8271ecc9d8d11c5cb544f56d8ff1f93
2021-12-10 02:30:08 +00:00
Aaron Huang
874001496b Move f/b/packages/Nsd files to f/b/packages/ConnectivityT
Move Nsd files to ConnectivityT so that nsd, ipsec,
ethernet and netstats files can live in the same
directory and it will be easier to move everything
in frameworks/base/packages/ConnectivityT to
packages/modules/Connectivity after fixing all of the
hidden API usages.

Bug: 204153604
Test: FrameworksNetTests
      CtsNetTestCases
Change-Id: I411e242e8739d15920cfc2fe274115f7f39bd89f
2021-12-09 16:22:00 +08:00
Paul Hu
5b08cd89e5 Merge "Remove @hide symbols from NativeDaemonConnector" am: 68d5b22c2d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1899031

Change-Id: I6883153a5ec2f1002180905fe9972a650b9c0c84
2021-12-07 07:33:32 +00:00
Paul Hu
016bedc88b Merge "Stop using NSD_ON setting" am: a37333ace6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1895245

Change-Id: I13cc751269756ba745f4327b35e3562e3aefd689
2021-12-07 06:01:15 +00:00
paulhu
db0b20b2ed Remove @hide symbols from NativeDaemonConnector
- FgThread is an service internal class that NativeDaemonConnector
  can not use it after moving into mainline module. Thus, replace
  it by creating a new thread.

- Remove shutting down check because the original problem owner
  netd isn't used NativeDaemonConnector now.

Bug: 206702844
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Ib2e227ef1e361f96b397abd7c2a88420ad5a2f22
2021-12-07 11:47:34 +08:00
paulhu
3279219a5a Stop using NSD_ON setting
NSD_ON setting has never been set since it created. Besides,
CTS tests assume that nsd service is always enabled otherwise
the tests will fail. Thus, remove the setting from NsdService
which is no need to read/write it and it's also a hidden symbols.

Bug: 206702844
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Id3cef7def96925cec5095e12910e9b97ba7efb11
2021-12-03 21:21:07 +08:00
Paul Hu
13f6f77569 Merge "Replace @hide APIs" am: c0d2b740f0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1894755

Change-Id: I19d1193f80c38e8e9f1ffa143ebd7fe8d9393ac3
2021-12-03 02:30:44 +00:00
Paul Hu
0919e6aa43 Merge "Centralize nsd associated files" am: 32942299d3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1895244

Change-Id: I15a6d3eaca8b0244258d08b1dc5e46f0394609cb
2021-12-02 03:26:56 +00:00
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
Android Build Coastguard Worker
8f317e558f Merge cherrypicks of [16065658, 16033980, 16105251, 16117045, 16086468, 15960214, 16077739, 16211938, 16222839, 16191693, 16091135, 16220980, 16214442, 16233501, 16286398, 16333337] into sc-qpr1-release.
Change-Id: I961e3b46e89863311915418d1d4b092d7d970d0e
2021-11-24 23:26:08 +00:00
Les Lee
e46f8703e3 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
Merged-In: I80c9f887cf8b4714716d657da92ed273a532ce27
(cherry picked from commit e6498416d6)
Merged-In:I80c9f887cf8b4714716d657da92ed273a532ce27
2021-11-24 23:22:14 +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