Commit graph android_packages_modules_Co.../framework-t/src/android
Message SHA1
[AF02.1] Support read by FastDataInput in the NetworkStatsRecorder
This increased reading performance by 35% while running
benchmark tests. But the feature is not enabled in the production
code until the service turns it on.

Test: atest ConnectivityBenchmarkTests
Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.NetworkStatsCollectionTest
Bug: 313841499

Change-Id: Ic827e6c4848cc31d46d62aa93993b483114a1f12

Junyu Lai   commited 2023-12-21 15:14:59 +08:00
2dce848e88
Merge changes from topic "mdns-subtypes" into main
* changes:
  [mdns] add service-side impl for subtypes advertising
  [mdns] add support for advertising subtypes

Kangping Dong   authored and   Gerrit Code Review   commited 2023-12-18 08:49:44 +00:00
19d055514c
[mdns] add service-side impl for subtypes advertising
This is the servide-side impl of the subtypes advertising added in
aosp/2608627. See that CL for more backgrounds.

Bug: 265095929
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: I3d6f96822ac89d12fe29c00f688d848297c25787

Kangping Dong   commited 2023-12-18 10:03:20 +08:00
5af24b65fe
[mdns] add support for advertising subtypes
This commit adds support of advertising and discovering services
with subtypes.

With this change, client can publish a new service with subtypes with
code:
```
NsdServiceInfo info = new NsdServiceInfo();
info.setServiceName("My Service");
info.setServiceType("_meshcop._udp");
info.setSubtypes(Set.of("_abc"));

nsdManager.registerService(info, PROTOCOL_DNS_SD, listener);
```

Bug: 265095929
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: Ia83182e2d43002243d1ef4357d14a8056d7da14b

Kangping Dong   commited 2023-12-18 10:03:16 +08:00
6d618d77fe
Expose APIs to query the state of an IpSecTransform
Bug: 308011229
Test: make update-api
Change-Id: I5ca6278305f814dbce6a7c41a4f4e491b1389b31

Yan Yan   commited 2023-12-12 22:20:53 +00:00
3976e49e40
Reland "Support getting transform state in IpSecService"
This reverts commit 69eb8325c0.

Bug: 308011229
Change-Id: I4dd68bdedc0088860895a833f2b4cb8e1845429a
Test: IpSecServiceParameterizedTest (new tests)

Yan Yan   authored and   Gerrit Code Review   commited 2023-12-12 22:19:55 +00:00
84fc0ee2d6
Revert "Support getting transform state in IpSecService"
This reverts commit ab5006c17d.

Reason for revert: b/316010034 breaking VCN unit tests

Change-Id: I68cb1a99bb6e492c16901972d201761cd00df6fa

Yan Yan   authored and   Gerrit Code Review   commited 2023-12-12 21:53:46 +00:00
69eb8325c0
Support getting transform state in IpSecService
Bug: 308011229
Test: IpSecServiceParameterizedTest (new tests)
Change-Id: I3f1c2ef60ee9b6ac17909e0ee083ee6f8483588e

Yan Yan   commited 2023-12-12 00:14:13 +00:00
ab5006c17d
Merge "[AF01] Move NetworkStatsCollection comparison code to NetworkStatsCollection" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-12-06 02:26:14 +00:00
2f67e0f2d4
[AF01] Move NetworkStatsCollection comparison code to NetworkStatsCollection
This is a no-op refactoring to move the ultility method to a
common place to be referenced outside NetworkStatsService
in later patches.

Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Bug: 313841499
Change-Id: Ib0ef40d87486bf3d8d5b3f97c77291a00c0378ac

Junyu Lai   commited 2023-12-05 07:30:56 +00:00
77f84a40d1
Merge "Add FlaggedAPI annotation to NSD offload APIs" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-11-30 07:33:19 +00:00
53f0825b5d
Add FlaggedAPI annotation to NSD offload APIs
These APIs were released via SDK extension but they need to have
FlaggedAPI annotation to avoid being released by quarterly release.

Note that this CL does not contain udc-extended-api change.
Once com.android.net.flags.register_nsd_offload_engine_api is marked as
released API, APIs with this annotations should be visible in
udc-mainline-prod API .txt files.

Bug: 301713539
Test: TH
Change-Id: I32b58ec64c1f599f48bc89b189ed24ac1717a1d7

Motomu Utsumi   commited 2023-11-28 17:50:14 +09:00
ce23d8467e
Fix the memory leak in nsd tests
The NsdManager constructor creates a new thread, which is not
intended to be closed. However, the test in NsdMangerTest and
NsdServiceTest create a new NsdManager instance, resulting in a
large number of threads running during the tests. This can lead
to an out-of-memory error for the tests. To resolve this issue,
use the common singleton thread ConnectivityThread to handle
tasks from the various instances.

Fix: 308544734
Test: atest ConnectivityCoverageTests --test-filter Nsd*
Change-Id: I1908a2bb1bd20da8e0498353bca26f7e89e16626

Paul Hu   commited 2023-11-21 14:04:07 +08:00
27662f0cc3
Catch UnsupportedOperationException on calling mdns
MDNS native support from Netd is stopped in V.

Bug: 298594687
Bug: 312092770
Test: run CtsNetTestCasesMaxTargetSdk30 on V, no fatal exception.
Change-Id: I3774288cdf5b82e6aeeee7ee2d030fdc524e1aa8

Ken Chen   commited 2023-11-20 17:15:22 +08:00
a49e8e0b7b
Allow to query NetworkStats for TYPE_PROXY
Test: atest FrameworksNetTests CtsNetTestCases
Bug: 307217169

Change-Id: I006e3191a8c6100af3d2906d5d37f4e38a3db519

Ivo Kay   commited 2023-11-16 13:43:00 +00:00
65186a72aa
Fix broken documentation in Connectivity
EthernetManager is @SystemApi, so cannot be referenced from public
API.

Bug: 303184203
Test: m docs
Change-Id: Ib5cc07c89b4ecfdeae704da131ebb307816e35fa

Anton Hansson   commited 2023-10-13 15:25:26 +00:00
5ac6c0b05b
Merge "[Thread] initial Thread network service" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2023-09-19 11:25:37 +00:00
01e6dadd1f
[Thread] initial Thread network service
This commit sets up the initial Thread network service for the
Android Thread feature which allows an Android device to create
a Thread network and being a Border Router.

See https://www.threadgroup.org/What-is-Thread for background of
Thread.

See b/235016403 for the Android Thread feature request.

Test: lunch aosp_cf_x86_64_tv-userdebug
      m && launch_cvd
      atest CtsThreadNetworkTestCases
Bug: 262683651
Change-Id: Ie1bb23084531f67165ec068ea3ca39592dbc01d1

Kangping Dong   commited 2023-09-12 21:48:57 +08:00
1cec48f3c0
Add newApi linter check for mDNS library
The mDNS library need to be backported to some internal library which
support minSdk 21. Therefore, updated the build rules to add the linter
check.

Bug: 296175311
Test: TH
Change-Id: Iae0bffa315dc6de2339a05f595b13480fa7385ae

Yuyang Huang   commited 2023-09-12 19:01:21 +09:00
fc83170c70
Merge "Address review followup comments for NetworkStats" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-09-08 20:11:03 +00:00
8df4d76aa2
Send rawOffloadPacket to OffloadEngine
Add the missing logic to send the rawOffloadPacket to OffloadEngine.

Bug: 297314970
Test: atest CtsNetTestCases FrameworksNetTestCases
Change-Id: I06d7a9bb84df72808eff4f0c9df60f7e60aa2a2c

Yuyang Huang   commited 2023-09-05 08:51:04 +00:00
31f6e2eccb
Address review followup comments for NetworkStats
This change includes:
1. Mark groupedBy*() deprecated and throw after android U.
2. Modify map() to mapKeysNotNull().
3. rename clearInterfaces to withoutInterfaces and refactoring.
4. Modify tests accordingly.

Test: atest FrameworksNetTests:android.net.connectivity.android.net.NetworkStatsTest
Fix: 296149902
Fix: 296150018
Change-Id: I5d97422ba957a212c0c5fbc1eee3f8b174343348

Junyu Lai   commited 2023-09-04 18:01:14 +08:00
35c69c7986
remove unused TcpTx/RxPackets java & jni constants
(is this a valid change from hiddenapi perspective?)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2dc1c54c56a628770149382f1e25b90a71f62167

Maciej Żenczykowski   commited 2023-08-13 09:32:33 +00:00
6f0ec43200
simplify tcpTx/RxPackets
On T+ this is mainline code, and the bpf program (netd.c)
does not support collecting tcp specific stats.

(note: this *is* a behaviour change, as it currently
just always returns 0, but UNSUPPORTED/-1 seems to make
more sense)

Test: TreeHugger
Bug: 294604315
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifda15e67d9167a2be98ab6f4e3817ff7c0bb3fea

Maciej Żenczykowski   commited 2023-08-13 09:31:53 +00:00
66645a8d68
Enable service offload API
API-Coverage-Bug: 282618639
Bug: 269240366
Test: atest CtsNetTestCases
Change-Id: I7ac72b675ff3715891f31bc03c453e14b1264e40

Yuyang Huang   commited 2023-08-04 19:24:01 +09:00
00cf7eda31
Add callbacks for service offload
Components that can provide offload like IpClient (packet
filter offloading) can use the API to register a callback to be notified
when offload is necessary.

Bug: 269240366
Test: atest CtsNetTestCases
Change-Id: I8080702f5b530001b88e79e504f4722ac01bc576

Yuyang Huang   commited 2023-08-04 19:22:15 +09:00
33fa4d268c
Deduplicate items after clear interface in NetworkStats
Follow-up from commit Ie60829a65d0d9b5b63ad353695a820c0586e3665,
the interface field was cleared before returning the result to
the caller. However, this can cause problems in the
NetworkStats#subtract method. If the interface field is cleared,
the findIndexHinted method can match to a wrong entry.
This is because the keys of multiple entries will now be the
same. This can cause the subtract result to be unexpectedly
large and the return value of getUidStatsForTransport to be
mismatched with the values retrieved from other APIs.

Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
      FrameworksNetTests:android.net.connectivity.android.net.NetworkStatsTest
Bug: 290728278
Change-Id: I891ab29b8a2902663febc7c32b04417caf510926

Junyu Lai   commited 2023-08-01 13:38:26 +08:00
23d89c0bbf
Refactor grouped by methods
This is a no-op refactoring, which re-write the group by methods
to use a common method that can slice NetworkStats by a given
lambda. This is useful for subsequent changes to slice NetworkStats
with different conditions.

Test: atest FrameworksNetTests:android.net.connectivity.android.net.NetworkStatsTest
Bug: 290728278
Change-Id: Ia28571021fba46fc59380798053ccdc91ddc6ae4

Junyu Lai   commited 2023-08-01 11:32:04 +08:00
0b9c0835b9
Remove the ServiceTypeClient after socket destroyed
The ServiceTypeClient should be removed after socket destroyed
because it's no longer used by any request. The requests will be
matched to the newly created ServiceTypeClient.

Bug: 278635632
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Ia917b14d3666f3bfe8e874606a34800a4ce65c5a

Paul Hu   commited 2023-05-11 15:17:21 +08:00
f2a51ac5f8
Merge changes from topic "statsaccess"
* changes:
  Check MAINLINE_NETWORK_STACK as well to make GTS can access proper stats
  Move checkAnyPermissionOf to PermissionUtils

Junyu Lai   authored and   Gerrit Code Review   commited 2023-04-14 09:54:49 +00:00
9d25241337
Add missed NSD event name
Some events are missed their name in the EVENT_NAMES array and
shows the number on dumpsys logs. Add their name to the event
array to show correct info.

Before:
 rec[0]: time=04-12 15:15:23.553 processed=DefaultState org=EnabledState dest=<null> what=21
 rec[1]: time=04-12 15:15:23.555 processed=EnabledState org=EnabledState dest=<null> what=REGISTER_SERVICE
 rec[2]: time=04-12 15:15:24.375 processed=EnabledState org=EnabledState dest=<null> what=DISCOVER_SERVICES
 rec[3]: time=04-12 15:15:25.338 processed=EnabledState org=EnabledState dest=<null> what=23
 rec[4]: time=04-12 15:15:25.342 processed=EnabledState org=EnabledState dest=<null> what=RESOLVE_SERVICE
 rec[5]: time=04-12 15:15:25.344 processed=EnabledState org=EnabledState dest=<null> what=23
 rec[6]: time=04-12 15:15:25.358 processed=EnabledState org=EnabledState dest=<null> what=UNREGISTER_SERVICE
 rec[7]: time=04-12 15:15:25.551 processed=DefaultState org=EnabledState dest=<null> what=22

