Commit graph android_packages_modules_Co.../staticlibs
Message SHA1
BpfMap: remove @CriticalNative from nativeSynchronizeKernelRCU()
There's been some reports that this can cause process termination due
to gc/sleep logic thinking the thread is stuck for >4s.

While this implies that RCU is stuck for >4s, maybe this is something
that can happen on lower power devices.

It seems prudent to (at least temporarily) revert back to the old
non-CriticalNative behaviour.

Test: TreeHugger
Flag: EXEMPT mainline, bugfix
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I56b2802132f252a02411a9a8f762d98ab2f336ad

Maciej Żenczykowski   commited 2025-09-11 13:01:08 -07:00
1e1d336141
Make AddrRegReplyPacket constructor public
So it can be used in tests.

Test: TH
Flag: EXEMPT mainline
Change-Id: Id44e448c1d3c21633fb1ed25a58f663caed61469

Patrick Rohr   commited 2025-09-09 10:56:01 -07:00
93d7c2ae7e
Convert uses of @hide to block tag
In most places the `@hide` doctag is treated as a block tag on its own
line. However, there are a few places where it is treated as an inline
doctag, e,g. `{@hide}`, and some places where it looks like a block
tag but is inline in the text, e.g. `Some text. @hide`. Dealing with
all the types increases the complexity of Metalava and makes it
slightly slower.

This change replaces the non-block tag forms with a block tag.

Flag: EXEMPT change the form of @hide does not change the API or behavior
Bug: 429965593
Test: m checkapi
Change-Id: I4ffe44a329dbcb7f0a7bd61af16c3bd99cacdac4

Paul Duffin   commited 2025-08-29 21:19:30 +00:00
6eaa841657
Migrate NetdUtils from networkAddRoute to networkAddRouteParcel.
This will allow us to deprecate networkAddRoute.

Bug:412629841
Test: atest TetheringTests
Flag: EXEMPT Using device config kill-switch
Change-Id: I20e988f760b8ad22b51effdc1f0e204763c6e240

Sarup Dalwani   commited 2025-08-28 15:28:48 +00:00
98e5827ccc
Merge "Tethering: Enable TETHERING_AND_P2P_GO_LOCAL_AGENT for 25Q4+" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-28 07:25:48 -07:00
3f16f0df11
Tethering: Enable TETHERING_AND_P2P_GO_LOCAL_AGENT for 25Q4+
This change enables the TETHERING_AND_P2P_GO_LOCAL_AGENT feature
on devices running Android 25Q4 or newer, in addition to being
controlled by the existing feature flag.

A new SdkUtil.isAtLeast25Q4() method is introduced to check for
the specific SDK version.

Flag: com.android.tethering.mainline.beta.tethering_and_p2p_go_local_agent
Test: atest ConnectivityCoverageTests --update-device \
      --test-filter '.*Tethering.*'
Test: TH
Bug: 420590461
Fix: 428098654
Fix: 420592689
Change-Id: I7ef79a201116de84f2c4973c4c360fd3d1ef0c4c

Junyu Lai   commited 2025-08-28 11:56:55 +08:00
bf75afdcd1
Merge "netjniutils: delete support for android R" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-27 13:05:29 -07:00
8aa8a4f1d1
Merge "Ensure flag restoration logic is always executed in SetFeatureFlagsRule." into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-27 05:08:59 -07:00
8edee1e3e6
Ensure flag restoration logic is always executed in SetFeatureFlagsRule.
`base.evaluate()` can be interrupted by other rules in the chain, such
as DevSdkIgnoreRule, if an assumption fails. This prevents
SetFeatureFlagsRule from executing its flag value restoration logic,
leading to an inconsistent state. This change ensures the restoration
logic runs regardless of exceptions.

Flag: EXEMPT mainline
Bug: 440618747
Test: TH
Change-Id: Iba4483b45f11aeed8ae565f8080b2bebd299046c

Xiao Ma   commited 2025-08-27 16:55:12 +09:00
bda151cd67
netjniutils: delete support for android R
Mainline M-2025-11 drops support for android R,
thus making the new minimum Android 12 / S (api 31)

