From c7c3db478ad7212d3b66cf83c702cd60004ff53a Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Thu, 24 Jul 2014 12:33:56 +0200 Subject: [PATCH] included version string in crash reports --- .../conversations/utils/ExceptionHelper.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/eu/siacs/conversations/utils/ExceptionHelper.java b/src/eu/siacs/conversations/utils/ExceptionHelper.java index 05b16240b..373aadd3e 100644 --- a/src/eu/siacs/conversations/utils/ExceptionHelper.java +++ b/src/eu/siacs/conversations/utils/ExceptionHelper.java @@ -17,7 +17,11 @@ import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.content.DialogInterface.OnClickListener; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; import android.preference.PreferenceManager; +import android.text.format.DateUtils; import android.util.Log; public class ExceptionHelper { @@ -49,13 +53,20 @@ public class ExceptionHelper { FileInputStream file = context.openFileInput("stacktrace.txt"); InputStreamReader inputStreamReader = new InputStreamReader( file); - BufferedReader bufferedReader = new BufferedReader( + BufferedReader stacktrace = new BufferedReader( inputStreamReader); - final StringBuilder stacktrace = new StringBuilder(); + final StringBuilder report = new StringBuilder(); + PackageManager pm = context.getPackageManager(); + PackageInfo packageInfo = null; + try { + packageInfo = pm.getPackageInfo(context.getPackageName(), 0); + report.append("Version: "+packageInfo.versionName+'\n'); + report.append("Last Update: "+DateUtils.formatDateTime(context, packageInfo.lastUpdateTime, DateUtils.FORMAT_SHOW_TIME|DateUtils.FORMAT_SHOW_DATE)+'\n'); + } catch (NameNotFoundException e) {} String line; - while((line = bufferedReader.readLine()) != null) { - stacktrace.append(line); - stacktrace.append('\n'); + while((line = stacktrace.readLine()) != null) { + report.append(line); + report.append('\n'); } file.close(); context.deleteFile("stacktrace.txt"); @@ -69,7 +80,7 @@ public class ExceptionHelper { Log.d("xmppService","using account="+finalAccount.getJid()+" to send in stack trace"); Conversation conversation = service.findOrCreateConversation(finalAccount, "bugs@siacs.eu", false); - Message message = new Message(conversation, stacktrace.toString(), Message.ENCRYPTION_NONE); + Message message = new Message(conversation, report.toString(), Message.ENCRYPTION_NONE); service.sendMessage(message); } });