Commit graph android_packages_modules_Co.../framework-t
Message SHA1
Fix a Rare Race In Clearing ResourceId
If the IpSecTransform is being manipulated in
multiple threads, there is a race between the
clearing of the resource id (setting it to
INVALID_RESOURCE_ID and making binder calls
with it. This wasn't a significant problem before
becasue the only side effect was that it could
occasionally cause an IAE instead of an ISE when
the caller was doing something weird. Unfortunately
the exception type now matters because it is being
relied upon to provide a callback rather than a
throw in the event of an error. Accordingly reads of
mResourceId have to be synchronized against the
the possibility of close() of that resourceId to
ensure that the right exception is thrown on the
service side of the binder.

Bug: 336897538
Test: atest CtsNetTestCases:IpSecManagerTest
Change-Id: I21c893034efa7f322ae2aa81d6c7e00dc9ef8d2f

Nathan Harold   commited 2024-05-06 22:27:19 +00:00
98b708d5a2
[mdns] add hidden API for public key
This commit adds support of registering a public key for a host/service.
This is required to enable Advertising Proxy feature for Thread devices.

For example:
```
NsdServiceInfo info = new NsdServiceInfo();

info.setServiceName("My Service");
info.setServiceType("_test._tcp");
info.setHostname("MyHost");
info.setHostAddresses(List.of(address1, address2));
info.setPublicKey(/* KEY RDATA */);

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

Bug: 317946010

Change-Id: I367ebff8119d5c1dff0410c85e6fb86dca6c66b8

Handa Wang   commited 2024-04-24 07:02:42 +00:00
364aa570e2
Merge changes from topic "rate-limit-trafficstats" into main
* changes:
  Make cache duration and max entries configurable
  Create TestRule: SetFeatureFlagsRule
  Rate-limit on TrafficStats#get*[Bytes|Packets] API calls
  Clear TrafficStats cache before getting readings from TrafficStats

Treehugger Robot   authored and   Gerrit Code Review   commited 2024-04-11 07:26:14 +00:00
47c819640d
Merge "[mDNS] pretty print txt values in log" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-04-02 08:15:34 +00:00
777b9ba0ca
Rate-limit on TrafficStats#get*[Bytes|Packets] API calls
This change put a rate-limit on TrafficStats getter APIs to
reduce the need of accessing bpf map. For any caller who calls
this method within 1 second, a stale result will be returned.

One expected outcome is this change would break any test which
relies on immediate change of the result of TrafficStats after
making network traffic. Thus, related tests are fixed in the
counter part CL accordingly.

Test: atest CtsNetTestCases:android.net.cts.TrafficStatsTest --rerun-until-failure 100
Test: atest CtsNetTestCases:android.net.cts.NetworkStatsManagerTest
Test: atest NetworkStackIntegrationTests:android.net.NetworkStatsIntegrationTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Bug: N/A

Change-Id: Ibd6ae92d7c806481bb8a5124dd231f8f5aa206f2

Junyu Lai   commited 2024-04-02 15:25:10 +08:00
3c9089c1d1
[mDNS] pretty print txt values in log
Without this commit, the Thread service logs look like:

```
03-27 14:50:07.033   739  1924 I NsdPublisher: Registering service. Listener ID: 1, serviceInfo: name: Android Thread Border Router #2CF8, type: _meshcop._udp, subtypes: , hostAddresses: , hostname: null, port: 49152, network: null, expirationTime: null, txtRecord: id=֞�"ҽD���.�j���nn=OpenThreadrv=1sb=������tv=1.3.0
03-27 14:50:07.033   739  1924 I NsdPublisher: vn=Android
                                                         xa=Q�;�P,�
                                                                   xp=ޭ��������

```

With this commit, the Thread service logs look like:

```
03-27 13:37:31.672   741  1925 I NsdPublisher: Registering service. Listener ID: 1, serviceInfo: name: Android Thread Border Router #7CE8, type: _meshcop._udp, subtypes: , hostAddresses: , hostname: null, port: 49152, network: null, expirationTime: null, txtRecord: {id=0x70A5AE087668D7522919F40D1684D182, mn=Thread Border Router, nn=OpenThread, rv=1, sb=0x00000021, tv=1.3.0, vn=Android, xa=0x06EC93E283A47CE8, xp=0xDEAD00BEEF00CAFE}
```

Bug: 329366417
Change-Id: I6b15e93ad117f4ebb5762df85e359a705bd65b7d

Kangping Dong   commited 2024-04-02 14:47:57 +08:00
aca202e4d9
Merge "Changes to support satellite stats appear as TYPE_MOBILE" into main
Nagendra Prasad Nagarle Basavaraju   authored and   Gerrit Code Review   commited 2024-04-01 14:33:37 +00:00
ad48c49ee0
Changes to support satellite stats appear as TYPE_MOBILE
With satellite transport supported at device and satellite
network to appear under type mobile, considers cellular or
satellite, or combination of both interfaces under mobile interfaces.

Note: getUidStatsForTransport(TRANSPORT_SATELLITE) is not supported,
considering the same interface name could be used by cellular as well,
supporting this might lead to double counting problem.

Bug: 329003473
Test: atest FrameworksNetTests
Change-Id: I85465cedcc5550fa0555dc36b3be364ac90aade1

Nagendra Prasad Nagarle Basavaraju   commited 2024-04-01 10:53:02 +00:00
756ca07f80
Improve documentation of addEthernetStateListener
The existing documentation was not clear at all about how this API
behaves.

Test: TH
Change-Id: I408f32c1e7b6c910aaaa197b6774865e79a03579

Patrick Rohr   commited 2024-03-21 11:26:07 -07:00
e762554170
follow up comments in custom TTL CLS (aosp/2870274 and aosp/2606573)
Summary of major changes in this CL:
1. update javadoc in AdvertisingRequest to start with one line
2. update ttl API document to ve clearer that values smaller than 1
   second is discarded
3. Remove redundant constructors of MdnsServiceInfo
4. add tests for MdnsRecordRepository to verify that addService works
   with non-null TTL

Other comments needs more consideration and relatively larger change, so
tracked in separated child issue of b/327619631

Bug: 327619631
Change-Id: I040b8451337d88d96da7120455c228cef204f768

Kangping Dong   commited 2024-03-05 20:04:48 +08:00
c6622e02b7
Merge "Move VpnManagerServiceTest and VpnTest to frameworks" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2024-03-01 00:58:31 +00:00
0df28d82be
Move VpnManagerServiceTest and VpnTest to frameworks
These unit tests are closely tied to the source code in
frameworks/base and were incorrectly placed in the connectivity
module. Also update the libraries visibility that are used by
the tests.

Test: atest FrameworksNetTests
Change-Id: I196c33a8bd5b5cdb9d42aea381e900681ff6d25e

Chiachang Wang   commited 2024-02-29 07:48:02 +00:00
a5d9875823
[mdns] add service-side impl for NSD service TTL support
This is the service-side implementation of the custom service TTL
support added in aosp/2606573.

Bug: 284903641
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: I35246dae37b9fd1710b99cdda10068928e418457

Kangping Dong   commited 2024-02-28 21:42:37 +08:00
cd35018bc6
[mdns] add API for setting/getting TTL value
To support Thread Border Router use case, an Android device needs to act
as a mDNS service discovery (RFC 8766) & advertising proxy (
https://datatracker.ietf.org/doc/draft-ietf-dnssd-advertising-proxy).
This means it needs to advertise and discover DNS-SD services of custom
TTL value on behalf of other devices.

This commit fulfills this requirement by adding TTL getter/setter to
NsdServiceInfo. When registering a service, the specified TTL will be
used for corresponding resource records.

Bug: 284903641
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: I23837834847dc3a0fb452c5929a1b36e3fc1fb3f

Kangping Dong   commited 2024-02-28 15:53:51 +08:00
2ffe82dab5
[Thread] add Thread aconfig_declaration to java_sdk_library
This commit also moves Thread flags to Connectivity/common to ease
maintenance.

Test: m framework-connectivity-t
Bug: 317290555
Merged-In: I50f3d3b8205a5a9ee8154a649318a2c175edbb71
Merged-In: I8a71f4ee49cc68a9512f432e454469200f2a5058
Change-Id: I8a71f4ee49cc68a9512f432e454469200f2a5058

Kangping Dong   commited 2024-02-26 11:18:03 +08:00
8fb80dd075
Merge "Move Nearby flags to common and add specify it in java_sdk_library" into main
Yahav Nussbaum   authored and   Gerrit Code Review   commited 2024-02-22 12:37:57 +00:00
c92872e3d5
Move Nearby flags to common and add specify it in java_sdk_library
Bug: 324993608
Test: TH
Change-Id: I1dc79353e9bae3d977db88e572e871cd459fc7fc

Yahav Nussbaum   commited 2024-02-22 06:49:15 +00:00
259be7bd4e
Merge "IpSecTransformState: Rename API methods and improve docs" into main
Yan Yan   authored and   Gerrit Code Review   commited 2024-02-16 01:12:21 +00:00
69171c6ca5
IpSecTransformState: Rename API methods and improve docs
Rename API methods and update API docs as per API
council feedbacks

Bug: 316603231
Test: make update-api && make
Change-Id: Ibb1f58792d2e40ef1084c2b532e999a516a87b37

Yan Yan   commited 2024-02-15 20:17:30 +00:00
1db3feeed7
Merge changes I57b37ea7,I00772535 into main
* changes:
  Introduce Powered Off Finding API
  Add Powered Off Finding operations to NearbyService

Yahav Nussbaum   authored and   Gerrit Code Review   commited 2024-02-13 14:34:22 +00:00
c412fd3987
Introduce Powered Off Finding API
Bug: 307898240
Test: atest CtsNearbyFastPairTestCases
Test: atest NearbyIntegrationPrivilegedTests
Test: atest NearbyIntegrationUntrustedTests
Change-Id: I57b37ea796c0791d72fec931f731a0143e816dac

Yahav Nussbaum   commited 2024-02-13 09:23:00 +00:00
c712a571dc
Allow more characters in subtypes
Allow all printable ASCII characters in subtypes, instead of only the
set of characters allowed in service types.

This is still more restrictive than what the spec allows, but allowing
random bytes would be harder to manage (especially when displaying the
subtypes in logs for example) and there is no known use-case for it.
Having the NsdManager API impose more restrictions is probably also best
for apps to minimize interoperability problems.

Bug: 324377460
Test: atest
Change-Id: Id75879a1c3ea6af8d7995b0e8e0dcc06e7160a0a

Remi NGUYEN VAN   commited 2024-02-08 19:59:14 +09:00
629234ce68
Merge "Rename check*Permission* to has*Permission" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2024-02-02 07:07:31 +00:00
ef58a8a33a
Rename check*Permission* to has*Permission
The check*Permission methods are a bit error-prone because people
can forget to check the return value and expect that they behave
like the enforce* methods. This was pointed out before in some bugs.

This change adds @CheckResult annotation to enforce linter warning
and rename methods accordingly.

Test: TH
Fix: 279691948
Change-Id: Ibb0df6540fe0ed40289bb190b790130daaa2f763

Junyu Lai   commited 2024-02-01 15:24:35 +08:00
71b5153898
[DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
<add g3 doc link>

Bug: 304529413
Test: N/A
Change-Id: I243f17b3f0ad7af9ffa15ca242456e36688733f5
Merged-In: I243f17b3f0ad7af9ffa15ca242456e36688733f5

Aditya Choudhary   commited 2024-01-31 12:34:50 +00:00
01b5ede2b2
Enrich javadoc for queryDetailsForUid
Test: TH
Fix: 299876562
Change-Id: I347a269889ea6cf39218b6322dcba92a14535e9c

Junyu Lai   commited 2024-01-30 11:25:59 +08:00
f3797e0c97
[mdns] add API support for custom hostname
This commit adds support of regsitering a service with a custom
hostname. This is required to enable Advertising Proxy feature for Thread
devices.

For example:
```
NsdServiceInfo info = new NsdServiceInfo();

info.setServiceName("My Service");
info.setServiceType("_test._tcp");
info.setHostname("MyHost");
info.setHostAddresses(List.of(address1, address2));

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

This CL also adds two new error codes for service/host registration
conflict: `FAILURE_SERVICE_NAME_CONFLICT` and
`FAILURE_HOST_NAME_CONFLICT`.

Bug: 284904661
Test: atest CtsNetTestCases FrameworksNetTests

Change-Id: I2fb974c38d851ba99144a18c7047084bbd61b938

Handa Wang   commited 2024-01-29 06:46:43 +00:00
1c2be6b391
Merge changes from topic "set-thread-enabled" into main
* changes:
  Add service implementation for ThreadNetworkController#setEnabled
  Add setEnabled API

Yang Sun   authored and   Gerrit Code Review   commited 2024-01-26 11:22:37 +00:00
8f9544539b
Add setEnabled API
setEnabled API is added to ThreadNetworkController, this
can be used by applications with privileged permission to set
Thread to enable/disabled state.

The Thread enabled state can be subscribed with
ThreadNetworkController#registerStateCallback.

When Thread is disabled, the join/scheduleMigration APIs will
fail with ERROR_THREAD_DISABLED.

When Thread is disabling, all commands will fail with ERROR_BUSY.

Bug: 299243765

Test: atest CtsThreadNetworkTestCases:android.net.thread.cts.ThreadNetworkControllerTest

Change-Id: Ifa7845bf1d5664ecd31ce74e24b3a839f92bba13

Yang Sun   commited 2024-01-26 15:53:33 +08:00
0797d9d501
[mdns] add API for discovery with subtype
This commit adds support of discovering services with explicit subtype.

With this change, a service can be discovered with subtype with:
```
nsdManager.discoverServices(
        new DiscoveryRequest.Builder("_http._tcp", PROTOCOL_DNS_SD)
	        .setSubtype("_printer").build(),
	executor, listener);
```

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

Kangping Dong   commited 2024-01-25 20:15:21 +08:00
97d6aeb3a2
Specify aconfig_declaration modules in java_sdk_library
java_sdk_library modules should specify the aconfig_declarations modules
in order to generate the exportable stubs (i.e. the stubs that exclude
the disabled aconfig flags) by providing the information about the
aconfig flag values.

The exportable stubs will be used when generating the module sdk
snapshots and to generate the hiddenapi flags, in order to prevent
exposing the disabled apis in runtime.

Test: m framework-connectivity-t
Bug: 317290555
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:60b21f877f88a6848ee6d0f0e5316362714b9d25)
Merged-In: Ieb8f41921054ed6f62db2edfc7d695ba0a2a0055
Change-Id: Ieb8f41921054ed6f62db2edfc7d695ba0a2a0055

