fix usb driver
This commit is contained in:
parent
377e101057
commit
59d6a8f8ea
3 changed files with 14 additions and 6 deletions
8
.idea/deploymentTargetSelector.xml
generated
8
.idea/deploymentTargetSelector.xml
generated
|
@ -4,6 +4,14 @@
|
|||
<selectionStates>
|
||||
<SelectionState runConfigName="app-unpriv">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2025-02-26T05:33:18.646829Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=44161JEKB15351" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
|
|
|
@ -8,7 +8,7 @@ import android.se.omapi.SEService
|
|||
import android.util.Log
|
||||
import im.angry.openeuicc.common.R
|
||||
import im.angry.openeuicc.core.usb.UsbApduInterface
|
||||
import im.angry.openeuicc.core.usb.getIoEndpoints
|
||||
import im.angry.openeuicc.core.usb.getBulkEndpoints
|
||||
import im.angry.openeuicc.util.*
|
||||
import java.lang.IllegalArgumentException
|
||||
|
||||
|
@ -61,7 +61,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
|
|||
}
|
||||
|
||||
override fun tryOpenUsbEuiccChannel(usbDevice: UsbDevice, usbInterface: UsbInterface): EuiccChannel? {
|
||||
val (bulkIn, bulkOut) = usbInterface.getIoEndpoints()
|
||||
val (bulkIn, bulkOut) = usbInterface.getBulkEndpoints()
|
||||
if (bulkIn == null || bulkOut == null) return null
|
||||
val conn = usbManager.openDevice(usbDevice) ?: return null
|
||||
if (!conn.claimInterface(usbInterface, true)) return null
|
||||
|
|
|
@ -14,14 +14,14 @@ val UsbDevice.interfaces: Iterable<UsbInterface>
|
|||
val UsbInterface.endpoints: Iterable<UsbEndpoint>
|
||||
get() = (0 until endpointCount).map(::getEndpoint)
|
||||
|
||||
fun UsbInterface.getIoEndpoints(): Pair<UsbEndpoint?, UsbEndpoint?> {
|
||||
fun UsbInterface.getBulkEndpoints(): Pair<UsbEndpoint?, UsbEndpoint?> {
|
||||
val endpoints = endpoints
|
||||
.filter { it.type == UsbConstants.USB_ENDPOINT_XFER_BULK }
|
||||
return Pair(
|
||||
endpoints.first { it.direction == UsbConstants.USB_DIR_IN },
|
||||
endpoints.first { it.direction == UsbConstants.USB_DIR_OUT },
|
||||
endpoints.find { it.direction == UsbConstants.USB_DIR_IN },
|
||||
endpoints.find { it.direction == UsbConstants.USB_DIR_OUT },
|
||||
)
|
||||
}
|
||||
|
||||
fun UsbDevice.getSmartCardInterface() =
|
||||
interfaces.first { it.interfaceClass == UsbConstants.USB_CLASS_CSCID }
|
||||
interfaces.find { it.interfaceClass == UsbConstants.USB_CLASS_CSCID }
|
Loading…
Add table
Reference in a new issue