From ef4b9c1680a04ab459567234d4873f2e86dfbefd Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 14 Apr 2018 11:11:30 +0200 Subject: [PATCH] Update CrashReporter. --- .idea/misc.xml | 2 +- .../client/crashreporter/CrashReporter.java | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 33952c6..503aca7 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -55,7 +55,7 @@ - + diff --git a/app/src/main/java/org/communiquons/android/comunic/client/crashreporter/CrashReporter.java b/app/src/main/java/org/communiquons/android/comunic/client/crashreporter/CrashReporter.java index f169213..6e5bc1e 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/crashreporter/CrashReporter.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/crashreporter/CrashReporter.java @@ -46,6 +46,14 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler { */ private static final int API_CONNEXION_TIMEOUT = 3000; + /** + * Enable server response reading (debug only) + * + * Note: On some situations, it might be also required to enable this option on production + * environment. + */ + private static final boolean API_READ_RESPONSE = true; + /** * Method used to connect to the api */ @@ -284,7 +292,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler { //Setup a few settings conn.setRequestMethod(API_CONNEXION_METHOD); conn.setDoOutput(true); - conn.setDoInput(false); + conn.setDoInput(API_READ_RESPONSE); conn.setConnectTimeout(API_CONNEXION_TIMEOUT); conn.setChunkedStreamingMode(0); @@ -299,6 +307,17 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler { writer.close(); os.close(); + //Read response if required + if(API_READ_RESPONSE){ + + //Read the response and return it immediately + InputStream is = conn.getInputStream(); + String response = readIs(is); + Log.v(TAG, "Server response:" + response); + is.close(); + } + + conn.disconnect(); //Success