diff --git a/README.md b/README.md index 17d2cfc31..24f4c9f47 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,13 @@ There are two variants of this project: - OpenEUICC: The full-fledged privileged variant. - Due to its privilege requirement, OpenEUICC must be placed inside `/system/priv-app` and be signed with the platform certificate. - The preferred way to including OpenEUICC in a system image is to [build it along with AOSP](#building-aosp). + - __Note__: When privileged, OpenEUICC supports any eUICC chip that implements the SGP.22 standard, internal or external. However, there is __no guarantee__ that external (removable) eSIMs actually follow the standard. Please __DO NOT__ submit bug reports for non-functioning removable eSIMs. They are __NOT__ officially supported unless they also support / are supported by EasyEUICC, the unprivileged variant. - EasyEUICC: Unprivileged version that can run as a user app. - - Due to obvious security requirements, EasyEUICC is only able to access eSIM chips whose [ARF/ARA](https://source.android.com/docs/core/connect/uicc#arf) contains the hash of EasyEUICC's signing certificate. + - This version supports two modes of operation: + 1. Inserted, removable eSIMs: Due to obvious security requirements, EasyEUICC is only able to access eSIM chips whose [ARF/ARA](https://source.android.com/docs/core/connect/uicc#arf) contains the hash of EasyEUICC's signing certificate. + 2. USB CCID Card Readers: Only `T=0` readers that use the standard [USB CCID protocol](https://en.wikipedia.org/wiki/CCID_(protocol)) are supported. In this mode, EasyEUICC can access any eSIM chip loaded in the card reader regardless of their ARF/ARA, as long as they implement the [SGP.22 standard](https://www.gsma.com/solutions-and-impact/technologies/esim/wp-content/uploads/2021/07/SGP.22-v2.3.pdf). - Prebuilt release-mode EasyEUICC apks can be downloaded [here](https://gitea.angry.im/PeterCxy/OpenEUICC/releases) - - For removable eSIM chip vendors: to have your chip supported by official builds of EasyEUICC, include the ARA-M hash `2A2FA878BC7C3354C2CF82935A5945A3EDAE4AFA` + - For removable eSIM chip vendors: to have your chip supported by official builds of EasyEUICC when inserted, include the ARA-M hash `2A2FA878BC7C3354C2CF82935A5945A3EDAE4AFA` Building (Gradle) === diff --git a/app-common/src/main/java/im/angry/openeuicc/core/OmapiApduInterface.kt b/app-common/src/main/java/im/angry/openeuicc/core/OmapiApduInterface.kt index 227977c90..711658adb 100644 --- a/app-common/src/main/java/im/angry/openeuicc/core/OmapiApduInterface.kt +++ b/app-common/src/main/java/im/angry/openeuicc/core/OmapiApduInterface.kt @@ -3,6 +3,7 @@ package im.angry.openeuicc.core import android.se.omapi.Channel import android.se.omapi.SEService import android.se.omapi.Session +import android.util.Log import im.angry.openeuicc.util.* import net.typeblog.lpac_jni.ApduInterface @@ -10,6 +11,10 @@ class OmapiApduInterface( private val service: SEService, private val port: UiccPortInfoCompat ): ApduInterface { + companion object { + const val TAG = "OmapiApduInterface" + } + private lateinit var session: Session private lateinit var lastChannel: Channel @@ -44,7 +49,17 @@ class OmapiApduInterface( "Unknown channel" } - return lastChannel.transmit(tx) + Log.d(TAG, "OMAPI APDU: ${tx.encodeHex()}") + + try { + return lastChannel.transmit(tx).also { + Log.d(TAG, "OMAPI APDU response: ${it.encodeHex()}") + } + } catch (e: Exception) { + Log.e(TAG, "OMAPI APDU exception") + e.printStackTrace() + throw e + } } } \ No newline at end of file diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt b/app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt index d49fa70ee..ac0a99f8a 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt @@ -1,6 +1,8 @@ package im.angry.openeuicc.ui import android.annotation.SuppressLint +import android.content.ClipData +import android.content.ClipboardManager import android.content.Intent import android.os.Bundle import android.text.method.PasswordTransformationMethod @@ -293,6 +295,14 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener, } } + iccid.setOnLongClickListener { + requireContext().getSystemService(ClipboardManager::class.java)!! + .setPrimaryClip(ClipData.newPlainText("iccid", iccid.text)) + Toast.makeText(requireContext(), R.string.toast_iccid_copied, Toast.LENGTH_SHORT) + .show() + true + } + profileMenu.setOnClickListener { showOptionsMenu() } } diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/MainActivity.kt b/app-common/src/main/java/im/angry/openeuicc/ui/MainActivity.kt index 74fe38598..0f504ebbc 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/MainActivity.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/MainActivity.kt @@ -146,7 +146,7 @@ open class MainActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker { // If USB readers exist, add them at the very last // We use a wrapper fragment to handle logic specific to USB readers usbDevice?.let { - pages.add(Page(it.productName ?: "USB") { UsbCcidReaderFragment() }) + pages.add(Page(it.productName ?: getString(R.string.usb)) { UsbCcidReaderFragment() }) } viewPager.visibility = View.VISIBLE diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt b/app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt index 9758d18df..59abbc563 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt @@ -20,6 +20,7 @@ import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import im.angry.openeuicc.common.R import im.angry.openeuicc.core.EuiccChannel +import im.angry.openeuicc.core.EuiccChannelManager import im.angry.openeuicc.util.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -53,6 +54,16 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker { notificationList.adapter = notificationAdapter registerForContextMenu(notificationList) + // This is slightly different from the MainActivity logic + // due to the length (we don't want to display the full USB product name) + val channelTitle = if (euiccChannel.logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) { + getString(R.string.usb) + } else { + getString(R.string.channel_name_format, euiccChannel.logicalSlotId) + } + + title = getString(R.string.profile_notifications_detailed_format, channelTitle) + swipeRefresh.setOnRefreshListener { refresh() } diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt b/app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt index d471efab8..754cc5825 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt @@ -44,6 +44,9 @@ class SettingsFragment: PreferenceFragmentCompat() { findPreference("pref_advanced_disable_safeguard_removable_esim") ?.bindBooleanFlow(preferenceRepository.disableSafeguardFlow, PreferenceKeys.DISABLE_SAFEGUARD_REMOVABLE_ESIM) + + findPreference("pref_advanced_operational_profiles_only") + ?.bindBooleanFlow(preferenceRepository.operationalOnlyFlow, PreferenceKeys.OPERATIONAL_PROFILES_ONLY) } private fun CheckBoxPreference.bindBooleanFlow(flow: Flow, key: Preferences.Key) { diff --git a/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt b/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt index 53153405e..f04b6a2a4 100644 --- a/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt +++ b/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt @@ -24,6 +24,7 @@ object PreferenceKeys { val NOTIFICATION_DELETE = booleanPreferencesKey("notification_delete") val NOTIFICATION_SWITCH = booleanPreferencesKey("notification_switch") val DISABLE_SAFEGUARD_REMOVABLE_ESIM = booleanPreferencesKey("disable_safeguard_removable_esim") + val OPERATIONAL_PROFILES_ONLY = booleanPreferencesKey("operational_profiles_only") } class PreferenceRepository(context: Context) { @@ -44,6 +45,9 @@ class PreferenceRepository(context: Context) { val disableSafeguardFlow: Flow = dataStore.data.map { it[PreferenceKeys.DISABLE_SAFEGUARD_REMOVABLE_ESIM] ?: false } + val operationalOnlyFlow: Flow = + dataStore.data.map { it[PreferenceKeys.OPERATIONAL_PROFILES_ONLY] ?: true } + suspend fun updatePreference(key: Preferences.Key, value: T) { dataStore.edit { it[key] = value diff --git a/app-common/src/main/res/layout/activity_main.xml b/app-common/src/main/res/layout/activity_main.xml index cb5f22464..a61a368f7 100644 --- a/app-common/src/main/res/layout/activity_main.xml +++ b/app-common/src/main/res/layout/activity_main.xml @@ -3,8 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".ui.MainActivity"> + android:layout_height="match_parent"> Reload Slots Logical Slot %d + USB Enabled Disabled @@ -23,6 +24,7 @@ Cannot switch to new eSIM profile. Nickname cannot be longer than 64 characters + ICCID copied to clipboard Select Slot Select @@ -47,7 +49,8 @@ Are you sure you want to delete the profile %s? This operation is irreversible. Type \'%s\' here to confirm deletion - Profile Notifications + Notifications + Notifications (%s) Manage Notifications eSIM profiles can send notifications to the carrier when they are downloaded, deleted, enabled, or disabled. The queue of these notifications to be sent is listed here.\n\nIn Settings, you can specify whether to send each type of notification automatically. Note that even if a notification has been sent, it will not be deleted automatically from the record, unless the queue runs out of space.\n\nHere, you can manually send or delete each pending notification. Downloaded @@ -73,6 +76,8 @@ Advanced Disable Safeguards for Removable eSIMs By default, this app prevents you from disabling the active profile on a removable eSIM inserted in the device, because doing so may sometimes render it inaccessible.\nCheck this box to remove this safeguard. + Display only operational profiles + By default, this app lists only operational profiles. You can disable this to also see (and manage) testing and bootstrap profiles. Logs View recent debug logs of the application Info diff --git a/app-common/src/main/res/xml/pref_settings.xml b/app-common/src/main/res/xml/pref_settings.xml index db348fc15..cc3d5b105 100644 --- a/app-common/src/main/res/xml/pref_settings.xml +++ b/app-common/src/main/res/xml/pref_settings.xml @@ -29,6 +29,11 @@ app:iconSpaceReserved="false" app:title="@string/pref_advanced_disable_safeguard_removable_esim" app:summary="@string/pref_advanced_disable_safeguard_removable_esim_desc" /> + CallVoidMethod(env, callback, on_state_update, download_state_finalizing); // TODO: Expose error code as Java-side exceptions? ret = es10b_load_bound_profile_package(ctx, &es10b_load_bound_profile_package_result); - syslog(LOG_INFO, "es10b_load_bound_profile_package %d", ret); + syslog(LOG_INFO, "es10b_load_bound_profile_package %d, reason %d", ret, es10b_load_bound_profile_package_result.errorReason); out: euicc_http_cleanup(ctx);