1 //
2 // Copyright (C) 2017 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef UPDATE_ENGINE_COMMON_METRICS_CONSTANTS_H_
18 #define UPDATE_ENGINE_COMMON_METRICS_CONSTANTS_H_
19 
20 namespace chromeos_update_engine {
21 
22 namespace metrics {
23 // The possible outcomes when checking for updates.
24 //
25 // This is used in the UpdateEngine.Check.Result histogram.
26 enum class CheckResult {
27   kUpdateAvailable,    // Response indicates an update is available.
28   kNoUpdateAvailable,  // Response indicates no updates are available.
29   kDownloadError,      // Error downloading response from Omaha.
30   kParsingError,       // Error parsing response.
31   kRebootPending,      // No update check was performed a reboot is pending.
32 
33   kNumConstants,
34   kUnset = -1
35 };
36 
37 // Possible ways a device can react to a new update being available.
38 //
39 // This is used in the UpdateEngine.Check.Reaction histogram.
40 enum class CheckReaction {
41   kUpdating,    // Device proceeds to download and apply update.
42   kIgnored,     // Device-policy dictates ignoring the update.
43   kDeferring,   // Device-policy dictates waiting.
44   kBackingOff,  // Previous errors dictates waiting.
45 
46   kNumConstants,
47   kUnset = -1
48 };
49 
50 // The possible ways that downloading from a HTTP or HTTPS server can fail.
51 //
52 // This is used in the UpdateEngine.Check.DownloadErrorCode and
53 // UpdateEngine.Attempt.DownloadErrorCode histograms.
54 enum class DownloadErrorCode {
55   // Errors that can happen in the field. See http://crbug.com/355745
56   // for how we plan to add more detail in the future.
57   kDownloadError = 0,  // Error downloading data from server.
58 
59   // IMPORTANT: When adding a new error code, add at the bottom of the
60   // above block and before the kInputMalformed field. This
61   // is to ensure that error codes are not reordered.
62 
63   // This error is reported when libcurl returns CURLE_COULDNT_RESOLVE_HOST and
64   // calling res_init() can recover.
65   kUnresolvedHostRecovered = 97,
66   // This error is reported when libcurl returns CURLE_COULDNT_RESOLVE_HOST.
67   kUnresolvedHostError = 98,
68   // This error is reported when libcurl has an internal error that
69   // update_engine can't recover from.
70   kInternalLibCurlError = 99,
71 
72   // This error code is used to convey that malformed input was given
73   // to the utils::GetDownloadErrorCode() function. This should never
74   // happen but if it does it's because of an internal update_engine
75   // error and we're interested in knowing this.
76   kInputMalformed = 100,
77 
78   // Bucket for capturing HTTP status codes not in the 200-599
79   // range. This should never happen in practice but if it does we
80   // want to know.
81   kHttpStatusOther = 101,
82 
83   // Above 200 and below 600, the value is the HTTP status code.
84   kHttpStatus200 = 200,
85 
86   kNumConstants = 600,
87 
88   kUnset = -1
89 };
90 
91 // Possible ways an update attempt can end.
92 //
93 // This is used in the UpdateEngine.Attempt.Result histogram.
94 enum class AttemptResult {
95   kUpdateSucceeded,             // The update succeeded.
96   kInternalError,               // An internal error occurred.
97   kPayloadDownloadError,        // Failure while downloading payload.
98   kMetadataMalformed,           // Metadata was malformed.
99   kOperationMalformed,          // An operation was malformed.
100   kOperationExecutionError,     // An operation failed to execute.
101   kMetadataVerificationFailed,  // Metadata verification failed.
102   kPayloadVerificationFailed,   // Payload verification failed.
103   kVerificationFailed,          // Root or Kernel partition verification failed.
104   kPostInstallFailed,           // The postinstall step failed.
105   kAbnormalTermination,         // The attempt ended abnormally.
106   kUpdateCanceled,              // Update canceled by the user.
107   kUpdateSucceededNotActive,    // Update succeeded but the new slot is not
108                                 // active.
109   kUpdateSkipped,               // Current update skipped.
110   kNumConstants,
111 
112   kUnset = -1
113 };
114 
115 // Possible ways the device is connected to the Internet.
116 //
117 // This is used in the UpdateEngine.Attempt.ConnectionType histogram.
118 enum class ConnectionType {
119   kUnknown = 0,           // Unknown.
120   kEthernet = 1,          // Ethernet.
121   kWifi = 2,              // Wireless.
122   kCellular = 5,          // Cellular.
123   kTetheredEthernet = 6,  // Tethered (Ethernet).
124   kTetheredWifi = 7,      // Tethered (Wifi).
125   kDisconnected = 8,      // Disconnected.
126   // deprecated: kWimax = 3,
127   // deprecated: kBluetooth = 4,
128 
129   kNumConstants,
130   kUnset = -1
131 };
132 
133 // Possible ways a rollback can end.
134 //
135 // This is used in the UpdateEngine.Rollback histogram.
136 enum class RollbackResult {
137   kFailed,
138   kSuccess,
139 
140   kNumConstants
141 };
142 
143 }  // namespace metrics
144 
145 }  // namespace chromeos_update_engine
146 
147 #endif  // UPDATE_ENGINE_COMMON_METRICS_CONSTANTS_H_
148