diff --git a/app-common/src/main/java/im/angry/openeuicc/service/EuiccChannelManagerService.kt b/app-common/src/main/java/im/angry/openeuicc/service/EuiccChannelManagerService.kt index 560ab67..9957f30 100644 --- a/app-common/src/main/java/im/angry/openeuicc/service/EuiccChannelManagerService.kt +++ b/app-common/src/main/java/im/angry/openeuicc/service/EuiccChannelManagerService.kt @@ -380,16 +380,6 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker { getString(R.string.task_profile_download_failure), R.drawable.ic_task_sim_card_download ) { - val callback = object : ProfileDownloadCallback { - override fun onStateUpdate(state: ProfileDownloadCallback.DownloadState) { - if (state.progress == 0) return - foregroundTaskState.value = ForegroundTaskState.InProgress(state.progress) - } - - override fun onProfileMetadata(metadata: ProfileDownloadCallback.ProfileMetadata) { - Log.d(TAG, "Received profile metadata: $metadata") - } - } euiccChannelManager.beginTrackedOperation(slotId, portId) { euiccChannelManager.withEuiccChannel(slotId, portId) { channel -> channel.lpa.downloadProfile( @@ -397,8 +387,13 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker { matchingId, imei, confirmationCode, - callback - ) + object : ProfileDownloadCallback { + override fun onStateUpdate(state: ProfileDownloadCallback.DownloadState) { + if (state.progress == 0) return + foregroundTaskState.value = + ForegroundTaskState.InProgress(state.progress) + } + }) } preferenceRepository.notificationDownloadFlow.first() diff --git a/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/ProfileDownloadCallback.kt b/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/ProfileDownloadCallback.kt index b50ec1a..6193a7a 100644 --- a/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/ProfileDownloadCallback.kt +++ b/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/ProfileDownloadCallback.kt @@ -1,7 +1,11 @@ package net.typeblog.lpac_jni +import android.util.Log + interface ProfileDownloadCallback { companion object { + private const val TAG = "ProfileDownloadCallback" + fun lookupStateFromProgress(progress: Int): DownloadState = when (progress) { 0 -> DownloadState.Preparing 20 -> DownloadState.Connecting @@ -31,5 +35,7 @@ interface ProfileDownloadCallback { fun onStateUpdate(state: DownloadState) - fun onProfileMetadata(metadata: ProfileMetadata) + fun onProfileMetadata(metadata: ProfileMetadata) { + Log.d(TAG, "Received profile metadata: $metadata") + } } \ No newline at end of file