Compare commits

...

11 commits

Author SHA1 Message Date
f167d059dc
feat: simplified error handling 2025-08-18 09:57:15 +08:00
915a05634b Add updateJson to Magisk module props 2025-08-17 09:42:09 -04:00
9e40232ed0 feat: es10x mss as preference (#213)
Reviewed-on: PeterCxy/OpenEUICC#213
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2025-08-17 02:45:48 +02:00
27b7e50b97 refactor: simplify developer options click handling and toast messages (#221)
Reviewed-on: PeterCxy/OpenEUICC#221
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2025-08-17 02:37:16 +02:00
7e7f5c2b05 feat: Magisk module builds on CI
Much of this is taken from AndroPlus's Magisk module repo, thanks!

There's still no release builds for privileged OpenEUICC and the Magisk
module; this is still intentional (for now). However, it is possible to
produce a release Magisk zip locally via the
`:app:assembleReleaseMagiskModule` task.
2025-08-15 21:06:23 -04:00
4d8b8e8fb5 fix: update .gitignore to ignore all deployment target files (#222)
Reviewed-on: PeterCxy/OpenEUICC#222
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2025-08-15 00:18:41 +02:00
a8b7482afb feat: version name suffix (#215)
see https://developer.android.com/build/build-variants

Reviewed-on: PeterCxy/OpenEUICC#215
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2025-08-10 22:08:31 +02:00
3fed4b2bd6 fix: aid list (#217)
Reviewed-on: PeterCxy/OpenEUICC#217
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2025-08-10 22:07:25 +02:00
deb0a372b1 feat: allow copy app version and source code url (#216)
Reviewed-on: PeterCxy/OpenEUICC#216
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2025-08-10 22:07:10 +02:00
72ec20f824 feat: 16k page sizes (#211)
see https://developer.android.com/guide/practices/page-sizes

Reviewed-on: PeterCxy/OpenEUICC#211
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2025-08-10 22:03:25 +02:00
7c2157daa4 chore: cleanup short string ids (#207)
Reviewed-on: PeterCxy/OpenEUICC#207
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2025-07-28 02:35:56 +02:00
35 changed files with 535 additions and 182 deletions

View file

@ -33,14 +33,23 @@ jobs:
uses: https://gitea.angry.im/actions/setup-android@v3
- name: Build Debug APKs
run: ./gradlew --no-daemon assembleDebug
run: ./gradlew --no-daemon assembleDebug :app:assembleDebugMagiskModuleDir
- name: Copy Artifacts
run: find . -name 'app*-debug.apk' -exec cp {} . \;
run: |
find . -name 'app*-debug.apk' -exec cp {} . \;
cp -r app/build/magisk/debug ./magisk-debug
- name: Upload Artifacts
- name: Upload APK Artifacts
uses: https://gitea.angry.im/actions/upload-artifact@v3
with:
name: Debug APKs
compression-level: 0
path: app*-debug.apk
- name: Upload Magisk Artifacts
uses: https://gitea.angry.im/actions/upload-artifact@v3
with:
name: magisk-debug
compression-level: 0
path: magisk-debug

2
.idea/.gitignore generated vendored
View file

@ -2,7 +2,7 @@
/caches
/libraries
/assetWizardSettings.xml
/deploymentTargetDropDown.xml
/deploymentTarget*.xml
/gradle.xml
/misc.xml
/modules.xml

View file

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app-unpriv">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
<SelectionState runConfigName="app-unpriv.androidTest">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
<SelectionState runConfigName="app-unpriv.main">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
<SelectionState runConfigName="app-unpriv.unitTest">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
<SelectionState runConfigName="app.unitTest">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
<SelectionState runConfigName="app.androidTest">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
<SelectionState runConfigName="app.main">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
<SelectionState runConfigName="workspace.OpenEUICC.app-unpriv">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
<SelectionState runConfigName="workspace.OpenEUICC.app">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>

View file

@ -21,7 +21,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
override suspend fun tryOpenEuiccChannel(
port: UiccPortInfoCompat,
isdrAid: ByteArray
): EuiccChannel? {
): EuiccChannel? = try {
if (port.portIndex != 0) {
Log.w(
DefaultEuiccChannelManager.TAG,
@ -35,9 +35,8 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
DefaultEuiccChannelManager.TAG,
"Trying OMAPI for physical slot ${port.card.physicalSlotIndex}"
)
try {
return EuiccChannelImpl(
context.getString(R.string.omapi),
EuiccChannelImpl(
context.getString(R.string.channel_type_omapi),
port,
intrinsicChannelName = null,
OmapiApduInterface(
@ -48,28 +47,23 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
isdrAid,
context.preferenceRepository.verboseLoggingFlow,
context.preferenceRepository.ignoreTLSCertificateFlow,
).also {
Log.i(DefaultEuiccChannelManager.TAG, "Is OMAPI channel, setting MSS to 60")
it.lpa.setEs10xMss(60)
}
context.preferenceRepository.es10xMssFlow,
)
} catch (_: IllegalArgumentException) {
// Failed
Log.w(
DefaultEuiccChannelManager.TAG,
"OMAPI APDU interface unavailable for physical slot ${port.card.physicalSlotIndex} with ISD-R AID: ${isdrAid.encodeHex()}."
)
}
return null
null
}
override fun tryOpenUsbEuiccChannel(
ccidCtx: UsbCcidContext,
isdrAid: ByteArray
): EuiccChannel? {
try {
return EuiccChannelImpl(
context.getString(R.string.usb),
): EuiccChannel? = try {
EuiccChannelImpl(
context.getString(R.string.channel_type_usb),
FakeUiccPortInfoCompat(FakeUiccCardInfoCompat(EuiccChannelManager.USB_CHANNEL_ID)),
intrinsicChannelName = ccidCtx.productName,
UsbApduInterface(
@ -78,6 +72,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
isdrAid,
context.preferenceRepository.verboseLoggingFlow,
context.preferenceRepository.ignoreTLSCertificateFlow,
context.preferenceRepository.es10xMssFlow,
)
} catch (_: IllegalArgumentException) {
// Failed
@ -85,8 +80,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
DefaultEuiccChannelManager.TAG,
"USB APDU interface unavailable for ISD-R AID: ${isdrAid.encodeHex()}."
)
}
return null
null
}
override fun cleanup() {

View file

@ -1,8 +1,9 @@
package im.angry.openeuicc.core
import im.angry.openeuicc.util.UiccPortInfoCompat
import im.angry.openeuicc.util.decodeHex
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import net.typeblog.lpac_jni.ApduInterface
import net.typeblog.lpac_jni.LocalProfileAssistant
import net.typeblog.lpac_jni.impl.HttpInterfaceImpl
@ -15,7 +16,8 @@ class EuiccChannelImpl(
override val apduInterface: ApduInterface,
override val isdrAid: ByteArray,
verboseLoggingFlow: Flow<Boolean>,
ignoreTLSCertificateFlow: Flow<Boolean>
ignoreTLSCertificateFlow: Flow<Boolean>,
es10xMssFlow: Flow<Int>,
) : EuiccChannel {
override val slotId = port.card.physicalSlotIndex
override val logicalSlotId = port.logicalSlotIndex
@ -25,8 +27,10 @@ class EuiccChannelImpl(
LocalProfileAssistantImpl(
isdrAid,
apduInterface,
HttpInterfaceImpl(verboseLoggingFlow, ignoreTLSCertificateFlow)
)
HttpInterfaceImpl(verboseLoggingFlow, ignoreTLSCertificateFlow),
).also {
it.setEs10xMss(runBlocking { es10xMssFlow.first().toByte() })
}
override val atr: ByteArray?
get() = (apduInterface as? ApduInterfaceAtrProvider)?.atr

View file

@ -36,7 +36,7 @@ private val RE_SAS = Regex(
class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
companion object {
private val YES_NO = Pair(R.string.yes, R.string.no)
private val YES_NO = Pair(R.string.euicc_info_yes, R.string.euicc_info_no)
}
private lateinit var swipeRefresh: SwipeRefreshLayout
@ -69,7 +69,7 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
logicalSlotId = intent.getIntExtra("logicalSlotId", 0)
val channelTitle = if (logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
getString(R.string.usb)
getString(R.string.channel_type_usb)
} else {
appContainer.customizableTextProvider.formatInternalChannelName(logicalSlotId)
}
@ -119,7 +119,7 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
channel.lpa.euiccInfo2?.let { info ->
add(Item(R.string.euicc_info_sgp22_version, info.sgp22Version.toString()))
add(Item(R.string.euicc_info_firmware_version, info.euiccFirmwareVersion.toString()))
add(Item(R.string.euicc_info_globalplatform_version, info.globalPlatformVersion.toString()))
add(Item(R.string.euicc_info_gp_version, info.globalPlatformVersion.toString()))
add(Item(R.string.euicc_info_pp_version, info.ppVersion.toString()))
info.sasAccreditationNumber.trim().takeIf(RE_SAS::matches)
?.let { add(Item(R.string.euicc_info_sas_accreditation_number, it.uppercase())) }
@ -131,14 +131,14 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
// FS.27 v2.0, Security Guidelines for UICC Profiles (Page 25 of 27, 2024-01-30)
// https://www.gsma.com/solutions-and-impact/technologies/security/wp-content/uploads/2024/01/FS.27-Security-Guidelines-for-UICC-Credentials-v2.0-FINAL-23-July.pdf#page=25
val resId = when {
signers.isEmpty() -> R.string.unknown // the case is not mp, but it's is not common
signers.isEmpty() -> R.string.euicc_info_unknown // the case is not mp, but it's is not common
PKID_GSMA_LIVE_CI.any(signers::contains) -> R.string.euicc_info_ci_gsma_live
PKID_GSMA_TEST_CI.any(signers::contains) -> R.string.euicc_info_ci_gsma_test
else -> R.string.euicc_info_ci_unknown
}
add(Item(R.string.euicc_info_ci_type, getString(resId)))
}
val atr = channel.atr?.encodeHex() ?: getString(R.string.information_unavailable)
val atr = channel.atr?.encodeHex() ?: getString(R.string.euicc_info_unavailable)
add(Item(R.string.euicc_info_atr, atr, copiedToastResId = R.string.toast_atr_copied))
}
@ -171,7 +171,7 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
fun bind(item: Item) {
copiedToastResId = item.copiedToastResId
title.setText(item.titleResId)
content.text = item.content ?: getString(R.string.unknown)
content.text = item.content ?: getString(R.string.euicc_info_unknown)
}
}

View file

@ -174,7 +174,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 {
val productName = it.productName ?: getString(R.string.usb)
val productName = it.productName ?: getString(R.string.channel_type_usb)
newPages.add(Page(EuiccChannelManager.USB_CHANNEL_ID, productName) {
UsbCcidReaderFragment()
})

View file

@ -60,7 +60,7 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
// 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 (logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
getString(R.string.usb)
getString(R.string.channel_type_usb)
} else {
appContainer.customizableTextProvider.formatInternalChannelName(logicalSlotId)
}

View file

@ -8,6 +8,7 @@ import android.provider.Settings
import android.widget.Toast
import androidx.lifecycle.lifecycleScope
import androidx.preference.CheckBoxPreference
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
@ -16,7 +17,6 @@ import im.angry.openeuicc.util.*
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
open class SettingsFragment: PreferenceFragmentCompat() {
private lateinit var developerPref: PreferenceCategory
@ -34,7 +34,7 @@ open class SettingsFragment: PreferenceFragmentCompat() {
// Show / hide developer preference based on whether it is enabled
lifecycleScope.launch {
preferenceRepository.developerOptionsEnabledFlow
.onEach { developerPref.isVisible = it }
.onEach(developerPref::setVisible)
.collect()
}
@ -84,6 +84,9 @@ open class SettingsFragment: PreferenceFragmentCompat() {
requirePreference<CheckBoxPreference>("pref_developer_euicc_memory_reset")
.bindBooleanFlow(preferenceRepository.euiccMemoryResetFlow)
requirePreference<ListPreference>("pref_developer_es10x_mss")
.bindIntFlow(preferenceRepository.es10xMssFlow, 63)
requirePreference<Preference>("pref_developer_isdr_aid_list").apply {
intent = Intent(requireContext(), IsdrAidListActivity::class.java)
}
@ -100,51 +103,53 @@ open class SettingsFragment: PreferenceFragmentCompat() {
@Suppress("UNUSED_PARAMETER")
private fun onAppVersionClicked(pref: Preference): Boolean {
if (developerPref.isVisible) return false
val now = System.currentTimeMillis()
if (now - lastClickTimestamp >= 1000) {
numClicks = 1
} else {
numClicks++
}
numClicks = if (now - lastClickTimestamp >= 1000) 1 else numClicks + 1
lastClickTimestamp = now
if (numClicks == 7) {
lifecycleScope.launch {
preferenceRepository.developerOptionsEnabledFlow.updatePreference(true)
preferenceRepository.developerOptionsEnabledFlow.updatePreference(numClicks >= 7)
}
val toastText = when {
numClicks == 7 -> getString(R.string.developer_options_enabled)
numClicks > 1 -> getString(R.string.developer_options_steps, 7 - numClicks)
else -> return true
}
lastToast?.cancel()
Toast.makeText(
requireContext(),
R.string.developer_options_enabled,
Toast.LENGTH_SHORT
).show()
}
} else if (numClicks > 1) {
lastToast?.cancel()
lastToast = Toast.makeText(
requireContext(),
getString(R.string.developer_options_steps, 7 - numClicks),
Toast.LENGTH_SHORT
)
lastToast = Toast.makeText(requireContext(), toastText, Toast.LENGTH_SHORT)
lastToast!!.show()
}
return true
}
protected fun CheckBoxPreference.bindBooleanFlow(flow: PreferenceFlowWrapper<Boolean>) {
lifecycleScope.launch {
flow.collect { isChecked = it }
flow.collect(::setChecked)
}
setOnPreferenceChangeListener { _, newValue ->
runBlocking {
lifecycleScope.launch {
flow.updatePreference(newValue as Boolean)
}
true
}
}
private fun ListPreference.bindIntFlow(flow: PreferenceFlowWrapper<Int>, defaultValue: Int) {
lifecycleScope.launch {
flow.collect { value = it.toString() }
}
setOnPreferenceChangeListener { _, newValue ->
lifecycleScope.launch {
flow.updatePreference((newValue as String).toIntOrNull() ?: defaultValue)
}
true
}
}
protected fun mergePreferenceOverlay(overlayKey: String, targetKey: String) {
val overlayCat = requirePreference<PreferenceCategory>(overlayKey)
val targetCat = requirePreference<PreferenceCategory>(targetKey)

View file

@ -19,7 +19,6 @@ import im.angry.openeuicc.util.*
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.launch
import net.typeblog.lpac_jni.LocalProfileInfo
class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardStepFragment() {
companion object {
@ -187,12 +186,12 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
}
title.text = if (item.logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
item.intrinsicChannelName ?: root.context.getString(R.string.usb)
item.intrinsicChannelName ?: root.context.getString(R.string.channel_type_usb)
} else {
appContainer.customizableTextProvider.formatInternalChannelName(item.logicalSlotId)
}
eID.text = item.eID
activeProfile.text = item.enabledProfileName ?: root.context.getString(R.string.unknown)
activeProfile.text = item.enabledProfileName ?: root.context.getString(R.string.profile_no_enabled_profile)
freeSpace.text = formatFreeSpace(item.freeSpace)
checkBox.isChecked = adapter.currentSelectedIdx == idx
}

View file

@ -0,0 +1,145 @@
package im.angry.openeuicc.ui.wizard
import androidx.annotation.StringRes
import im.angry.openeuicc.common.R
import net.typeblog.lpac_jni.LocalProfileAssistant
import org.json.JSONObject
import java.net.NoRouteToHostException
import java.net.PortUnreachableException
import java.net.SocketException
import java.net.SocketTimeoutException
import java.net.UnknownHostException
import javax.net.ssl.SSLException
object SimplifiedErrorHandling {
enum class ErrorCode(@StringRes val titleResId: Int, @StringRes val suggestResId: Int?) {
ICCIDAlready(
R.string.download_wizard_error_iccid_already,
R.string.download_wizard_error_suggest_profile_installed
),
InsufficientMemory(
R.string.download_wizard_error_insufficient_memory,
R.string.download_wizard_error_suggest_insufficient_memory
),
UnsupportedProfile(
R.string.download_wizard_error_unsupported_profile,
null
),
CardInternalError(
R.string.download_wizard_error_card_internal_error,
null
),
EIDMismatch(
R.string.download_wizard_error_eid_mismatch,
R.string.download_wizard_error_suggest_contact_reissue
),
UnreleasedProfile(
R.string.download_wizard_error_profile_unreleased,
R.string.download_wizard_error_suggest_contact_reissue
),
MatchingIDRefused(
R.string.download_wizard_error_matching_id_refused,
R.string.download_wizard_error_suggest_contact_carrier
),
ProfileRetriesExceeded(
R.string.download_wizard_error_profile_retries_exceeded,
R.string.download_wizard_error_suggest_contact_carrier
),
ConfirmationCodeMissing(
R.string.download_wizard_error_confirmation_code_missing,
R.string.download_wizard_error_suggest_contact_carrier
),
ConfirmationCodeRefused(
R.string.download_wizard_error_confirmation_code_refused,
R.string.download_wizard_error_suggest_contact_carrier
),
ConfirmationCodeRetriesExceeded(
R.string.download_wizard_error_confirmation_code_retries_exceeded,
R.string.download_wizard_error_suggest_contact_carrier
),
ProfileExpired(
R.string.download_wizard_error_profile_expired,
R.string.download_wizard_error_suggest_contact_carrier
),
UnknownHost(
R.string.download_wizard_error_unknown_hostname,
null
),
NetworkUnreachable(
R.string.download_wizard_error_network_unreachable,
R.string.download_wizard_error_suggest_network_unreachable
),
TLSError(
R.string.download_wizard_error_tls_certificate,
null
)
}
private val httpErrors = buildMap {
// Stage: AuthenticateClient
put("8.1" to "4.8", ErrorCode.InsufficientMemory)
put("8.1.1" to "3.8", ErrorCode.EIDMismatch)
put("8.2" to "1.2", ErrorCode.UnreleasedProfile)
put("8.2.6" to "3.8", ErrorCode.MatchingIDRefused)
put("8.8.5" to "6.4", ErrorCode.ProfileRetriesExceeded)
// Stage: GetBoundProfilePackage
put("8.2.7" to "2.2", ErrorCode.ConfirmationCodeMissing)
put("8.2.7" to "3.8", ErrorCode.ConfirmationCodeRefused)
put("8.2.7" to "6.4", ErrorCode.ConfirmationCodeRetriesExceeded)
// Stage: AuthenticateClient, GetBoundProfilePackage
put("8.8.5" to "4.10", ErrorCode.ProfileExpired)
}
fun toSimplifiedDownloadError(exc: LocalProfileAssistant.ProfileDownloadException) = when {
exc.lpaErrorReason != "ES10B_ERROR_REASON_UNDEFINED" -> toSimplifiedLPAErrorReason(exc.lpaErrorReason)
exc.lastHttpResponse?.rcode == 200 -> toSimplifiedHTTPResponse(exc.lastHttpResponse!!)
exc.lastHttpException != null -> toSimplifiedHTTPException(exc.lastHttpException!!)
exc.lastApduResponse != null -> toSimplifiedAPDUResponse(exc.lastApduResponse!!)
else -> null
}
private fun toSimplifiedLPAErrorReason(reason: String) = when (reason) {
"ES10B_ERROR_REASON_UNSUPPORTED_CRT_VALUES" -> ErrorCode.UnsupportedProfile
"ES10B_ERROR_REASON_UNSUPPORTED_REMOTE_OPERATION_TYPE" -> ErrorCode.UnsupportedProfile
"ES10B_ERROR_REASON_UNSUPPORTED_PROFILE_CLASS" -> ErrorCode.UnsupportedProfile
"ES10B_ERROR_REASON_INSTALL_FAILED_DUE_TO_ICCID_ALREADY_EXISTS_ON_EUICC" -> ErrorCode.ICCIDAlready
"ES10B_ERROR_REASON_INSTALL_FAILED_DUE_TO_INSUFFICIENT_MEMORY_FOR_PROFILE" -> ErrorCode.InsufficientMemory
"ES10B_ERROR_REASON_INSTALL_FAILED_DUE_TO_INTERRUPTION" -> ErrorCode.CardInternalError
"ES10B_ERROR_REASON_INSTALL_FAILED_DUE_TO_PE_PROCESSING_ERROR" -> ErrorCode.CardInternalError
else -> null
}
private fun toSimplifiedHTTPResponse(response: net.typeblog.lpac_jni.HttpInterface.HttpResponse): ErrorCode? {
if (response.data.first().toInt() != '{'.code) return null
val response = JSONObject(response.data.decodeToString())
val statusCodeData = response.optJSONObject("header")
?.optJSONObject("functionExecutionStatus")
?.optJSONObject("statusCodeData")
?: return null
val subjectCode = statusCodeData.optString("subjectCode")
val reasonCode = statusCodeData.optString("reasonCode")
return httpErrors[subjectCode to reasonCode]
}
private fun toSimplifiedHTTPException(exc: Exception) = when (exc) {
is SSLException -> ErrorCode.TLSError
is UnknownHostException -> ErrorCode.UnknownHost
is NoRouteToHostException -> ErrorCode.NetworkUnreachable
is PortUnreachableException -> ErrorCode.NetworkUnreachable
is SocketTimeoutException -> ErrorCode.NetworkUnreachable
is SocketException -> exc.message
?.contains("Connection reset", ignoreCase = true)
?.let { if (it) ErrorCode.NetworkUnreachable else null }
else -> null
}
private fun toSimplifiedAPDUResponse(resp: ByteArray): ErrorCode? {
val isSuccess = resp.size >= 2 &&
resp[resp.size - 2] == 0x90.toByte() &&
resp[resp.size - 1] == 0x00.toByte()
if (isSuccess) return null
return ErrorCode.CardInternalError
}
}

View file

@ -5,6 +5,7 @@ import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.intPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import androidx.fragment.app.Fragment
@ -38,6 +39,7 @@ internal object PreferenceKeys {
val IGNORE_TLS_CERTIFICATE = booleanPreferencesKey("ignore_tls_certificate")
val EUICC_MEMORY_RESET = booleanPreferencesKey("euicc_memory_reset")
val ISDR_AID_LIST = stringPreferencesKey("isdr_aid_list")
val ES10X_MSS = intPreferencesKey("es10x_mss")
}
const val EUICC_DEFAULT_ISDR_AID = "A0000005591010FFFFFFFF8900000100"
@ -50,9 +52,12 @@ internal object PreferenceConstants {
# eUICC standard
$EUICC_DEFAULT_ISDR_AID
# eSTK.me
# ESTKme AUX (deprecated, use SE0 instead)
A06573746B6D65FFFFFFFF4953442D52
# ESTKme SE0
A06573746B6D65FFFF4953442D522030
# eSIM.me
A0000005591010000000008900000300
@ -86,6 +91,7 @@ open class PreferenceRepository(private val context: Context) {
PreferenceConstants.DEFAULT_AID_LIST,
{ Base64.getEncoder().encodeToString(it.encodeToByteArray()) },
{ Base64.getDecoder().decode(it).decodeToString() })
val es10xMssFlow = bindFlow(PreferenceKeys.ES10X_MSS, 63)
protected fun <T> bindFlow(
key: Preferences.Key<T>,

View file

@ -102,8 +102,8 @@ fun <T : ActivityResultCaller> T.setupLogSaving(
AlertDialog.Builder(context).apply {
setMessage(R.string.logs_saved_message)
setNegativeButton(R.string.no) { _, _ -> }
setPositiveButton(R.string.yes) { _, _ ->
setNegativeButton(android.R.string.cancel) { _, _ -> }
setPositiveButton(android.R.string.ok) { _, _ ->
val intent = Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
clipData = ClipData.newUri(context.contentResolver, lastFileName, uri)

View file

@ -9,7 +9,7 @@
<item
android:id="@+id/reset"
android:title="@string/reset"
android:title="@string/isdr_aid_list_restore_defaults"
android:icon="@drawable/ic_refresh_black"
app:showAsAction="ifRoom" />
</menu>

View file

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/reload"
android:title="@string/reload"
android:title="@string/profile_reload_slots"
android:icon="@drawable/ic_refresh_black"
app:showAsAction="ifRoom" />

View file

@ -4,6 +4,6 @@
<item
android:id="@+id/help"
android:icon="@drawable/ic_help_black"
android:title="@string/help"
android:title="@string/notification_help"
app:showAsAction="always" />
</menu>

View file

@ -2,10 +2,10 @@
<resources>
<string name="no_euicc">このアプリでアクセスできるリムーバブル eUICC カードがデバイス上で検出されていません。互換性のあるカード挿入または USB リーダーを接続してください。</string>
<string name="no_profile">この eSIM にはプロファイルがありません。</string>
<string name="unknown">不明</string>
<string name="information_unavailable">情報がありません</string>
<string name="help">ヘルプ</string>
<string name="reload">スロットを再読み込み</string>
<string name="euicc_info_unknown">不明</string>
<string name="euicc_info_unavailable">情報がありません</string>
<string name="notification_help">ヘルプ</string>
<string name="profile_reload_slots">スロットを再読み込み</string>
<string name="channel_name_format">論理スロット %d</string>
<string name="profile_state_enabled">有効済み</string>
<string name="profile_state_disabled">無効済み</string>
@ -110,7 +110,7 @@
<string name="euicc_info_fw_ver">製品ファームウェアバージョン</string>
<string name="euicc_info_sgp22_version">SGP.22 バージョン</string>
<string name="euicc_info_firmware_version">eUICC OS バージョン</string>
<string name="euicc_info_globalplatform_version">グローバルプラットフォームのバージョン</string>
<string name="euicc_info_gp_version">グローバルプラットフォームのバージョン</string>
<string name="euicc_info_sas_accreditation_number">SAS 認定番号</string>
<string name="euicc_info_pp_version">保護されたプロファイルのバージョン</string>
<string name="euicc_info_free_nvram">NVRAM の空き容量 (eSIM プロファイルストレージ)</string>
@ -118,8 +118,8 @@
<string name="euicc_info_ci_gsma_live">GSMA ライブ CI</string>
<string name="euicc_info_ci_gsma_test">GSMA テスト CI</string>
<string name="euicc_info_ci_unknown">不明な eSIM CI</string>
<string name="yes">はい</string>
<string name="no">いいえ</string>
<string name="euicc_info_yes">はい</string>
<string name="euicc_info_no">いいえ</string>
<string name="logs_save">保存</string>
<string name="logs_filename_template">%s のログ</string>
<string name="developer_options_steps">開発者になるまであと %d ステップです。</string>
@ -167,6 +167,6 @@
<string name="pref_developer_euicc_memory_reset_desc">この操作は、デフォルトでは非表示になっている危険な操作です。代わりに、すべての構成ファイルを手動で削除することもできます。</string>
<string name="pref_developer_refresh_after_switch">モデムに更新コマンドを送信</string>
<string name="pref_developer_isdr_aid_list">ISD-R AID リストのカスタマイズ</string>
<string name="reset">リセット</string>
<string name="isdr_aid_list_restore_defaults">リセット</string>
<string name="isdr_aid_list">ISD-R AID リスト</string>
</resources>

View file

@ -2,9 +2,9 @@
<resources>
<string name="no_euicc">在此设备上未检测到此应用程序可访问的可插拔 eUICC 卡。请插入兼容卡或 USB 读卡器。</string>
<string name="no_profile">此 eSIM 上还没有配置文件</string>
<string name="unknown">未知</string>
<string name="help">帮助</string>
<string name="reload">重新加载卡槽</string>
<string name="euicc_info_unknown">未知</string>
<string name="notification_help">帮助</string>
<string name="profile_reload_slots">重新加载卡槽</string>
<string name="channel_name_format">逻辑卡槽 %d</string>
<string name="profile_state_enabled">已启用</string>
<string name="profile_state_disabled">已禁用</string>
@ -132,7 +132,7 @@
<string name="euicc_info_removable">可插拔</string>
<string name="euicc_info_sgp22_version">SGP.22 版本</string>
<string name="euicc_info_firmware_version">eUICC OS 版本</string>
<string name="euicc_info_globalplatform_version">GlobalPlatform 版本</string>
<string name="euicc_info_gp_version">GlobalPlatform 版本</string>
<string name="euicc_info_sas_accreditation_number">SAS 认证号码</string>
<string name="euicc_info_pp_version">Protected Profile 版本</string>
<string name="euicc_info_free_nvram">NVRAM 剩余空间 (eSIM 存储容量)</string>
@ -140,8 +140,8 @@
<string name="euicc_info_ci_gsma_live">GSMA 生产环境 CI</string>
<string name="euicc_info_ci_gsma_test">GSMA 测试 CI</string>
<string name="euicc_info_ci_unknown">未知 eSIM CI</string>
<string name="yes"></string>
<string name="no"></string>
<string name="euicc_info_yes"></string>
<string name="euicc_info_no"></string>
<string name="developer_options_steps">还有 %d 步成为开发者</string>
<string name="developer_options_enabled">你现在是开发者了!</string>
<string name="pref_advanced_language">语言</string>
@ -152,7 +152,7 @@
<string name="pref_developer_unfiltered_profile_list_desc">在配置文件列表中包括非生产环境的配置文件</string>
<string name="pref_developer_ignore_tls_certificate">无视 SM-DP+ 的 TLS 证书</string>
<string name="pref_developer_ignore_tls_certificate_desc">允许 RSP 服务器使用任意证书</string>
<string name="information_unavailable">无信息</string>
<string name="euicc_info_unavailable">无信息</string>
<string name="toast_euicc_memory_reset_confirm_text_mismatched">输入的确认文本不匹配</string>
<string name="toast_euicc_memory_reset_finitshed">此芯片已被擦除</string>
<string name="task_euicc_memory_reset">正在擦除 eSIM 芯片</string>
@ -167,6 +167,6 @@
<string name="pref_developer_euicc_memory_reset_desc">此操作是默认隐藏的危险操作。作为替代方案,您可以手动删除所有配置文件。</string>
<string name="pref_developer_refresh_after_switch">向基带发送刷新命令</string>
<string name="pref_developer_isdr_aid_list">自定义 ISD-R AID 列表</string>
<string name="reset">重置</string>
<string name="isdr_aid_list_restore_defaults">重置</string>
<string name="isdr_aid_list">ISD-R AID 列表</string>
</resources>

View file

@ -2,9 +2,9 @@
<resources>
<string name="no_euicc">在此裝置上未檢測到此應用程式可訪問的可插拔 eUICC 卡。請插入相容卡或 USB 晶片讀卡機。</string>
<string name="no_profile">此 eSIM 上還沒有設定檔</string>
<string name="unknown">未知</string>
<string name="help">幫助</string>
<string name="reload">重新載入卡槽</string>
<string name="euicc_info_unknown">未知</string>
<string name="notification_help">幫助</string>
<string name="profile_reload_slots">重新載入卡槽</string>
<string name="channel_name_format">虛擬卡槽 %d</string>
<string name="profile_state_enabled">已啟用</string>
<string name="profile_state_disabled">已停用</string>
@ -132,7 +132,7 @@
<string name="euicc_info_removable">可插拔</string>
<string name="euicc_info_sgp22_version">SGP.22 版本</string>
<string name="euicc_info_firmware_version">eUICC OS 版本</string>
<string name="euicc_info_globalplatform_version">GlobalPlatform 版本</string>
<string name="euicc_info_gp_version">GlobalPlatform 版本</string>
<string name="euicc_info_sas_accreditation_number">SAS 認證號碼</string>
<string name="euicc_info_pp_version">Protected Profile 版本</string>
<string name="euicc_info_free_nvram">NVRAM 剩餘空間 (eSIM 儲存容量)</string>
@ -140,8 +140,8 @@
<string name="euicc_info_ci_gsma_live">GSMA 生產環境 CI</string>
<string name="euicc_info_ci_gsma_test">GSMA 測試 CI</string>
<string name="euicc_info_ci_unknown">未知 eSIM CI</string>
<string name="yes"></string>
<string name="no"></string>
<string name="euicc_info_yes"></string>
<string name="euicc_info_no"></string>
<string name="developer_options_steps">還有 %d 步成為開發者</string>
<string name="developer_options_enabled">您現在是開發者了!</string>
<string name="pref_advanced_language">語言</string>
@ -152,7 +152,7 @@
<string name="pref_developer_unfiltered_profile_list_desc">在設定檔列表中包括非生產環境的設定檔</string>
<string name="pref_developer_ignore_tls_certificate">忽略 SM-DP+ 的 TLS 證書</string>
<string name="pref_developer_ignore_tls_certificate_desc">允許 RSP 伺服器使用任意證書</string>
<string name="information_unavailable">無資訊</string>
<string name="euicc_info_unavailable">無資訊</string>
<string name="toast_euicc_memory_reset_confirm_text_mismatched">輸入的確認文字不匹配</string>
<string name="toast_euicc_memory_reset_finitshed">此晶片已被擦除</string>
<string name="task_euicc_memory_reset">正在擦除 eSIM 晶片</string>
@ -167,6 +167,6 @@
<string name="pref_developer_euicc_memory_reset_desc">此操作是預設隱藏的危險操作。作為替代方案,您可以手動刪除所有設定檔。</string>
<string name="pref_developer_refresh_after_switch">向基帶發送刷新命令</string>
<string name="pref_developer_isdr_aid_list">自訂 ISD-R AID 列表</string>
<string name="reset">重置</string>
<string name="isdr_aid_list_restore_defaults">重置</string>
<string name="isdr_aid_list">ISD-R AID 列表</string>
</resources>

View file

@ -2,14 +2,15 @@
<resources>
<string name="no_euicc">No removable eUICC card accessible by this app is detected on this device. Insert a compatible card or a USB reader.</string>
<string name="no_profile">No profiles (yet) on this eSIM.</string>
<string name="unknown">Unknown</string>
<string name="information_unavailable">Information Unavailable</string>
<string name="help">Help</string>
<string name="reload">Reload Slots</string>
<string name="notification_help">Help</string>
<string name="profile_reload_slots">Reload Slots</string>
<string name="profile_no_enabled_profile">Unknown</string>
<string name="channel_name_format">Logical Slot %d</string>
<string name="usb" translatable="false">USB</string>
<string name="omapi" translatable="false">OpenMobile API (OMAPI)</string>
<string name="channel_type_usb" translatable="false">USB</string>
<string name="channel_type_omapi" translatable="false">OpenMobile API (OMAPI)</string>
<!-- Profile -->
<string name="profile_state_enabled">Enabled</string>
@ -103,6 +104,26 @@
<string name="download_wizard_diagnostics_last_apdu_exception">Last APDU exception:</string>
<string name="download_wizard_diagnostics_save">Save</string>
<string name="download_wizard_diagnostics_file_template">Diagnostics at %s</string>
<string name="download_wizard_error_iccid_already">This eSIM profile is installed, Cannot be reinstalled.</string>
<string name="download_wizard_error_insufficient_memory">Sorry, The remaining capacity of this eSIM chip cannot be used to install this eSIM profile.</string>
<string name="download_wizard_error_unsupported_profile">Sorry, This eSIM profile is unsupported.</string>
<string name="download_wizard_error_card_internal_error">An error occurred inside the card.</string>
<string name="download_wizard_error_eid_mismatch">This eSIM profile has been installed on another device.</string>
<string name="download_wizard_error_profile_unreleased">This eSIM profile has been unreleased.</string>
<string name="download_wizard_error_matching_id_refused">This eSIM activation code is invalid.</string>
<string name="download_wizard_error_profile_retries_exceeded">The maximum number of retries for the eSIM profile has been exceeded.</string>
<string name="download_wizard_error_confirmation_code_missing">Please enter the confirmation code to continue.</string>
<string name="download_wizard_error_confirmation_code_refused">The confirmation code you entered is invalid.</string>
<string name="download_wizard_error_profile_expired">This eSIM profile has been expired.</string>
<string name="download_wizard_error_confirmation_code_retries_exceeded">The maximum number of retries for the Confirmation Code has been exceeded.</string>
<string name="download_wizard_error_unknown_hostname">Unknown SM-DP+ address</string>
<string name="download_wizard_error_network_unreachable">The current network is unreachable</string>
<string name="download_wizard_error_tls_certificate">TLS certificate error, this eSIM profile is not supported</string>
<string name="download_wizard_error_suggest_profile_installed">You are trying to reinstall an already installed eSIM profile</string>
<string name="download_wizard_error_suggest_insufficient_memory">Please delete an eSIM profile and try again</string>
<string name="download_wizard_error_suggest_contact_carrier">Please contact your carrier for assistance.</string>
<string name="download_wizard_error_suggest_contact_reissue">Please contact your carrier to reissue this eSIM profile.</string>
<string name="download_wizard_error_suggest_network_unreachable">The current network is unavailable. Please try again after changing the network.</string>
<string name="logs_saved_message">Logs have been saved to the selected path. Would you like to share the log through another app?</string>
@ -139,7 +160,7 @@
<string name="euicc_info_isdr_aid" translatable="false">ISD-R AID</string>
<string name="euicc_info_sgp22_version">SGP.22 Version</string>
<string name="euicc_info_firmware_version">eUICC OS Version</string>
<string name="euicc_info_globalplatform_version">GlobalPlatform Version</string>
<string name="euicc_info_gp_version">GlobalPlatform Version</string>
<string name="euicc_info_sas_accreditation_number">SAS Accreditation Number</string>
<string name="euicc_info_pp_version">Protected Profile Version</string>
<string name="euicc_info_free_nvram">Free NVRAM (eSIM profile storage)</string>
@ -156,8 +177,11 @@
<string name="euicc_memory_reset_confirm_text">I CONFIRM TO ERASE THE CHIP WHOSE EID ENDS WITH %s AND UNDERSTAND THAT THIS IS IRREVERSIBLE</string>
<string name="euicc_memory_reset_invoke_button">Erase</string>
<string name="yes">Yes</string>
<string name="no">No</string>
<!-- eUICC Info -->
<string name="euicc_info_yes">Yes</string>
<string name="euicc_info_no">No</string>
<string name="euicc_info_unknown">Unknown</string>
<string name="euicc_info_unavailable">Information Unavailable</string>
<string name="logs_save">Save</string>
<string name="logs_filename_template">Logs at %s</string>
@ -165,10 +189,9 @@
<string name="developer_options_steps">You are %d steps away from being a developer.</string>
<string name="developer_options_enabled">You are now a developer!</string>
<string name="reset">Reset</string>
<string name="isdr_aid_list">ISD-R AID List</string>
<string name="isdr_aid_list_saved">Saved custom ISD-R AID list.</string>
<string name="isdr_aid_list_restore_defaults">Reset</string>
<string name="pref_settings">Settings</string>
<string name="pref_notifications">Notifications</string>
@ -197,6 +220,16 @@
<string name="pref_developer_ignore_tls_certificate_desc">Accept any TLS certificate used by the RSP server</string>
<string name="pref_developer_euicc_memory_reset">Allow erasing eUICC</string>
<string name="pref_developer_euicc_memory_reset_desc">This is a dangerous operation and hidden by default. As an alternative, you can delete all profiles manually.</string>
<string name="pref_developer_es10x_mss">ES10x MSS</string>
<string name="pref_developer_es10x_mss_desc">Global ES10x MSS</string>
<string-array name="pref_developer_es10x_entry_keys">
<item>High Speed</item>
<item>Compatibility Mode</item>
</string-array>
<string-array name="pref_developer_es10x_entry_values" translatable="false">
<item>255</item>
<item>63</item>
</string-array>
<string name="pref_developer_isdr_aid_list">Customize ISD-R AID list</string>
<string name="pref_developer_isdr_aid_list_desc">Some brands of removable eUICCs may use their own non-standard ISD-R AID, rendering them inaccessible to third-party apps. We can attempt to use non-standard AIDs added in this list, but there is no guarantee that they will work.</string>
<string name="pref_info">Info</string>

View file

@ -81,6 +81,14 @@
app:summary="@string/pref_developer_euicc_memory_reset_desc"
app:title="@string/pref_developer_euicc_memory_reset" />
<ListPreference
app:iconSpaceReserved="false"
app:key="pref_developer_es10x_mss"
app:summary="@string/pref_developer_es10x_mss_desc"
app:title="@string/pref_developer_es10x_mss"
app:entries="@array/pref_developer_es10x_entry_keys"
app:entryValues="@array/pref_developer_es10x_entry_values" />
<Preference
app:iconSpaceReserved="false"
app:key="pref_developer_isdr_aid_list"
@ -96,12 +104,14 @@
<Preference
app:iconSpaceReserved="false"
app:title="@string/pref_info_app_version"
app:enableCopying="true"
app:key="pref_info_app_version" />
<Preference
app:iconSpaceReserved="false"
app:title="@string/pref_info_source_code"
app:summary="@string/pref_info_source_code_url"
app:enableCopying="true"
app:key="pref_info_source_code">
<intent
android:action="android.intent.action.VIEW"

View file

@ -27,6 +27,9 @@ android {
}
buildTypes {
defaultConfig {
versionNameSuffix = "-unpriv"
}
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")

View file

@ -1,3 +1,4 @@
import com.android.build.gradle.internal.api.ApkVariantOutputImpl
import im.angry.openeuicc.build.*
plugins {
@ -23,6 +24,9 @@ android {
}
buildTypes {
defaultConfig {
versionNameSuffix = "-priv"
}
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
@ -46,3 +50,62 @@ dependencies {
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}
val modulePropsTemplate = mutableMapOf(
"id" to android.defaultConfig.applicationId!!,
"name" to "OpenEUICC",
"version" to android.defaultConfig.versionName!!,
"versionCode" to "${android.defaultConfig.versionCode}",
"author" to "OpenEUICC authors",
"description" to "OpenEUICC is an open-source app that provides system-level eSIM integration."
)
val moduleCustomizeScript = project.file("magisk/customize.sh").readText()
.replace("{APK_NAME}", "OpenEUICC")
.replace("{PKG_NAME}", android.defaultConfig.applicationId!!)
val moduleUninstallScript = project.file("magisk/uninstall.sh").readText()
.replace("{PKG_NAME}", android.defaultConfig.applicationId!!)
tasks.register<MagiskModuleDirTask>("assembleDebugMagiskModuleDir") {
variant = "debug"
appName = "OpenEUICC"
permsFile = project.rootProject.file("privapp_whitelist_im.angry.openeuicc.xml")
moduleInstaller = project.file("magisk/module_installer.sh")
moduleCustomizeScriptText = moduleCustomizeScript
moduleUninstallScriptText = moduleUninstallScript
moduleProp = modulePropsTemplate.let {
it["description"] = "(debug build) ${it["description"]}"
it["versionCode"] = "${(android.applicationVariants.find { it.name == "debug" }!!.outputs.first() as ApkVariantOutputImpl).versionCodeOverride}"
it["updateJson"] = "https://openeuicc.com/magisk/magisk-debug.json"
it
}
dependsOn("assembleDebug")
}
tasks.register<Zip>("assembleDebugMagiskModule") {
dependsOn("assembleDebugMagiskModuleDir")
from((tasks.getByName("assembleDebugMagiskModuleDir") as MagiskModuleDirTask).outputDir)
archiveFileName = "magisk-debug.zip"
destinationDirectory = project.layout.buildDirectory.dir("magisk")
entryCompression = ZipEntryCompression.STORED
}
tasks.register<MagiskModuleDirTask>("assembleReleaseMagiskModuleDir") {
variant = "release"
appName = "OpenEUICC"
permsFile = project.rootProject.file("privapp_whitelist_im.angry.openeuicc.xml")
moduleInstaller = project.file("magisk/module_installer.sh")
moduleCustomizeScriptText = moduleCustomizeScript
moduleUninstallScriptText = moduleUninstallScript
moduleProp = modulePropsTemplate
dependsOn("assembleRelease")
}
tasks.register<Zip>("assembleReleaseMagiskModule") {
dependsOn("assembleReleaseMagiskModuleDir")
from((tasks.getByName("assembleReleaseMagiskModuleDir") as MagiskModuleDirTask).outputDir)
archiveFileName = "magisk-release.zip"
destinationDirectory = project.layout.buildDirectory.dir("magisk")
entryCompression = ZipEntryCompression.STORED
}

9
app/magisk/customize.sh Normal file
View file

@ -0,0 +1,9 @@
TMP_FILE="$TMPDIR/{APK_NAME}"
chmod u+x "$MODPATH/uninstall.sh"
cp "$MODPATH/system/system_ext/{APK_NAME}/{APK_NAME}.apk" "$TMP_FILE"
pm install -r "$TMP_FILE"
rm -f "$TMP_FILE"
pm grant "{PKG_NAME}" android.permission.READ_PHONE_STATE

View file

@ -0,0 +1,33 @@
#!/sbin/sh
#################
# Initialization
#################
umask 022
# echo before loading util_functions
ui_print() { echo "$1"; }
require_new_magisk() {
ui_print "*******************************"
ui_print " Please install Magisk v20.4+! "
ui_print "*******************************"
exit 1
}
#########################
# Load util_functions.sh
#########################
OUTFD=$2
ZIPFILE=$3
mount /data 2>/dev/null
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
. /data/adb/magisk/util_functions.sh
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
install_module
exit 0

1
app/magisk/uninstall.sh Normal file
View file

@ -0,0 +1 @@
pm uninstall "{PKG_NAME}"

View file

@ -2,7 +2,6 @@ package im.angry.openeuicc.core
import android.content.Context
import android.util.Log
import im.angry.openeuicc.OpenEuiccApplication
import im.angry.openeuicc.R
import im.angry.openeuicc.util.*
import kotlinx.coroutines.flow.first
@ -32,7 +31,7 @@ class PrivilegedEuiccChannelFactory(context: Context) : DefaultEuiccChannelFacto
)
try {
return EuiccChannelImpl(
context.getString(R.string.telephony_manager),
context.getString(R.string.channel_type_telephony_manager),
port,
intrinsicChannelName = null,
TelephonyManagerApduInterface(
@ -43,6 +42,7 @@ class PrivilegedEuiccChannelFactory(context: Context) : DefaultEuiccChannelFacto
isdrAid,
context.preferenceRepository.verboseLoggingFlow,
context.preferenceRepository.ignoreTLSCertificateFlow,
context.preferenceRepository.es10xMssFlow,
)
} catch (_: IllegalArgumentException) {
// Failed

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="no_euicc_priv">このデバイスで eUICC が見つかりません。\nデバイスによってはアプリのメニューからデュアル SIM を有効化する必要があります。</string>
<string name="telephony_manager">TelephonyManager (特権)</string>
<string name="channel_type_telephony_manager">TelephonyManager (特権)</string>
<string name="dsds">デュアル SIM</string>
<string name="toast_dsds_switched">DSDS の状態が切り替わりました。モデムが再起動するまでお待ちください。</string>
<string name="footer_mep">このスロットは MEP (Multiple Enabled Profiles) をサポートしています。この機能を有効化または無効化するには「スロットマッピングツール」を使用してください。</string>

View file

@ -16,7 +16,7 @@
<string name="lui_desc">您的设备支持 eSIM。要连接到移动网络请下载运营商发布的 eSIM或插入物理 SIM 卡。</string>
<string name="lui_skip">跳过</string>
<string name="lui_download">下载 eSIM</string>
<string name="telephony_manager">TelephonyManager (特权)</string>
<string name="channel_type_telephony_manager">TelephonyManager (特权)</string>
<string name="pref_developer_telephony_manager_removable">全局使用 TelephonyManager</string>
<string name="pref_developer_telephony_manager_removable_desc">在默认情况下,可移除 eUICC 将仅使用 OMAPI。这与非特权模式 (EasyEUICC) 一致。在某些设备上 OMAPI 可能存在问题 -- 选择此选项以强制使用 TelephonyManager。</string>
</resources>

View file

@ -16,7 +16,7 @@
<string name="lui_desc">您的裝置支援 eSIM。要連線到行動網路請下載電信業者釋出的 eSIM或插入實體 SIM 卡。</string>
<string name="lui_skip">跳過</string>
<string name="lui_download">下載 eSIM</string>
<string name="telephony_manager">TelephonyManager (特權)</string>
<string name="channel_type_telephony_manager">TelephonyManager (特權)</string>
<string name="pref_developer_telephony_manager_removable">全域使用 TelephonyManager</string>
<string name="pref_developer_telephony_manager_removable_desc">在預設情況下,可移除 eUICC 將僅使用 OMAPI。這與非特權模式 (EasyEUICC) 一致。在某些裝置上 OMAPI 可能有問題 -- 選擇此選項以強制使用 TelephonyManager。</string>
</resources>

View file

@ -1,7 +1,7 @@
<resources>
<string name="app_name" translatable="false">OpenEUICC</string>
<string name="no_euicc_priv">No eUICC found on this device.\nOn some devices, you may need to enable dual SIM first in the menu of this app.</string>
<string name="telephony_manager">TelephonyManager (Privileged)</string>
<string name="channel_type_telephony_manager">TelephonyManager (Privileged)</string>
<string name="dsds">Dual SIM</string>

View file

@ -0,0 +1,74 @@
package im.angry.openeuicc.build
import org.gradle.api.DefaultTask
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import java.io.File
abstract class MagiskModuleDirTask : DefaultTask() {
@get:Input
abstract val variant : Property<String>
@get:Input
abstract val appName : Property<String>
@get:InputFile
abstract val permsFile : Property<File>
@get:InputFile
abstract val moduleInstaller : Property<File>
@get:Input
abstract val moduleCustomizeScriptText : Property<String>
@get:Input
abstract val moduleUninstallScriptText : Property<String>
@get:Input
abstract val moduleProp : MapProperty<String, String>
@InputDirectory
val inputDir = variant.map { project.layout.buildDirectory.dir("outputs/apk/${it}") }
@OutputDirectory
val outputDir = variant.map { project.layout.buildDirectory.dir("magisk/${it}") }
@TaskAction
fun build() {
val dir = outputDir.get().get()
project.mkdir(dir)
val systemExtDir = dir.dir("system/system_ext")
val permDir = dir.dir("system/system_ext/etc/permissions")
val appDir = systemExtDir.dir("priv-app/${appName.get()}")
val metaInfDir = dir.dir("META-INF/com/google/android")
project.mkdir(systemExtDir)
project.mkdir(metaInfDir)
project.mkdir(appDir)
project.mkdir(permDir)
project.copy {
into(appDir)
from(inputDir) {
include("app-${variant.get()}.apk")
rename("app-${variant.get()}.apk", "${appName.get()}.apk")
}
}
project.copy {
from(permsFile)
into(permDir)
}
project.copy {
from(moduleInstaller)
into(metaInfDir)
rename(".*", "update-binary")
}
dir.file("customize.sh").asFile.writeText(moduleCustomizeScriptText.get())
dir.file("uninstall.sh").asFile.writeText(moduleUninstallScriptText.get())
metaInfDir.file("updater-script").asFile.writeText("# MAGISK")
dir.file("module.prop").asFile.writeText(moduleProp.get().map { (k, v) -> "$k=$v" }.joinToString("\n"))
}
}

View file

@ -16,7 +16,7 @@ val Project.gitVersionCode: Int
standardOutput = stdout
}
stdout.toString("utf-8").trim('\n').toInt()
} catch (e: Exception) {
} catch (_: Exception) {
0
}
@ -29,7 +29,7 @@ val Project.gitVersionName: String
standardOutput = stdout
}
stdout.toString("utf-8").trim('\n')
} catch (e: Exception) {
} catch (_: Exception) {
"Unknown"
}
@ -38,7 +38,7 @@ class MyVersioningPlugin: Plugin<Project> {
target.configure<BaseAppModuleExtension> {
defaultConfig {
versionCode = target.gitVersionCode
versionName = target.gitVersionName
versionName = target.gitVersionName.removePrefix("unpriv-")
}
applicationVariants.all {

View file

@ -2,3 +2,4 @@ APP_ABI := all
APP_SHORT_COMMANDS := true
APP_CFLAGS := -Wno-compound-token-split-by-macro
APP_LDFLAGS := -Wl,--build-id=none -z muldefs
APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true

View file

@ -1,4 +1,5 @@
LOCAL_PATH := $(call my-dir)
LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384"
# function to find all *.c files under a directory
define all-c-files-under