[Replicant] [libsamsung-ril] [PATCH 23/23] Android.mk: Add support for Android 11

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Thu Mar 4 12:42:50 UTC 2021

If we configure Replicant 11, libsamsung-ipc and libsamsung-ril
to have both libraries in /system/lib/, tools work fine on the
Galaxy SIII (GT-I9300):
    # find -name libsamsung-ril.so 2>/dev/null

    # find -name libsamsung-ipc.so 2>/dev/null

    # find -name nv_data-md5 2>/dev/null

    # nv_data-md5
    Usage: nv_data-md5 [nv_data.bin]

And libsamsung-ril tries to load libsamsung-ipc from the right
location in /system/lib/, but it fails due to the vendor and system
    01-14 15:50:57.739  1475  1475 E RILD    : dlopen failed:
    dlopen failed: library "/system/lib/libsamsung-ril.so"
    needed or dlopened by "/system/vendor/bin/hw/rild" is not
    accessible for the namespace "(default)"

Adding LOCAL_PROPRIETARY_MODULE fixes that. Note that the name
of that property can be misleading here: libsamsung-ril is free
software and shall remain free software.

Instead we need to understand LOCAL_PROPRIETARY_MODULE as a way
to tell the Android build system that libsamsung-ril is not part
of the base Android code but instead that it is code that is
specific to a device, set of devices and/or Android distribution.

LOCAL_MODULE_RELATIVE_PATH cannot be used instead: even if the
binaies end up in /vendor/bin/hw/, and that the libraries ends
up in /vendor/lib/hw/, for some reasons the libraries can't be
    i9300:/ # /system/vendor/bin/hw/nv_data-md5
    CANNOT LINK EXECUTABLE "/system/vendor/bin/hw/nv_data-md5":
    library "libsamsung-ipc.so" not found: needed by main executable

And most importantly, rild has the same issue than before:
    E RILD    : dlopen failed: dlopen failed: library
                "libsamsung-ipc.so" not found: needed by
                 in namespace (default)

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
 Android.mk          |  6 ++++++
 android_versions.mk | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 android_versions.mk

diff --git a/Android.mk b/Android.mk
index 9da4d2e..2b92a56 100644
--- a/Android.mk
+++ b/Android.mk
@@ -19,6 +19,7 @@
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
+include $(LOCAL_PATH)/android_versions.mk
 	samsung-ril.c \
@@ -43,6 +44,7 @@ LOCAL_C_INCLUDES := \
 	$(LOCAL_PATH)/include \
 	hardware/libhardware_legacy/include \
+	hardware/ril/include/ \
@@ -56,12 +58,14 @@ LOCAL_MODULE := libsamsung-ril
 include $(CLEAR_VARS)
+include $(LOCAL_PATH)/android_versions.mk
 LOCAL_SRC_FILES := srs-client/srs-client.c
 	$(LOCAL_PATH)/include \
 	$(LOCAL_PATH)/srs-client/include \
+        hardware/ril/include/ \
 LOCAL_SHARED_LIBRARIES := liblog libcutils
@@ -72,12 +76,14 @@ LOCAL_MODULE := libsrs-client
 include $(CLEAR_VARS)
+include $(LOCAL_PATH)/android_versions.mk
 LOCAL_SRC_FILES := tools/srs-test.c
 	$(LOCAL_PATH)/include \
 	$(LOCAL_PATH)/srs-client/include \
+        hardware/ril/include/ \
 LOCAL_SHARED_LIBRARIES := liblog libcutils libsrs-client
diff --git a/android_versions.mk b/android_versions.mk
new file mode 100644
index 0000000..f34ce57
--- /dev/null
+++ b/android_versions.mk
@@ -0,0 +1,39 @@
+# This file is part of libsamsung-ipc.
+# Copyright (C) 2021 Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
+# libsamsung-ipc is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# libsamsung-ipc is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with libsamsung-ipc.  If not, see <http://www.gnu.org/licenses/>.
+# We need to keep the compatibility with older Replicant versions, at least for
+# testing purposes: some of the devices we support in libsamsung-ipc are not
+# supported (yet) in newer Android versions or recent GNU/Linux distributions,
+# and doing tests on older devices might enable us to also understand better
+# the modem protocol and/or the EFS.
+# To limit the amount of work, we need to avoid modifying older Android versions
+# to be able to use recent libsamsung-ril and libsamsung-ipc.
+# Here's how different Android distributions behave with
+# LOCAL_PROPRIETARY_MODULE := true in libsamsung-ipc's Android.mk:
+# Replicant  4.2: It probably breaks the modem support
+# Replicant  6.0: It break the modem support
+# Replicant  9.0: The modem integration doesn't work because it was not finished
+# Replicant 10.0: The modem integration doesn't work because it was not finished
+# Replicant 11.0: It is required for the modem to work
+# Set a default value for build systems like Guix
+ifneq (1,$(filter 1,$(shell echo "$$(( $$(echo $(PLATFORM_VERSION) | sed 's/\..*//g') < 7 ))" )))

More information about the Replicant mailing list