mobile/android/base/background/healthreport/HealthReportConstants.java.in

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/background/healthreport/HealthReportConstants.java.in	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,128 @@
     1.4 +#filter substitution
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +package org.mozilla.gecko.background.healthreport;
    1.10 +
    1.11 +import org.mozilla.gecko.background.common.GlobalConstants;
    1.12 +
    1.13 +public class HealthReportConstants {
    1.14 +  public static final String HEALTH_AUTHORITY = "@ANDROID_PACKAGE_NAME@.health";
    1.15 +  public static final String GLOBAL_LOG_TAG = "GeckoHealth";
    1.16 +
    1.17 +  public static final String USER_AGENT = "Firefox-Android-HealthReport/" + GlobalConstants.MOZ_APP_VERSION + " (" + GlobalConstants.MOZ_APP_DISPLAYNAME + ")";
    1.18 +
    1.19 +  /**
    1.20 +   * The earliest allowable value for the last ping time, corresponding to May 2nd 2013.
    1.21 +   * Used for sanity checks.
    1.22 +   */
    1.23 +  public static final long EARLIEST_LAST_PING = 1367500000000L;
    1.24 +
    1.25 +  // Not `final` so we have the option to turn this on at runtime with a magic addon.
    1.26 +  public static boolean UPLOAD_FEATURE_DISABLED = false;
    1.27 +
    1.28 +  // Android SharedPreferences branch where global (not per-profile) uploader
    1.29 +  // settings are stored.
    1.30 +  public static final String PREFS_BRANCH = "background";
    1.31 +
    1.32 +  // How frequently the submission and prune policies are ticked over. This is how frequently our
    1.33 +  // intent is scheduled to be called by the Android Alarm Manager, not how frequently we
    1.34 +  // actually submit. These values are set as preferences rather than constants so that testing
    1.35 +  // addons can change their values.
    1.36 +  public static final String PREF_SUBMISSION_INTENT_INTERVAL_MSEC = "healthreport_submission_intent_interval_msec";
    1.37 +  public static final long DEFAULT_SUBMISSION_INTENT_INTERVAL_MSEC = GlobalConstants.MILLISECONDS_PER_DAY / 24;
    1.38 +  public static final String PREF_PRUNE_INTENT_INTERVAL_MSEC = "healthreport_prune_intent_interval_msec";
    1.39 +  public static final long DEFAULT_PRUNE_INTENT_INTERVAL_MSEC = GlobalConstants.MILLISECONDS_PER_DAY;
    1.40 +
    1.41 +  public static final String ACTION_HEALTHREPORT_UPLOAD_PREF = "@ANDROID_PACKAGE_NAME@.HEALTHREPORT_UPLOAD_PREF";
    1.42 +  public static final String ACTION_HEALTHREPORT_PRUNE = "@ANDROID_PACKAGE_NAME@.HEALTHREPORT_PRUNE";
    1.43 +
    1.44 +  public static final String PREF_MINIMUM_TIME_BETWEEN_UPLOADS = "healthreport_time_between_uploads";
    1.45 +  public static final long DEFAULT_MINIMUM_TIME_BETWEEN_UPLOADS = GlobalConstants.MILLISECONDS_PER_DAY;
    1.46 +
    1.47 +  public static final String PREF_MINIMUM_TIME_BEFORE_FIRST_SUBMISSION = "healthreport_time_before_first_submission";
    1.48 +  public static final long DEFAULT_MINIMUM_TIME_BEFORE_FIRST_SUBMISSION = GlobalConstants.MILLISECONDS_PER_DAY;
    1.49 +
    1.50 +  public static final String PREF_MINIMUM_TIME_AFTER_FAILURE = "healthreport_time_after_failure";
    1.51 +  public static final long DEFAULT_MINIMUM_TIME_AFTER_FAILURE = DEFAULT_SUBMISSION_INTENT_INTERVAL_MSEC;
    1.52 +
    1.53 +  public static final String PREF_MAXIMUM_FAILURES_PER_DAY = "healthreport_maximum_failures_per_day";
    1.54 +  public static final long DEFAULT_MAXIMUM_FAILURES_PER_DAY = 2;
    1.55 +
    1.56 +  // Authoritative.
    1.57 +  public static final String PREF_FIRST_RUN = "healthreport_first_run";
    1.58 +  public static final String PREF_NEXT_SUBMISSION = "healthreport_next_submission";
    1.59 +  public static final String PREF_CURRENT_DAY_FAILURE_COUNT = "healthreport_current_day_failure_count";
    1.60 +  public static final String PREF_CURRENT_DAY_RESET_TIME = "healthreport_current_day_reset_time";
    1.61 +
    1.62 +  // Forensic.
    1.63 +  public static final String PREF_LAST_UPLOAD_REQUESTED = "healthreport_last_upload_requested";
    1.64 +  public static final String PREF_LAST_UPLOAD_SUCCEEDED = "healthreport_last_upload_succeeded";
    1.65 +  public static final String PREF_LAST_UPLOAD_FAILED = "healthreport_last_upload_failed";
    1.66 +
    1.67 +  // Preferences for deleting obsolete documents.
    1.68 +  public static final String PREF_MINIMUM_TIME_BETWEEN_DELETES = "healthreport_time_between_deletes";
    1.69 +  public static final long DEFAULT_MINIMUM_TIME_BETWEEN_DELETES = DEFAULT_SUBMISSION_INTENT_INTERVAL_MSEC;
    1.70 +
    1.71 +  public static final String PREF_OBSOLETE_DOCUMENT_IDS_TO_DELETION_ATTEMPTS_REMAINING = "healthreport_obsolete_document_ids_to_deletions_remaining";
    1.72 +
    1.73 +  // We don't want to try to delete forever, but we also don't want to orphan
    1.74 +  // obsolete document IDs from devices that fail to reach the server for a few
    1.75 +  // days.  This tries to delete document IDs for at least one week (of upload
    1.76 +  // failures).  Note that if the device is really offline, no upload is
    1.77 +  // performed and our count of attempts is not altered.
    1.78 +  public static final long DELETION_ATTEMPTS_PER_OBSOLETE_DOCUMENT_ID = (DEFAULT_MAXIMUM_FAILURES_PER_DAY + 1) * 7;
    1.79 +
    1.80 +  // If we absolutely know that a document ID reached the server, we really
    1.81 +  // don't want to orphan it.  This tries to delete document IDs that will
    1.82 +  // definitely be orphaned for at least six weeks (of upload failures).  Note
    1.83 +  // that if the device is really offline, no upload is performed and our count
    1.84 +  // of attempts is not altered.
    1.85 +  public static final long DELETION_ATTEMPTS_PER_KNOWN_TO_BE_ON_SERVER_DOCUMENT_ID = (DEFAULT_MAXIMUM_FAILURES_PER_DAY + 1) * 7 * 6;
    1.86 +
    1.87 +  // We don't want to allocate unbounded storage for obsolete IDs, but we also
    1.88 +  // don't want to orphan obsolete document IDs from devices that fail to delete
    1.89 +  // for a few days.  This stores as many IDs as are expected to be generated in
    1.90 +  // a month.  Note that if the device is really offline, no upload is performed
    1.91 +  // and our count of attempts is not altered.
    1.92 +  public static final long MAXIMUM_STORED_OBSOLETE_DOCUMENT_IDS = (DEFAULT_MAXIMUM_FAILURES_PER_DAY + 1) * 30;
    1.93 +
    1.94 +  // Forensic.
    1.95 +  public static final String PREF_LAST_DELETE_REQUESTED = "healthreport_last_delete_requested";
    1.96 +  public static final String PREF_LAST_DELETE_SUCCEEDED = "healthreport_last_delete_succeeded";
    1.97 +  public static final String PREF_LAST_DELETE_FAILED = "healthreport_last_delete_failed";
    1.98 +
    1.99 +  // Preferences for upload client.
   1.100 +  public static final String PREF_LAST_UPLOAD_LOCAL_TIME  = "healthreport_last_upload_local_time";
   1.101 +  public static final String PREF_LAST_UPLOAD_DOCUMENT_ID  = "healthreport_last_upload_document_id";
   1.102 +
   1.103 +  public static final String PREF_DOCUMENT_SERVER_URI = "healthreport_document_server_uri";
   1.104 +  public static final String DEFAULT_DOCUMENT_SERVER_URI = "https://fhr.data.mozilla.com/";
   1.105 +
   1.106 +  public static final String PREF_DOCUMENT_SERVER_NAMESPACE = "healthreport_document_server_namespace";
   1.107 +  public static final String DEFAULT_DOCUMENT_SERVER_NAMESPACE = "metrics";
   1.108 +
   1.109 +  // One UUID is 36 characters (like e56542e0-e4d2-11e2-a28f-0800200c9a66), so
   1.110 +  // we limit the number of obsolete IDs passed so that each request is not a
   1.111 +  // large upload (and therefore more likely to fail).  We also don't want to
   1.112 +  // push Bagheera to make too many deletes, since we don't know how the cluster
   1.113 +  // will handle such API usage.  This obsoletes 2 days worth of old documents
   1.114 +  // at a time.
   1.115 +  public static final int MAXIMUM_DELETIONS_PER_POST = ((int) DEFAULT_MAXIMUM_FAILURES_PER_DAY + 1) * 2;
   1.116 +
   1.117 +  public static final String PREF_PRUNE_BY_SIZE_TIME = "healthreport_prune_by_size_time";
   1.118 +  public static final long MINIMUM_TIME_BETWEEN_PRUNE_BY_SIZE_CHECKS_MILLIS =
   1.119 +      GlobalConstants.MILLISECONDS_PER_DAY;
   1.120 +  public static final int MAX_ENVIRONMENT_COUNT = 50;
   1.121 +  public static final int ENVIRONMENT_COUNT_AFTER_PRUNE = 35;
   1.122 +  public static final int MAX_EVENT_COUNT = 10000;
   1.123 +  public static final int EVENT_COUNT_AFTER_PRUNE = 8000;
   1.124 +
   1.125 +  public static final String PREF_EXPIRATION_TIME = "healthreport_expiration_time";
   1.126 +  public static final long MINIMUM_TIME_BETWEEN_EXPIRATION_CHECKS_MILLIS = GlobalConstants.MILLISECONDS_PER_DAY * 7;
   1.127 +  public static final long EVENT_EXISTENCE_DURATION = GlobalConstants.MILLISECONDS_PER_SIX_MONTHS;
   1.128 +
   1.129 +  public static final String PREF_CLEANUP_TIME = "healthreport_cleanup_time";
   1.130 +  public static final long MINIMUM_TIME_BETWEEN_CLEANUP_CHECKS_MILLIS = GlobalConstants.MILLISECONDS_PER_DAY * 30;
   1.131 +}

mercurial