OpenEuiccService: Don't ignore the only removable eUICC #358

Merged
PeterCxy merged 1 commit from Macktherealonereally/OpenEUICC:fix-removable-euicc-ignored into master 2026-09-28 15:43:03 +02:00
Contributor

shouldIgnoreSlot() returns true for slots to ignore. On devices without an internal eUICC, its own comment says it should expose the first removable eUICC to the system:

// Otherwise, we can report at least one removable eUICC to the system without confusing it too much.
telephonyManager.uiccCardsInfoCompat.firstOrNull { it.isEuicc }?.physicalSlotIndex == physicalSlotId

The comparison is inverted, so exactly that slot is ignored. Every EuiccService call on it (onGetEid, onGetDownloadableSubscriptionMetadata, onDownloadSubscription, onSwitchToSubscription…) returns RESULT_FIRST_USER within a few milliseconds.

How it showed up: on a Samsung Galaxy S21 (SM-G991B, LineageOS 23.2, OpenEUICC as system LPA), the Samsung RIL reports the built-in eUICC as removable (isRemovable=true), so hasInternalEuicc is false. EuiccManager downloads from carrier apps failed immediately. The log showed OpenEuiccService: onGetDownloadableSubscriptionMetadata slotId=1 portIndex=0 ..., and 11 ms later the call returned an error to EuiccController without a single APDU being sent (the app showed its generic install error). Meanwhile the same eUICC worked fine inside the OpenEUICC UI, which doesn't go through shouldIgnoreSlot().

Fix: == → !=.

Testing: with the fix, the platform download flow reaches the eUICC (metadata → carrier-privilege check → download). On 2026-09-27 a travel-eSIM provider's app installed its profile end to end through EuiccManager on that phone (the app-side changes are in a separate PR).

🤖 Generated with Claude Code

`shouldIgnoreSlot()` returns **true for slots to ignore**. On devices without an internal eUICC, its own comment says it should *expose* the first removable eUICC to the system: ```kotlin // Otherwise, we can report at least one removable eUICC to the system without confusing it too much. telephonyManager.uiccCardsInfoCompat.firstOrNull { it.isEuicc }?.physicalSlotIndex == physicalSlotId ``` The comparison is inverted, so exactly that slot is ignored. Every `EuiccService` call on it (`onGetEid`, `onGetDownloadableSubscriptionMetadata`, `onDownloadSubscription`, `onSwitchToSubscription…`) returns `RESULT_FIRST_USER` within a few milliseconds. **How it showed up:** on a Samsung Galaxy S21 (SM-G991B, LineageOS 23.2, OpenEUICC as system LPA), the Samsung RIL reports the built-in eUICC as *removable* (`isRemovable=true`), so `hasInternalEuicc` is false. `EuiccManager` downloads from carrier apps failed immediately. The log showed `OpenEuiccService: onGetDownloadableSubscriptionMetadata slotId=1 portIndex=0 ...`, and 11 ms later the call returned an error to EuiccController without a single APDU being sent (the app showed its generic install error). Meanwhile the same eUICC worked fine inside the OpenEUICC UI, which doesn't go through `shouldIgnoreSlot()`. **Fix:** `==` → `!=`. **Testing:** with the fix, the platform download flow reaches the eUICC (metadata → carrier-privilege check → download). On 2026-09-27 a travel-eSIM provider's app installed its profile end to end through `EuiccManager` on that phone (the app-side changes are in a separate PR). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
shouldIgnoreSlot() returns true for slots to ignore. On devices without an
internal eUICC it is meant to expose the first removable eUICC to the system,
but the comparison was inverted, so exactly that slot was ignored and every
EuiccService call (metadata, download, switch, EID) on it returned
RESULT_FIRST_USER.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator

This is may by design, If use Removable eUICC cards, please use unprivileged build (EasyEUICC).

This is may by design, If use Removable eUICC cards, please use unprivileged build (EasyEUICC).
Owner

This is a LineageOS bug. You need the device overlay XML to claim that the internal eUICC is, in fact, internal. Report with upstream.

This is a LineageOS bug. You need the device overlay XML to claim that the internal eUICC is, in fact, internal. Report with upstream.
Owner

On second thought, that logic is indeed broken in this case. I'll merge this, HOWEVER this is STILL A BUG OF THE LINEAGEOS BUILD. Without marking the internal eUICC properly as internal we cannot decide correctly which one to expose to system when there are multiple. Please fix your LineageOS overlay.

On second thought, that logic is indeed broken in this case. I'll merge this, HOWEVER this is STILL A BUG OF THE LINEAGEOS BUILD. Without marking the internal eUICC properly as internal we cannot decide correctly which one to expose to system when there are multiple. Please fix your LineageOS overlay.
PeterCxy merged commit 89d677e07d into master 2026-09-28 15:43:03 +02:00
PeterCxy deleted branch fix-removable-euicc-ignored 2026-09-28 15:43:03 +02:00
Author
Contributor

Thanks for merging! You're right, the device tree is missing non_removable_euicc_slots. I'll fix that in the exy2100 overlay.

Thanks for merging! You're right, the device tree is missing non_removable_euicc_slots. I'll fix that in the exy2100 overlay.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
PeterCxy/OpenEUICC!358
No description provided.