Fix missing api version check for usb/ip
This commit is contained in:
@@ -169,23 +169,6 @@ interface PlatformInterfaceWrapper : PlatformInterface {
|
||||
|
||||
override fun localDNSTransport(): LocalDNSTransport? = LocalResolver
|
||||
|
||||
@OptIn(ExperimentalEncodingApi::class)
|
||||
override fun systemCertificates(): StringIterator {
|
||||
val certificates = mutableListOf<String>()
|
||||
val keyStore = KeyStore.getInstance("AndroidCAStore")
|
||||
if (keyStore != null) {
|
||||
keyStore.load(null, null)
|
||||
val aliases = keyStore.aliases()
|
||||
while (aliases.hasMoreElements()) {
|
||||
val cert = keyStore.getCertificate(aliases.nextElement())
|
||||
certificates.add(
|
||||
"-----BEGIN CERTIFICATE-----\n" + Base64.encode(cert.encoded) + "\n-----END CERTIFICATE-----",
|
||||
)
|
||||
}
|
||||
}
|
||||
return StringArray(certificates.iterator())
|
||||
}
|
||||
|
||||
override fun startNeighborMonitor(listener: NeighborUpdateListener?) {
|
||||
if (listener == null) return
|
||||
val callback = object : INeighborTableCallback.Stub() {
|
||||
|
||||
@@ -52,6 +52,10 @@ data class USBIPStatusState(
|
||||
)
|
||||
|
||||
class USBIPStatusViewModel : BaseViewModel<USBIPStatusState, Nothing>() {
|
||||
companion object {
|
||||
private const val MIN_API_VERSION_USBIP = 2
|
||||
}
|
||||
|
||||
private var subscription: USBIPServerStatusSubscription? = null
|
||||
|
||||
override fun createInitialState() = USBIPStatusState()
|
||||
@@ -62,8 +66,16 @@ class USBIPStatusViewModel : BaseViewModel<USBIPStatusState, Nothing>() {
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
val client = CommandTarget.standaloneClient()
|
||||
if (client.getAPIVersion() < MIN_API_VERSION_USBIP) {
|
||||
viewModelScope.launch {
|
||||
updateState { copy(servers = emptyList(), isSubscribed = false) }
|
||||
subscription = null
|
||||
}
|
||||
return@launch
|
||||
}
|
||||
subscription =
|
||||
CommandTarget.standaloneClient().subscribeUSBIPServerStatus(
|
||||
client.subscribeUSBIPServerStatus(
|
||||
object : USBIPServerStatusHandler {
|
||||
override fun onStatusUpdate(status: USBIPServerStatusUpdate) {
|
||||
val servers = convertUpdate(status)
|
||||
|
||||
Reference in New Issue
Block a user