android_packages_modules_Co.../staticlibs/native
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Maciej Żenczykowski 307c3db71d switch to using OWNERS from master branch of Connectivity module
Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If8c59abaf706b4c787be6454c08be3e26212ba21
2021-11-17 10:58:14 -08:00
..
bpf_syscall_wrappers bpfmap: Move to Common Util Location 2021-10-29 12:38:05 -07:00
bpfmapjni Separate bpf and struct util from netlink util library 2021-11-11 18:50:53 +08:00
netjniutils Move to renamed NDK symbol AFileDescriptor_getFd 2021-05-12 09:43:35 +01:00
README.md Separate bpf and struct util from netlink util library 2021-11-11 18:50:53 +08: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.