From aaa7d71ae3412991c8674c088983d848d7b5a2ff Mon Sep 17 00:00:00 2001 From: Ricki Hirner Date: Tue, 24 Nov 2015 17:59:47 +0100 Subject: [PATCH] Version bump to 0.9.1.2 * debug info: send report inline up to 8000 characters, as attachment otherwise * ical4android: fix bug which locally deleted tasks by mistake --- app/build.gradle | 4 +-- .../resource/DavResourceFinderTest.java | 13 ++++++++ .../syncadapter/DavResourceFinderTest.java | 33 ------------------- .../davdroid/ui/DebugInfoActivity.java | 33 ++++++++++++------- vcard4android | 2 +- 5 files changed, 38 insertions(+), 47 deletions(-) delete mode 100644 app/src/androidTest/java/at/bitfire/davdroid/syncadapter/DavResourceFinderTest.java diff --git a/app/build.gradle b/app/build.gradle index 0aa69323..ef3e8a7f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,8 +17,8 @@ android { minSdkVersion 14 targetSdkVersion 22 - versionCode 85 - versionName "0.9.1.1" + versionCode 86 + versionName "0.9.1.2" buildConfigField "java.util.Date", "buildTime", "new java.util.Date()" } diff --git a/app/src/androidTest/java/at/bitfire/davdroid/resource/DavResourceFinderTest.java b/app/src/androidTest/java/at/bitfire/davdroid/resource/DavResourceFinderTest.java index 5a9c4dcc..99105d44 100644 --- a/app/src/androidTest/java/at/bitfire/davdroid/resource/DavResourceFinderTest.java +++ b/app/src/androidTest/java/at/bitfire/davdroid/resource/DavResourceFinderTest.java @@ -34,6 +34,7 @@ public class DavResourceFinderTest extends InstrumentationTestCase { ServerInfo serverInfo = new ServerInfo(url.uri(), "admin", "12345", true); DavResourceFinder finder = new DavResourceFinder(Constants.log, getInstrumentation().getTargetContext().getApplicationContext(), serverInfo); + // positive test case server.enqueue(new MockResponse() .setResponseCode(207) .setHeader("Content-Type", "application/xml;charset=utf-8") @@ -50,6 +51,18 @@ public class DavResourceFinderTest extends InstrumentationTestCase { "")); HttpUrl principal = finder.getCurrentUserPrincipal(url); assertEquals(url.resolve("/principals/myself"), principal); + + // negative test case + server.enqueue(new MockResponse() + .setResponseCode(207) + .setHeader("Content-Type", "application/xml;charset=utf-8") + .setBody("" + + " " + + " /dav" + + " HTTP/1.0 200 OK" + + " " + + "")); + assertNull(finder.getCurrentUserPrincipal(url)); } } diff --git a/app/src/androidTest/java/at/bitfire/davdroid/syncadapter/DavResourceFinderTest.java b/app/src/androidTest/java/at/bitfire/davdroid/syncadapter/DavResourceFinderTest.java deleted file mode 100644 index ad68d229..00000000 --- a/app/src/androidTest/java/at/bitfire/davdroid/syncadapter/DavResourceFinderTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright © 2013 – 2015 Ricki Hirner (bitfire web engineering). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - */ - -package at.bitfire.davdroid.syncadapter; - -import junit.framework.TestCase; - -import java.io.IOException; - -import at.bitfire.davdroid.resource.DavResourceFinder; - -public class DavResourceFinderTest extends TestCase { - - DavResourceFinder finder; - - @Override - protected void setUp() { - } - - @Override - protected void tearDown() throws IOException { - } - - public void testFindResources() { - // TODO - } - -} diff --git a/app/src/main/java/at/bitfire/davdroid/ui/DebugInfoActivity.java b/app/src/main/java/at/bitfire/davdroid/ui/DebugInfoActivity.java index 3c48652a..41d8e779 100644 --- a/app/src/main/java/at/bitfire/davdroid/ui/DebugInfoActivity.java +++ b/app/src/main/java/at/bitfire/davdroid/ui/DebugInfoActivity.java @@ -49,6 +49,8 @@ public class DebugInfoActivity extends Activity implements LoaderManager.LoaderC KEY_AUTHORITY = "authority", KEY_PHASE = "phase"; + private static final int MAX_INLINE_REPORT_LENGTH = 8000; + TextView tvReport; String report; @@ -74,20 +76,29 @@ public class DebugInfoActivity extends Activity implements LoaderManager.LoaderC Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setType("text/plain"); - sendIntent.putExtra(Intent.EXTRA_SUBJECT, "DAVdroid Exception Details"); + sendIntent.putExtra(Intent.EXTRA_SUBJECT, "DAVdroid debug info"); - try { - File reportFile = File.createTempFile("davdroid-debug", ".txt", getExternalCacheDir()); - Constants.log.debug("Writing debug info to " + reportFile.getAbsolutePath()); - FileWriter writer = new FileWriter(reportFile); - writer.write(report); - writer.close(); + boolean inline = false; - sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(reportFile)); - } catch (IOException e) { - // let's hope the report is < 1 MB + if (report.length() > MAX_INLINE_REPORT_LENGTH) + // report is too long for inline text, send it as an attachment + try { + File reportFile = File.createTempFile("davdroid-debug", ".txt", getExternalCacheDir()); + Constants.log.debug("Writing debug info to " + reportFile.getAbsolutePath()); + FileWriter writer = new FileWriter(reportFile); + writer.write(report); + writer.close(); + + sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(reportFile)); + } catch (IOException e) { + // let's hope the report is < 1 MB (Android IPC limit) + inline = true; + } + else + inline = true; + + if (inline) sendIntent.putExtra(Intent.EXTRA_TEXT, report); - } startActivity(sendIntent); } diff --git a/vcard4android b/vcard4android index c59c7b4e..6e9ab868 160000 --- a/vcard4android +++ b/vcard4android @@ -1 +1 @@ -Subproject commit c59c7b4e65e431d7c3ca554cdab9b7ff065e914c +Subproject commit 6e9ab8680d27a9be7fb677c3b755c4550bc3e80a