ipc/android: Allow custom service library names

Monado derivatives may choose to create and use a
custom variant of service-lib for android builds
with a different library name, this change replaces the
hard-coded library name used for dynamic lib loading.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2265>
This commit is contained in:
Korcan Hussein 2024-06-28 13:33:54 +01:00
parent b59b11101b
commit da80ac3f71
2 changed files with 9 additions and 1 deletions

View file

@ -21,6 +21,13 @@ android {
minSdkVersion 26
targetSdkVersion project.sharedTargetSdk
def defaultServiceLibName = "monado-service"
def serviceLibName = project.hasProperty("serviceLibName") ?
project.serviceLibName : defaultServiceLibName
if (serviceLibName == null || serviceLibName.length() == 0) {
serviceLibName = defaultServiceLibName
}
// Single point of truth for these names.
def serviceAction = "org.freedesktop.monado.ipc.CONNECT"
def shutdownAction = "org.freedesktop.monado.ipc.SHUTDOWN"
@ -31,6 +38,7 @@ android {
buildConfigField("String", "SERVICE_ACTION", "\"${serviceAction}\"")
buildConfigField("String", "SHUTDOWN_ACTION", "\"${shutdownAction}\"")
buildConfigField("Long", "WATCHDOG_TIMEOUT_MILLISECONDS", "1500L")
buildConfigField("String", "SERVICE_LIB_NAME", "\"${serviceLibName}\"")
}
buildTypes {

View file

@ -36,7 +36,7 @@ public class MonadoImpl extends IMonado.Stub {
static {
// Load the shared library with the native parts of this class
// This is the service-lib target.
System.loadLibrary("monado-service");
System.loadLibrary(BuildConfig.SERVICE_LIB_NAME);
}
private final Context context;