@SuppressWarnings("WeakerAccess") protected void handleResponse(int responseCode, String responseMessage) throws IOException { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Request response : " + responseCode + " : " + responseMessage); if (responseCode >= HttpURLConnection.HTTP_OK && responseCode < HttpURLConnection.HTTP_MULT_CHOICE) { // All is good ACRA.log.i(LOG_TAG, "Request received by server"); } else if (responseCode == HttpURLConnection.HTTP_CLIENT_TIMEOUT || responseCode >= HttpURLConnection.HTTP_INTERNAL_ERROR) { //timeout or server error. Repeat the request later. ACRA.log.w(LOG_TAG, "Could not send ACRA Post responseCode=" + responseCode + " message=" + responseMessage); throw new IOException("Host returned error code " + responseCode); } else if (responseCode >= HttpURLConnection.HTTP_BAD_REQUEST) { // Client error. The request must not be repeated. Discard it. ACRA.log.w(LOG_TAG, responseCode + ": Client error - request will be discarded"); } else { ACRA.log.w(LOG_TAG, "Could not send ACRA Post - request will be discarded. responseCode=" + responseCode + " message=" + responseMessage); } } }
public static void deleteFile(@NonNull File file) { final boolean deleted = file.delete(); if (!deleted) { ACRA.log.w(LOG_TAG, "Could not delete file: " + file); } }
@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 void onActivityDestroyed(@NonNull Activity activity) { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "onActivityDestroyed " + activity.getClass()); } });
/** * {@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."); } }
/** * 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); } } }
@Override public void onActivityStarted(@NonNull Activity activity) { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "onActivityStarted " + activity.getClass()); }
@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!"); } }
@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; } }
@Override public void onActivityResumed(@NonNull Activity activity) { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "onActivityResumed " + activity.getClass()); }
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)); } }
@Override public void onActivityPaused(@NonNull Activity activity) { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "onActivityPaused " + activity.getClass()); }
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 onActivitySaveInstanceState(@NonNull Activity activity, Bundle outState) { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "onActivitySaveInstanceState " + activity.getClass()); }
/** * 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"); } }
@Override public void onActivityStopped(@NonNull Activity activity) { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "onActivityStopped " + activity.getClass()); synchronized (this) { notify(); } }
@Override public void onActivityCreated(@NonNull Activity activity, Bundle savedInstanceState) { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "onActivityCreated " + activity.getClass()); lastActivityCreated = new WeakReference<>(activity); }
/** * @return true if the current process is the process running the SenderService. * NB this assumes that your SenderService is configured to used the default ':acra' process. */ public static boolean isACRASenderServiceProcess() { final String processName = getCurrentProcessName(); if (ACRA.DEV_LOGGING) log.d(LOG_TAG, "ACRA processName='" + processName + '\''); //processName sometimes (or always?) starts with the package name, so we use endsWith instead of equals return processName != null && processName.endsWith(ACRA_PRIVATE_PROCESS_NAME); }
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent.hasExtra(EXTRA_ACRA_CONFIG)) { final boolean onlySendSilentReports = intent.getBooleanExtra(EXTRA_ONLY_SEND_SILENT_REPORTS, false); final CoreConfiguration config = (CoreConfiguration) intent.getSerializableExtra(EXTRA_ACRA_CONFIG); new SendingConductor(this, config).sendReports(onlySendSilentReports); } else { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "SenderService was started but no valid intent was delivered, will now quit"); } return START_REDELIVER_INTENT; }
@Override public boolean onCreate() { //noinspection ConstantConditions authority = getAuthority(getContext()); if (ACRA.DEV_LOGGING) ACRA.log.d(ACRA.LOG_TAG, "Registered content provider for authority " + authority); return true; }