Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | #filter substitution |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | package org.mozilla.gecko.background.healthreport; |
michael@0 | 7 | |
michael@0 | 8 | import org.mozilla.gecko.background.common.GlobalConstants; |
michael@0 | 9 | |
michael@0 | 10 | public class HealthReportConstants { |
michael@0 | 11 | public static final String HEALTH_AUTHORITY = "@ANDROID_PACKAGE_NAME@.health"; |
michael@0 | 12 | public static final String GLOBAL_LOG_TAG = "GeckoHealth"; |
michael@0 | 13 | |
michael@0 | 14 | public static final String USER_AGENT = "Firefox-Android-HealthReport/" + GlobalConstants.MOZ_APP_VERSION + " (" + GlobalConstants.MOZ_APP_DISPLAYNAME + ")"; |
michael@0 | 15 | |
michael@0 | 16 | /** |
michael@0 | 17 | * The earliest allowable value for the last ping time, corresponding to May 2nd 2013. |
michael@0 | 18 | * Used for sanity checks. |
michael@0 | 19 | */ |
michael@0 | 20 | public static final long EARLIEST_LAST_PING = 1367500000000L; |
michael@0 | 21 | |
michael@0 | 22 | // Not `final` so we have the option to turn this on at runtime with a magic addon. |
michael@0 | 23 | public static boolean UPLOAD_FEATURE_DISABLED = false; |
michael@0 | 24 | |
michael@0 | 25 | // Android SharedPreferences branch where global (not per-profile) uploader |
michael@0 | 26 | // settings are stored. |
michael@0 | 27 | public static final String PREFS_BRANCH = "background"; |
michael@0 | 28 | |
michael@0 | 29 | // How frequently the submission and prune policies are ticked over. This is how frequently our |
michael@0 | 30 | // intent is scheduled to be called by the Android Alarm Manager, not how frequently we |
michael@0 | 31 | // actually submit. These values are set as preferences rather than constants so that testing |
michael@0 | 32 | // addons can change their values. |
michael@0 | 33 | public static final String PREF_SUBMISSION_INTENT_INTERVAL_MSEC = "healthreport_submission_intent_interval_msec"; |
michael@0 | 34 | public static final long DEFAULT_SUBMISSION_INTENT_INTERVAL_MSEC = GlobalConstants.MILLISECONDS_PER_DAY / 24; |
michael@0 | 35 | public static final String PREF_PRUNE_INTENT_INTERVAL_MSEC = "healthreport_prune_intent_interval_msec"; |
michael@0 | 36 | public static final long DEFAULT_PRUNE_INTENT_INTERVAL_MSEC = GlobalConstants.MILLISECONDS_PER_DAY; |
michael@0 | 37 | |
michael@0 | 38 | public static final String ACTION_HEALTHREPORT_UPLOAD_PREF = "@ANDROID_PACKAGE_NAME@.HEALTHREPORT_UPLOAD_PREF"; |
michael@0 | 39 | public static final String ACTION_HEALTHREPORT_PRUNE = "@ANDROID_PACKAGE_NAME@.HEALTHREPORT_PRUNE"; |
michael@0 | 40 | |
michael@0 | 41 | public static final String PREF_MINIMUM_TIME_BETWEEN_UPLOADS = "healthreport_time_between_uploads"; |
michael@0 | 42 | public static final long DEFAULT_MINIMUM_TIME_BETWEEN_UPLOADS = GlobalConstants.MILLISECONDS_PER_DAY; |
michael@0 | 43 | |
michael@0 | 44 | public static final String PREF_MINIMUM_TIME_BEFORE_FIRST_SUBMISSION = "healthreport_time_before_first_submission"; |
michael@0 | 45 | public static final long DEFAULT_MINIMUM_TIME_BEFORE_FIRST_SUBMISSION = GlobalConstants.MILLISECONDS_PER_DAY; |
michael@0 | 46 | |
michael@0 | 47 | public static final String PREF_MINIMUM_TIME_AFTER_FAILURE = "healthreport_time_after_failure"; |
michael@0 | 48 | public static final long DEFAULT_MINIMUM_TIME_AFTER_FAILURE = DEFAULT_SUBMISSION_INTENT_INTERVAL_MSEC; |
michael@0 | 49 | |
michael@0 | 50 | public static final String PREF_MAXIMUM_FAILURES_PER_DAY = "healthreport_maximum_failures_per_day"; |
michael@0 | 51 | public static final long DEFAULT_MAXIMUM_FAILURES_PER_DAY = 2; |
michael@0 | 52 | |
michael@0 | 53 | // Authoritative. |
michael@0 | 54 | public static final String PREF_FIRST_RUN = "healthreport_first_run"; |
michael@0 | 55 | public static final String PREF_NEXT_SUBMISSION = "healthreport_next_submission"; |
michael@0 | 56 | public static final String PREF_CURRENT_DAY_FAILURE_COUNT = "healthreport_current_day_failure_count"; |
michael@0 | 57 | public static final String PREF_CURRENT_DAY_RESET_TIME = "healthreport_current_day_reset_time"; |
michael@0 | 58 | |
michael@0 | 59 | // Forensic. |
michael@0 | 60 | public static final String PREF_LAST_UPLOAD_REQUESTED = "healthreport_last_upload_requested"; |
michael@0 | 61 | public static final String PREF_LAST_UPLOAD_SUCCEEDED = "healthreport_last_upload_succeeded"; |
michael@0 | 62 | public static final String PREF_LAST_UPLOAD_FAILED = "healthreport_last_upload_failed"; |
michael@0 | 63 | |
michael@0 | 64 | // Preferences for deleting obsolete documents. |
michael@0 | 65 | public static final String PREF_MINIMUM_TIME_BETWEEN_DELETES = "healthreport_time_between_deletes"; |
michael@0 | 66 | public static final long DEFAULT_MINIMUM_TIME_BETWEEN_DELETES = DEFAULT_SUBMISSION_INTENT_INTERVAL_MSEC; |
michael@0 | 67 | |
michael@0 | 68 | public static final String PREF_OBSOLETE_DOCUMENT_IDS_TO_DELETION_ATTEMPTS_REMAINING = "healthreport_obsolete_document_ids_to_deletions_remaining"; |
michael@0 | 69 | |
michael@0 | 70 | // We don't want to try to delete forever, but we also don't want to orphan |
michael@0 | 71 | // obsolete document IDs from devices that fail to reach the server for a few |
michael@0 | 72 | // days. This tries to delete document IDs for at least one week (of upload |
michael@0 | 73 | // failures). Note that if the device is really offline, no upload is |
michael@0 | 74 | // performed and our count of attempts is not altered. |
michael@0 | 75 | public static final long DELETION_ATTEMPTS_PER_OBSOLETE_DOCUMENT_ID = (DEFAULT_MAXIMUM_FAILURES_PER_DAY + 1) * 7; |
michael@0 | 76 | |
michael@0 | 77 | // If we absolutely know that a document ID reached the server, we really |
michael@0 | 78 | // don't want to orphan it. This tries to delete document IDs that will |
michael@0 | 79 | // definitely be orphaned for at least six weeks (of upload failures). Note |
michael@0 | 80 | // that if the device is really offline, no upload is performed and our count |
michael@0 | 81 | // of attempts is not altered. |
michael@0 | 82 | public static final long DELETION_ATTEMPTS_PER_KNOWN_TO_BE_ON_SERVER_DOCUMENT_ID = (DEFAULT_MAXIMUM_FAILURES_PER_DAY + 1) * 7 * 6; |
michael@0 | 83 | |
michael@0 | 84 | // We don't want to allocate unbounded storage for obsolete IDs, but we also |
michael@0 | 85 | // don't want to orphan obsolete document IDs from devices that fail to delete |
michael@0 | 86 | // for a few days. This stores as many IDs as are expected to be generated in |
michael@0 | 87 | // a month. Note that if the device is really offline, no upload is performed |
michael@0 | 88 | // and our count of attempts is not altered. |
michael@0 | 89 | public static final long MAXIMUM_STORED_OBSOLETE_DOCUMENT_IDS = (DEFAULT_MAXIMUM_FAILURES_PER_DAY + 1) * 30; |
michael@0 | 90 | |
michael@0 | 91 | // Forensic. |
michael@0 | 92 | public static final String PREF_LAST_DELETE_REQUESTED = "healthreport_last_delete_requested"; |
michael@0 | 93 | public static final String PREF_LAST_DELETE_SUCCEEDED = "healthreport_last_delete_succeeded"; |
michael@0 | 94 | public static final String PREF_LAST_DELETE_FAILED = "healthreport_last_delete_failed"; |
michael@0 | 95 | |
michael@0 | 96 | // Preferences for upload client. |
michael@0 | 97 | public static final String PREF_LAST_UPLOAD_LOCAL_TIME = "healthreport_last_upload_local_time"; |
michael@0 | 98 | public static final String PREF_LAST_UPLOAD_DOCUMENT_ID = "healthreport_last_upload_document_id"; |
michael@0 | 99 | |
michael@0 | 100 | public static final String PREF_DOCUMENT_SERVER_URI = "healthreport_document_server_uri"; |
michael@0 | 101 | public static final String DEFAULT_DOCUMENT_SERVER_URI = "https://fhr.data.mozilla.com/"; |
michael@0 | 102 | |
michael@0 | 103 | public static final String PREF_DOCUMENT_SERVER_NAMESPACE = "healthreport_document_server_namespace"; |
michael@0 | 104 | public static final String DEFAULT_DOCUMENT_SERVER_NAMESPACE = "metrics"; |
michael@0 | 105 | |
michael@0 | 106 | // One UUID is 36 characters (like e56542e0-e4d2-11e2-a28f-0800200c9a66), so |
michael@0 | 107 | // we limit the number of obsolete IDs passed so that each request is not a |
michael@0 | 108 | // large upload (and therefore more likely to fail). We also don't want to |
michael@0 | 109 | // push Bagheera to make too many deletes, since we don't know how the cluster |
michael@0 | 110 | // will handle such API usage. This obsoletes 2 days worth of old documents |
michael@0 | 111 | // at a time. |
michael@0 | 112 | public static final int MAXIMUM_DELETIONS_PER_POST = ((int) DEFAULT_MAXIMUM_FAILURES_PER_DAY + 1) * 2; |
michael@0 | 113 | |
michael@0 | 114 | public static final String PREF_PRUNE_BY_SIZE_TIME = "healthreport_prune_by_size_time"; |
michael@0 | 115 | public static final long MINIMUM_TIME_BETWEEN_PRUNE_BY_SIZE_CHECKS_MILLIS = |
michael@0 | 116 | GlobalConstants.MILLISECONDS_PER_DAY; |
michael@0 | 117 | public static final int MAX_ENVIRONMENT_COUNT = 50; |
michael@0 | 118 | public static final int ENVIRONMENT_COUNT_AFTER_PRUNE = 35; |
michael@0 | 119 | public static final int MAX_EVENT_COUNT = 10000; |
michael@0 | 120 | public static final int EVENT_COUNT_AFTER_PRUNE = 8000; |
michael@0 | 121 | |
michael@0 | 122 | public static final String PREF_EXPIRATION_TIME = "healthreport_expiration_time"; |
michael@0 | 123 | public static final long MINIMUM_TIME_BETWEEN_EXPIRATION_CHECKS_MILLIS = GlobalConstants.MILLISECONDS_PER_DAY * 7; |
michael@0 | 124 | public static final long EVENT_EXISTENCE_DURATION = GlobalConstants.MILLISECONDS_PER_SIX_MONTHS; |
michael@0 | 125 | |
michael@0 | 126 | public static final String PREF_CLEANUP_TIME = "healthreport_cleanup_time"; |
michael@0 | 127 | public static final long MINIMUM_TIME_BETWEEN_CLEANUP_CHECKS_MILLIS = GlobalConstants.MILLISECONDS_PER_DAY * 30; |
michael@0 | 128 | } |