From 8b87e97f51aac4f0e78f2ff33aee0fb68f406902 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Tue, 8 Dec 2015 18:59:37 +0100 Subject: [PATCH] fix crash in FileUTils.copyURItoFile() if source and destination are the same file. This allows to install pbw files from the pbw-cache manually though a file manager. --- CHANGELOG.md | 1 + .../nodomain/freeyourgadget/gadgetbridge/util/FileUtils.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e23488e4..ffa253683 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Pebble: Support installing .pbl (language files) on firmware 3.x * Pebble: Correct setting the timezone on firmware 3.x (pebble expects the "ID" eg. Europe/Berlin) * Pebble: Show correct icon for activity tracker and watchfaces in app installer (language and fw icons still missing) +* Pebble: Fix crash when trying to install files though a file manager which are located inside the pbw-cache on firmware 3.x ####Version 0.6.8 * Mi Band support for Firmware upgrade/downgrade on Mi Band 1A (white LEDs, no heartrate sensor) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/FileUtils.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/FileUtils.java index 491646377..de9bc9dcd 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/FileUtils.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/FileUtils.java @@ -48,6 +48,10 @@ public class FileUtils { } public static void copyURItoFile(Context ctx, Uri uri, File destFile) throws IOException { + if (uri.getPath().equals(destFile.getPath())) { + return; + } + ContentResolver cr = ctx.getContentResolver(); InputStream fin; try {