public static void deleteFile(@NonNull File file) { final boolean deleted = file.delete(); if (!deleted) { ACRA.log.w(LOG_TAG, "Could not delete file: " + file); } }
public synchronized void put(@NonNull String key, double value) { try { content.put(key, value); } catch (JSONException e) { ACRA.log.w(ACRA.LOG_TAG, "Failed to put value into CrashReportData: " + String.valueOf(value)); } }
public synchronized void put(@NonNull String key, int value) { try { content.put(key, value); } catch (JSONException e) { ACRA.log.w(ACRA.LOG_TAG, "Failed to put value into CrashReportData: " + String.valueOf(value)); } }
@Override public void send(@NonNull Context context, @NonNull CrashReportData errorContent) { ACRA.log.w(LOG_TAG, context.getPackageName() + " reports will NOT be sent - no valid ReportSender was found!"); } }
public synchronized void put(@NonNull String key, boolean value) { try { content.put(key, value); } catch (JSONException e) { ACRA.log.w(ACRA.LOG_TAG, "Failed to put value into CrashReportData: " + String.valueOf(value)); } }
public synchronized void put(@NonNull String key, long value) { try { content.put(key, value); } catch (JSONException e) { ACRA.log.w(ACRA.LOG_TAG, "Failed to put value into CrashReportData: " + String.valueOf(value)); } }
public synchronized void put(@NonNull String key, @Nullable String value) { if (value == null) { putNA(key); return; } try { content.put(key, value); } catch (JSONException e) { ACRA.log.w(ACRA.LOG_TAG, "Failed to put value into CrashReportData: " + value); } }
public synchronized void put(@NonNull String key, @Nullable JSONArray value) { if (value == null) { putNA(key); return; } try { content.put(key, value); } catch (JSONException e) { ACRA.log.w(ACRA.LOG_TAG, "Failed to put value into CrashReportData: " + String.valueOf(value)); } }
/** * Starts a Process to start sending outstanding error reports. * * @param onlySendSilentReports If true then only send silent reports. */ private void sendReport(@NonNull File report, boolean onlySendSilentReports) { if (enabled) { schedulerStarter.scheduleReports(report, onlySendSilentReports); } else { ACRA.log.w(LOG_TAG, "Would be sending reports, but ACRA is disabled"); } }
public void collectStartUp() { for (Collector collector : collectors) { if (collector instanceof ApplicationStartupCollector) { //catch absolutely everything possible here so no collector obstructs the others try { ((ApplicationStartupCollector) collector).collectApplicationStartUp(context, config); } catch (Exception t) { ACRA.log.w(ACRA.LOG_TAG, collector.getClass().getSimpleName() + " failed to collect its startup data", t); } } } } }
public synchronized void put(@NonNull String key, @Nullable JSONObject value) { if (value == null) { putNA(key); return; } try { content.put(key, value); } catch (JSONException e) { ACRA.log.w(ACRA.LOG_TAG, "Failed to put value into CrashReportData: " + String.valueOf(value)); } }
@NonNull public static ErrorReporter createErrorReporterStub() { return createStub(ErrorReporter.class, (proxy, method, args) -> { String message = ACRA.isACRASenderServiceProcess() ? "in SenderService process" : "before ACRA#init (if you did call #init, check if your configuration is valid)"; ACRA.log.w(ACRA.LOG_TAG, String.format("ErrorReporter#%s called %s. THIS CALL WILL BE IGNORED!", method.getName(), message)); return null; }); }
@SuppressWarnings("WeakerAccess") protected void putAttachment(@NonNull CoreConfiguration configuration, @NonNull Context context, @Nullable String login, @Nullable String password, int connectionTimeOut, int socketTimeOut, @Nullable Map<String, String> headers, @NonNull URL url, @NonNull Uri attachment) throws IOException { try { final URL attachmentUrl = new URL(url.toString() + "-" + UriUtils.getFileNameFromUri(context, attachment)); new BinaryHttpRequest(configuration, context, login, password, connectionTimeOut, socketTimeOut, headers).send(attachmentUrl, attachment); } catch (FileNotFoundException e) { ACRA.log.w("Not sending attachment", e); } }
@NonNull public static synchronized String id(@NonNull Context context) { final File installation = new File(context.getFilesDir(), INSTALLATION); try { if (!installation.exists()) { IOUtils.writeStringToFile(installation, UUID.randomUUID().toString()); } return new StreamReader(installation).read(); } catch (IOException | RuntimeException e) { ACRA.log.w(LOG_TAG, "Couldn't retrieve InstallationId for " + context.getPackageName(), e); return "Couldn't retrieve InstallationId"; } } }
@NonNull @BuilderMethod public <R extends ConfigurationBuilder> R getPluginConfigurationBuilder(@NonNull Class<R> c) { for (ConfigurationBuilder builder : configurationBuilders()) { if (c.isAssignableFrom(builder.getClass())) { //noinspection unchecked return (R) builder; } } if (c.isInterface()) { ACRA.log.w(LOG_TAG, "Couldn't find ConfigurationBuilder " + c.getSimpleName() + ". ALL CALLS TO IT WILL BE IGNORED!"); return StubCreator.createStub(c, (proxy, method, args) -> proxy); } throw new IllegalArgumentException("Class " + c.getName() + " is not a registered ConfigurationBuilder"); } }
@Override void collect(@NonNull ReportField reportField, @NonNull Context context, @NonNull CoreConfiguration config, @NonNull ReportBuilder reportBuilder, @NonNull CrashReportData target) { final JSONObject result = new JSONObject(); for (Display display : getDisplays(context)) { try { result.put(String.valueOf(display.getDisplayId()), collectDisplayData(display)); } catch (JSONException e) { ACRA.log.w(ACRA.LOG_TAG, "Failed to collect data for display " + display.getDisplayId(), e); } } target.put(ReportField.DISPLAY, result); }
public SchedulerStarter(@NonNull Context context, @NonNull CoreConfiguration config) { locator = new ReportLocator(context); List<SenderSchedulerFactory> schedulerFactories = config.pluginLoader().loadEnabled(config, SenderSchedulerFactory.class); if (schedulerFactories.isEmpty()) { senderScheduler = new DefaultSenderScheduler(context, config); } else { senderScheduler = schedulerFactories.get(0).create(context, config); if (schedulerFactories.size() > 1) ACRA.log.w(ACRA.LOG_TAG, "More than one SenderScheduler found. Will use only " + senderScheduler.getClass().getSimpleName()); } }
/** * @param approved Whether to delete approved or unapproved reports. * @param nrToKeep Number of latest reports to keep. */ public void deleteReports(boolean approved, int nrToKeep) { final File[] files = approved ? reportLocator.getApprovedReports() : reportLocator.getUnapprovedReports(); Arrays.sort(files, new LastModifiedComparator()); for (int i = 0; i < files.length - nrToKeep; i++) { if (!files[i].delete()) { ACRA.log.w(LOG_TAG, "Could not delete report : " + files[i]); } } } }
/** * {@inheritDoc} */ @Override public void setEnabled(boolean enabled) { if (supportedAndroidVersion) { ACRA.log.i(LOG_TAG, "ACRA is " + (enabled ? "enabled" : "disabled") + " for " + context.getPackageName()); reportExecutor.setEnabled(enabled); } else { ACRA.log.w(LOG_TAG, "ACRA requires ICS or greater. ACRA is disabled and will NOT catch crashes or send messages."); } }
public static LimiterData load(@NonNull Context context) { try { return new LimiterData(new StreamReader(context.openFileInput(FILE_LIMITER_DATA)).read()); } catch (FileNotFoundException e){ return new LimiterData(); }catch (IOException | JSONException e) { ACRA.log.w(LOG_TAG, "Failed to load LimiterData", e); return new LimiterData(); } }