From 7efb1f81b5d2cf988a2450b95edc3517b52e51b5 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Tue, 4 Apr 2023 22:27:56 +0000 Subject: [PATCH] Switch desugaring lib to desugar_jdk_libs_nio Enables desugaring of the `Files` class, which is otherwise only available on API 26+. --- build.gradle | 4 ++-- .../SharePlugin/CompositeReceiveFileJob.java | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 0ecfe361..f2ab0ed3 100644 --- a/build.gradle +++ b/build.gradle @@ -136,7 +136,7 @@ ext { } dependencies { - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.2' + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.0.3' implementation 'androidx.media:media:1.6.0' implementation 'androidx.appcompat:appcompat:1.6.1' @@ -155,7 +155,7 @@ dependencies { implementation 'com.jaredrummler:android-device-names:1.1.9' //To get a human-friendly device name implementation 'org.apache.sshd:sshd-core:0.14.0' - implementation 'org.apache.mina:mina-core:2.0.19' //For some reason, makes sshd-core:0.14.0 work without NIO, which isn't available until Android 8 (api 26) + implementation 'org.apache.mina:mina-core:2.0.19' // Desugar does not backport AsynchronousSocketChannel. //implementation('com.github.bright:slf4android:0.1.6') { transitive = true } // For org.apache.sshd debugging implementation 'org.bouncycastle:bcpkix-jdk15on:1.70' //For SSL certificate generation diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeReceiveFileJob.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeReceiveFileJob.java index 3b068036..f4e5c782 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeReceiveFileJob.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeReceiveFileJob.java @@ -165,15 +165,13 @@ public class CompositeReceiveFileJob extends BackgroundJob { publishFile(fileDocument, 0); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - if (currentNetworkPacket.has("lastModified")) { - try { - long lastModified = currentNetworkPacket.getLong("lastModified"); - Files.setLastModifiedTime(Paths.get(fileDocument.getUri().getPath()), FileTime.fromMillis(lastModified)); - } catch (Exception e) { - Log.e("SharePlugin", "Can't set date on file"); - e.printStackTrace(); - } + if (currentNetworkPacket.has("lastModified")) { + try { + long lastModified = currentNetworkPacket.getLong("lastModified"); + Files.setLastModifiedTime(Paths.get(fileDocument.getUri().getPath()), FileTime.fromMillis(lastModified)); + } catch (Exception e) { + Log.e("SharePlugin", "Can't set date on file"); + e.printStackTrace(); } }