Once we get this to pass tests, we can merge it,
then we need to bump min sdk to 31, then we can
probably get rid of the dlsym stuff and just link it directly.

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com
Change-Id: I9d68ea9f4aa180b3ec24d252bcd49593e19cf475

Maciej Żenczykowski   commited 2025-08-26 09:56:44 -07:00
94d800d96f
Merge "Reduce unecessary allocation churn in MdnsServiceTypeClient.processResponse" into main
Richard Uhler   authored and   Android (Google) Code Review   commited 2025-08-15 08:57:01 -07:00
50ee5cd590
Add ethertype constant for Wake-on-LAN
Bug: 408247593
Test: atest NetworkStackTests
Flag: EXEMPT mainline
Change-Id: I5ff868ee66c2941c496db1fdfa02f0322e48d243

Marc Lepage   commited 2025-08-13 14:48:18 -04:00
6498be751c
BpfBitmap: some minor optimizations
Test: TreeHugger, atest BpfBitmapTest
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5acf5bcb31777e503e58cef733d617a53006d2b9

Maciej Żenczykowski   commited 2025-08-12 16:02:23 -07:00
d2d26c661a
Optimize BpfMap JNI calls with FastNative/CriticalNative annotations
Convert BpfMap native methods to use @FastNative to reduce JNI overhead.

