michael@0: #filter substitution michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko.background.healthreport; michael@0: michael@0: import org.mozilla.gecko.background.common.GlobalConstants; michael@0: michael@0: public class HealthReportConstants { michael@0: public static final String HEALTH_AUTHORITY = "@ANDROID_PACKAGE_NAME@.health"; michael@0: public static final String GLOBAL_LOG_TAG = "GeckoHealth"; michael@0: michael@0: public static final String USER_AGENT = "Firefox-Android-HealthReport/" + GlobalConstants.MOZ_APP_VERSION + " (" + GlobalConstants.MOZ_APP_DISPLAYNAME + ")"; michael@0: michael@0: /** michael@0: * The earliest allowable value for the last ping time, corresponding to May 2nd 2013. michael@0: * Used for sanity checks. michael@0: */ michael@0: public static final long EARLIEST_LAST_PING = 1367500000000L; michael@0: michael@0: // Not `final` so we have the option to turn this on at runtime with a magic addon. michael@0: public static boolean UPLOAD_FEATURE_DISABLED = false; michael@0: michael@0: // Android SharedPreferences branch where global (not per-profile) uploader michael@0: // settings are stored. michael@0: public static final String PREFS_BRANCH = "background"; michael@0: michael@0: // How frequently the submission and prune policies are ticked over. This is how frequently our michael@0: // intent is scheduled to be called by the Android Alarm Manager, not how frequently we michael@0: // actually submit. These values are set as preferences rather than constants so that testing michael@0: // addons can change their values. michael@0: public static final String PREF_SUBMISSION_INTENT_INTERVAL_MSEC = "healthreport_submission_intent_interval_msec"; michael@0: public static final long DEFAULT_SUBMISSION_INTENT_INTERVAL_MSEC = GlobalConstants.MILLISECONDS_PER_DAY / 24; michael@0: public static final String PREF_PRUNE_INTENT_INTERVAL_MSEC = "healthreport_prune_intent_interval_msec"; michael@0: public static final long DEFAULT_PRUNE_INTENT_INTERVAL_MSEC = GlobalConstants.MILLISECONDS_PER_DAY; michael@0: michael@0: public static final String ACTION_HEALTHREPORT_UPLOAD_PREF = "@ANDROID_PACKAGE_NAME@.HEALTHREPORT_UPLOAD_PREF"; michael@0: public static final String ACTION_HEALTHREPORT_PRUNE = "@ANDROID_PACKAGE_NAME@.HEALTHREPORT_PRUNE"; michael@0: michael@0: public static final String PREF_MINIMUM_TIME_BETWEEN_UPLOADS = "healthreport_time_between_uploads"; michael@0: public static final long DEFAULT_MINIMUM_TIME_BETWEEN_UPLOADS = GlobalConstants.MILLISECONDS_PER_DAY; michael@0: michael@0: public static final String PREF_MINIMUM_TIME_BEFORE_FIRST_SUBMISSION = "healthreport_time_before_first_submission"; michael@0: public static final long DEFAULT_MINIMUM_TIME_BEFORE_FIRST_SUBMISSION = GlobalConstants.MILLISECONDS_PER_DAY; michael@0: michael@0: public static final String PREF_MINIMUM_TIME_AFTER_FAILURE = "healthreport_time_after_failure"; michael@0: public static final long DEFAULT_MINIMUM_TIME_AFTER_FAILURE = DEFAULT_SUBMISSION_INTENT_INTERVAL_MSEC; michael@0: michael@0: public static final String PREF_MAXIMUM_FAILURES_PER_DAY = "healthreport_maximum_failures_per_day"; michael@0: public static final long DEFAULT_MAXIMUM_FAILURES_PER_DAY = 2; michael@0: michael@0: // Authoritative. michael@0: public static final String PREF_FIRST_RUN = "healthreport_first_run"; michael@0: public static final String PREF_NEXT_SUBMISSION = "healthreport_next_submission"; michael@0: public static final String PREF_CURRENT_DAY_FAILURE_COUNT = "healthreport_current_day_failure_count"; michael@0: public static final String PREF_CURRENT_DAY_RESET_TIME = "healthreport_current_day_reset_time"; michael@0: michael@0: // Forensic. michael@0: public static final String PREF_LAST_UPLOAD_REQUESTED = "healthreport_last_upload_requested"; michael@0: public static final String PREF_LAST_UPLOAD_SUCCEEDED = "healthreport_last_upload_succeeded"; michael@0: public static final String PREF_LAST_UPLOAD_FAILED = "healthreport_last_upload_failed"; michael@0: michael@0: // Preferences for deleting obsolete documents. michael@0: public static final String PREF_MINIMUM_TIME_BETWEEN_DELETES = "healthreport_time_between_deletes"; michael@0: public static final long DEFAULT_MINIMUM_TIME_BETWEEN_DELETES = DEFAULT_SUBMISSION_INTENT_INTERVAL_MSEC; michael@0: michael@0: public static final String PREF_OBSOLETE_DOCUMENT_IDS_TO_DELETION_ATTEMPTS_REMAINING = "healthreport_obsolete_document_ids_to_deletions_remaining"; michael@0: michael@0: // We don't want to try to delete forever, but we also don't want to orphan michael@0: // obsolete document IDs from devices that fail to reach the server for a few michael@0: // days. This tries to delete document IDs for at least one week (of upload michael@0: // failures). Note that if the device is really offline, no upload is michael@0: // performed and our count of attempts is not altered. michael@0: public static final long DELETION_ATTEMPTS_PER_OBSOLETE_DOCUMENT_ID = (DEFAULT_MAXIMUM_FAILURES_PER_DAY + 1) * 7; michael@0: michael@0: // If we absolutely know that a document ID reached the server, we really michael@0: // don't want to orphan it. This tries to delete document IDs that will michael@0: // definitely be orphaned for at least six weeks (of upload failures). Note michael@0: // that if the device is really offline, no upload is performed and our count michael@0: // of attempts is not altered. michael@0: public static final long DELETION_ATTEMPTS_PER_KNOWN_TO_BE_ON_SERVER_DOCUMENT_ID = (DEFAULT_MAXIMUM_FAILURES_PER_DAY + 1) * 7 * 6; michael@0: michael@0: // We don't want to allocate unbounded storage for obsolete IDs, but we also michael@0: // don't want to orphan obsolete document IDs from devices that fail to delete michael@0: // for a few days. This stores as many IDs as are expected to be generated in michael@0: // a month. Note that if the device is really offline, no upload is performed michael@0: // and our count of attempts is not altered. michael@0: public static final long MAXIMUM_STORED_OBSOLETE_DOCUMENT_IDS = (DEFAULT_MAXIMUM_FAILURES_PER_DAY + 1) * 30; michael@0: michael@0: // Forensic. michael@0: public static final String PREF_LAST_DELETE_REQUESTED = "healthreport_last_delete_requested"; michael@0: public static final String PREF_LAST_DELETE_SUCCEEDED = "healthreport_last_delete_succeeded"; michael@0: public static final String PREF_LAST_DELETE_FAILED = "healthreport_last_delete_failed"; michael@0: michael@0: // Preferences for upload client. michael@0: public static final String PREF_LAST_UPLOAD_LOCAL_TIME = "healthreport_last_upload_local_time"; michael@0: public static final String PREF_LAST_UPLOAD_DOCUMENT_ID = "healthreport_last_upload_document_id"; michael@0: michael@0: public static final String PREF_DOCUMENT_SERVER_URI = "healthreport_document_server_uri"; michael@0: public static final String DEFAULT_DOCUMENT_SERVER_URI = "https://fhr.data.mozilla.com/"; michael@0: michael@0: public static final String PREF_DOCUMENT_SERVER_NAMESPACE = "healthreport_document_server_namespace"; michael@0: public static final String DEFAULT_DOCUMENT_SERVER_NAMESPACE = "metrics"; michael@0: michael@0: // One UUID is 36 characters (like e56542e0-e4d2-11e2-a28f-0800200c9a66), so michael@0: // we limit the number of obsolete IDs passed so that each request is not a michael@0: // large upload (and therefore more likely to fail). We also don't want to michael@0: // push Bagheera to make too many deletes, since we don't know how the cluster michael@0: // will handle such API usage. This obsoletes 2 days worth of old documents michael@0: // at a time. michael@0: public static final int MAXIMUM_DELETIONS_PER_POST = ((int) DEFAULT_MAXIMUM_FAILURES_PER_DAY + 1) * 2; michael@0: michael@0: public static final String PREF_PRUNE_BY_SIZE_TIME = "healthreport_prune_by_size_time"; michael@0: public static final long MINIMUM_TIME_BETWEEN_PRUNE_BY_SIZE_CHECKS_MILLIS = michael@0: GlobalConstants.MILLISECONDS_PER_DAY; michael@0: public static final int MAX_ENVIRONMENT_COUNT = 50; michael@0: public static final int ENVIRONMENT_COUNT_AFTER_PRUNE = 35; michael@0: public static final int MAX_EVENT_COUNT = 10000; michael@0: public static final int EVENT_COUNT_AFTER_PRUNE = 8000; michael@0: michael@0: public static final String PREF_EXPIRATION_TIME = "healthreport_expiration_time"; michael@0: public static final long MINIMUM_TIME_BETWEEN_EXPIRATION_CHECKS_MILLIS = GlobalConstants.MILLISECONDS_PER_DAY * 7; michael@0: public static final long EVENT_EXISTENCE_DURATION = GlobalConstants.MILLISECONDS_PER_SIX_MONTHS; michael@0: michael@0: public static final String PREF_CLEANUP_TIME = "healthreport_cleanup_time"; michael@0: public static final long MINIMUM_TIME_BETWEEN_CLEANUP_CHECKS_MILLIS = GlobalConstants.MILLISECONDS_PER_DAY * 30; michael@0: }