|
@@ -3,17 +3,22 @@ package im.angry.openeuicc.service
|
|
|
import android.service.euicc.*
|
|
import android.service.euicc.*
|
|
|
import android.telephony.euicc.DownloadableSubscription
|
|
import android.telephony.euicc.DownloadableSubscription
|
|
|
import android.telephony.euicc.EuiccInfo
|
|
import android.telephony.euicc.EuiccInfo
|
|
|
-import com.truphone.lpa.LocalProfileAssistant
|
|
|
|
|
import com.truphone.lpa.LocalProfileInfo
|
|
import com.truphone.lpa.LocalProfileInfo
|
|
|
|
|
+import com.truphone.util.TextUtil
|
|
|
import im.angry.openeuicc.OpenEuiccApplication
|
|
import im.angry.openeuicc.OpenEuiccApplication
|
|
|
|
|
+import im.angry.openeuicc.core.EuiccChannel
|
|
|
|
|
+import im.angry.openeuicc.util.*
|
|
|
|
|
|
|
|
class OpenEuiccService : EuiccService() {
|
|
class OpenEuiccService : EuiccService() {
|
|
|
- private fun findLpa(slotId: Int): LocalProfileAssistant? =
|
|
|
|
|
- (application as OpenEuiccApplication).euiccChannelManager
|
|
|
|
|
- .findEuiccChannelBySlotBlocking(slotId)?.lpa
|
|
|
|
|
|
|
+ private val openEuiccApplication
|
|
|
|
|
+ get() = application as OpenEuiccApplication
|
|
|
|
|
+
|
|
|
|
|
+ private fun findChannel(slotId: Int): EuiccChannel? =
|
|
|
|
|
+ openEuiccApplication.euiccChannelManager
|
|
|
|
|
+ .findEuiccChannelBySlotBlocking(slotId)
|
|
|
|
|
|
|
|
override fun onGetEid(slotId: Int): String? =
|
|
override fun onGetEid(slotId: Int): String? =
|
|
|
- findLpa(slotId)?.eid
|
|
|
|
|
|
|
+ findChannel(slotId)?.lpa?.eid
|
|
|
|
|
|
|
|
override fun onGetOtaStatus(slotId: Int): Int {
|
|
override fun onGetOtaStatus(slotId: Int): Int {
|
|
|
// Not implemented
|
|
// Not implemented
|
|
@@ -46,7 +51,7 @@ class OpenEuiccService : EuiccService() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override fun onGetEuiccProfileInfoList(slotId: Int): GetEuiccProfileInfoListResult? {
|
|
override fun onGetEuiccProfileInfoList(slotId: Int): GetEuiccProfileInfoListResult? {
|
|
|
- val profiles = (findLpa(slotId) ?: return null).profiles.filter {
|
|
|
|
|
|
|
+ val profiles = (findChannel(slotId) ?: return null).lpa.profiles.filter {
|
|
|
it.profileClass != LocalProfileInfo.Clazz.Testing
|
|
it.profileClass != LocalProfileInfo.Clazz.Testing
|
|
|
}.map {
|
|
}.map {
|
|
|
EuiccProfileInfo.Builder(it.iccidLittleEndian).apply {
|
|
EuiccProfileInfo.Builder(it.iccidLittleEndian).apply {
|
|
@@ -89,8 +94,16 @@ class OpenEuiccService : EuiccService() {
|
|
|
TODO("Not yet implemented")
|
|
TODO("Not yet implemented")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- override fun onUpdateSubscriptionNickname(slotId: Int, iccid: String?, nickname: String?): Int {
|
|
|
|
|
- TODO("Not yet implemented")
|
|
|
|
|
|
|
+ override fun onUpdateSubscriptionNickname(slotId: Int, iccid: String, nickname: String?): Int {
|
|
|
|
|
+ val channel = findChannel(slotId) ?: return RESULT_FIRST_USER
|
|
|
|
|
+ val success = channel.lpa
|
|
|
|
|
+ .setNickname(TextUtil.iccidLittleToBig(iccid), nickname)
|
|
|
|
|
+ openEuiccApplication.subscriptionManager.tryRefreshCachedEuiccInfo(channel.cardId)
|
|
|
|
|
+ return if (success) {
|
|
|
|
|
+ RESULT_OK
|
|
|
|
|
+ } else {
|
|
|
|
|
+ RESULT_FIRST_USER
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Deprecated("Deprecated in Java")
|
|
@Deprecated("Deprecated in Java")
|