@Override public InputStream getInputStream(@NonNull Context context) { try { return new FileInputStream(filePath); } catch (FileNotFoundException e) { ACRA.log.e(LOG_TAG, "Could not find File "+filePath, e); } return null; } }
@Override public InputStream getInputStream(@NonNull Context context) { try { return context.getAssets().open(assetName); } catch (IOException e) { ACRA.log.e(LOG_TAG, "Could not open certificate in asset://"+assetName, e); } return null; } }
@VisibleForTesting @Nullable <T> T create(@NonNull Class<? extends T> clazz) { try { return clazz.newInstance(); } catch (InstantiationException e) { ACRA.log.e(LOG_TAG, "Failed to create instance of class " + clazz.getName(), e); } catch (IllegalAccessException e) { ACRA.log.e(LOG_TAG, "Failed to create instance of class " + clazz.getName(), e); } return null; }
/** * pass-through to default handler * * @param t the crashed thread * @param e the uncaught exception */ public void handReportToDefaultExceptionHandler(@Nullable Thread t, @NonNull Throwable e) { if (defaultExceptionHandler != null) { ACRA.log.i(LOG_TAG, "ACRA is disabled for " + context.getPackageName() + " - forwarding uncaught Exception on to default ExceptionHandler"); defaultExceptionHandler.uncaughtException(t, e); } else { ACRA.log.e(LOG_TAG, "ACRA is disabled for " + context.getPackageName() + " - no default ExceptionHandler"); ACRA.log.e(LOG_TAG, "ACRA caught a " + e.getClass().getSimpleName() + " for " + context.getPackageName(), e); } }
/** * {@inheritDoc} */ @NonNull @Override public List<Uri> getAttachments(@NonNull Context context, @NonNull CoreConfiguration configuration) { final ArrayList<Uri> result = new ArrayList<>(); for (String s : configuration.attachmentUris()) { try { result.add(Uri.parse(s)); } catch (Exception e) { ACRA.log.e(LOG_TAG, "Failed to parse Uri " + s, e); } } return result; } }
/** * Collect results of the <code>dumpsys meminfo</code> command restricted to this application process. * * @return The execution result. */ @Nullable private String collectMemInfo() { try { final List<String> commandLine = new ArrayList<>(); commandLine.add("dumpsys"); commandLine.add("meminfo"); commandLine.add(Integer.toString(android.os.Process.myPid())); final Process process = Runtime.getRuntime().exec(commandLine.toArray(new String[commandLine.size()])); return new StreamReader(process.getInputStream()).read(); } catch (IOException e) { ACRA.log.e(LOG_TAG, "MemoryInfoCollector.meminfo could not retrieve data", e); return null; } }
private <T extends Plugin> List<T> loadInternal(@NonNull Class<T> clazz, Predicate<T> shouldLoadPredicate) { List<T> plugins = new ArrayList<>(); //noinspection ForLoopReplaceableByForEach final ServiceLoader<T> serviceLoader = ServiceLoader.load(clazz, getClass().getClassLoader()); if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "ServicePluginLoader loading services from ServiceLoader : " + serviceLoader); for (final Iterator<T> iterator = serviceLoader.iterator(); iterator.hasNext(); ) { try { final T plugin = iterator.next(); if (shouldLoadPredicate.apply(plugin)) { if (ACRA.DEV_LOGGING) ACRA.log.d(ACRA.LOG_TAG, "Loaded " + clazz.getSimpleName() + " of type " + plugin.getClass().getName()); plugins.add(plugin); } else { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Ignoring disabled " + clazz.getSimpleName() + " of type " + plugin.getClass().getSimpleName()); } } catch (ServiceConfigurationError e) { ACRA.log.e(ACRA.LOG_TAG, "Unable to load " + clazz.getSimpleName(), e); } } if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Found services (" + plugins + ") for class : " + clazz); return plugins; } }
ACRA.log.e(LOG_TAG, "Could not load certificate", e); } catch (KeyStoreException e) { ACRA.log.e(LOG_TAG, "Could not load keystore", e); } catch (NoSuchAlgorithmException e) { ACRA.log.e(LOG_TAG, "Could not load keystore", e); } catch (IOException e) { ACRA.log.e(LOG_TAG, "Could not load keystore", e); } finally { IOUtils.safeClose(bufferedInputStream);
private void stopServices() { if (config.stopServicesOnCrash()) { try { final ActivityManager activityManager = SystemServices.getActivityManager(context); final List<ActivityManager.RunningServiceInfo> runningServices = activityManager.getRunningServices(Integer.MAX_VALUE); final int pid = Process.myPid(); for (ActivityManager.RunningServiceInfo serviceInfo : runningServices) { if (serviceInfo.pid == pid && !LegacySenderService.class.getName().equals(serviceInfo.service.getClassName()) && !JobSenderService.class.getName().equals(serviceInfo.service.getClassName())) { try { final Intent intent = new Intent(); intent.setComponent(serviceInfo.service); context.stopService(intent); } catch (SecurityException e) { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Unable to stop Service " + serviceInfo.service.getClassName() + ". Permission denied"); } } } } catch (SystemServices.ServiceNotReachedException e) { ACRA.log.e(LOG_TAG, "Unable to stop services", e); } } }
/** * Store a report * * @param file the file to store in * @param crashData the content */ private void saveCrashReportFile(@NonNull File file, @NonNull CrashReportData crashData) { try { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Writing crash report file " + file); final CrashReportPersister persister = new CrashReportPersister(); persister.store(crashData, file); } catch (Exception e) { ACRA.log.e(LOG_TAG, "An error occurred while writing the report file...", e); } } }
ACRA.log.w(LOG_TAG, e); }catch (Exception t) { ACRA.log.e(LOG_TAG, "Error in collector " + collector.getClass().getSimpleName(), t);
return true; } catch (RuntimeException e) { ACRA.log.e(LOG_TAG, "Failed to send crash reports for " + reportFile, e); IOUtils.deleteFile(reportFile); } catch (IOException e) { ACRA.log.e(LOG_TAG, "Failed to load crash report for " + reportFile, e); IOUtils.deleteFile(reportFile); } catch (JSONException e) { ACRA.log.e(LOG_TAG, "Failed to load crash report for " + reportFile, e); IOUtils.deleteFile(reportFile); } catch (ReportSenderException e) { ACRA.log.e(LOG_TAG, "Failed to send crash report for " + reportFile, e);
@Override public void uncaughtException(@Nullable Thread t, @NonNull Throwable e) { // If we're not enabled then just pass the Exception on to the defaultExceptionHandler. if (!reportExecutor.isEnabled()) { reportExecutor.handReportToDefaultExceptionHandler(t, e); return; } try { ACRA.log.e(LOG_TAG, "ACRA caught a " + e.getClass().getSimpleName() + " for " + context.getPackageName(), e); if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Building report"); // Generate and send crash report new ReportBuilder() .uncaughtExceptionThread(t) .exception(e) .customData(customData) .endApplication() .build(reportExecutor); } catch (Exception fatality) { // ACRA failed. Prevent any recursive call to ACRA.uncaughtException(), let the native reporter do its job. ACRA.log.e(LOG_TAG, "ACRA failed to capture the error - handing off to native error reporter", fatality); reportExecutor.handReportToDefaultExceptionHandler(t, e); } }
configureHttps((HttpsURLConnection) urlConnection); } catch (GeneralSecurityException e) { ACRA.log.e(LOG_TAG, "Could not configure SSL for ACRA request to " + url, e);
ACRA.log.e(LOG_TAG, "Failed to handle notification action", t);
ACRA.log.e(LOG_TAG, "", e);
log.e(LOG_TAG, "ACRA#init called but no CoreConfiguration provided"); return;