From 9b901ae6ce4c74e5152f23fb3887c601ef56e617 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Sat, 2 Dec 2023 13:33:13 -0500 Subject: [PATCH 1/3] lpac-jni: NDK build with 4 threads --- libs/lpac-jni/build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/lpac-jni/build.gradle b/libs/lpac-jni/build.gradle index f3c9d40..9faf136 100644 --- a/libs/lpac-jni/build.gradle +++ b/libs/lpac-jni/build.gradle @@ -12,6 +12,12 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" + + externalNativeBuild { + ndkBuild { + arguments '-j4' + } + } } buildTypes { From 195861f24bfa64d86799b717b0e284ff6611c88d Mon Sep 17 00:00:00 2001 From: BeRealQueally <129683130+BeRealQueally@users.noreply.github.com> Date: Sat, 2 Dec 2023 23:35:26 +0800 Subject: [PATCH 2/3] fix: jni build on windows --- libs/lpac-jni/src/main/jni/Android.mk | 32 +++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/libs/lpac-jni/src/main/jni/Android.mk b/libs/lpac-jni/src/main/jni/Android.mk index 08d7de6..e307295 100644 --- a/libs/lpac-jni/src/main/jni/Android.mk +++ b/libs/lpac-jni/src/main/jni/Android.mk @@ -1,14 +1,29 @@ LOCAL_PATH := $(call my-dir) # function to find all *.c files under a directory +# Detecting the operating system +ifeq ($(OS),Windows_NT) +# Windows-specific commands define all-c-files-under -$(patsubst ./%,%, \ - $(shell cd $(LOCAL_PATH) ; \ - find $(1) -name "*.c" -and -not -name ".*" -maxdepth 1) \ - ) + $(patsubst .\%,%, \ + $(shell cd $(LOCAL_PATH) & \ + dir /b/s $(subst /,\,$(1))\*.c) \ + ) endef +else +# UNIX commands +define all-c-files-under + $(patsubst ./%,%, \ + $(shell cd $(LOCAL_PATH) ; \ + find $(1) -name "*.c" -and -not -name ".*" -maxdepth 1) \ + ) +endef +endif include $(CLEAR_VARS) +LOCAL_SHORT_COMMANDS := true +APP_SHORT_COMMANDS := true + # libcjson LOCAL_MODULE := lpac-cjson LOCAL_SRC_FILES := \ @@ -16,6 +31,9 @@ LOCAL_SRC_FILES := \ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) +LOCAL_SHORT_COMMANDS := true +APP_SHORT_COMMANDS := true + # libasn1c, the ASN parser component from lpac LOCAL_MODULE := lpac-asn1c LOCAL_C_INCLUDES := \ @@ -26,6 +44,9 @@ LOCAL_CFLAGS := -DHAVE_CONFIG_H include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) +LOCAL_SHORT_COMMANDS := true +APP_SHORT_COMMANDS := true + # libeuicc component from lpac, which contains the actual implementation LOCAL_MODULE := lpac-euicc LOCAL_STATIC_LIBRARIES := lpac-asn1c lpac-cjson @@ -36,6 +57,9 @@ LOCAL_SRC_FILES := \ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) +LOCAL_SHORT_COMMANDS := true +APP_SHORT_COMMANDS := true + LOCAL_MODULE := lpac-jni LOCAL_STATIC_LIBRARIES := lpac-euicc LOCAL_C_INCLUDES := \ From e493a8e885921bd58c0312ccc0f3f5c4b3085672 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Sat, 2 Dec 2023 13:40:55 -0500 Subject: [PATCH 3/3] EuiccChannelManager: Better logging about the APDU channel used --- .../main/java/im/angry/openeuicc/core/EuiccChannelManager.kt | 2 ++ .../im/angry/openeuicc/core/PrivilegedEuiccChannelManager.kt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app-common/src/main/java/im/angry/openeuicc/core/EuiccChannelManager.kt b/app-common/src/main/java/im/angry/openeuicc/core/EuiccChannelManager.kt index aaf1659..ab3914c 100644 --- a/app-common/src/main/java/im/angry/openeuicc/core/EuiccChannelManager.kt +++ b/app-common/src/main/java/im/angry/openeuicc/core/EuiccChannelManager.kt @@ -81,10 +81,12 @@ open class EuiccChannelManager(protected val context: Context) { var euiccChannel: EuiccChannel? = tryOpenEuiccChannelPrivileged(uiccInfo, channelInfo) if (euiccChannel == null) { + Log.i(TAG, "Trying OMAPI for slot ${uiccInfo.slotIndex}") try { euiccChannel = OmapiChannel(seService!!, channelInfo) } catch (e: IllegalArgumentException) { // Failed + Log.w(TAG, "OMAPI APDU interface unavailable for slot ${uiccInfo.slotIndex}.") } } diff --git a/app/src/main/java/im/angry/openeuicc/core/PrivilegedEuiccChannelManager.kt b/app/src/main/java/im/angry/openeuicc/core/PrivilegedEuiccChannelManager.kt index e7c19c9..b262e49 100644 --- a/app/src/main/java/im/angry/openeuicc/core/PrivilegedEuiccChannelManager.kt +++ b/app/src/main/java/im/angry/openeuicc/core/PrivilegedEuiccChannelManager.kt @@ -13,12 +13,13 @@ class PrivilegedEuiccChannelManager(context: Context): EuiccChannelManager(conte override fun tryOpenEuiccChannelPrivileged(uiccInfo: UiccCardInfo, channelInfo: EuiccChannelInfo): EuiccChannel? { if (uiccInfo.isEuicc && !uiccInfo.isRemovable) { - Log.d(TAG, "Using TelephonyManager for slot ${uiccInfo.slotIndex}") + Log.i(TAG, "Trying TelephonyManager for slot ${uiccInfo.slotIndex}") // TODO: On Tiramisu, we should also connect all available "ports" for MEP support try { return TelephonyManagerChannel(channelInfo, tm) } catch (e: IllegalArgumentException) { // Failed + Log.w(TAG, "TelephonyManager APDU interface unavailable for slot ${uiccInfo.slotIndex}, falling back") } } return null