Jihoon Kang   authored and   Android Build Cherrypicker Worker   commited 2024-01-25 02:17:28 +00:00
49bbfc92f9
Merge "[Thread] add error code ERROR_UNKNOWN for forward compatibility" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-01-24 02:20:42 +00:00
649571ddf7
Fix incorrect nullability annotations
Some callers of openSessionInternal could have null package name.
Update nullability annotations accordingly.

Test: TH
Bug: N/A
Change-Id: Ifafafcd64612c99e5174364a010ec95415702b0d

Junyu Lai   commited 2024-01-18 11:26:55 +08:00
6da1c70379
[Thread] add error code ERROR_UNKNOWN for forward compatibility
This is per the go/android-api-guidelines#return-error:
```
Make sure your chosen error handling option gives you the
flexibility to introduce new error types in the future. For
@IntDef, that means including an OTHER or UNKNOWN value - when
returning a new code, you can check the caller's targetSdkVersion
to avoid returning an error code the application doesn't know
about. For exceptions, have a common superclass that your
exceptions implement, so that any code that handles that type will
also catch and handle subtypes.
```

Bug: 320403080
Change-Id: I2ee663b75107dac6d84fa697f449fa0424128fde

Kangping Dong   commited 2024-01-16 16:07:53 +08:00
2c83e2fcc9
Stop registering native mdns service
NsdService switched from Netd native solution to Java solution on
Android U. MDNS service provided by Netd will be removed from Android V.

