• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2015 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_CLIENT_LIBRARY_INCLUDE_UPDATE_ENGINE_UPDATE_STATUS_H_
18 #define UPDATE_ENGINE_CLIENT_LIBRARY_INCLUDE_UPDATE_ENGINE_UPDATE_STATUS_H_
19 
20 #include <string>
21 
22 #include <brillo/enum_flags.h>
23 
24 namespace update_engine {
25 
26 // ATTENTION: When adding a new enum value here, always append at the end and
27 // make sure to make proper adjustments in UpdateAttempter:ActionCompleted(). If
28 // any enum memeber is deprecated, the assigned value of other members should
29 // not change. See b/62842358.
30 enum class UpdateStatus {
31   IDLE = 0,
32   CHECKING_FOR_UPDATE = 1,
33   UPDATE_AVAILABLE = 2,
34   DOWNLOADING = 3,
35   VERIFYING = 4,
36   FINALIZING = 5,
37   UPDATED_NEED_REBOOT = 6,
38   REPORTING_ERROR_EVENT = 7,
39   ATTEMPTING_ROLLBACK = 8,
40   DISABLED = 9,
41   // Broadcast this state when an update aborts because user preferences do not
42   // allow updates, e.g. over cellular network.
43   NEED_PERMISSION_TO_UPDATE = 10,
44   CLEANUP_PREVIOUS_UPDATE = 11,
45 };
46 
47 // Enum of bit-wise flags for controlling how updates are attempted.
48 enum UpdateAttemptFlags : int32_t {
49   kNone = 0,
50   // Treat the update like a non-interactive update, even when being triggered
51   // by the interactive APIs.
52   kFlagNonInteractive = (1 << 0),
53   // Restrict (disallow) downloading of updates.
54   kFlagRestrictDownload = (1 << 1),
55 };
56 
57 // Enable bit-wise operators for the above enumeration of flag values.
58 DECLARE_FLAGS_ENUM(UpdateAttemptFlags);
59 
60 struct UpdateEngineStatus {
61   // When the update_engine last checked for updates (time_t: seconds from unix
62   // epoch)
63   int64_t last_checked_time;
64   // the current status/operation of the update_engine
65   UpdateStatus status;
66   // the current product version (oem bundle id)
67   std::string current_version;
68   // the current system version
69   std::string current_system_version;
70   // The current progress (0.0f-1.0f).
71   double progress;
72   // the size of the update (bytes)
73   uint64_t new_size_bytes;
74   // the new product version
75   std::string new_version;
76   // the new system version, if there is one (empty, otherwise)
77   std::string new_system_version;
78 };
79 
80 }  // namespace update_engine
81 
82 #endif  // UPDATE_ENGINE_CLIENT_LIBRARY_INCLUDE_UPDATE_ENGINE_UPDATE_STATUS_H_
83