From c070e856b2b1a5d1b6bddac5e20fd56e28dca85d Mon Sep 17 00:00:00 2001 From: Tad Date: Mon, 21 Aug 2023 08:10:18 -0400 Subject: [PATCH] eSIM enablement via @PeterCxy's OpenEUICC tested working on bluejay Signed-off-by: Tad --- Manifests/Manifest_LAOS-20.0.xml | 4 +- .../android_vendor_divested/packages.mk | 8 +- .../0001-hacky-fix.patch | 132 ++++++++++++++++++ Scripts/LineageOS-20.0/Patch.sh | 4 + Scripts/init.sh | 2 +- 5 files changed, 143 insertions(+), 7 deletions(-) create mode 100644 Patches/LineageOS-20.0/android_packages_apps_OpenEUICC/0001-hacky-fix.patch diff --git a/Manifests/Manifest_LAOS-20.0.xml b/Manifests/Manifest_LAOS-20.0.xml index 797f46cd..d2af54f7 100644 --- a/Manifests/Manifest_LAOS-20.0.xml +++ b/Manifests/Manifest_LAOS-20.0.xml @@ -52,9 +52,9 @@ - - --> + diff --git a/Patches/Common/android_vendor_divested/packages.mk b/Patches/Common/android_vendor_divested/packages.mk index 816ae69d..f137a72d 100644 --- a/Patches/Common/android_vendor_divested/packages.mk +++ b/Patches/Common/android_vendor_divested/packages.mk @@ -13,10 +13,10 @@ PRODUCT_PACKAGES += \ # OpenCamera #endif -#ifneq ($(filter crosshatch blueline bonito sargo coral flame sunfish barbet redfin bluejay oriole raven panther cheetah FP4,$(TARGET_DEVICE)),) -#PRODUCT_PACKAGES += \ -# OpenEUICC -#endif +ifeq (,$(filter crosshatch blueline bonito sargo coral flame sunfish barbet redfin bluejay oriole raven panther cheetah FP4,$(TARGET_PRODUCT))) +PRODUCT_PACKAGES += \ + OpenEUICC +endif # Extras PRODUCT_PACKAGES += \ diff --git a/Patches/LineageOS-20.0/android_packages_apps_OpenEUICC/0001-hacky-fix.patch b/Patches/LineageOS-20.0/android_packages_apps_OpenEUICC/0001-hacky-fix.patch new file mode 100644 index 00000000..1d336088 --- /dev/null +++ b/Patches/LineageOS-20.0/android_packages_apps_OpenEUICC/0001-hacky-fix.patch @@ -0,0 +1,132 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tad +Date: Mon, 21 Aug 2023 08:07:40 -0400 +Subject: [PATCH] Hacky fix for misidentifying physical SIM + +Signed-off-by: Tad +--- + app/src/main/java/im/angry/openeuicc/core/EuiccChannel.kt | 4 +++- + .../java/im/angry/openeuicc/core/EuiccChannelManager.kt | 7 ++++--- + .../java/im/angry/openeuicc/service/OpenEuiccService.kt | 3 ++- + .../java/im/angry/openeuicc/ui/EuiccManagementFragment.kt | 4 ++-- + app/src/main/java/im/angry/openeuicc/ui/MainActivity.kt | 6 ++++-- + 5 files changed, 15 insertions(+), 9 deletions(-) + +diff --git a/app/src/main/java/im/angry/openeuicc/core/EuiccChannel.kt b/app/src/main/java/im/angry/openeuicc/core/EuiccChannel.kt +index 53fd3c7..0067996 100644 +--- a/app/src/main/java/im/angry/openeuicc/core/EuiccChannel.kt ++++ b/app/src/main/java/im/angry/openeuicc/core/EuiccChannel.kt +@@ -8,7 +8,8 @@ data class EuiccChannelInfo( + val cardId: Int, + val name: String, + val imei: String, +- val removable: Boolean ++ val removable: Boolean, ++ val ignore: Boolean + ) + + abstract class EuiccChannel( +@@ -19,6 +20,7 @@ abstract class EuiccChannel( + val name = info.name + val imei = info.imei + val removable = info.removable ++ val ignore = info.ignore + + abstract val lpa: LocalProfileAssistant + abstract val valid: Boolean +diff --git a/app/src/main/java/im/angry/openeuicc/core/EuiccChannelManager.kt b/app/src/main/java/im/angry/openeuicc/core/EuiccChannelManager.kt +index c710c9d..4e709ae 100644 +--- a/app/src/main/java/im/angry/openeuicc/core/EuiccChannelManager.kt ++++ b/app/src/main/java/im/angry/openeuicc/core/EuiccChannelManager.kt +@@ -67,12 +67,13 @@ class EuiccChannelManager(private val context: Context) { + uiccInfo.cardId, + "SIM ${uiccInfo.slotIndex}", + tm.getImei(uiccInfo.slotIndex) ?: return null, +- uiccInfo.isRemovable ++ uiccInfo.isRemovable, ++ (uiccInfo.getEid() == null || uiccInfo.getEid().matches("^[0]+$".toRegex())) + ) + + var euiccChannel: EuiccChannel? = null + +- if (uiccInfo.isEuicc && !uiccInfo.isRemovable) { ++ if (uiccInfo.isEuicc && !uiccInfo.isRemovable && !channelInfo.ignore) { + Log.d(TAG, "Using TelephonyManager for slot ${uiccInfo.slotIndex}") + // TODO: On Tiramisu, we should also connect all available "ports" for MEP support + euiccChannel = TelephonyManagerChannel.tryConnect(tm, channelInfo) +@@ -141,4 +142,4 @@ class EuiccChannelManager(private val context: Context) { + } + } + } +-} +\ No newline at end of file ++} +diff --git a/app/src/main/java/im/angry/openeuicc/service/OpenEuiccService.kt b/app/src/main/java/im/angry/openeuicc/service/OpenEuiccService.kt +index eb41e7c..be94316 100644 +--- a/app/src/main/java/im/angry/openeuicc/service/OpenEuiccService.kt ++++ b/app/src/main/java/im/angry/openeuicc/service/OpenEuiccService.kt +@@ -58,6 +58,7 @@ class OpenEuiccService : EuiccService() { + + override fun onGetEuiccProfileInfoList(slotId: Int): GetEuiccProfileInfoListResult? { + val channel = findChannel(slotId) ?: return null ++ if(findChannel(slotId)!!.ignore) { return null } + val profiles = channel.lpa.profiles.operational.map { + EuiccProfileInfo.Builder(it.iccid).apply { + setProfileName(it.name) +@@ -179,4 +180,4 @@ class OpenEuiccService : EuiccService() { + // No-op -- we do not care + return RESULT_FIRST_USER + } +-} +\ No newline at end of file ++} +diff --git a/app/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt b/app/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt +index 6a3b253..e261cac 100644 +--- a/app/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt ++++ b/app/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt +@@ -80,7 +80,7 @@ class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesCh + @SuppressLint("NotifyDataSetChanged") + private fun refresh() { + swipeRefresh.isRefreshing = true +- ++ if(channel!!.ignore) { return } + lifecycleScope.launch { + val profiles = withContext(Dispatchers.IO) { + openEuiccApplication.subscriptionManager.tryRefreshCachedEuiccInfo(channel.cardId) +@@ -221,4 +221,4 @@ class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesCh + + override fun getItemCount(): Int = profiles.size + } +-} +\ No newline at end of file ++} +diff --git a/app/src/main/java/im/angry/openeuicc/ui/MainActivity.kt b/app/src/main/java/im/angry/openeuicc/ui/MainActivity.kt +index d0f7465..b286cde 100644 +--- a/app/src/main/java/im/angry/openeuicc/ui/MainActivity.kt ++++ b/app/src/main/java/im/angry/openeuicc/ui/MainActivity.kt +@@ -95,15 +95,17 @@ class MainActivity : AppCompatActivity() { + manager.enumerateEuiccChannels() + manager.knownChannels.forEach { + Log.d(TAG, it.name) +- Log.d(TAG, it.lpa.eid) ++ //Log.d(TAG, it.lpa.eid) + openEuiccApplication.subscriptionManager.tryRefreshCachedEuiccInfo(it.cardId) + } + } + + withContext(Dispatchers.Main) { + manager.knownChannels.forEach { channel -> ++ if(!channel!!.ignore) { + spinnerAdapter.add(channel.name) + fragments.add(EuiccManagementFragment.newInstance(channel.slotId)) ++ } + } + + if (fragments.isNotEmpty()) { +@@ -112,4 +114,4 @@ class MainActivity : AppCompatActivity() { + } + } + } +-} +\ No newline at end of file ++} diff --git a/Scripts/LineageOS-20.0/Patch.sh b/Scripts/LineageOS-20.0/Patch.sh index 9d7cb801..0e8ff767 100644 --- a/Scripts/LineageOS-20.0/Patch.sh +++ b/Scripts/LineageOS-20.0/Patch.sh @@ -293,6 +293,10 @@ if enterAndClear "packages/apps/Nfc"; then if [ "$DOS_GRAPHENE_CONSTIFY" = true ]; then applyPatch "$DOS_PATCHES/android_packages_apps_Nfc/0001-constify_JNINativeMethod.patch"; fi; #Constify JNINativeMethod tables (GrapheneOS) fi; +if enterAndClear "packages/apps/OpenEUICC"; then +applyPatch "$DOS_PATCHES/android_packages_apps_OpenEUICC/0001-hacky-fix.patch"; #Hacky fix for misidentifying physical SIM (DivestOS) +fi; + if enterAndClear "packages/apps/Settings"; then git revert --no-edit 41b4ed345a91da1dd46c00ee11a151c2b5ff4f43; applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0004-Private_DNS.patch"; #More 'Private DNS' options (heavily based off of a CalyxOS patch) diff --git a/Scripts/init.sh b/Scripts/init.sh index 8266ccdc..93cd3b1a 100644 --- a/Scripts/init.sh +++ b/Scripts/init.sh @@ -48,7 +48,7 @@ export DOS_DEBLOBBER_REMOVE_DPP=false; #Set true to remove all Display Post Proc export DOS_DEBLOBBER_REMOVE_FP=false; #Set true to remove all fingerprint reader blobs export DOS_DEBLOBBER_REMOVE_GRAPHICS=false; #Set true to remove all graphics blobs and use SwiftShader CPU renderer #TODO: Needs work export DOS_DEBLOBBER_REMOVE_EUICC=true; #Set true to remove all Google eUICC blobs -export DOS_DEBLOBBER_REMOVE_EUICC_FULL=true; #Set true to remove all hardware eUICC blobs #TODO: needs work +export DOS_DEBLOBBER_REMOVE_EUICC_FULL=false; #Set true to remove all hardware eUICC blobs export DOS_DEBLOBBER_REMOVE_IMS=false; #Set true to remove all IMS blobs #XXX: Carriers are phasing out 3G, making IMS mandatory for calls export DOS_DEBLOBBER_REMOVE_IPA=false; #Set true to remove all IPA blobs export DOS_DEBLOBBER_REMOVE_IR=false; #Set true to remove all IR blobs