2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 05:37:43 +00:00

Unify the check for NativeFileSystem support

This commit is contained in:
Albert Vaca Cintora 2024-08-31 19:51:32 +02:00
parent 0f7af315f5
commit 3f53180b1d
No known key found for this signature in database
2 changed files with 7 additions and 5 deletions

View File

@ -41,7 +41,7 @@ class SftpPlugin : Plugin(), OnSharedPreferenceChangeListener {
override fun onCreate(): Boolean = true
override fun checkRequiredPermissions(): Boolean {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
return if (SimpleSftpServer.SUPPORTS_NATIVEFS) {
Environment.isExternalStorageManager()
} else {
SftpSettingsFragment.getStorageInfoList(context, this).size != 0
@ -49,7 +49,7 @@ class SftpPlugin : Plugin(), OnSharedPreferenceChangeListener {
}
override val permissionExplanationDialog: AlertDialogFragment
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
get() = if (SimpleSftpServer.SUPPORTS_NATIVEFS) {
StartActivityAlertDialogFragment.Builder()
.setTitle(displayName)
.setMessage(R.string.sftp_manage_storage_permission_explanation)
@ -90,7 +90,7 @@ class SftpPlugin : Plugin(), OnSharedPreferenceChangeListener {
val paths = mutableListOf<String>()
val pathNames = mutableListOf<String>()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (SimpleSftpServer.SUPPORTS_NATIVEFS) {
val volumes = context.getSystemService(
StorageManager::class.java
).storageVolumes
@ -200,7 +200,7 @@ class SftpPlugin : Plugin(), OnSharedPreferenceChangeListener {
override val outgoingPacketTypes: Array<String> = arrayOf(PACKET_TYPE_SFTP)
override fun hasSettings(): Boolean = Build.VERSION.SDK_INT < Build.VERSION_CODES.R
override fun hasSettings(): Boolean = !SimpleSftpServer.SUPPORTS_NATIVEFS
override fun supportsDeviceSpecificSettings(): Boolean = true

View File

@ -86,7 +86,7 @@ internal class SimpleSftpServer {
fun initialize(context: Context, device: Device) {
val sshd = ServerBuilder.builder().apply {
fileSystemFactory(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (SUPPORTS_NATIVEFS) {
NativeFileSystemFactory()
} else {
safFileSystemFactory = SafFileSystemFactory(context)
@ -262,6 +262,8 @@ internal class SimpleSftpServer {
companion object {
private const val TAG = "SimpleSftpServer"
val SUPPORTS_NATIVEFS = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
private val PORT_RANGE = 1739..1764
const val USER: String = "kdeconnect"