Updated the exception handler to work with redmine
you can now specify the app and tracker you want in the prop file Change-Id: Iee3c36865e395f7f3491fb8b2d82d8fe9e0c4297 Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -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){
|
||||
|
||||
@@ -34,7 +34,7 @@ import android.os.Parcelable;
|
||||
*/
|
||||
public class Report implements Parcelable{
|
||||
|
||||
private String mUrl;
|
||||
private final String mUrl;
|
||||
private ArrayList<ReportItem> mReport;
|
||||
|
||||
public static final Parcelable.Creator<Report> CREATOR = new Parcelable.Creator<Report>() {
|
||||
@@ -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<ReportItem>();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ReportItem> CREATOR = new Parcelable.Creator<ReportItem>() {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user