mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 22:25:08 +00:00
Unify the check for NativeFileSystem support
This commit is contained in:
@@ -41,7 +41,7 @@ class SftpPlugin : Plugin(), OnSharedPreferenceChangeListener {
|
|||||||
override fun onCreate(): Boolean = true
|
override fun onCreate(): Boolean = true
|
||||||
|
|
||||||
override fun checkRequiredPermissions(): Boolean {
|
override fun checkRequiredPermissions(): Boolean {
|
||||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
return if (SimpleSftpServer.SUPPORTS_NATIVEFS) {
|
||||||
Environment.isExternalStorageManager()
|
Environment.isExternalStorageManager()
|
||||||
} else {
|
} else {
|
||||||
SftpSettingsFragment.getStorageInfoList(context, this).size != 0
|
SftpSettingsFragment.getStorageInfoList(context, this).size != 0
|
||||||
@@ -49,7 +49,7 @@ class SftpPlugin : Plugin(), OnSharedPreferenceChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val permissionExplanationDialog: AlertDialogFragment
|
override val permissionExplanationDialog: AlertDialogFragment
|
||||||
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
get() = if (SimpleSftpServer.SUPPORTS_NATIVEFS) {
|
||||||
StartActivityAlertDialogFragment.Builder()
|
StartActivityAlertDialogFragment.Builder()
|
||||||
.setTitle(displayName)
|
.setTitle(displayName)
|
||||||
.setMessage(R.string.sftp_manage_storage_permission_explanation)
|
.setMessage(R.string.sftp_manage_storage_permission_explanation)
|
||||||
@@ -90,7 +90,7 @@ class SftpPlugin : Plugin(), OnSharedPreferenceChangeListener {
|
|||||||
val paths = mutableListOf<String>()
|
val paths = mutableListOf<String>()
|
||||||
val pathNames = mutableListOf<String>()
|
val pathNames = mutableListOf<String>()
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (SimpleSftpServer.SUPPORTS_NATIVEFS) {
|
||||||
val volumes = context.getSystemService(
|
val volumes = context.getSystemService(
|
||||||
StorageManager::class.java
|
StorageManager::class.java
|
||||||
).storageVolumes
|
).storageVolumes
|
||||||
@@ -200,7 +200,7 @@ class SftpPlugin : Plugin(), OnSharedPreferenceChangeListener {
|
|||||||
|
|
||||||
override val outgoingPacketTypes: Array<String> = arrayOf(PACKET_TYPE_SFTP)
|
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
|
override fun supportsDeviceSpecificSettings(): Boolean = true
|
||||||
|
|
||||||
|
@@ -86,7 +86,7 @@ internal class SimpleSftpServer {
|
|||||||
fun initialize(context: Context, device: Device) {
|
fun initialize(context: Context, device: Device) {
|
||||||
val sshd = ServerBuilder.builder().apply {
|
val sshd = ServerBuilder.builder().apply {
|
||||||
fileSystemFactory(
|
fileSystemFactory(
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (SUPPORTS_NATIVEFS) {
|
||||||
NativeFileSystemFactory()
|
NativeFileSystemFactory()
|
||||||
} else {
|
} else {
|
||||||
safFileSystemFactory = SafFileSystemFactory(context)
|
safFileSystemFactory = SafFileSystemFactory(context)
|
||||||
@@ -262,6 +262,8 @@ internal class SimpleSftpServer {
|
|||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "SimpleSftpServer"
|
private const val TAG = "SimpleSftpServer"
|
||||||
|
|
||||||
|
val SUPPORTS_NATIVEFS = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
|
||||||
|
|
||||||
private val PORT_RANGE = 1739..1764
|
private val PORT_RANGE = 1739..1764
|
||||||
const val USER: String = "kdeconnect"
|
const val USER: String = "kdeconnect"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user