Search in sources :

Example 1 with ACRAConfiguration

use of org.acra.config.ACRAConfiguration in project NewPipe by TeamNewPipe.

the class App method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    // init crashreport
    try {
        final ACRAConfiguration acraConfig = new ConfigurationBuilder(this).setReportSenderFactoryClasses(reportSenderFactoryClasses).build();
        ACRA.init(this, acraConfig);
    } catch (ACRAConfigurationException ace) {
        ace.printStackTrace();
        ErrorActivity.reportError(this, ace, null, null, ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED, "none", "Could not initialize ACRA crash report", R.string.app_ui_crash));
    }
    //init NewPipe
    NewPipe.init(Downloader.getInstance());
    // Initialize image loader
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
    ImageLoader.getInstance().init(config);
    /*
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        if(prefs.getBoolean(getString(R.string.use_tor_key), false)) {
            OrbotHelper.requestStartTor(this);
            configureTor(true);
        } else {
            configureTor(false);
        }*/
    configureTor(false);
    // DO NOT REMOVE THIS FUNCTION!!!
    // Otherwise downloadPathPreference has invalid value.
    SettingsActivity.initSettings(this);
}
Also used : ConfigurationBuilder(org.acra.config.ConfigurationBuilder) ACRAConfiguration(org.acra.config.ACRAConfiguration) ACRAConfigurationException(org.acra.config.ACRAConfigurationException) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 2 with ACRAConfiguration

use of org.acra.config.ACRAConfiguration in project acra by ACRA.

the class BaseCrashReportDialog method onCreate.

/**
     * NB if you were previously creating and showing your dialog in this method,
     * you should move that code to {@link #init(Bundle)}.
     *
     * @param savedInstanceState    If the activity is being re-initialized after
     *     previously being shut down then this Bundle contains the data it most
     *     recently supplied in {@link #onSaveInstanceState}.  <b><i>Note: Otherwise it is null.</i></b>
     */
@Override
protected final void onCreate(@Nullable Bundle savedInstanceState) {
    preInit(savedInstanceState);
    super.onCreate(savedInstanceState);
    if (ACRA.DEV_LOGGING) {
        ACRA.log.d(LOG_TAG, "CrashReportDialog extras=" + getIntent().getExtras());
    }
    final Serializable sConfig = getIntent().getSerializableExtra(ACRAConstants.EXTRA_REPORT_CONFIG);
    final Serializable sReportFile = getIntent().getSerializableExtra(ACRAConstants.EXTRA_REPORT_FILE);
    final Serializable sException = getIntent().getSerializableExtra(ACRAConstants.EXTRA_REPORT_EXCEPTION);
    final boolean forceCancel = getIntent().getBooleanExtra(ACRAConstants.EXTRA_FORCE_CANCEL, false);
    if (forceCancel) {
        if (ACRA.DEV_LOGGING)
            ACRA.log.d(LOG_TAG, "Forced reports deletion.");
        cancelReports();
        finish();
    } else if ((sConfig instanceof ACRAConfiguration) && (sReportFile instanceof File) && ((sException instanceof Throwable) || sException == null)) {
        config = (ACRAConfiguration) sConfig;
        reportFile = (File) sReportFile;
        exception = (Throwable) sException;
        init(savedInstanceState);
    } else {
        ACRA.log.w(LOG_TAG, "Illegal or incomplete call of BaseCrashReportDialog.");
        finish();
    }
}
Also used : Serializable(java.io.Serializable) ACRAConfiguration(org.acra.config.ACRAConfiguration) File(java.io.File)

Example 3 with ACRAConfiguration

use of org.acra.config.ACRAConfiguration in project acra by ACRA.

the class SenderService method onHandleIntent.

@Override
protected void onHandleIntent(@Nullable final Intent intent) {
    if (intent == null || !intent.hasExtra(EXTRA_ACRA_CONFIG)) {
        if (ACRA.DEV_LOGGING)
            ACRA.log.d(LOG_TAG, "SenderService was started but no valid intent was delivered, will now quit");
        return;
    }
    final boolean onlySendSilentReports = intent.getBooleanExtra(EXTRA_ONLY_SEND_SILENT_REPORTS, false);
    final boolean approveReportsFirst = intent.getBooleanExtra(EXTRA_APPROVE_REPORTS_FIRST, false);
    final ACRAConfiguration config = (ACRAConfiguration) intent.getSerializableExtra(EXTRA_ACRA_CONFIG);
    final Collection<Class<? extends ReportSenderFactory>> senderFactoryClasses = config.reportSenderFactoryClasses();
    if (ACRA.DEV_LOGGING)
        ACRA.log.d(LOG_TAG, "About to start sending reports from SenderService");
    try {
        final List<ReportSender> senderInstances = getSenderInstances(config, senderFactoryClasses);
        // Mark reports as approved
        if (approveReportsFirst) {
            markReportsAsApproved();
        }
        // Get approved reports
        final File[] reports = locator.getApprovedReports();
        final ReportDistributor reportDistributor = new ReportDistributor(this, config, senderInstances);
        // Iterate over approved reports and send via all Senders.
        // Use to rate limit sending
        int reportsSentCount = 0;
        final CrashReportFileNameParser fileNameParser = new CrashReportFileNameParser();
        for (final File report : reports) {
            if (onlySendSilentReports && !fileNameParser.isSilent(report.getName())) {
                continue;
            }
            if (reportsSentCount >= ACRAConstants.MAX_SEND_REPORTS) {
                // send only a few reports to avoid overloading the network
                break;
            }
            reportDistributor.distribute(report);
            reportsSentCount++;
        }
    } catch (Exception e) {
        ACRA.log.e(LOG_TAG, "", e);
    }
    if (ACRA.DEV_LOGGING)
        ACRA.log.d(LOG_TAG, "Finished sending reports from SenderService");
}
Also used : CrashReportFileNameParser(org.acra.file.CrashReportFileNameParser) ACRAConfiguration(org.acra.config.ACRAConfiguration) File(java.io.File)

Aggregations

ACRAConfiguration (org.acra.config.ACRAConfiguration)3 File (java.io.File)2 ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)1 Serializable (java.io.Serializable)1 ACRAConfigurationException (org.acra.config.ACRAConfigurationException)1 ConfigurationBuilder (org.acra.config.ConfigurationBuilder)1 CrashReportFileNameParser (org.acra.file.CrashReportFileNameParser)1