
org.acra.annotation.ReportsCrashes Maven / Gradle / Ivy
/*
* Copyright 2010 Emmanuel Astier & Kevin Gaudin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.acra.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.acra.ACRA;
import org.acra.ACRAConstants;
import org.acra.BaseCrashReportDialog;
import org.acra.CrashReportDialog;
import org.acra.ReportField;
import org.acra.ReportingInteractionMode;
import org.acra.sender.HttpSender.Method;
import org.acra.sender.HttpSender.Type;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
/**
* Provide configuration elements to the
* {@link ACRA#init(android.app.Application)} method. The only mandatory
* configuration item is the {@link #formUri()} parameter which is the Uri
* to the server that will receive your reports.
*
* @author Kevin Gaudin
*
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface ReportsCrashes {
/**
* The Uri of your own server-side script that will receive reports. This is
* to use if you don't want to send reports to Google Docs but to your own,
* self-hosted script.
*
* @return URI of a custom server to which to post reports.
*/
String formUri() default ACRAConstants.DEFAULT_STRING_VALUE;
/**
*
* The interaction mode you want to implement. Default is
* {@link ReportingInteractionMode#SILENT} which does not require any
* resources configuration.
*
*
* Other modes have resources requirements:
*
*
* - {@link ReportingInteractionMode#TOAST} requires
* {@link #resToastText()} to be provided to define the text that you want
* to be displayed to the user when a report is being sent.
* - {@link ReportingInteractionMode#NOTIFICATION} requires
* {@link #resNotifTickerText()}, {@link #resNotifTitle()},
* {@link #resNotifText()}, {@link #resDialogText()}.
* - {@link ReportingInteractionMode#DIALOG} requires
* {@link #resDialogText()}.
*
*
* Default is {@link ReportingInteractionMode#SILENT}
*
*
* @return the interaction mode that you want ACRA to implement.
*/
ReportingInteractionMode mode() default ReportingInteractionMode.SILENT;
/**
* @return Resource id for the label of positive button in the crash dialog.
* If not provided, defaults to 'OK'.
*/
int resDialogPositiveButtonText() default ACRAConstants.DEFAULT_DIALOG_POSITIVE_BUTTON_TEXT;
/**
* @return Resource id for the label of negative button in the crash dialog.
* If not provided, defaults to 'cancel'.
*/
int resDialogNegativeButtonText() default ACRAConstants.DEFAULT_DIALOG_NEGATIVE_BUTTON_TEXT;
/**
* @return Resource id for the user comment input label in the crash dialog.
* If not provided, disables the input field.
*/
int resDialogCommentPrompt() default ACRAConstants.DEFAULT_RES_VALUE;
/**
* @return Resource id for the user email address input label in the crash
* dialog. If not provided, disables the input field.
*/
int resDialogEmailPrompt() default ACRAConstants.DEFAULT_RES_VALUE;
/**
* @return Resource id for the icon in the crash dialog. Default value is
* the system alert icon.
*/
int resDialogIcon() default ACRAConstants.DEFAULT_DIALOG_ICON;
/**
* @return Resource id for the Toast text triggered when the user accepts to
* send a report in the crash dialog.
*/
int resDialogOkToast() default ACRAConstants.DEFAULT_RES_VALUE;
/**
* @return Resource id for the text in the crash dialog.
*/
int resDialogText() default ACRAConstants.DEFAULT_RES_VALUE;
/**
* @return Resource id for the title in the crash dialog.
*/
int resDialogTitle() default ACRAConstants.DEFAULT_RES_VALUE;
/**
* @return Resource id for the icon in the status bar notification. Default
* is the system error notification icon.
*/
int resNotifIcon() default ACRAConstants.DEFAULT_NOTIFICATION_ICON;
/**
* @return Resource id for the text in the status bar notification.
*/
int resNotifText() default ACRAConstants.DEFAULT_RES_VALUE;
/**
* @return Resource id for the ticker text in the status bar notification.
*/
int resNotifTickerText() default ACRAConstants.DEFAULT_RES_VALUE;
/**
* @return Resource id for the title in the status bar notification.
*/
int resNotifTitle() default ACRAConstants.DEFAULT_RES_VALUE;
/**
* Resource id for the Toast text triggered when the application crashes if
* the {@link ReportingInteractionMode#TOAST} mode is used. Can also be used
* in {@link ReportingInteractionMode#NOTIFICATION} and
* {@link ReportingInteractionMode#DIALOG} modes to display a Toast message
* while the report is being created, before the dialog/notification
* appears. This allows the user to know what is happening just before the
* application is terminated.
*
* @return Resource id for the Toast text triggered when the application
* crashes.
*/
int resToastText() default ACRAConstants.DEFAULT_RES_VALUE;
/**
* @return Name of the SharedPreferences that will host ACRA settings you
* can make accessible to your users through a preferences screen:
*
* -
* {@link ACRA#PREF_DISABLE_ACRA} or {@link ACRA#PREF_ENABLE_ACRA}
* -
* {@link ACRA#PREF_ALWAYS_ACCEPT}
* -
* {@link ACRA#PREF_ENABLE_DEVICE_ID}
* -
* {@link ACRA#PREF_ENABLE_SYSTEM_LOGS}
*
* preference. Default is to use the application default
* SharedPreferences, as retrieved with
* {@link PreferenceManager#getDefaultSharedPreferences(Context)}.
*/
String sharedPreferencesName() default ACRAConstants.DEFAULT_STRING_VALUE;
/**
* If using a custom {@link ReportsCrashes#sharedPreferencesName()}, pass
* here the mode that you need for the SharedPreference file creation:
* {@link Context#MODE_PRIVATE}, {@link Context#MODE_WORLD_READABLE} or
* {@link Context#MODE_WORLD_WRITEABLE}. Default is
* {@link Context#MODE_PRIVATE}.
*
* @return Mode to use with the SharedPreference creation.
* @see Context#getSharedPreferences(String, int)
*/
int sharedPreferencesMode() default ACRAConstants.DEFAULT_SHARED_PREFERENCES_MODE;
/**
* If enabled, DropBox events collection will include system tags:
*
* - system_app_anr
* - system_app_wtf
* - system_app_crash
* - system_server_anr
* - system_server_wtf
* - system_server_crash
* - BATTERY_DISCHARGE_INFO
* - SYSTEM_RECOVERY_LOG
* - SYSTEM_BOOT
* - SYSTEM_LAST_KMSG
* - APANIC_CONSOLE
* - APANIC_THREADS
* - SYSTEM_RESTART
* - SYSTEM_TOMBSTONE
* - data_app_strictmode
*
*
* @return True if system tags are to be included as part of DropBox events.
*/
boolean includeDropBoxSystemTags() default ACRAConstants.DEFAULT_INCLUDE_DROPBOX_SYSTEM_TAGS;
/**
* @return Array of tags that you want to be fetched when collecting DropBox
* entries.
*/
String[] additionalDropBoxTags() default {};
/**
* @return Number of minutes to look back when collecting events from
* DropBoxManager.
*/
int dropboxCollectionMinutes() default ACRAConstants.DEFAULT_DROPBOX_COLLECTION_MINUTES;
/**
*
* Arguments to be passed to the logcat command line. Default is { "-t",
* "100", "-v", "time" } for:
*
*
*
* logcat -t 100 -v time
*
*
*
* Do not include -b arguments for buffer selection, include
* {@link ReportField#EVENTSLOG} and {@link ReportField#RADIOLOG} in
* {@link ReportsCrashes#customReportContent()} to activate alternative
* logcat buffers reporting. They will use the same other arguments as those
* provided here.
*
*
*
* See Listing of logcat Command Options.
*
*
* @return Array of arguments to supply if retrieving the log as part of the
* report.
*/
String[] logcatArguments() default { "-t", "" + ACRAConstants.DEFAULT_LOGCAT_LINES, "-v", "time" };
/**
* When using the {@link #formUri()} parameter to send reports to a custom
* server-side script, you can set here and in
* {@link #formUriBasicAuthPassword()} the credentials for a BASIC HTTP
* authentication.
*
* @return Login to use when posting reports to a custom server.
*/
String formUriBasicAuthLogin() default ACRAConstants.NULL_VALUE;
/**
* When using the {@link #formUri()} parameter to send reports to a custom
* server-side script, you can set here and in
* {@link #formUriBasicAuthLogin()} the credentials for a BASIC HTTP
* authentication.
*
* @return Password to use when posting reports to a custom server.
*/
String formUriBasicAuthPassword() default ACRAConstants.NULL_VALUE;
/**
*
* Redefines the list of {@link ReportField}s collected and sent in your
* reports. If you modify this list, you have to create a new Google Drive
* Spreadsheet & Form which will be based on these fields as column headers.
*
*
* The fields order is significant. You can also use this property to modify
* fields order in your reports.
*
*
* The default list is the following, except if you send reports by mail
* using {@link #mailTo()}.
*
*
* -
* {@link ReportField#REPORT_ID}
* -
* {@link ReportField#APP_VERSION_CODE}
* -
* {@link ReportField#APP_VERSION_NAME}
* -
* {@link ReportField#PACKAGE_NAME}
* -
* {@link ReportField#FILE_PATH}
* -
* {@link ReportField#PHONE_MODEL}
* -
* {@link ReportField#BRAND}
* -
* {@link ReportField#PRODUCT}
* -
* {@link ReportField#ANDROID_VERSION}
* -
* {@link ReportField#BUILD}
* -
* {@link ReportField#TOTAL_MEM_SIZE}
* -
* {@link ReportField#AVAILABLE_MEM_SIZE}
* -
* {@link ReportField#CUSTOM_DATA}
* -
* {@link ReportField#IS_SILENT}
* -
* {@link ReportField#STACK_TRACE}
* -
* {@link ReportField#INITIAL_CONFIGURATION}
* -
* {@link ReportField#CRASH_CONFIGURATION}
* -
* {@link ReportField#DISPLAY}
* -
* {@link ReportField#USER_COMMENT}
* -
* {@link ReportField#USER_EMAIL}
* -
* {@link ReportField#USER_APP_START_DATE}
* -
* {@link ReportField#USER_CRASH_DATE}
* -
* {@link ReportField#DUMPSYS_MEMINFO}
* -
* {@link ReportField#LOGCAT}
* -
* {@link ReportField#INSTALLATION_ID}
* -
* {@link ReportField#DEVICE_FEATURES}
* -
* {@link ReportField#ENVIRONMENT}
* -
* {@link ReportField#SHARED_PREFERENCES}
* -
* {@link ReportField#SETTINGS_SYSTEM}
* -
* {@link ReportField#SETTINGS_SECURE}
* -
* {@link ReportField#SETTINGS_GLOBAL}
*
*
* @return ReportField Array listing the fields to be included in the
* report.
*/
ReportField[] customReportContent() default {};
/**
*
* Add your crash reports mailbox here if you want to send reports via
* email. This allows to get rid of the INTERNET permission. Reports content
* can be customized with {@link #customReportContent()} . Default fields
* are:
*
*
* -
* {@link ReportField#USER_COMMENT}
* -
* {@link ReportField#ANDROID_VERSION}
* -
* {@link ReportField#APP_VERSION_NAME}
* -
* {@link ReportField#BRAND}
* -
* {@link ReportField#PHONE_MODEL}
* -
* {@link ReportField#CUSTOM_DATA}
* -
* {@link ReportField#STACK_TRACE}
*
*
* @return email address to which to send reports.
*/
String mailTo() default ACRAConstants.DEFAULT_STRING_VALUE;
/**
* Controls whether unapproved reports are deleted on application start or
* not. Default is true. This is a change from versions of ACRA before 3.2
* as in {@link ReportingInteractionMode#NOTIFICATION} mode reports were
* previously kept until the user explicitly opens the Notification dialog
* AND choose to send or discard the report. Until then, on application
* restart, ACRA was issuing a new crash notification for previous reports
* pending for approval. This could be misunderstood by the user with a new
* crash, resulting in bad appreciation of the application.
*
* @return true if ACRA should delete unapproved reports on application
* start.
*/
boolean deleteUnapprovedReportsOnApplicationStart() default ACRAConstants.DEFAULT_DELETE_UNAPPROVED_REPORTS_ON_APPLICATION_START;
/**
* This property can be used to determine whether old (out of date) reports
* should be sent or not. By default they are discarded.
*
* @return true if ACRA should delete any unsent reports on startup if the
* application has been updated since the last time the application
* was started.
*/
boolean deleteOldUnsentReportsOnApplicationStart() default ACRAConstants.DEFAULT_DELETE_OLD_UNSENT_REPORTS_ON_APPLICATION_START;
/**
* @return Value in milliseconds for timeout attempting to connect to a
* network (default 3000ms).
*/
int connectionTimeout() default ACRAConstants.DEFAULT_CONNECTION_TIMEOUT;
/**
* If the request is retried due to timeout, the socketTimeout will double
* before retrying the request.
*
* @return Value in milliseconds for timeout receiving a response to a
* network request (default 5000ms).
* @see #maxNumberOfRequestRetries()
*/
int socketTimeout() default ACRAConstants.DEFAULT_SOCKET_TIMEOUT;
/**
* @return Maximum number of times a network request will be retried when
* receiving the response times out (default 3).
* @see #socketTimeout()
*/
int maxNumberOfRequestRetries() default ACRAConstants.DEFAULT_MAX_NUMBER_OF_REQUEST_RETRIES;
/**
* In {@link ReportingInteractionMode#TOAST} mode, set this to true if you
* prefer displaying the native Force Close dialog after the Toast.
*
* @return true if the Force Close dialog has to be displayed.
*/
boolean forceCloseDialogAfterToast() default ACRAConstants.DEFAULT_FORCE_CLOSE_DIALOG_AFTER_TOAST;
/**
* Add here your {@link SharedPreferences} identifier Strings if you use
* others than your application's default. They will be added to the
* {@link ReportField#SHARED_PREFERENCES} field.
*
* @return String Array containing the names of the additional preferences.
*/
String[] additionalSharedPreferences() default {};
/**
* Set this to true if you want to include only logcat lines related to your
* Application process.
*
* @return true if you want to filter logcat with your process id.
*/
boolean logcatFilterByPid() default ACRAConstants.DEFAULT_LOGCAT_FILTER_BY_PID;
/**
* Set this to false if you want to disable sending reports in development
* mode. Only signed application packages will send reports. Default value
* is true.
*
* @return false if reports should not be sent.
*/
boolean sendReportsInDevMode() default ACRAConstants.DEFAULT_SEND_REPORTS_IN_DEV_MODE;
/**
* Set this to false if you want to disable sending reports at the time the
* exception is caught. In this case, reports will not be sent until the
* application is restarted.
*
* @return false if reports should not be sent.
*/
boolean sendReportsAtShutdown() default ACRAConstants.DEFAULT_SEND_REPORTS_AT_SHUTDOWN;
/**
* Provide here regex patterns to be evaluated on each SharedPreference key
* to exclude KV pairs from the collected SharedPreferences. This allows you
* to exclude sensitive user data like passwords to be collected.
*
* @return an array of regex patterns, every matching key is not collected.
*/
String[] excludeMatchingSharedPreferencesKeys() default {};
/**
* Provide here regex patterns to be evaluated on each Settings.System,
* Settings.Secure and Settings.Global key to exclude KV pairs from the
* collected SharedPreferences. This allows you to exclude sensitive data to
* be collected.
*
* @return an array of regex patterns, every matching key is not collected.
*/
String[] excludeMatchingSettingsKeys() default {};
/**
* The default value will be a BuildConfig class residing in the same package as the Application class.
*
* @return BuildConfig class from which to read any BuildConfig attributes.
*/
Class buildConfigClass() default Object.class;
/**
* To use in combination with {@link ReportField#APPLICATION_LOG} to set the
* path/name of your application log file. If the string does not contain
* any path separator, the file is assumed as being in
* {@link Context#getFilesDir()}.
*
* @return a String containing the path/name of your application log file.
* If the string does not containt any path separator, the file is
* assumed as being in {@link Context#getFilesDir()}.
*/
String applicationLogFile() default ACRAConstants.DEFAULT_APPLICATION_LOGFILE;
/**
* To use in combination with {@link ReportField#APPLICATION_LOG} to set the
* number of latest lines of your application log file to be collected.
* Default value is 100.
*
* @return number of lines to collect.
*/
int applicationLogFileLines() default ACRAConstants.DEFAULT_APPLICATION_LOGFILE_LINES;
/**
*
* Set this to true if you need to post reports to your own server using an
* SSL connection with a self-signed certificate.
*
*
* @return True if SSL certificates validation has to be ignored when
* posting reports.
*/
boolean disableSSLCertValidation() default ACRAConstants.DEFAULT_DISABLE_SSL_CERT_VALIDATION;
String httpsSocketFactoryFactoryClass() default ACRAConstants.DEFAULT_HTTP_SOCKET_FACTORY_FACTORY_CLASS;
/**
* @return Class for the CrashReportDialog used when sending intent.
* If not provided, defaults to CrashReportDialog.class
*/
Class extends BaseCrashReportDialog> reportDialogClass() default CrashReportDialog.class;
/**
*
* The {@link Method} to be used when posting with {@link #formUri()}.
*
*
* @return HTTP method used when posting reports.
*/
Method httpMethod() default Method.POST;
Type reportType() default Type.FORM;
}