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 // NOTE: Keep this file in sync with
25 // platform2/system_api/dbus/update_engine/update_engine.proto especially:
26 // - |UpdateStatus| <-> |Operation|
27 // - |UpdateEngineStatus| <-> |StatusResult|
28 
29 namespace update_engine {
30 
31 // ATTENTION:
32 // When adding a new enum value:
33 // - always append at the end with proper adjustments in |ActionCompleted()|.
34 // - always update |kNonIdleUpdateStatues| in update_attempter_unittest.cc.
35 // When deprecating an old enum value:
36 // - other enum values should not change their old values. See b/62842358.
37 enum class UpdateStatus {
38   IDLE = 0,
39   CHECKING_FOR_UPDATE = 1,
40   UPDATE_AVAILABLE = 2,
41   DOWNLOADING = 3,
42   VERIFYING = 4,
43   FINALIZING = 5,
44   UPDATED_NEED_REBOOT = 6,
45   REPORTING_ERROR_EVENT = 7,
46   ATTEMPTING_ROLLBACK = 8,
47   DISABLED = 9,
48   // Broadcast this state when an update aborts because user preferences do not
49   // allow updates, e.g. over cellular network.
50   NEED_PERMISSION_TO_UPDATE = 10,
51   CLEANUP_PREVIOUS_UPDATE = 11,
52 
53   // This value is exclusively used in Chrome. DO NOT define nor use it.
54   // TODO(crbug.com/977320): Remove this value from chrome by refactoring the
55   // Chrome code and evantually from here. This is not really an operation or
56   // state that the update_engine stays on. This is the result of an internal
57   // failure and should be reflected differently.
58   // ERROR = -1,
59 };
60 
61 // Enum of bit-wise flags for controlling how updates are attempted.
62 enum UpdateAttemptFlags : int32_t {
63   kNone = 0,
64   // Treat the update like a non-interactive update, even when being triggered
65   // by the interactive APIs.
66   kFlagNonInteractive = (1 << 0),
67   // Restrict (disallow) downloading of updates.
68   kFlagRestrictDownload = (1 << 1),
69 };
70 
71 // Enable bit-wise operators for the above enumeration of flag values.
72 DECLARE_FLAGS_ENUM(UpdateAttemptFlags);
73 
74 struct UpdateEngineStatus {
75   // Update engine last checked update (time_t: seconds from unix epoch).
76   int64_t last_checked_time;
77   // Current status/operation of the update_engine.
78   UpdateStatus status;
79   // Current product version (oem bundle id).
80   std::string current_version;
81   // Current progress (0.0f-1.0f).
82   double progress;
83   // Size of the update in bytes.
84   uint64_t new_size_bytes;
85   // New product version.
86   std::string new_version;
87   // Wether the update is an enterprise rollback. The value is valid only if the
88   // current operation is passed CHECKING_FOR_UPDATE.
89   bool is_enterprise_rollback;
90   // Indication of install for DLC(s).
91   bool is_install;
92   // The end-of-life date of the device in the number of days since Unix Epoch.
93   int64_t eol_date;
94   // The system will powerwash once the update is applied.
95   bool will_powerwash_after_reboot;
96 };
97 
98 }  // namespace update_engine
99 
100 #endif  // UPDATE_ENGINE_CLIENT_LIBRARY_INCLUDE_UPDATE_ENGINE_UPDATE_STATUS_H_
101