Skip to content

Commit

Permalink
Tell Apache MINA SSHD that we are on Android
Browse files Browse the repository at this point in the history
There is code in MINA SSHD which uses the ReflectionException class,
which is not present on Android. This code is not supposed to be run on
Android, but the OsUtils.isAndroid() check apparently does not work.

Thankfully, there is a setAndroid() method.
  • Loading branch information
amberin committed Nov 28, 2023
1 parent cc3d2ed commit dd9e01c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
3 changes: 0 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,6 @@ dependencies {
// Git sync via SSH
implementation "org.eclipse.jgit:org.eclipse.jgit:$versions.jgit"
implementation "org.eclipse.jgit:org.eclipse.jgit.ssh.apache:$versions.jgit"
implementation("javax.management:jmx:$versions.javax_management") {
because 'Jgit uses ReflectionException'
}
implementation("androidx.security:security-crypto:$versions.security_crypto") {
because 'SSH key generation'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.orgzly.android.git
import android.os.Build
import androidx.annotation.RequiresApi
import com.orgzly.android.App
import org.apache.sshd.common.util.OsUtils
import org.eclipse.jgit.annotations.NonNull
import org.eclipse.jgit.api.TransportCommand
import org.eclipse.jgit.api.TransportConfigCallback
Expand Down Expand Up @@ -52,6 +53,8 @@ class GitSshKeyTransportSetter: GitTransportSetter {

// org.apache.sshd.common.config.keys.IdentityUtils freaks out if user.home is not set
System.setProperty("user.home", context.filesDir.toString())
// org.apache.sshd.common.util.OsUtils has trouble recognizing Android
OsUtils.setAndroid(true)

configCallback = TransportConfigCallback { transport: Transport ->
val sshTransport = transport as SshTransport
Expand All @@ -65,4 +68,4 @@ class GitSshKeyTransportSetter: GitTransportSetter {
return tc
}

}
}
7 changes: 0 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ buildscript {

versions.jgit = '6.7.0.202309050840-r'

versions.javax_management = '1.2.1'

versions.security_crypto = '1.1.0-alpha03'

versions.biometric_ktx = '1.2.0-alpha04'
Expand Down Expand Up @@ -100,11 +98,6 @@ allprojects {
maven {
url 'https://jitpack.io'
}

// For javax.management
maven {
url 'https://www.datanucleus.org/downloads/maven2/'
}
}

tasks.withType(JavaCompile) {
Expand Down

0 comments on commit dd9e01c

Please sign in to comment.