1. Stop registering native mdns service from V.
2. Stop startDaemon() in NsdManager from V.
3. As a double safety, return early in NsdService methods that call the
   native mdns service when platform version is V+.
4. Modify NsdManagerTest to cover V+ behavior.

Bug: 298594687
Test: Build. Presubmit.
Change-Id: Ifdac8f7a44aa57d93d453ba482ec473a2b531452

Ken Chen   commited 2023-12-27 13:54:50 +00:00
80c9f6f35f
Merge "Introduce NsdManager API for in-place service updates without re-announcement." into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-12-27 08:26:54 +00:00
8c22b9a37c
Merge "implement Thread Border Router e2e integration test" into main
Handa Wang   authored and   Gerrit Code Review   commited 2023-12-26 11:41:35 +00:00
5b96f865cd
[AF03] Adopt FastDataInput
FastDataInput for reading persistent data is currently disabled
by default. This functionality will be gradually enabled through
A/B experiments to assess its impact.

One-shot boot time increase up to 10 second is one expected
outcome in worst case. Currently, the persistent data was loaded
when the first caller query it, but in this change it will be
done twice in the boot stage due to the needs of doing comparison.

Test: adb shell dumpsys netstats
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Test: manual test against data points under benchmark/assets/dataset
Bug: 313841499

