euicc: add module scaffold with Rust JNI core and Compose UI
- Commit
d0caea7f7bf16033ce0a8fefd5a6a038584bd46f- Author
- Vayun Mathur <[email protected]>
- When
- 2026-08-12 16:09 UTC (3 months ago)
- Parents
332c644
Diff
Cargo.lock
diff --git a/Cargo.lock b/Cargo.lockindex 889820e06c..73be15bf11 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -586,6 +586,14 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]]+name = "euicc"+version = "0.1.0"+dependencies = [+ "jni",+ "log",+]+ [[package]] name = "eyre" version = "0.6.12"
Cargo.toml
diff --git a/Cargo.toml b/Cargo.tomlindex 1eb2f168f3..e7b6fae9a5 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -8,6 +8,7 @@ members = [ "camera/src/main/rust", "maps/src/main/rust", "networklocation/src/main/rust",+ "euicc/src/main/rust", "passwords/src/main/rust", "vpn/src/main/rust", "library/e2ee-p2p/src/main/rust",
euicc/build.gradle.kts
diff --git a/euicc/build.gradle.kts b/euicc/build.gradle.ktsnew file mode 100644index 0000000000..3825a5cb11--- /dev/null+++ b/euicc/build.gradle.kts@@ -0,0 +1,36 @@+plugins {+ id("common-conventions-app")+ // Listing screenshots come from Compose previews (src/screenshotTest), not from an+ // instrumented test on a device. Same `:euicc:metadata` task name either way.+ id("common-conventions-preview-metadata")+}++launcherIcon {+ symbol = "sim_card"+}++android {+ defaultConfig {+ applicationId = "com.vayunmathur.euicc"+ }+}++androidComponents {+ onVariants { variant ->+ variant.sources.jniLibs?.addStaticSourceDirectory(+ layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath+ )+ }+}++// SGP.22 core (ASN.1 + ES9+/ES10 + crypto) is native, loaded as libeuicc.so.+// See euicc/src/main/rust/.+rustNativeLib("euicc")++dependencies {+ // Rust reaches the SM-DP+ over HTTP through the flat-framed JNI bridge in+ // library:network (NativeHttpBridge), so libeuicc.so links no TLS of its own.+ implementation(project(":library:network"))+ // Local per-profile nicknames / prefs.+ implementation(libs.androidx.datastore.preferences)+}
euicc/src/main/AndroidManifest.xml
diff --git a/euicc/src/main/AndroidManifest.xml b/euicc/src/main/AndroidManifest.xmlnew file mode 100644index 0000000000..baf0cf9707--- /dev/null+++ b/euicc/src/main/AndroidManifest.xml@@ -0,0 +1,24 @@+<?xml version="1.0" encoding="utf-8"?>+<manifest xmlns:android="http://schemas.android.com/apk/res/android">++ <application+ android:allowBackup="true"+ android:dataExtractionRules="@xml/data_extraction_rules"+ android:icon="@mipmap/ic_launcher"+ android:label="@string/app_name"+ android:roundIcon="@mipmap/ic_launcher"+ android:supportsRtl="true"+ android:theme="@style/Theme.General">+ <activity+ android:configChanges="mcc|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|keyboardHidden|layoutDirection|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"+ android:name=".MainActivity"+ android:exported="true"+ android:theme="@style/Theme.General">+ <intent-filter>+ <action android:name="android.intent.action.MAIN" />+ <category android:name="android.intent.category.LAUNCHER" />+ </intent-filter>+ </activity>+ </application>++</manifest>
euicc/src/main/java/com/vayunmathur/euicc/EuiccNative.kt
diff --git a/euicc/src/main/java/com/vayunmathur/euicc/EuiccNative.kt b/euicc/src/main/java/com/vayunmathur/euicc/EuiccNative.ktnew file mode 100644index 0000000000..0c7977b194--- /dev/null+++ b/euicc/src/main/java/com/vayunmathur/euicc/EuiccNative.kt@@ -0,0 +1,17 @@+package com.vayunmathur.euicc++/**+ * JNI entry points into the native SGP.22 core (libeuicc.so).+ *+ * The Rust side owns the ASN.1 + ES9+/ES10 protocol logic and calls back into+ * [transmitApdu] to drive the eUICC over the telephony logical channel. Only+ * marshalling lives here; see euicc/src/main/rust/.+ */+object EuiccNative {+ init {+ System.loadLibrary("euicc")+ }++ /** Returns the native core's version string. Stub sanity check for Phase 1. */+ external fun nativeVersion(): String+}
euicc/src/main/java/com/vayunmathur/euicc/MainActivity.kt
diff --git a/euicc/src/main/java/com/vayunmathur/euicc/MainActivity.kt b/euicc/src/main/java/com/vayunmathur/euicc/MainActivity.ktnew file mode 100644index 0000000000..653a69bf72--- /dev/null+++ b/euicc/src/main/java/com/vayunmathur/euicc/MainActivity.kt@@ -0,0 +1,20 @@+package com.vayunmathur.euicc++import android.os.Bundle+import androidx.activity.ComponentActivity+import androidx.activity.compose.setContent+import androidx.activity.enableEdgeToEdge+import com.vayunmathur.euicc.ui.EuiccApp+import com.vayunmathur.library.ui.DynamicTheme++class MainActivity : ComponentActivity() {+ override fun onCreate(savedInstanceState: Bundle?) {+ super.onCreate(savedInstanceState)+ enableEdgeToEdge()+ setContent {+ DynamicTheme {+ EuiccApp()+ }+ }+ }+}
euicc/src/main/java/com/vayunmathur/euicc/ui/EuiccApp.kt
diff --git a/euicc/src/main/java/com/vayunmathur/euicc/ui/EuiccApp.kt b/euicc/src/main/java/com/vayunmathur/euicc/ui/EuiccApp.ktnew file mode 100644index 0000000000..16ad05626a--- /dev/null+++ b/euicc/src/main/java/com/vayunmathur/euicc/ui/EuiccApp.kt@@ -0,0 +1,20 @@+package com.vayunmathur.euicc.ui++import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.padding+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.unit.dp+import com.vayunmathur.euicc.EuiccNative+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.Text++@Composable+fun EuiccApp() {+ AppScaffold(title = "EUICC") { padding ->+ Column(modifier = Modifier.padding(padding).padding(16.dp)) {+ Text("eSIM Local Profile Assistant")+ Text("Native core: ${runCatching { EuiccNative.nativeVersion() }.getOrElse { "unavailable" }}")+ }+ }+}
euicc/src/main/res/values/strings.xml
diff --git a/euicc/src/main/res/values/strings.xml b/euicc/src/main/res/values/strings.xmlnew file mode 100644index 0000000000..9d5e1a0313--- /dev/null+++ b/euicc/src/main/res/values/strings.xml@@ -0,0 +1,7 @@+<?xml version="1.0" encoding="utf-8"?>+<resources>+ <string name="app_name">EUICC</string>+ <string name="eid_title">EID</string>+ <string name="euicc_info_title">eUICC info</string>+ <string name="no_euicc">No eUICC available on this device.</string>+</resources>
euicc/src/main/res/xml/data_extraction_rules.xml
diff --git a/euicc/src/main/res/xml/data_extraction_rules.xml b/euicc/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..81a97e0f26--- /dev/null+++ b/euicc/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,17 @@+<?xml version="1.0" encoding="utf-8"?>+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
euicc/src/main/rust/Cargo.toml
diff --git a/euicc/src/main/rust/Cargo.toml b/euicc/src/main/rust/Cargo.tomlnew file mode 100644index 0000000000..d389d8b362--- /dev/null+++ b/euicc/src/main/rust/Cargo.toml@@ -0,0 +1,24 @@+[package]+name = "euicc"+version = "0.1.0"+edition = "2021"+description = "SGP.22 eUICC Local Profile Assistant core (ASN.1 + ES9+/ES10 + crypto) exposed over JNI. Reimplemented for this repo, following the open-source OpenEUICC (GPL-3.0-only)."+license = "GPL-3.0-only"++[lib]+# Must match `rustNativeLib("euicc")` in build.gradle.kts and+# `System.loadLibrary("euicc")` in EuiccNative.kt: cargo emits `lib<name>.so`,+# which RustNative.kt copies into jniLibs.+name = "euicc"+crate-type = ["cdylib", "rlib"]++[dependencies]+jni.workspace = true+log.workspace = true++[profile.release]+opt-level = 3+lto = true+codegen-units = 1+strip = true+panic = "abort"
euicc/src/main/rust/src/jni.rs
diff --git a/euicc/src/main/rust/src/jni.rs b/euicc/src/main/rust/src/jni.rsnew file mode 100644index 0000000000..d2e90631cd--- /dev/null+++ b/euicc/src/main/rust/src/jni.rs@@ -0,0 +1,21 @@+//! Thin JNI marshalling layer bridging the Kotlin `EuiccNative` object to the+//! native SGP.22 core. This file contains no protocol logic; later phases add+//! the ES10/ES9+ entry points and the `transmitApdu` upcall here.++use jni::objects::JClass;+use jni::sys::jstring;+use jni::JNIEnv;++use crate::VERSION;++/// `nativeVersion()` — returns the native core's version string, or null on error.+#[no_mangle]+pub extern "system" fn Java_com_vayunmathur_euicc_EuiccNative_nativeVersion<'l>(+ env: JNIEnv<'l>,+ _class: JClass<'l>,+) -> jstring {+ match env.new_string(VERSION) {+ Ok(s) => s.into_raw(),+ Err(_) => std::ptr::null_mut(),+ }+}
euicc/src/main/rust/src/lib.rs
diff --git a/euicc/src/main/rust/src/lib.rs b/euicc/src/main/rust/src/lib.rsnew file mode 100644index 0000000000..bb1a3bae37--- /dev/null+++ b/euicc/src/main/rust/src/lib.rs@@ -0,0 +1,21 @@+//! SGP.22 eUICC Local Profile Assistant (LPA) native core.+//!+//! This crate owns the SGP.22 protocol logic — ASN.1 (BER/DER) encode/decode,+//! the local ISD-R command set (ES10), SM-DP+ orchestration (ES9+), and the+//! download crypto (P-256 / BrainpoolP256r1 ECDSA/ECKA, GSMA CI chain+//! validation, AES Bound Profile Package decryption). Kotlin owns the UI, the+//! APDU transport (a telephony logical channel to the ISD-R), and system+//! integration (`EuiccService`); Rust reaches the eUICC by calling back into+//! Kotlin `EuiccNative.transmitApdu`, and reaches the SM-DP+ over HTTP through+//! the `library:network` JNI bridge.+//!+//! Reimplemented for this repo, following the open-source OpenEUICC+//! (GPL-3.0-only). Ported files carry attribution in their own headers.+//!+//! Phase 1 ships only the JNI plumbing and a version stub; the protocol modules+//! land in later phases.++mod jni;++/// Version string reported by the native core.+pub const VERSION: &str = concat!("euicc-core ", env!("CARGO_PKG_VERSION"));
settings.gradle.kts
diff --git a/settings.gradle.kts b/settings.gradle.ktsindex fa4cc9cf17..3742d704fb 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -95,6 +95,7 @@ include(":musicbrainz") include(":measure") include(":taxi") include(":communicate")+include(":euicc") // Personal / private app modules live under personal/ (gitignored). Included only // when present so the public repo still configures without them.