removing crash handler, we not have google play reports

This commit is contained in:
Bartek Przybylski 2012-09-29 22:48:50 +02:00
parent b00957b5fa
commit c7dc135987
4 changed files with 1 additions and 272 deletions

View file

@ -32,7 +32,6 @@
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- uses-permission android:name="android.permission.READ_LOGS" / -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-sdk
@ -143,8 +142,7 @@
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
</receiver>
<activity android:name="CrashlogSendActivity"></activity>
</receiver>
<!-- receiver android:name=".files.BootupBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>

View file

@ -1,154 +0,0 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.owncloud.android;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.LinkedList;
import java.util.List;
import com.owncloud.android.authenticator.AccountAuthenticator;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.net.ConnectivityManager;
import android.os.Environment;
import android.util.Log;
public class CrashHandler implements UncaughtExceptionHandler {
public static final String KEY_CRASH_FILENAME = "KEY_CRASH_FILENAME";
private Context mContext;
private static final String TAG = "CrashHandler";
private static final String crash_filename_template = "crash";
private static List<String> TAGS;
private UncaughtExceptionHandler defaultUEH;
// TODO: create base activity which will register for crashlog tag automaticly
static {
TAGS = new LinkedList<String>();
TAGS.add("AccountAuthenticator");
TAGS.add("AccountAuthenticator");
TAGS.add("ConnectionCheckerRunnable");
TAGS.add("EasySSLSocketFactory");
TAGS.add("FileDataStorageManager");
TAGS.add("PhotoTakenBroadcastReceiver");
TAGS.add("InstantUploadService");
TAGS.add("FileDownloader");
TAGS.add("FileUploader");
TAGS.add("LocationUpdateService");
TAGS.add("FileSyncAdapter");
TAGS.add("AuthActivity");
TAGS.add("OwnCloudPreferences");
TAGS.add("FileDetailFragment");
TAGS.add("FileListFragment");
TAGS.add("ownCloudUploader");
TAGS.add("WebdavClient");
}
public CrashHandler(Context context) {
mContext = context;
defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
}
@Override
public void uncaughtException(Thread thread, Throwable ex) {
final Writer writer = new StringWriter();
final PrintWriter printwriter = new PrintWriter(writer);
ex.printStackTrace(printwriter);
final String startrace = writer.toString();
printwriter.close();
File ocdir = new File(Environment.getExternalStorageDirectory().getAbsoluteFile(), "owncloud");
ocdir.mkdirs();
String crash_filename = crash_filename_template + System.currentTimeMillis() + ".txt";
File crashfile = new File(ocdir, crash_filename);
try {
PackageInfo pi = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
String header = String.format("Model: %s, SDK: %d, Current net: %s AppVersion: %s\n\n",
android.os.Build.MODEL,
android.os.Build.VERSION.SDK_INT,
cm.getActiveNetworkInfo() != null ? cm.getActiveNetworkInfo().getTypeName() : "NONE",
pi.versionName);
Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
AccountManager am = AccountManager.get(mContext);
String header2 = String.format("Account: %s, OCUrl: %s, OCVersion: %s\n\n",
account.name,
am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL),
am.getUserData(account, AccountAuthenticator.KEY_OC_VERSION));
crashfile.createNewFile();
FileWriter fw = new FileWriter(crashfile);
fw.write(header);
fw.write(header2);
fw.write(startrace);
fw.write("\n\n");
String logcat = "logcat -d *:S ";
for (String s : TAGS)
logcat += s + ":V ";
Process process = Runtime.getRuntime().exec(logcat);
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String logline;
while ((logline = br.readLine()) != null)
fw.write(logline+"\n");
br.close();
fw.close();
Intent dataintent = new Intent(mContext, CrashlogSendActivity.class);
dataintent.putExtra(KEY_CRASH_FILENAME, crashfile.getAbsolutePath());
PendingIntent intent;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
intent = PendingIntent.getActivity(mContext.getApplicationContext(), 0, dataintent, Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
} else {
intent = PendingIntent.getActivity(mContext.getApplicationContext(), 0, dataintent, Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
AlarmManager mngr = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
if (mngr == null) {
Log.e(TAG, "Couldn't retrieve alarm manager!");
defaultUEH.uncaughtException(thread, ex);
return;
}
mngr.set(AlarmManager.RTC, System.currentTimeMillis(), intent);
System.exit(2);
} catch (Exception e1) {
Log.e(TAG, "Crash handler failed!");
Log.e(TAG, e1.toString());
defaultUEH.uncaughtException(thread, ex);
return;
}
}
}

View file

@ -1,112 +0,0 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.owncloud.android;
import java.io.File;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.util.Log;
import com.actionbarsherlock.app.SherlockActivity;
import com.owncloud.android.R;
public class CrashlogSendActivity extends SherlockActivity implements OnClickListener, OnCancelListener {
private static final String TAG = "CrashlogSendActivity";
private static final String CRASHLOG_SUBMIT_URL = "http://alefzero.eu/a/crashlog/";
private static final int DIALOG_SUBMIT = 5;
private String mLogFilename;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLogFilename = getIntent().getStringExtra(CrashHandler.KEY_CRASH_FILENAME);
if (mLogFilename == null) {
Log.wtf(TAG, "No file crashlog path given!");
finish();
return;
}
Log.i(TAG, "crashlog file path " + mLogFilename);
showDialog(DIALOG_SUBMIT);
}
@Override
protected Dialog onCreateDialog(int id) {
if (id == DIALOG_SUBMIT) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.crashlog_message);
builder.setNegativeButton(R.string.crashlog_dont_send_report, this);
builder.setPositiveButton(R.string.crashlog_send_report, this);
builder.setCancelable(true);
builder.setOnCancelListener(this);
return builder.create();
}
return super.onCreateDialog(id);
}
@Override
public void onClick(DialogInterface dialog, final int which) {
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
File file = new File(mLogFilename);
if (which == Dialog.BUTTON_POSITIVE) {
try {
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(CRASHLOG_SUBMIT_URL);
Part[] parts = {new FilePart("crashfile", file)};
post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
client.executeMethod(post);
post.releaseConnection();
} catch (Exception e) {
e.printStackTrace();
}
}
file.delete();
finish();
}
}).start();
}
@Override
public void onCancel(DialogInterface dialog) {
new File(mLogFilename).delete();
finish();
}
}

View file

@ -61,7 +61,6 @@ import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
import com.owncloud.android.AccountUtils;
import com.owncloud.android.CrashHandler;
import com.owncloud.android.authenticator.AccountAuthenticator;
import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.FileDataStorageManager;
@ -116,8 +115,6 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
public void onCreate(Bundle savedInstanceState) {
Log.d(getClass().toString(), "onCreate() start");
super.onCreate(savedInstanceState);
//Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(getApplicationContext()));
/// saved instance state: keep this always before initDataFromCurrentAccount()
if(savedInstanceState != null) {