Change-Id: Ia927bd115de5453ca3ee22104f3efbf44a55c2b8

Junyu Lai   commited 2023-12-26 15:42:09 +08:00
da6020a329
implement Thread Border Router e2e integration test
This implements a basic border routing test case (ping) and demonstrates a
valid test environment for Thread Border Router test cases.

Later we can add more packet verifications and more test cases.

Bug: 295843010
Test: atest android.net.ThreadBorderRouterTest

Change-Id: Ifb9b6d45539143a227c2bc0ed69b5c3167ef9acd

Handa Wang   commited 2023-12-26 15:24:54 +08:00
806f5a1bec
Introduce NsdManager API for in-place service updates without re-announcement.
This commit builds upon CL aosp/2817455 by adding a new NsdManager API to
update registered services directly, eliminating the need for exit and
re-announcement messages. This preserves compatibility with existing
apps without requiring an API bump. If an app registers a service with
the same listener and NsdServiceInfo, it's treated as an update request.

Bug: 309372239
Test: TH
Change-Id: Ib84ddf0d92e757eaef225f3e32f5223bc50c8fd6

Yuyang Huang   authored and   Remi NGUYEN VAN   commited 2023-12-26 13:09:00 +09:00
86d083f3a4
[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
Merge "Remove workaround to remove FlaggedAPI in ump" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-12-06 01:17:43 +00:00
dc7a325a55