mirror of
https://github.com/etesync/android
synced 2025-01-23 14:10:54 +00:00
ACRA: Only send reports in the body if Protonmail is installed.
This commit is contained in:
parent
633e1228f0
commit
dbe3730fe4
@ -0,0 +1,46 @@
|
||||
package com.etesync.syncadapter;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.acra.annotation.AcraCore;
|
||||
import org.acra.config.CoreConfigurationBuilder;
|
||||
import org.acra.config.MailSenderConfigurationBuilder;
|
||||
import org.acra.config.ToastConfigurationBuilder;
|
||||
import org.acra.data.StringFormat;
|
||||
|
||||
public class AcraConfiguration {
|
||||
private static Boolean shouldReportAsFile(Context context) {
|
||||
Boolean shouldReport = false;
|
||||
|
||||
try {
|
||||
context.getPackageManager().getPackageInfo("ch.protonmail.android", 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
shouldReport = true;
|
||||
}
|
||||
|
||||
System.out.println("ACRA with attached files: " + shouldReport.toString());
|
||||
return shouldReport;
|
||||
}
|
||||
|
||||
public static CoreConfigurationBuilder getConfig(Context context) {
|
||||
CoreConfigurationBuilder builder = new CoreConfigurationBuilder(context)
|
||||
.setBuildConfigClass(BuildConfig.class)
|
||||
.setLogcatArguments("-t", "500", "-v", "time")
|
||||
.setReportFormat(StringFormat.JSON);
|
||||
builder.getPluginConfigurationBuilder(MailSenderConfigurationBuilder.class)
|
||||
.setMailTo("reports@etesync.com")
|
||||
.setResSubject(R.string.crash_email_subject)
|
||||
.setReportFileName("ACRA-report.stacktrace.json")
|
||||
.setReportAsFile(shouldReportAsFile(context))
|
||||
.setEnabled(true);
|
||||
builder.getPluginConfigurationBuilder(ToastConfigurationBuilder.class)
|
||||
.setResText(R.string.crash_message)
|
||||
.setLength(Toast.LENGTH_SHORT)
|
||||
.setEnabled(true);
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.database.Cursor
|
||||
import android.database.DatabaseUtils
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
@ -76,10 +77,9 @@ import io.requery.meta.EntityModel
|
||||
import io.requery.sql.Configuration
|
||||
import io.requery.sql.EntityDataStore
|
||||
import okhttp3.internal.tls.OkHostnameVerifier
|
||||
import org.acra.config.CoreConfigurationBuilder
|
||||
|
||||
|
||||
@AcraCore(buildConfigClass = BuildConfig::class, logcatArguments = arrayOf("-t", "500", "-v", "time"))
|
||||
@AcraMailSender(mailTo = "reports@etesync.com", resSubject = R.string.crash_email_subject, reportAsFile = false, reportFileName = "ACRA-report.stacktrace.json")
|
||||
@AcraToast(resText = R.string.crash_message, length = Toast.LENGTH_LONG)
|
||||
class App : Application() {
|
||||
|
||||
var certManager: CustomCertManager? = null
|
||||
@ -123,7 +123,7 @@ class App : Application() {
|
||||
|
||||
if (!BuildConfig.DEBUG) {
|
||||
// The following line triggers the initialization of ACRA
|
||||
ACRA.init(this)
|
||||
ACRA.init(this, AcraConfiguration.getConfig(this))
|
||||
val pm = base.packageManager
|
||||
var installedFrom = pm.getInstallerPackageName(BuildConfig.APPLICATION_ID)
|
||||
ACRA.getErrorReporter().putCustomData("installedFrom", installedFrom);
|
||||
|
Loading…
Reference in New Issue
Block a user