Refactor synchronizeKernelRCU() to be @CriticalNative for maximum
performance by changing its error handling to return an error code
instead of throwing directly from native code.
(In practice we don't expect it to *ever* fail)

FYI:

@FastNative and @CriticalNative are Android-specific annotations
that signal to the ART runtime to use a lower-overhead JNI transition,
resulting in better performance.

A standard JNI call tells the Garbage Collector (GC) that the thread
is transitioning to a 'Native' state. This is a signal to the GC that
the thread might be busy for a while and shouldn't be suspended arbitrarily.

@FastNative is for short, quick functions:
  This provides a moderately faster JNI call (thread is still 'Runnable').
  The native function signature remains the same as a standard JNI method,
  and it can still access the JNIEnv* to interact with Java objects
  or throw exceptions.

@CriticalNative is for short, quick & trivial functions:
  This provides the fastest possible JNI transition and is intended
  for simple, performance-critical leaf functions.
  It comes with strict requirements:
    - The native method cannot throw exceptions, create Java objects,
      or make any other JNI calls.
    - All arguments and the return type must be primitive, ie:
        jboolean [bool]
        jbyte [s8]
        jchar [u16]
        jshort [s16]
        jint [s32]
        jlong [s64]
        jfloat [32-bit]
        jdouble [64-bit]
        void
      Java objects like String or byte[] are not allowed.
  Because of these restrictions, the native C++ function signature
  must not include JNIEnv* or jobject/jclass parameters.
  (This likely also means it must be 'static')

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9b6107b26086df2e87218ff9274593e9f2eb6b0b

Maciej Żenczykowski   commited 2025-08-12 15:28:05 -07:00
2afef5070a
Reduce unecessary allocation churn in MdnsServiceTypeClient.processResponse
Bug: 413371501
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.mdns.MdnsServiceTypeClientTests
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.CollectionUtilsTest
Flag: EXEMPT bugfix

Change-Id: Id9abf0b79f6db155e6895b0dd7661d0aafb6b0a7

Richard Uhler   commited 2025-08-08 10:08:36 -07:00
532b263b45
TcUtils: remove dead BPF_FD_JUST_USE_INT hack
Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I311fc585d7c01c9aa5f89a42c2d1e673f7e55ae8

Maciej Żenczykowski   commited 2025-08-07 20:04:43 -07:00
762f83b5fb
Merge "Adding isLocalRoute parameter to RouteInfoParcel" into main
Lorenzo Colitti   authored and   Android (Google) Code Review   commited 2025-08-06 20:05:22 -07:00
43a7ec601e
Merge "Stabilize flaky tests by adding packet delay" into main
Jimi Chen   authored and   Android (Google) Code Review   commited 2025-08-06 18:26:21 -07:00
a9a7a7c0d2
Merge "Move #nativeWaitForService into CommonConnectivityJni" into main
Patrick Rohr   authored and   Android (Google) Code Review   commited 2025-08-06 11:12:41 -07:00
2e342c6d9b
Move #nativeWaitForService into CommonConnectivityJni
AServiceManager_waitForService sytem APIs currently only callable
via dlsym(): b/376759605. When built with sdk_version current,
the NDK stubs for "sdk" variants only include NDK APIs,
excluding #systemapi APIs.

Flag: EXEMPT Mechanical refactors
Test: atest ServiceManagerWrapperIntegrationTest
Change-Id: I48f690d771c7905e79e463617ded772f753cc854

Mark Chien   authored and   Patrick Rohr   commited 2025-08-06 10:44:39 -07:00
f250ade6fa
Adding isLocalRoute parameter to RouteInfoParcel
ConnectivityService would be centralized location for deciding local
network so for this effort adding isLocalRoute parameter to RouteInfoParcel

Bug: 394308861
Test: Manually tested.
Test: atest ConnectivityCoverageTests
Flag: EXEMPT Using device config kill-switch
Change-Id: I3ed34f96af1cbd7d8645a6c19e696a75525ce68a

Sarup Dalwani   commited 2025-08-06 15:40:08 +00:00
1bec0d629b
Merge "Make callers of RoutingCoordinatorService pass in RouteInfoParcel" into main
Sarup Dalwani   authored and   Android (Google) Code Review   commited 2025-08-06 07:45:24 -07:00
a4f34a8836
Stabilize flaky tests by adding packet delay
Introduce a 3-second delay in each packet send.
Before sending each packet, wait for 3 seconds to give the
firmware time to turn on the APF.
The firmware may have throughput calculation logic that
depends on a certain time window.

Flag: EXEMPT test only
Bug: 434614102
Test: atest CtsConnectivityMultiDevicesTestCases:ApfV6Test
Test: ./cts-tradefed run commandAndExit cts \
      -m CtsConnectivityMultiDevicesTestCases \
      -t ApfV6Test --shard-count 2
Change-Id: I0807562cd87cbfe90c90d48cf2d0e41673c153b0

Jimi Chen   commited 2025-08-06 13:11:46 +00:00
003403e237
Make callers of RoutingCoordinatorService pass in RouteInfoParcel
RoutingCoordinatorService's {add,remove,update}Route methods
all end up calling netd's *RouteParcel methods.

Make callers explicitly generate and pass in the parcel to the
manager class instead of having them pass in a RouteInfo and
having the service class convert the RouteInfo to a parcel.

Also remove the {add,remove,update}Route methods from
RoutingCoordinatorManager since they are unused.

This is a no-op refactor that simplifies upcoming changes.

RoutingCoordinator is not a stable interface and is not used
across the platform/mainline boundary, so there are no version
skew considerations.

Bug: 394308861
Test: atest ConnectivityCoverageTests
Flag: EXEMPT no-op refactor
Change-Id: Iedf4c9bc28c3fc8c289db421857acddc8c694990

Lorenzo Colitti   commited 2025-08-06 15:57:36 +09:00
8f8e59abf7
Merge changes I26d8e987,Icc00abb6 into main
* changes:
  Use FakeSettingsProvider callbacks to simplify CS tests.
  Don't call ContentObserver#onChange(..., UserHandle) on S.

Lorenzo Colitti   authored and   Android (Google) Code Review   commited 2025-08-05 22:59:00 -07:00
a6cb9b734c
Merge "Make Dhcp6AddrRegInformPacket constructor public" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-05 12:46:34 -07:00
24c7ddf8c8
Make Dhcp6AddrRegInformPacket constructor public
Test: TH
Flag: EXEMPT mainline
Change-Id: I20455f9fab089c85de44e5f815c1c5df6f6c0f21

Patrick Rohr   commited 2025-08-05 10:39:23 -07:00
97891a2cfe
Don't call ContentObserver#onChange(..., UserHandle) on S.
S does not have this method (and correspondingly does not have
registerContentObserverAsUser). Use the overload that
does not take a UserHandle.

Bug: 397521796
Flag: TEST_ONLY
Test: test-only change
Change-Id: Icc00abb64fdc47128b93636708990f8ab67057f2

Lorenzo Colitti   commited 2025-08-05 18:02:02 +09:00
7b693cae9f
Merge "simplify netjniutils" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-04 11:52:15 -07:00
b8a76f540c
Merge "make Struct expose a new parse method that takes a raw byte array" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-01 19:59:09 -07:00
eb7d854d5f
simplify netjniutils
Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic1c3207ef3a800f1e5d2da846b1f010f64a0e18f

Maciej Żenczykowski   commited 2025-08-01 16:08:12 -07:00
f14dc8c26f
Merge "Fix missing '/' for retrieving interface MTU from ProcfsUtils" into main
Jimi Chen   authored and   Android (Google) Code Review   commited 2025-07-30 02:07:08 -07:00
9bbdbc56b4
Merge changes I74c24016,I3b2b533e into main
* changes:
  NetBpfLoad: remove foo@1.o support
  Tweak: Throw exception for oversized BpfMap keys/values

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-07-30 00:09:14 -07:00
2b9447dcf6
Tweak: Throw exception for oversized BpfMap keys/values
Throw an IllegalArgumentException if the key or value sizes exceed the
limits supported by the BpfMap implementation. This prevents potential
file descriptor cache collisions and makes errors explicit.

Test: TreeHugger
Flag: EXEMPT mainline/noop
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3b2b533e4217ee2ab8bfcd71e93b02ffcf9feba9

Maciej Żenczykowski   commited 2025-07-29 19:52:55 -07:00
2a2ee0af44
make Struct expose a new parse method that takes a raw byte array
Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifdfc93e0c35df58a983beb30da546db7a0876398

Maciej Żenczykowski   commited 2025-07-29 13:54:39 -07:00
724b2d27d4
Merge "Introduce LegacyStruct to expose writeToBytes(ByteOrder)" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-07-29 13:14:53 -07:00
bd78be51a5
Fix missing '/' for retrieving interface MTU from ProcfsUtils
The `SYS_CLASS_NET_PATH` constant lacked a trailing slash, which
hindered the correct construction of paths for interface-specific
files (e.g., `/sys/class/net/<interface>/mtu`).

This change adds the missing trailing slash, enabling `ProcfsUtils`
to correctly retrieve interface MTU values and other interface-specific
details from `/sys/class/net`.

Flag: EXEMPT mainline
Bug: 429012888
Test: TH
Change-Id: Ib562061d7aa29ed3a7786cca91d79068d4101766

Jimi Chen   commited 2025-07-29 15:26:44 +00:00
b22b23e2ad
Make APF packet count assertion more robust
Improve the APF test by changing the packet count assertion from
`== 1` to `> matched_pkt_count_before_test`.

This handles scenarios where the packet counter might already
have a non-zero value or increment due to other traffic, making
the test more reliable. The test now asserts that the specific
test packet caused the counter to increase.

Flag: EXEMPT test only
Bug: 419427388
Test: atest CtsConnectivityMultiDevicesTestCases:ApfV6Test
Change-Id: Id3c0de786e674214948e7030519fe25383c9958c

Jimi Chen   commited 2025-07-29 08:56:35 +00:00
c4fcf02870
Send multiple packets for stability
The test was observed to be flaky when sending a single packet.
Sending three packets increases the likelihood of the test's
assertion passing reliably, addressing potential timing issues
or packet loss.

Flag: EXEMPT test only
Bug: 419427388
Test: atest CtsConnectivityMultiDevicesTestCases:ApfV6Test --iteration 10
Change-Id: I42426d49a81871e6c8e275b1bd8cb0964290ce17

Jimi Chen   commited 2025-07-29 07:23:24 +00:00
ed5e3c185a
Merge "Addressing feedback on IpStructure" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-07-28 18:39:49 -07:00
a383882f7c
Introduce LegacyStruct to expose writeToBytes(ByteOrder)
The ByteOrder should be encoded by the field, not by the writeToBytes()
method. To fix this, a LegacyStruct is introduced which continues to
expose writeToBytes(ByteOrder) during the transition. This approach
helpfully creates a compile error when converting a Struct class back to
inheriting from Struct for all call sites of writeToBytes(ByteOrder).

Test: TH
Flag: EXEMPT mainline
Change-Id: I3b28c53ce3e884e59760744838b3518596de5c75

Patrick Rohr   commited 2025-07-28 15:58:48 -07:00
62d51d1bcd
Merge "Create CommonConnectivityJni to share between modules" into main
Patrick Rohr   authored and   Android (Google) Code Review   commited 2025-07-24 09:56:39 -07:00
0e5defc1e9
Create CommonConnectivityJni to share between modules
Flag: EXEMPT mainline
Test: TH
Change-Id: Ia85dfd3d979803baca9e971d1083f54dff46de53

Jimi Chen   commited 2025-07-23 05:47:12 +00:00
e5a4e6b0ba
Fix lambda returning set instead of boolean
The `expect_with_retry` utility expects the lambda to return a
boolean value. However, the previous implementation wrapped the
comparison result `apf_utils.get_matched_packet_counts(...) == 1`
inside a set `{...}`.

This caused the lambda to return a set (e.g., `{True}` or `{False}`),
which is truthy if non-empty, but not the actual boolean result.
This commit removes the unnecessary set wrapper, ensuring the lambda
directly returns the boolean outcome of the packet count comparison

Flag: EXEMPT test only
Bug: 419427388
Test: atest CtsConnectivityMultiDevicesTestCases:ApfV6Test
Change-Id: Idd77d905e5be7933b3213df5cb772773286becfa

Jimi Chen   commited 2025-07-22 08:47:03 +00:00
7e922cf917
Increase retry interval for APF packet count assertion
Adds `retry_interval_sec` to the packet count assertion in `ApfTestBase`.
This addresses intermittent test flakiness by allowing more time for the
server device to capture offloaded packets.

Flag: EXEMPT test only
Bug: 419427388
Test: atest CtsConnectivityMultiDevicesTestCases:ApfV6Test --iteration 10
Change-Id: Ia0ac83a7054c6a606f300546306fef1b8fccd701

Jimi Chen   commited 2025-07-21 07:27:43 +00:00
ab0cdd8fce
Merge "Use Log.e for procfs file read errors" into main
Jimi Chen   authored and   Android (Google) Code Review   commited 2025-07-18 01:09:45 -07:00
4e4f2e6da6
Use Log.e for procfs file read errors
Log.wtf implies a catastrophic, unrecoverable failure. Failures to read
procfs files (e.g., due to permissions or non-existence) are better
represented by Log.e as they are often recoverable or expected under
certain conditions, and not always indicative of a fatal application state.

Flag: EXEMPT mainline
Bug: 429012888
Test: TH
Change-Id: I717d46d4c3802ac478e80d2a9dd28c79a9ebc5f7

Jimi Chen   commited 2025-07-18 06:11:15 +00:00
83298a7b5d
Fix permissions in RestoreEthernetRule
The previous runAsShell calls adopted permissions spuriously. This
change fixes runAsShell to consistently adopt the correct permission
for the respective API call.

Also calls setEthernetEnabled() no matter what the current state is at
the end of the test (as there is no harm in doing so).

Test: TH
Flag: EXEMPT mainline
Change-Id: Ib11b889148213b160567cf0a3b9ea72b5b0c851e

Patrick Rohr   commited 2025-07-17 13:54:12 -07:00
ac29211362
Merge changes I6fb98e87,I3f61b474 into main
* changes:
  Delete unused TestInterfaceStateListener
  Reset EthernetManagerTest to reintroduce InterfaceStateListener

Patrick Rohr   authored and   Android (Google) Code Review   commited 2025-07-17 09:33:42 -07:00
7134b8ca22
Delete unused TestInterfaceStateListener
Test: TH
Flag: EXEMPT mainline
Change-Id: I6fb98e87ca1aa460aca6d08cbdd5ddcaaaee55de

Patrick Rohr   commited 2025-07-16 11:21:08 -07:00
3563cc1725