Update CrashReporter.

This commit is contained in:
Pierre 2018-04-14 11:11:30 +02:00
parent d665be6138
commit ef4b9c1680
2 changed files with 21 additions and 2 deletions

View File

@ -55,7 +55,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -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