android_packages_modules_Co.../staticlibs/native
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Maciej Żenczykowski 1e1d336141 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
2025-09-11 13:01:08 -07:00
..
bpfmapjni BpfMap: remove @CriticalNative from nativeSynchronizeKernelRCU() 2025-09-11 13:01:08 -07:00
bpfutiljni [DON'T BLOCK] Test ownership migration rules 2024-01-31 12:34:50 +00:00
commonconnectivityjni Move #nativeWaitForService into CommonConnectivityJni 2025-08-06 10:44:39 -07:00
ip_checksum [DON'T BLOCK] Test ownership migration rules 2024-01-31 12:34:50 +00:00
netjniutils netjniutils: delete support for android R 2025-08-26 09:56:44 -07:00
nettestutils [DON'T BLOCK] Test ownership migration rules 2024-01-31 12:34:50 +00:00
serviceconnectivityjni Create CommonConnectivityJni to share between modules 2025-07-23 05:47:12 +00:00
tcutils TcUtils: allow ignoring netlink error code ENOENT 2025-02-06 12:56:09 -08:00
README.md doc: echo >> staticlibs/native/README.md 2024-08-20 19:52:18 -07:00

JNI

As a general rule, jarjar every static library dependency used in a mainline module into the modules's namespace (especially if it is also used by other modules)

Fully-qualified name of java class needs to be hard-coded into the JNI .so, because JNI_OnLoad does not take any parameters. This means that there needs to be a different .so target for each post-jarjared package, so for each module.

This is the guideline to provide JNI library shared with modules:

  • provide a common java library in frameworks/libs/net with the Java class (e.g. BpfMap.java).

  • provide a common native library in frameworks/libs/net with the JNI and provide the native register function with class_name parameter. See register_com_android_net_module_util_BpfMap function in frameworks/libs/net/common/native/bpfmapjni/com_android_net_module_util_BpfMap.cpp as an example.

When you want to use JNI library from frameworks/lib/net:

  • Each module includes the java library (e.g. net-utils-device-common-bpf) and applies its jarjar rules after build.

  • Each module creates a native library in their directory, which statically links against the common native library (e.g. libnet_utils_device_common_bpf), and calls the native registered function by hardcoding the post-jarjar class_name. Linkage MUST be static because common functions in the file (e.g., register_com_android_net_module_util_BpfMap) will appear in the library (.so) file, and different versions of the library loaded in the same process by different modules will in general have different versions. It's important that each of these libraries loads the common function from its own library. Static linkage should guarantee this because static linkage resolves symbols at build time, not runtime.