diff --git a/ExceptionHandlerLib/.gitignore b/ExceptionHandlerLib/.gitignore new file mode 100644 index 0000000..a02fbbe --- /dev/null +++ b/ExceptionHandlerLib/.gitignore @@ -0,0 +1,2 @@ +/gen +/bin diff --git a/ExceptionHandlerLib/exceptionhandler.properties b/ExceptionHandlerLib/exceptionhandler.properties index 07e821f..21d1215 100644 --- a/ExceptionHandlerLib/exceptionhandler.properties +++ b/ExceptionHandlerLib/exceptionhandler.properties @@ -1,19 +1,22 @@ # exceptionhandler.properties -# This is the default Twenty Codes, LLC Exception Handler properties file -# -# This file must be included in the main project's assets folder -# -# @author Twenty Codes, LLC -# @author ricky barrette +# @author ricky barrette +# @author twenty codes - -# The following is for using our custom server based exception handler web application +# This file is used to tell the Exception Handler LIbrary how to file +# new exception reports +# HTTP ONLY +# +# Place this file in you project's assets folder and edit as needed +# # server is the physical web address for your server # file is the path to your filing script # get is the path to your json retrieval script -server = http://powers.doesntexist.com:666/testing -file = /index.php?post=1 -#get = /index.php?get=1 +# app is the redmine project name +# tracker is the redmine tracker +server = http://rickbarrette.dyndns.org:8080/ +file = redmine/exceptionhandler +app = test +tracker = Bug # uncomment the following if you want your application to use email to file reports. # if this is uncommented, email will always be used. diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionHandler.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionHandler.java index b2fb251..17739ea 100644 --- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionHandler.java +++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionHandler.java @@ -49,6 +49,8 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable { private static final String TAG = "ExceptionHandler"; private String mURL = null; private String mEmail; + private String mAppName; + private String mTracker; /** * Creates a new ExceptionHandler @@ -143,6 +145,8 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable { properties.load(inputStream); this.mURL = properties.getProperty("server") + properties.getProperty("file"); this.mEmail = properties.getProperty("email"); + this.mAppName = properties.getProperty("app"); + this.mTracker = properties.getProperty("tracker"); } catch (IOException e) { Log.e(TAG, "Failed to open exceptionhandler.properties"); e.printStackTrace(); @@ -166,8 +170,8 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable { public void uncaughtException(Thread t, Throwable e) { Log.d(TAG, "uncaughtException()"); - Log.d(TAG,"mURL = "+ this.mURL); - Log.d(TAG,"mEmail = "+ this.mEmail); +// Log.d(TAG,"mURL = "+ this.mURL); +// Log.d(TAG,"mEmail = "+ this.mEmail); Date theDate = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd_HH.mm.ss_zzz"); @@ -197,7 +201,7 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable { } //generate the report - this.mReport = new Report(mURL).generateReport(e.toString(), report.toString(), causereport.toString(), sdf.format(theDate), Build.FINGERPRINT, pi.versionName+"b"+pi.versionCode, mContext.getPackageName()); + this.mReport = new Report(mURL).generateReport(e.toString(), report.toString(), causereport.toString(), sdf.format(theDate), Build.FINGERPRINT, pi.versionName+"b"+pi.versionCode, mAppName != null ? mAppName : mContext.getPackageName(), this.mTracker); //try to send file contents via email (need to do so via the UI thread) if(this.mApp != null){ diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/Report.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/Report.java index f658d9a..c1104c2 100644 --- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/Report.java +++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/Report.java @@ -34,7 +34,7 @@ import android.os.Parcelable; */ public class Report implements Parcelable{ - private String mUrl; + private final String mUrl; private ArrayList mReport; public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { @@ -82,7 +82,6 @@ public class Report implements Parcelable{ HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(mUrl); httppost.setEntity(new UrlEncodedFormEntity(getNameValuePairs())); - //return the results HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); @@ -128,7 +127,7 @@ public class Report implements Parcelable{ * @return this * @author ricky barrette */ - public Report generateReport(String msg, String stackTrace, String cause, String date, String device, String appVersion, String app){ + public Report generateReport(String msg, String stackTrace, String cause, String date, String device, String appVersion, String app, String tracker){ this.mReport = new ArrayList(); this.mReport.add(new ReportItem("app",app)); this.mReport.add(new ReportItem("version",appVersion)); @@ -137,6 +136,7 @@ public class Report implements Parcelable{ this.mReport.add(new ReportItem("stackTrace",stackTrace)); this.mReport.add(new ReportItem("cause",cause)); this.mReport.add(new ReportItem("device",device)); + this.mReport.add(new ReportItem("tracker",tracker)); return this; } diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportItem.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportItem.java index 21cd76b..71b3037 100644 --- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportItem.java +++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportItem.java @@ -14,7 +14,7 @@ import android.os.Parcelable; * This will allow for our report items to stay in the proper order. * @author ricky */ -public class ReportItem implements Parcelable { +public final class ReportItem implements Parcelable { public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public ReportItem createFromParcel(Parcel in) { @@ -26,8 +26,8 @@ public class ReportItem implements Parcelable { } }; - private String mKey; - private String mValue; + private final String mKey; + private final String mValue; /** * Creates a new ReportItem