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