Browse Source

Expose USB device name as intrinsic name for use with download wizard

Peter Cai 1 year ago
parent
commit
815d4d4324

+ 2 - 0
app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt

@@ -37,6 +37,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
             return EuiccChannelImpl(
             return EuiccChannelImpl(
                 context.getString(R.string.omapi),
                 context.getString(R.string.omapi),
                 port,
                 port,
+                intrinsicChannelName = null,
                 OmapiApduInterface(
                 OmapiApduInterface(
                     seService!!,
                     seService!!,
                     port,
                     port,
@@ -67,6 +68,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
         return EuiccChannelImpl(
         return EuiccChannelImpl(
             context.getString(R.string.usb),
             context.getString(R.string.usb),
             FakeUiccPortInfoCompat(FakeUiccCardInfoCompat(EuiccChannelManager.USB_CHANNEL_ID)),
             FakeUiccPortInfoCompat(FakeUiccCardInfoCompat(EuiccChannelManager.USB_CHANNEL_ID)),
+            intrinsicChannelName = usbDevice.productName,
             UsbApduInterface(
             UsbApduInterface(
                 conn,
                 conn,
                 bulkIn,
                 bulkIn,

+ 7 - 0
app-common/src/main/java/im/angry/openeuicc/core/EuiccChannel.kt

@@ -16,5 +16,12 @@ interface EuiccChannel {
 
 
     val valid: Boolean
     val valid: Boolean
 
 
+    /**
+     * Intrinsic name of this channel. For device-internal SIM slots,
+     * this should be null; for USB readers, this should be the name of
+     * the reader device.
+     */
+    val intrinsicChannelName: String?
+
     fun close()
     fun close()
 }
 }

+ 1 - 0
app-common/src/main/java/im/angry/openeuicc/core/EuiccChannelImpl.kt

@@ -10,6 +10,7 @@ import net.typeblog.lpac_jni.impl.LocalProfileAssistantImpl
 class EuiccChannelImpl(
 class EuiccChannelImpl(
     override val type: String,
     override val type: String,
     override val port: UiccPortInfoCompat,
     override val port: UiccPortInfoCompat,
+    override val intrinsicChannelName: String?,
     apduInterface: ApduInterface,
     apduInterface: ApduInterface,
     verboseLoggingFlow: Flow<Boolean>,
     verboseLoggingFlow: Flow<Boolean>,
     ignoreTLSCertificateFlow: Flow<Boolean>
     ignoreTLSCertificateFlow: Flow<Boolean>

+ 2 - 0
app-common/src/main/java/im/angry/openeuicc/core/EuiccChannelWrapper.kt

@@ -31,6 +31,8 @@ class EuiccChannelWrapper(orig: EuiccChannel) : EuiccChannel {
     override val lpa: LocalProfileAssistant by lpaDelegate
     override val lpa: LocalProfileAssistant by lpaDelegate
     override val valid: Boolean
     override val valid: Boolean
         get() = channel.valid
         get() = channel.valid
+    override val intrinsicChannelName: String?
+        get() = channel.intrinsicChannelName
 
 
     override fun close() = channel.close()
     override fun close() = channel.close()
 
 

+ 5 - 3
app-common/src/main/java/im/angry/openeuicc/ui/wizard/DownloadWizardSlotSelectFragment.kt

@@ -35,7 +35,8 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
         val eID: String,
         val eID: String,
         val freeSpace: Int,
         val freeSpace: Int,
         val imei: String,
         val imei: String,
-        val enabledProfileName: String?
+        val enabledProfileName: String?,
+        val intrinsicChannelName: String?,
     )
     )
 
 
     private var loaded = false
     private var loaded = false
@@ -106,7 +107,8 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
                     } catch (e: Exception) {
                     } catch (e: Exception) {
                         ""
                         ""
                     },
                     },
-                    channel.lpa.profiles.find { it.state == LocalProfileInfo.State.Enabled }?.displayName
+                    channel.lpa.profiles.find { it.state == LocalProfileInfo.State.Enabled }?.displayName,
+                    channel.intrinsicChannelName,
                 )
                 )
             }
             }
         }.toList().sortedBy { it.logicalSlotId }
         }.toList().sortedBy { it.logicalSlotId }
@@ -177,7 +179,7 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
             }
             }
 
 
             title.text = if (item.logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
             title.text = if (item.logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
-                root.context.getString(R.string.usb)
+                item.intrinsicChannelName ?: root.context.getString(R.string.usb)
             } else {
             } else {
                 appContainer.customizableTextProvider.formatInternalChannelName(item.logicalSlotId)
                 appContainer.customizableTextProvider.formatInternalChannelName(item.logicalSlotId)
             }
             }

+ 1 - 0
app/src/main/java/im/angry/openeuicc/core/PrivilegedEuiccChannelFactory.kt

@@ -30,6 +30,7 @@ class PrivilegedEuiccChannelFactory(context: Context) : DefaultEuiccChannelFacto
                 return EuiccChannelImpl(
                 return EuiccChannelImpl(
                     context.getString(R.string.telephony_manager),
                     context.getString(R.string.telephony_manager),
                     port,
                     port,
+                    intrinsicChannelName = null,
                     TelephonyManagerApduInterface(
                     TelephonyManagerApduInterface(
                         port,
                         port,
                         tm,
                         tm,