aboutsummaryrefslogtreecommitdiffstats
path: root/src/org
diff options
context:
space:
mode:
authorMarkus Doits <markus.doits@gmail.com>2011-01-20 17:38:25 +0000
committerMarkus Doits <markus.doits@gmail.com>2011-01-20 17:38:25 +0000
commitdfb4f4e03050757c9226f0a3b089cb18ab29c6f5 (patch)
tree60a317a0404e38cac1e477f4425aaf9fd3cca606 /src/org
parentd4901f5999b51398b3a2ff43ba82f356225f4fef (diff)
downloadopen-keychain-dfb4f4e03050757c9226f0a3b089cb18ab29c6f5.tar.gz
open-keychain-dfb4f4e03050757c9226f0a3b089cb18ab29c6f5.tar.bz2
open-keychain-dfb4f4e03050757c9226f0a3b089cb18ab29c6f5.zip
Allow at compile time to enable stacktraces on exceptions
Diffstat (limited to 'src/org')
-rw-r--r--src/org/thialfihar/android/apg/utils/ApgCon.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/org/thialfihar/android/apg/utils/ApgCon.java b/src/org/thialfihar/android/apg/utils/ApgCon.java
index 4852ad548..5277222eb 100644
--- a/src/org/thialfihar/android/apg/utils/ApgCon.java
+++ b/src/org/thialfihar/android/apg/utils/ApgCon.java
@@ -24,6 +24,11 @@ import org.thialfihar.android.apg.IApgService;
*/
public class ApgCon {
+ /**
+ * Put stacktraces into the log?
+ */
+ private final boolean stacktraces = true;
+
private class call_async extends AsyncTask<String, Void, Void> {
@Override
@@ -42,14 +47,20 @@ public class ApgCon {
callback_object.getClass().getMethod(callback_method).invoke(callback_object);
Log.d(TAG, "Callback executed");
} catch (NoSuchMethodException e) {
+ if (stacktraces)
+ e.printStackTrace();
Log.w(TAG, "Exception in callback: Method '" + callback_method + "' not found");
warning_list.add("(LOCAL) Could not execute callback, method '" + callback_method + "()' not found");
} catch (InvocationTargetException e) {
+ if (stacktraces)
+ e.printStackTrace();
Throwable orig = e.getTargetException();
Log.w(TAG, "Exception of type '" + orig.getClass() + "' in callback's method '" + callback_method + "()':" + orig.getMessage());
warning_list.add("(LOCAL) Exception of type '" + orig.getClass() + "' in callback's method '" + callback_method + "()':"
+ orig.getMessage());
} catch (Exception e) {
+ if (stacktraces)
+ e.printStackTrace();
Log.w(TAG, "Exception on callback: (" + e.getClass() + ") " + e.getMessage());
warning_list.add("(LOCAL) Could not execute callback (" + e.getClass() + "): " + e.getMessage());
}
@@ -153,6 +164,8 @@ public class ApgCon {
}
}
} catch (PackageManager.NameNotFoundException e) {
+ if (stacktraces)
+ e.printStackTrace();
Log.e(TAG, "Could not find APG, is it installed?");
error_list.add("(LOCAL) Could not find APG, is it installed?");
local_error = error.APG_NOT_FOUND;
@@ -171,6 +184,8 @@ public class ApgCon {
try {
mContext.bindService(new Intent(IApgService.class.getName()), apgConnection, Context.BIND_AUTO_CREATE);
} catch (Exception e) {
+ if (stacktraces)
+ e.printStackTrace();
Log.v(TAG, "could not bind APG service");
return false;
}
@@ -305,16 +320,22 @@ public class ApgCon {
pReturn.remove(ret.WARNINGS.name());
return success;
} catch (NoSuchMethodException e) {
+ if (stacktraces)
+ e.printStackTrace();
Log.e(TAG, "Remote call not known (" + function + "): " + e.getMessage());
error_list.add("(LOCAL) Remote call not known (" + function + "): " + e.getMessage());
local_error = error.CALL_NOT_KNOWN;
return false;
} catch (InvocationTargetException e) {
+ if (stacktraces)
+ e.printStackTrace();
Throwable orig = e.getTargetException();
- Log.w(TAG, "Exception of type '" + orig.getClass() + "' on AIDL call '" + function + "':" + orig.getMessage());
- error_list.add("(LOCAL) Exception of type '" + orig.getClass() + "' on AIDL call '" + function + "':" + orig.getMessage());
+ Log.w(TAG, "Exception of type '" + orig.getClass() + "' on AIDL call '" + function + "': " + orig.getMessage());
+ error_list.add("(LOCAL) Exception of type '" + orig.getClass() + "' on AIDL call '" + function + "': " + orig.getMessage());
return false;
} catch (Exception e) {
+ if (stacktraces)
+ e.printStackTrace();
Log.e(TAG, "Generic error (" + e.getClass() + "): " + e.getMessage());
error_list.add("(LOCAL) Generic error (" + e.getClass() + "): " + e.getMessage());
local_error = error.GENERIC;