After:
 rec[0]: time=04-12 15:19:58.955 processed=DefaultState org=EnabledState dest=<null> what=REGISTER_CLIENT
 rec[1]: time=04-12 15:19:58.958 processed=EnabledState org=EnabledState dest=<null> what=REGISTER_SERVICE
 rec[2]: time=04-12 15:19:59.979 processed=EnabledState org=EnabledState dest=<null> what=DISCOVER_SERVICES
 rec[3]: time=04-12 15:20:00.768 processed=EnabledState org=EnabledState dest=<null> what=MDNS_DISCOVERY_MANAGER_EVENT
 rec[4]: time=04-12 15:20:00.777 processed=EnabledState org=EnabledState dest=<null> what=RESOLVE_SERVICE
 rec[5]: time=04-12 15:20:00.778 processed=EnabledState org=EnabledState dest=<null> what=MDNS_DISCOVERY_MANAGER_EVENT
 rec[6]: time=04-12 15:20:00.785 processed=EnabledState org=EnabledState dest=<null> what=UNREGISTER_SERVICE
 rec[7]: time=04-12 15:20:00.925 processed=DefaultState org=EnabledState dest=<null> what=UNREGISTER_CLIENT

Test: adb shell dumpsys servicediscovery
Bug: 275004614
Change-Id: I9c05efc2d2993af353a2a902fd8810f53ab2cd16

Paul Hu   commited 2023-04-12 15:24:02 +08:00
99fdf93066
Check MAINLINE_NETWORK_STACK as well to make GTS can access proper stats
Follow up from aosp/1933093. The test failed because certain
devices use a flattened apex that lacks the NETWORK_STACK
permission for sharing with the GTS apk.
Additionally, the NetworkStatsAccess does not recognize the
GTS apk, which holds the MAINLINE_NETWORK_STACK permission.

Test: TH
Bug: 275532605
Change-Id: Icce80a3d3dbea4a84fbd369d9b5fbe0029ab463e

Junyu Lai   commited 2023-04-11 14:56:15 +08:00
e68c42b888
Fix a var name in a comment
Remaining comment from aosp/2527124

Test: comment-only change
Change-Id: Ic0418bf0bc15b854e25e211bc7399d83487fe971

Chalard Jean   commited 2023-04-10 10:38:20 +09:00
e2294fb13e
Rename throwAboveU to throwAtLeastU
And address other comments on aosp/2527139

Bug: 273963543
Test: FrameworksNetTests
Change-Id: I4328aea2881badc2be667b900b7ac2a296af1678

Chalard Jean   commited 2023-04-07 12:19:10 +09:00
1bfd3ccf0b
Restore the null behavior of buildWifiTemplate
The old behavior was to only return those wifis that have
a null key/subscriber ID (e.g. not carrier wifi). To keep
backward compatibility, restore that behavior.

Also only crash the old methods on devices with initial
SDK U, because it can't be mandated that devices that
upgrade must not call these methods.

Bug: 273963543
Test: FrameworksNetTests
Merged-In: Iefb976ed86a732158964fae38e9e601001c2637a
Change-Id: Iefb976ed86a732158964fae38e9e601001c2637a

Chalard Jean   authored and   Remi NGUYEN VAN   commited 2023-04-07 02:49:28 +00:00
843cd6ca48
Do not crash when passing null into buildTemplateMobileAll
Test: atest FrameworksNetTests:android.net.connectivity.android.net.NetworkTemplateTest
Test: atest FrameworksNetTests:android.net.connectivity.android.net.netstats.NetworkTemplateTest
Bug: 273963543
Change-Id: I0a8f94df124147e92d35cf474b3d69d1dee6902c

Junyu Lai   commited 2023-03-30 13:59:02 +08:00
2c12f922de
Merge "Add back @hide NetworkTemplate methods"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-03-24 03:37:24 +00:00
123595655a
Add back @hide NetworkTemplate methods
Add back methods that were removed in recent refactoring
(aosp/2286634).  Even though they are fully @hide, some usage by
an OEM has been found on T.

Test: atest; the methods should be unused except on the OEM device
Change-Id: Icd67fb8b7e63cc131356a30a3044458ae2f5efff

Remi NGUYEN VAN   commited 2023-03-23 18:49:28 +09:00
37c4a9f222
Merge "Add a CompatChange flag to enable platform backend"
Paul Hu   authored and   Gerrit Code Review   commited 2023-03-17 13:14:19 +00:00
62503cfef1
Add a CompatChange flag to enable platform backend
Apps targeting sdk < U are considered to use a legacy native
daemon as NsdManager backend, but other apps use a
platform-integration mDNS implementation as backend. So add a
CompatChange flag to enable platform backend for non-legacy
apps.

Bug: 270306772
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I7ba58f8a5186fb49ad5f8aeacc8b8234bef1eabe

