From 904ce469f833d005b9d209b415924d3ba64bfb01 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Sat, 22 Dec 2012 17:47:59 +0100 Subject: Add google-breakpad support to ics-openvpn --- AndroidManifest.xml | 11 +++++- jni/Android.mk | 4 ++ jni/Application.mk | 1 + openvpn/Android.mk | 17 ++++++-- openvpn/src/openvpn/init.c | 5 ++- openvpn/src/openvpn/openvpn.c | 6 +++ res/menu/logmenu.xml | 12 ++++-- src/de/blinkt/openvpn/LogWindow.java | 75 +++++++++++++++++++++++++++++++++++- src/de/blinkt/openvpn/OpenVPN.java | 2 +- 9 files changed, 122 insertions(+), 11 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index a56ba309..8ccd1e96 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -24,10 +24,13 @@ + - + + + \ No newline at end of file diff --git a/jni/Android.mk b/jni/Android.mk index 3514b920..283be302 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -5,6 +5,10 @@ include lzo/Android.mk include openssl/Android.mk +ifneq ($(TARGET_ARCH),mips) +include google-breakpad/android/google_breakpad/Android.mk +endif + include openvpn/Android.mk diff --git a/jni/Application.mk b/jni/Application.mk index 38ce95f3..5670b6e3 100644 --- a/jni/Application.mk +++ b/jni/Application.mk @@ -1,6 +1,7 @@ APP_ABI := all NDK_TOOLCHAIN_VERSION=4.4.3 #APP_PLATFORM := android-14 +APP_STL:=stlport_static #APP_OPTIM := release diff --git a/openvpn/Android.mk b/openvpn/Android.mk index b27ef794..6307e5e0 100644 --- a/openvpn/Android.mk +++ b/openvpn/Android.mk @@ -1,17 +1,21 @@ -# Android openvpn JNI LOCAL_PATH:= $(call my-dir)/ include $(CLEAR_VARS) LOCAL_LDLIBS := -lz -LOCAL_C_INCLUDES := openssl/include lzo/include openssl/crypto openssl openvpn/src/compat openvpn/src/openvpn openvpn/include +LOCAL_C_INCLUDES := openssl/include lzo/include openssl/crypto openssl openvpn/src/compat openvpn/src/openvpn openvpn/include google-breakpad/src google-breakpad/src/common/android/include LOCAL_SHARED_LIBRARIES := libssl libcrypto #LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static liblzo-static + +LOCAL_CFLAGS= -DHAVE_CONFIG_H -DTARGET_ABI=\"${TARGET_ABI}\" LOCAL_STATIC_LIBRARIES := liblzo-static +ifneq ($(TARGET_ARCH),mips) +LOCAL_STATIC_LIBRARIES += breakpad_client +LOCAL_CFLAGS += -DGOOGLE_BREAKPAD=1 +endif -LOCAL_CFLAGS= -DHAVE_CONFIG_H -DTARGET_ABI=\"${TARGET_ABI}\" LOCAL_MODULE = openvpn LOCAL_SRC_FILES:= \ @@ -85,7 +89,12 @@ LOCAL_SRC_FILES:= \ src/openvpn/ssl_verify_openssl.c \ src/openvpn/ssl_verify_polarssl.c \ src/openvpn/status.c \ - src/openvpn/tun.c + src/openvpn/tun.c +ifneq ($(TARGET_ARCH),mips) +LOCAL_SRC_FILES+=../jni/icsandroid.cpp +endif + + include $(BUILD_SHARED_LIBRARY) #include $(BUILD_EXECUTABLE) diff --git a/openvpn/src/openvpn/init.c b/openvpn/src/openvpn/init.c index 6a1ed02d..e2942c00 100644 --- a/openvpn/src/openvpn/init.c +++ b/openvpn/src/openvpn/init.c @@ -3704,7 +3704,10 @@ close_context (struct context *c, int sig, unsigned int flags) { if ((flags & CC_USR1_TO_HUP) || (c->sig->source == SIG_SOURCE_HARD && (flags & CC_HARD_USR1_TO_HUP))) - c->sig->signal_received = SIGHUP; + { + c->sig->signal_received = SIGHUP; + c->sig->signal_text = "close_context usr1 to hup"; + } } if (!(flags & CC_NO_CLOSE)) diff --git a/openvpn/src/openvpn/openvpn.c b/openvpn/src/openvpn/openvpn.c index 104c9e93..4bae5274 100644 --- a/openvpn/src/openvpn/openvpn.c +++ b/openvpn/src/openvpn/openvpn.c @@ -321,6 +321,12 @@ wmain (int argc, wchar_t *wargv[]) { #else int main (int argc, char *argv[]) { +#ifdef TARGET_ANDROID +#ifdef GOOGLE_BREAKPAD +#include "../jni/icsandroid.h" + setup_breakpad(); +#endif +#endif return openvpn_main(argc, argv); } #endif diff --git a/res/menu/logmenu.xml b/res/menu/logmenu.xml index 4b55e73b..ec2997b0 100644 --- a/res/menu/logmenu.xml +++ b/res/menu/logmenu.xml @@ -1,6 +1,11 @@ - + + - - + \ No newline at end of file diff --git a/src/de/blinkt/openvpn/LogWindow.java b/src/de/blinkt/openvpn/LogWindow.java index 8d228cf1..3c0f7246 100644 --- a/src/de/blinkt/openvpn/LogWindow.java +++ b/src/de/blinkt/openvpn/LogWindow.java @@ -1,5 +1,9 @@ package de.blinkt.openvpn; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; import java.util.Vector; import android.app.AlertDialog; @@ -12,6 +16,7 @@ import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.database.DataSetObserver; +import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Handler.Callback; @@ -76,6 +81,7 @@ public class LogWindow extends ListActivity implements StateListener { return str; } + private void shareLog() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, getLogStr()); @@ -215,12 +221,15 @@ public class LogWindow extends ListActivity implements StateListener { OpenVpnManagementThread.stopOpenVPN(); } }); - + builder.show(); return true; } else if(item.getItemId()==R.id.info) { if(mBconfig==null) OpenVPN.triggerLogBuilderConfig(); + } else if(item.getItemId()==R.id.minidump) { + emailMiniDumps(); + } else if(item.getItemId()==R.id.send) { ladapter.shareLog(); } else if(item.getItemId()==R.id.edit_vpn) { @@ -249,9 +258,73 @@ public class LogWindow extends ListActivity implements StateListener { public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.logmenu, menu); + + + + if(getLastestDump()==null) + menu.removeItem(R.id.minidump); + return true; } + private File getLastestDump() { + long newestDumpTime=0; + File newestDumpFile=null; + + for(File f:getCacheDir().listFiles()) { + if(!f.getName().endsWith(".dmp")) + continue; + + if (newestDumpTime < f.lastModified()) { + newestDumpTime = f.lastModified(); + newestDumpFile=f; + } + } + return newestDumpFile; + } + + + public void emailMiniDumps() + { + //need to "send multiple" to get more than one attachment + final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); + emailIntent.setType("*/*"); + emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, + new String[]{"Arne Schwabe "}); + emailIntent.putExtra(Intent.EXTRA_SUBJECT, "OpenVPN Minidump"); + + + ArrayList textarraylist = new ArrayList(); + textarraylist.add("Please describe the issue you have experienced"); + emailIntent.putExtra(Intent.EXTRA_TEXT, textarraylist); + + + ArrayList uris = new ArrayList(); + + File ldump = getLastestDump(); + if(ldump==null) { + OpenVPN.logError("No Minidump found!"); + } + + uris.add(Uri.parse("content://de.blinkt.openvpn.FileProvider/" + ldump.getName())); + uris.add(Uri.parse("content://de.blinkt.openvpn.FileProvider/openvpn.log")); + + + try { + FileWriter logout = new FileWriter(new File(getCacheDir(),"openvpn.log")); + logout.write(ladapter.getLogStr()); + logout.close(); + + } catch (IOException e1) { + OpenVPN.logError("Error writing log: " + e1.getLocalizedMessage()); + } + + //emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); + startActivity(emailIntent); + } + + @Override protected void onResume() { super.onResume(); diff --git a/src/de/blinkt/openvpn/OpenVPN.java b/src/de/blinkt/openvpn/OpenVPN.java index 6b65c22e..48623865 100644 --- a/src/de/blinkt/openvpn/OpenVPN.java +++ b/src/de/blinkt/openvpn/OpenVPN.java @@ -163,7 +163,7 @@ public class OpenVPN { } public static void logInfo(String message) { - + newlogItem(new LogItem(LogItem.INFO, message)); } public static void logInfo(int ressourceId, Object... args) { -- cgit v1.2.3