mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 13:47:41 +00:00
Use IOUtils.close().
This commit is contained in:
committed by
Nicolas Fella
parent
1c416852e2
commit
06aac453ea
@@ -33,6 +33,7 @@ import android.os.Build;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.kde.kdeconnect.Backends.BaseLinkProvider;
|
import org.kde.kdeconnect.Backends.BaseLinkProvider;
|
||||||
import org.kde.kdeconnect.Device;
|
import org.kde.kdeconnect.Device;
|
||||||
import org.kde.kdeconnect.NetworkPacket;
|
import org.kde.kdeconnect.NetworkPacket;
|
||||||
@@ -230,7 +231,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
synchronized (sockets) {
|
synchronized (sockets) {
|
||||||
sockets.remove(socket.getRemoteDevice());
|
sockets.remove(socket.getRemoteDevice());
|
||||||
if (connection != null) connection.close();
|
IOUtils.close(connection);
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ package org.kde.kdeconnect;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@@ -361,9 +362,7 @@ public class NetworkPacket {
|
|||||||
public void close() {
|
public void close() {
|
||||||
//TODO: If socket only close socket if that also closes the streams that is
|
//TODO: If socket only close socket if that also closes the streams that is
|
||||||
try {
|
try {
|
||||||
if (inputStream != null) {
|
IOUtils.close(inputStream);
|
||||||
inputStream.close();
|
|
||||||
}
|
|
||||||
} catch(IOException ignored) {}
|
} catch(IOException ignored) {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@@ -32,6 +32,7 @@ import androidx.core.content.ContextCompat;
|
|||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
import androidx.documentfile.provider.DocumentFile;
|
import androidx.documentfile.provider.DocumentFile;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.kde.kdeconnect.Device;
|
import org.kde.kdeconnect.Device;
|
||||||
import org.kde.kdeconnect.Helpers.FilesHelper;
|
import org.kde.kdeconnect.Helpers.FilesHelper;
|
||||||
import org.kde.kdeconnect.Helpers.MediaStoreHelper;
|
import org.kde.kdeconnect.Helpers.MediaStoreHelper;
|
||||||
@@ -244,10 +245,9 @@ public class CompositeReceiveFileJob extends BackgroundJob<Device, Void> {
|
|||||||
} finally {
|
} finally {
|
||||||
closeAllInputStreams();
|
closeAllInputStreams();
|
||||||
networkPacketList.clear();
|
networkPacketList.clear();
|
||||||
if (outputStream != null) {
|
try {
|
||||||
try {
|
IOUtils.close(outputStream);
|
||||||
outputStream.close();
|
} catch (IOException ignored) {
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user