Paul Hu   commited 2023-03-17 09:10:46 +08:00
2e0a88c0fa
Merge "Remove requireNonNull check from matchesWifiNetworkKey"
Junyu Lai   authored and   Gerrit Code Review   commited 2023-03-09 09:13:40 +00:00
7ee63b6895
Remove requireNonNull check from matchesWifiNetworkKey
matchesWifiNetworkKey expects a non-null value of the
wifiNetworkKey, however, it might be null in practice
and the null wifiNetworkKey will be stored into disk.
And then when the matchesWifiNetworkKey is called, the
requireNonNull will crash the system. Thus, remove the
requireNonNull from matchesWifiNetworkKey to avoid
system crash and handle if the wifiNetworkKey is null
then it should not match a template with non-empty
mMatchWifiNetworkKeys.

Check if WifiInfo contains a null network key then skip it
to prevent adding the identity to the network identity set.
Also, add a Log.wtf when setWifiNetworkKey(info.getNetworkKey()),
this might be useful to catch why the wifiNetworkKey is
null.

Bug: 267815242
Bug: 266598304
Test: FrmeworksNetTests
Change-Id: I9c21f7e3dca9482133c7e331741cf808105414e9

Aaron Huang   authored and   Junyu Lai   commited 2023-03-07 18:16:55 +08:00
8ac1143594
Migrate reigster service callback backend
registerServiceInfoCallback currently only sends updates for
addresses added, but does not handle removes (expiration) and
TXT/SRV record updates. Thus, migrate its backend to
MdnsDiscoveryManager which can support the expiration update.

Bug: 266030646
Test: atest FrameworksNetTests CteNetTestCases
Change-Id: I72add213935dc1beacb6277007868ad30bd89c00

Paul Hu   commited 2023-03-06 13:49:19 +08:00
30bd70d168
Merge changes I197fbfb8,I6375e771,I48536927
* changes:
  Add constructor which used by Android T CTS
  Delete testUnsupportedAppUsageConstructor from coverage test
  Add some hidden APIs back to NetworkTemplate

Junyu Lai   authored and   Gerrit Code Review   commited 2023-03-03 09:34:47 +00:00
d3e793d8a1
Add constructor which used by Android T CTS
aosp/2241257 and aosp/2241058 are included in the mainline train
release and it causes the T device can’t pass CTS-13_R2/CTS-13_R3.
It’s because some parameters of the constructor have been removed.

Add it back to keep backward compatibility.

Test: 1. atest CtsNetTestCases:android.net.netstats.NetworkTemplateTest
      2. CTS-13_R3
Fix: 269974916
Fix: 269834366
Change-Id: I197fbfb8419e4d4885a97a93a71f13d33c3f02da

Junyu Lai   commited 2023-03-03 15:16:36 +08:00
84b5936e3d
Add some hidden APIs back to NetworkTemplate
Since there's a bug about apps still call hidden
APIs, it's likely some developers might build apps
against hidden API.
To be safe, add these methods back to avoid apps
crash. These methods are still in
hiddenapi-max-target-o-low-priority.txt, so they
should not be removed without considering hidden
API usage. Removing hidden API in general isn't
forbidden, but the ones listed in hiddenapi usage
need extra care.

Bug: 269178029
Test: 1. atest CtsNetTestCases:android.net.netstats.NetworkTemplateTest
      2. CTS-13_R3
Change-Id: I485369274ccacd314230e3d267df665d8083bf97

Aaron Huang   authored and   Junyu Lai   commited 2023-03-03 13:54:42 +08:00
960c6267ca
Merge "Clear calling identity before calling into DPM"
Junyu Lai   authored and   Gerrit Code Review   commited 2023-03-02 05:56:51 +00:00
ae04a1a842
Clear calling identity before calling into DPM
Test: 1. manual test with test app
      2. atest CtsNetTestCases:android.net.cts.NetworkStatsManagerTest
Fix: 249920382
Fix: 269561252
Change-Id: I4af7fd640d551be3ef62ea248e58bf8bae5e0b87

Junyu Lai   commited 2023-03-01 15:56:59 +08:00
09330c436e
Merge "Add isMatchRuleMobile back"
Aaron Huang   authored and   Gerrit Code Review   commited 2023-02-24 05:30:06 +00:00
9ff2fe7747
Add isMatchRuleMobile back
There's a user still call this method which causes the app
crash and it might be the app was built against hidden API.
The bug was observed after updating the mainline module so
adding this method back to the module to avoid apps crash
due to the method is not found in NetworkTemplate.

Bug: 269178029
Test: build
Change-Id: I06dc694b1ce060488135f5d34138f14abd50ad32

Aaron Huang   commited 2023-02-21 17:23:48 +08:00
dc97905786