diff --git a/libvlc/jni/Android.mk b/libvlc/jni/Android.mk index be570760d..ccfa6186d 100644 --- a/libvlc/jni/Android.mk +++ b/libvlc/jni/Android.mk @@ -51,7 +51,7 @@ LOCAL_SRC_FILES += libvlcjni-mediaplayer.c LOCAL_SRC_FILES += libvlcjni-vlcobject.c LOCAL_SRC_FILES += libvlcjni-media.c libvlcjni-medialist.c libvlcjni-mediadiscoverer.c LOCAL_SRC_FILES += libvlcjni-dialog.c -LOCAL_SRC_FILES += native_crash_handler.c thumbnailer.c +LOCAL_SRC_FILES += thumbnailer.c LOCAL_SRC_FILES += std_logger.c LOCAL_LDLIBS := -llog diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c index fe64c1dfa..a88d362cf 100644 --- a/libvlc/jni/libvlcjni.c +++ b/libvlc/jni/libvlcjni.c @@ -36,7 +36,6 @@ #include "libvlcjni-vlcobject.h" #include "utils.h" -#include "native_crash_handler.h" #include "std_logger.h" struct fields fields; @@ -161,8 +160,6 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) fields.FileDescriptor.descriptorID, fields.FileDescriptor.clazz, "descriptor", "I"); - GET_CLASS(fields.LibVLC.clazz, - "org/videolan/libvlc/LibVLC", true); GET_CLASS(fields.VLCObject.clazz, "org/videolan/libvlc/VLCObject", true); GET_CLASS(fields.Media.clazz, @@ -188,11 +185,6 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) GET_CLASS(fields.Dialog.clazz, "org/videolan/libvlc/Dialog", true); - GET_ID(GetStaticMethodID, - fields.LibVLC.onNativeCrashID, - fields.LibVLC.clazz, - "onNativeCrash", "()V"); - GET_ID(GetFieldID, fields.VLCObject.mInstanceID, fields.VLCObject.clazz, @@ -328,8 +320,6 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) #undef GET_CLASS #undef GET_ID - init_native_crash_handler(); - LOGD("JNI interface loaded."); return VLC_JNI_VERSION; } @@ -338,8 +328,6 @@ void JNI_OnUnload(JavaVM* vm, void* reserved) { JNIEnv* env = NULL; - destroy_native_crash_handler(); - if ((*vm)->GetEnv(vm, (void**) &env, VLC_JNI_VERSION) != JNI_OK) return; diff --git a/libvlc/jni/native_crash_handler.c b/libvlc/jni/native_crash_handler.c deleted file mode 100644 index 31a19e708..000000000 --- a/libvlc/jni/native_crash_handler.c +++ /dev/null @@ -1,91 +0,0 @@ -/***************************************************************************** - * native_crash_handler.c - ***************************************************************************** - * Copyright © 2010-2014 VLC authors and VideoLAN - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#include -#include - -#include "native_crash_handler.h" -#include "utils.h" - -static struct sigaction old_actions[NSIG]; - -#define THREAD_NAME "native_crash_handler" -extern JNIEnv *jni_get_env(const char *name); - -// Monitored signals. -static const int monitored_signals[] = { - SIGILL, - SIGABRT, - SIGBUS, - SIGFPE, - SIGSEGV, -#ifndef _MIPS_ARCH - SIGSTKFLT, -#else - SIGEMT, -#endif - SIGPIPE -}; - - -/** - * Callback called when a monitored signal is triggered. - */ -void sigaction_callback(int signal, siginfo_t *info, void *reserved) -{ - JNIEnv *env; - if (!(env = jni_get_env(THREAD_NAME))) - return; - - // Call the Java LibVLC method that handle the crash. - (*env)->CallStaticVoidMethod(env, fields.LibVLC.clazz, - fields.LibVLC.onNativeCrashID); - - // Call the old signal handler. - old_actions[signal].sa_handler(signal); -} - - -void init_native_crash_handler() -{ - struct sigaction handler; - memset(&handler, 0, sizeof(struct sigaction)); - - handler.sa_sigaction = sigaction_callback; - handler.sa_flags = SA_RESETHAND; - - // Install the signal handlers and save their old actions. - for (unsigned i = 0; i < sizeof(monitored_signals) / sizeof(int); ++i) - { - const int s = monitored_signals[i]; - sigaction(s, &handler, &old_actions[s]); - } -} - - -void destroy_native_crash_handler() -{ - // Uninstall the signal handlers and restore their old actions. - for (unsigned i = 0; i < sizeof(monitored_signals) / sizeof(int); ++i) - { - const int s = monitored_signals[i]; - sigaction(s, &old_actions[s], NULL); - } -} diff --git a/libvlc/jni/native_crash_handler.h b/libvlc/jni/native_crash_handler.h deleted file mode 100644 index 5ec998ec6..000000000 --- a/libvlc/jni/native_crash_handler.h +++ /dev/null @@ -1,29 +0,0 @@ -/***************************************************************************** - * native_crash_handler.h - ***************************************************************************** - * Copyright © 2010-2013 VLC authors and VideoLAN - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#ifndef LIBVLCJNI_NATIVE_CRASH_HANDLER_H -#define LIBVLCJNI_NATIVE_CRASH_HANDLER_H - -#include - -void init_native_crash_handler(); -void destroy_native_crash_handler(); - -#endif // LIBVLCJNI_NATIVE_CRASH_HANDLER_H diff --git a/libvlc/jni/utils.h b/libvlc/jni/utils.h index 7df7c0845..53d54b3b2 100644 --- a/libvlc/jni/utils.h +++ b/libvlc/jni/utils.h @@ -40,10 +40,6 @@ struct fields { jclass clazz; jfieldID descriptorID; } FileDescriptor; - struct { - jclass clazz; - jmethodID onNativeCrashID; - } LibVLC; struct { jclass clazz; jfieldID mInstanceID; diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java index 10c932052..a53b8799a 100644 --- a/libvlc/src/org/videolan/libvlc/LibVLC.java +++ b/libvlc/src/org/videolan/libvlc/LibVLC.java @@ -38,9 +38,6 @@ public class LibVLC extends VLCObject { } } - /** Native crash handler */ - private static OnNativeCrashListener sOnNativeCrashListener; - /** * Create a LibVLC withs options * @@ -117,19 +114,6 @@ public class LibVLC extends VLCObject { nativeRelease(); } - public interface OnNativeCrashListener { - void onNativeCrash(); - } - - public static void setOnNativeCrashListener(OnNativeCrashListener l) { - sOnNativeCrashListener = l; - } - - private static void onNativeCrash() { - if (sOnNativeCrashListener != null) - sOnNativeCrashListener.onNativeCrash(); - } - /** * Sets the application name. LibVLC passes this as the user agent string * when a protocol requires it. diff --git a/vlc-android/src/org/videolan/vlc/gui/NativeCrashActivity.java b/vlc-android/src/org/videolan/vlc/gui/NativeCrashActivity.java deleted file mode 100644 index 404c993b2..000000000 --- a/vlc-android/src/org/videolan/vlc/gui/NativeCrashActivity.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.videolan.vlc.gui; - -import android.app.Activity; -import android.app.ProgressDialog; -import android.content.Intent; -import android.os.AsyncTask; -import android.os.Build; -import android.os.Bundle; -import android.view.View; -import android.widget.Button; -import android.widget.TextView; - -import org.videolan.vlc.R; -import org.videolan.vlc.StartActivity; -import org.videolan.vlc.util.Logcat; -import org.videolan.vlc.util.Util; - -import java.io.BufferedOutputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.zip.GZIPOutputStream; - -public class NativeCrashActivity extends Activity { - - private TextView mCrashLog; - private Button mRestartButton; - private Button mSendLog; - - private ProgressDialog mProgressDialog; - - private String mLog; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.native_crash); - - mCrashLog = (TextView) findViewById(R.id.crash_log); - mRestartButton = (Button) findViewById(R.id.restart_vlc); - mRestartButton.setEnabled(false); - mSendLog = (Button) findViewById(R.id.send_log); - mSendLog.setEnabled(false); - - mRestartButton.setOnClickListener(new Button.OnClickListener() { - @Override - public void onClick(View v) { - android.os.Process.killProcess(android.os.Process.myPid()); - Intent i = new Intent(NativeCrashActivity.this, StartActivity.class); - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(i); - finish(); - } - }); - - mSendLog.setOnClickListener(new Button.OnClickListener() { - @Override - public void onClick(View v) { - String buildDate = "Build date: " + getString(R.string.build_time); - String builder = "Builder: " + getString(R.string.build_host); - String revision = "Revision: " + getString(R.string.build_revision); - AsyncHttpRequest asyncHttpRequest = new AsyncHttpRequest(); - asyncHttpRequest.execute(Build.BRAND, Build.MANUFACTURER, Build.PRODUCT, Build.MODEL, - Build.DEVICE, Build.VERSION.RELEASE, - buildDate, builder, revision, mLog); - } - }); - - new LogTask().execute(); - } - - class LogTask extends AsyncTask - { - @Override - protected String doInBackground(Void... v) { - String log = null; - try { - log = Logcat.getLogcat(); - } catch (IOException e) { - e.printStackTrace(); - } - return log; - } - - @Override - protected void onPostExecute(String log) { - mLog = log; - mCrashLog.setText(log); - mRestartButton.setEnabled(true); - mSendLog.setEnabled(true); - } - } - - public class AsyncHttpRequest extends AsyncTask { - - @Override - protected void onPreExecute() { - mProgressDialog = new ProgressDialog(NativeCrashActivity.this); - mProgressDialog.setMessage(NativeCrashActivity.this.getText(R.string.sending_log)); - mProgressDialog.show(); - } - - @Override - protected Boolean doInBackground(String... params) { - if (params[0].length() == 0) - return false; - HttpURLConnection urlConnection = null; - try { - URL url = new URL("http://people.videolan.org/~magsoft/vlc-android_crashes/upload_crash_log.php"); - urlConnection = (HttpURLConnection) url.openConnection(); - urlConnection.setDoOutput(true); - urlConnection.setRequestMethod("POST"); - urlConnection.setDoInput(true); - OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream()); - - StringBuilder msgBuilder = new StringBuilder(); - for (int i = 0; i < params.length; ++i) { - msgBuilder.append(params[i]); - msgBuilder.append("\n"); - } - byte[] body = compress(msgBuilder.toString()); - urlConnection.setFixedLengthStreamingMode(body.length); - out.write(body); - } catch (MalformedURLException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (urlConnection != null) - urlConnection.disconnect(); - } - return true; - } - - private byte[] compress(String string) throws IOException { - ByteArrayOutputStream os = new ByteArrayOutputStream(string.length()); - GZIPOutputStream gos = new GZIPOutputStream(os); - gos.write(string.getBytes()); - Util.close(gos); - byte[] compressed = os.toByteArray(); - Util.close(os); - return compressed; - } - - @Override - protected void onPostExecute(Boolean result) { - mProgressDialog.cancel(); - mSendLog.setEnabled(false); - } - } - -} diff --git a/vlc-android/src/org/videolan/vlc/util/VLCInstance.java b/vlc-android/src/org/videolan/vlc/util/VLCInstance.java index d2ee1aad4..ecc29f88e 100644 --- a/vlc-android/src/org/videolan/vlc/util/VLCInstance.java +++ b/vlc-android/src/org/videolan/vlc/util/VLCInstance.java @@ -32,7 +32,6 @@ import org.videolan.libvlc.util.VLCUtil; import org.videolan.vlc.VLCApplication; import org.videolan.vlc.VLCCrashHandler; import org.videolan.vlc.gui.CompatErrorActivity; -import org.videolan.vlc.gui.NativeCrashActivity; import java.io.File; import java.io.FileOutputStream; @@ -113,15 +112,6 @@ public class VLCInstance { } sLibVLC = new LibVLC(context, VLCOptions.getLibOptions()); - LibVLC.setOnNativeCrashListener(new LibVLC.OnNativeCrashListener() { - @Override - public void onNativeCrash() { - Intent i = new Intent(context, NativeCrashActivity.class); - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(i); - } - }); - VLCApplication.runBackground(sCopyLua); } return sLibVLC;