Search code examples
androidandroid-ndkandroid-source

What can load private native libraries on Android N+?


I have to load some hardware exclusive non-NDK (i.e. private) platform native libraries in my application; due to a long dependency chain and differences in individual device implementations, bundling copies of the native libraries per Google's advice is not practical. Since the libraries are hardware specific, they can't be added to the NDK or VNDK.

Since even system apps are no longer allowed to load private native libs, I'm not sure what Android component would be able to. I found out by accident that apps installed and running from /system/priv-app seem to get a pass because /system/lib is considered to be on their library search path, but updates to them installed in the usual /data partition lose that access (so a stub privileged app with later updates is not an option). I would prefer to avoid having a non-updateable /system/priv-app solution, and anyway I haven't found this workaround documented anywhere so I doubt it's an official and reliable alternative.

I have access to the full system source code for my devices, so adding framework modules is a fine solution; however, I'm not sure what constitutes 'framework code' in this context and/or would have access to private native libs on Android N+.

What components of Android have access to private native libs?

Would a system service discoverable via ServiceManager and Context.getSystemService() have access to private native libs?


Solution

  • Aiui this is what the VNDK is for.

    What components of Android have access to private native libs?

    System services. Not apps; normal programs.