2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-22 18:07:55 +00:00

fix: use Apache MINA as IO Service of SSHD Core to fix issues when Android SDK < 26 (Android 8.0)

NIO2 is the default IO Service of SSHD Core. But when Android SDK < 26, NIO2 doesn't exists. So we have to use Apache MINA as IO Service to fix this issue.
This commit is contained in:
ShellWen Chen 2024-06-15 02:41:36 +08:00 committed by Albert Vaca Cintora
parent aaa750bbc6
commit cd8237d773
3 changed files with 6 additions and 0 deletions

View File

@ -295,6 +295,7 @@ dependencies {
implementation(libs.apache.sshd.core)
implementation(libs.apache.sshd.sftp)
implementation(libs.apache.sshd.scp)
implementation(libs.apache.sshd.mina)
implementation(libs.apache.mina.core) //For some reason, makes sshd-core:0.14.0 work without NIO, which isn't available until Android 8 (api 26)
//implementation("com.github.bright:slf4android:0.1.6") { transitive = true } // For org.apache.sshd debugging

View File

@ -76,6 +76,7 @@ apache-mina-core = { module = "org.apache.mina:mina-core", version.ref = "minaCo
apache-sshd-core = { module = "org.apache.sshd:sshd-core", version.ref = "sshdCore" }
apache-sshd-sftp = { module = "org.apache.sshd:sshd-sftp", version.ref = "sshdCore" }
apache-sshd-scp = { module = "org.apache.sshd:sshd-scp", version.ref = "sshdCore" }
apache-sshd-mina = { module = "org.apache.sshd:sshd-mina", version.ref = "sshdCore" }
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockitoCore" }
reactive-streams = { module = "org.reactivestreams:reactive-streams", version.ref = "reactiveStreams" }
rxjava = { module = "io.reactivex.rxjava2:rxjava", version.ref = "rxjava" }

View File

@ -189,6 +189,10 @@ internal class SimpleSftpServer {
init {
System.setProperty(SECURITY_PROVIDER_REGISTRARS, "") // disable BouncyCastle
System.setProperty(
"org.apache.sshd.common.io.IoServiceFactoryFactory",
"org.apache.sshd.mina.MinaServiceFactoryFactory"
) // Use MINA instead NIO2 due to compatibility issues
PathUtils.setUserHomeFolderResolver { Path.of("/") } // TODO: Remove it when SSHD Core is fixed
}
}