From f381dd6240d3d20de4f5d540609bcb60aa97f3aa Mon Sep 17 00:00:00 2001 From: vinceve Date: Wed, 30 Oct 2013 14:53:00 +0100 Subject: [PATCH 1/2] Update ErrbitNotifier.java Implement SSL support for errbit. --- .../welaika/android/errbit/ErrbitNotifier.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/com/welaika/android/errbit/ErrbitNotifier.java b/src/com/welaika/android/errbit/ErrbitNotifier.java index 7e5ca76..259a38d 100644 --- a/src/com/welaika/android/errbit/ErrbitNotifier.java +++ b/src/com/welaika/android/errbit/ErrbitNotifier.java @@ -70,6 +70,7 @@ public class ErrbitNotifier { private static final String ENVIRONMENT_PRODUCTION = "production"; private static final String ENVIRONMENT_DEFAULT = ENVIRONMENT_PRODUCTION; + private static boolean ssl = false; // Exception meta-data private static String environmentName = ENVIRONMENT_DEFAULT; @@ -118,6 +119,14 @@ public static void register(Context context, String endpoint, String apiKey, Str register(context, endpoint, apiKey, environmentName, true); } + public static void setSsl(boolean ssl) { + this.ssl = ssl; + } + + public static boolean isSsl() { + return this.ssl; + } + public static void register(Context context, String endpoint, String apiKey, String environmentName, boolean notifyOnlyProduction) { // Require an airbrake api key if(apiKey != null) { @@ -126,8 +135,11 @@ public static void register(Context context, String endpoint, String apiKey, Str throw new RuntimeException("ErrBitNotifier requires an API key."); } + String prefix = isSsl() ? "https" : "http"; + + if(endpoint != null) { - ErrbitNotifier.errbit_endpoint = "http://" + endpoint + "/notifier_api/v2/notices"; + ErrbitNotifier.errbit_endpoint = prefix + "://" + endpoint + "/notifier_api/v2/notices"; } else { ErrbitNotifier.errbit_endpoint = "http://airbrakeapp.com/notifier_api/v2/notices"; } @@ -428,4 +440,4 @@ private static synchronized void flushExceptions() { } } } -} \ No newline at end of file +} From 3a1daa3e3bf9f6d395ec450764be7794b69c2bef Mon Sep 17 00:00:00 2001 From: Vince Verberckt Date: Wed, 30 Oct 2013 15:30:27 +0100 Subject: [PATCH 2/2] Correct syntax errors. --- .../android/errbit/ErrbitNotifier.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/com/welaika/android/errbit/ErrbitNotifier.java b/src/com/welaika/android/errbit/ErrbitNotifier.java index 259a38d..73e24a3 100644 --- a/src/com/welaika/android/errbit/ErrbitNotifier.java +++ b/src/com/welaika/android/errbit/ErrbitNotifier.java @@ -2,9 +2,9 @@ Errbit Notifier for Android Copyright (c) 2012 Matteo Piotto http://welaika.com - + based on - + Airbrake Notifier for Android Copyright (c) 2011 James Smith http://loopj.com @@ -54,8 +54,8 @@ * ErrBit Notifier * * Logs exceptions to Errbit - * - * Based on https://github.com/loopj/airbrake-android/ v.1.3.0 + * + * Based on https://github.com/loopj/airbrake-android/ v.1.3.0 */ public class ErrbitNotifier { private static final String LOG_TAG = "ErrbitNotifier"; @@ -80,7 +80,7 @@ public class ErrbitNotifier { private static String androidVersion = android.os.Build.VERSION.RELEASE; private static String brandDevice = android.os.Build.BRAND; private static String manufacturerDevice = android.os.Build.MANUFACTURER; - + // Anything extra the app wants to add private static Map extraData; @@ -90,7 +90,7 @@ public class ErrbitNotifier { // Errbit api key private static String errbit_endpoint = "http://airbrakeapp.com/notifier_api/v2/notices"; - + // Exception storage info private static boolean notifyOnlyProduction = false; private static String filePath; @@ -119,12 +119,12 @@ public static void register(Context context, String endpoint, String apiKey, Str register(context, endpoint, apiKey, environmentName, true); } - public static void setSsl(boolean ssl) { - this.ssl = ssl; + public static void setSsl(boolean ssl_setting) { + ssl = ssl_setting; } public static boolean isSsl() { - return this.ssl; + return ssl; } public static void register(Context context, String endpoint, String apiKey, String environmentName, boolean notifyOnlyProduction) { @@ -134,10 +134,10 @@ public static void register(Context context, String endpoint, String apiKey, Str } else { throw new RuntimeException("ErrBitNotifier requires an API key."); } - - String prefix = isSsl() ? "https" : "http"; - - + + String prefix = isSsl() ? "https" : "http"; + + if(endpoint != null) { ErrbitNotifier.errbit_endpoint = prefix + "://" + endpoint + "/notifier_api/v2/notices"; } else { @@ -148,7 +148,7 @@ public static void register(Context context, String endpoint, String apiKey, Str if(context == null) { throw new IllegalArgumentException("context cannot be null."); } - + // Fill in environment name if passed if(environmentName != null) { ErrbitNotifier.environmentName = environmentName; @@ -306,27 +306,27 @@ private static void writeExceptionToDisk(Throwable e, final Map m s.startTag("", "action"); s.endTag("", "action"); s.startTag("", "cgi-data"); - + s.startTag("", "var"); s.attribute("", "key", "Manufacturer"); s.text(manufacturerDevice); s.endTag("", "var"); - + s.startTag("", "var"); s.attribute("", "key", "Device"); s.text(phoneModel); s.endTag("", "var"); - + s.startTag("", "var"); s.attribute("", "key", "Brand"); s.text(brandDevice); s.endTag("", "var"); - + s.startTag("", "var"); s.attribute("", "key", "Android Version"); s.text(androidVersion); s.endTag("", "var"); - + s.startTag("", "var"); s.attribute("", "key", "App Version"); s.text(versionName); @@ -413,7 +413,7 @@ private static void sendExceptionData(File file) { } finally { - // delete the file only if sending was successful + // delete the file only if sending was successful if ( sent ) { file.delete(); } @@ -422,7 +422,7 @@ private static void sendExceptionData(File file) { } } catch(Exception e) { - + // unknown exception Log.v(LOG_TAG, "Exception caught:",e);