Browse Source
This not working since android 5.0, this prevent us to have useful native traces (that can be used with ndk-stack) and this mess up native crash report on the Google Play Developer Console.2.0.x
8 changed files with 1 additions and 318 deletions
@ -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 <stdbool.h> |
|||
#include <signal.h> |
|||
|
|||
#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); |
|||
} |
|||
} |
|||
@ -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 <jni.h> |
|||
|
|||
void init_native_crash_handler(); |
|||
void destroy_native_crash_handler(); |
|||
|
|||
#endif // LIBVLCJNI_NATIVE_CRASH_HANDLER_H
|
|||
@ -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<Void, Void, String> |
|||
{ |
|||
@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<String, String, Boolean> { |
|||
|
|||
@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); |
|||
} |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue