xref: /aosp_15_r20/system/update_engine/aosp/update_attempter_android.h (revision 5a9231315b4521097b8dc3750bc806fcafe0c72f)
1*5a923131SAndroid Build Coastguard Worker //
2*5a923131SAndroid Build Coastguard Worker // Copyright (C) 2016 The Android Open Source Project
3*5a923131SAndroid Build Coastguard Worker //
4*5a923131SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
5*5a923131SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
6*5a923131SAndroid Build Coastguard Worker // You may obtain a copy of the License at
7*5a923131SAndroid Build Coastguard Worker //
8*5a923131SAndroid Build Coastguard Worker //      http://www.apache.org/licenses/LICENSE-2.0
9*5a923131SAndroid Build Coastguard Worker //
10*5a923131SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
11*5a923131SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
12*5a923131SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*5a923131SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
14*5a923131SAndroid Build Coastguard Worker // limitations under the License.
15*5a923131SAndroid Build Coastguard Worker //
16*5a923131SAndroid Build Coastguard Worker 
17*5a923131SAndroid Build Coastguard Worker #ifndef UPDATE_ENGINE_AOSP_UPDATE_ATTEMPTER_ANDROID_H_
18*5a923131SAndroid Build Coastguard Worker #define UPDATE_ENGINE_AOSP_UPDATE_ATTEMPTER_ANDROID_H_
19*5a923131SAndroid Build Coastguard Worker 
20*5a923131SAndroid Build Coastguard Worker #include <stdint.h>
21*5a923131SAndroid Build Coastguard Worker 
22*5a923131SAndroid Build Coastguard Worker #include <memory>
23*5a923131SAndroid Build Coastguard Worker #include <string>
24*5a923131SAndroid Build Coastguard Worker #include <vector>
25*5a923131SAndroid Build Coastguard Worker 
26*5a923131SAndroid Build Coastguard Worker #include <android-base/unique_fd.h>
27*5a923131SAndroid Build Coastguard Worker #include <base/time/time.h>
28*5a923131SAndroid Build Coastguard Worker 
29*5a923131SAndroid Build Coastguard Worker #include "update_engine/aosp/apex_handler_interface.h"
30*5a923131SAndroid Build Coastguard Worker #include "update_engine/aosp/service_delegate_android_interface.h"
31*5a923131SAndroid Build Coastguard Worker #include "update_engine/client_library/include/update_engine/update_status.h"
32*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/action_processor.h"
33*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/boot_control_interface.h"
34*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/clock_interface.h"
35*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/daemon_state_interface.h"
36*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/download_action.h"
37*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/error_code.h"
38*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/hardware_interface.h"
39*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/metrics_reporter_interface.h"
40*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/network_selector_interface.h"
41*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/prefs_interface.h"
42*5a923131SAndroid Build Coastguard Worker #include "update_engine/metrics_utils.h"
43*5a923131SAndroid Build Coastguard Worker #include "update_engine/payload_consumer/filesystem_verifier_action.h"
44*5a923131SAndroid Build Coastguard Worker #include "update_engine/payload_consumer/postinstall_runner_action.h"
45*5a923131SAndroid Build Coastguard Worker 
46*5a923131SAndroid Build Coastguard Worker namespace chromeos_update_engine {
47*5a923131SAndroid Build Coastguard Worker 
48*5a923131SAndroid Build Coastguard Worker enum class OTAResult {
49*5a923131SAndroid Build Coastguard Worker   NOT_ATTEMPTED,
50*5a923131SAndroid Build Coastguard Worker   ROLLED_BACK,
51*5a923131SAndroid Build Coastguard Worker   UPDATED_NEED_REBOOT,
52*5a923131SAndroid Build Coastguard Worker   OTA_SUCCESSFUL,
53*5a923131SAndroid Build Coastguard Worker };
54*5a923131SAndroid Build Coastguard Worker 
55*5a923131SAndroid Build Coastguard Worker class UpdateAttempterAndroid final
56*5a923131SAndroid Build Coastguard Worker     : public ServiceDelegateAndroidInterface,
57*5a923131SAndroid Build Coastguard Worker       public ActionProcessorDelegate,
58*5a923131SAndroid Build Coastguard Worker       public DownloadActionDelegate,
59*5a923131SAndroid Build Coastguard Worker       public FilesystemVerifyDelegate,
60*5a923131SAndroid Build Coastguard Worker       public PostinstallRunnerAction::DelegateInterface,
61*5a923131SAndroid Build Coastguard Worker       public CleanupPreviousUpdateActionDelegateInterface {
62*5a923131SAndroid Build Coastguard Worker  public:
63*5a923131SAndroid Build Coastguard Worker   using UpdateStatus = update_engine::UpdateStatus;
64*5a923131SAndroid Build Coastguard Worker 
65*5a923131SAndroid Build Coastguard Worker   UpdateAttempterAndroid(DaemonStateInterface* daemon_state,
66*5a923131SAndroid Build Coastguard Worker                          PrefsInterface* prefs,
67*5a923131SAndroid Build Coastguard Worker                          BootControlInterface* boot_control_,
68*5a923131SAndroid Build Coastguard Worker                          HardwareInterface* hardware_,
69*5a923131SAndroid Build Coastguard Worker                          std::unique_ptr<ApexHandlerInterface> apex_handler);
70*5a923131SAndroid Build Coastguard Worker   ~UpdateAttempterAndroid() override;
71*5a923131SAndroid Build Coastguard Worker 
72*5a923131SAndroid Build Coastguard Worker   // Further initialization to be done post construction.
73*5a923131SAndroid Build Coastguard Worker   void Init();
74*5a923131SAndroid Build Coastguard Worker 
75*5a923131SAndroid Build Coastguard Worker   // ServiceDelegateAndroidInterface overrides.
76*5a923131SAndroid Build Coastguard Worker   bool ApplyPayload(const std::string& payload_url,
77*5a923131SAndroid Build Coastguard Worker                     int64_t payload_offset,
78*5a923131SAndroid Build Coastguard Worker                     int64_t payload_size,
79*5a923131SAndroid Build Coastguard Worker                     const std::vector<std::string>& key_value_pair_headers,
80*5a923131SAndroid Build Coastguard Worker                     Error* error) override;
81*5a923131SAndroid Build Coastguard Worker   bool ApplyPayload(int fd,
82*5a923131SAndroid Build Coastguard Worker                     int64_t payload_offset,
83*5a923131SAndroid Build Coastguard Worker                     int64_t payload_size,
84*5a923131SAndroid Build Coastguard Worker                     const std::vector<std::string>& key_value_pair_headers,
85*5a923131SAndroid Build Coastguard Worker                     Error* error) override;
86*5a923131SAndroid Build Coastguard Worker   bool SuspendUpdate(Error* error) override;
87*5a923131SAndroid Build Coastguard Worker   bool ResumeUpdate(Error* error) override;
88*5a923131SAndroid Build Coastguard Worker   bool CancelUpdate(Error* error) override;
89*5a923131SAndroid Build Coastguard Worker   bool ResetStatus(Error* error) override;
90*5a923131SAndroid Build Coastguard Worker   bool VerifyPayloadApplicable(const std::string& metadata_filename,
91*5a923131SAndroid Build Coastguard Worker                                Error* error) override;
92*5a923131SAndroid Build Coastguard Worker   uint64_t AllocateSpaceForPayload(
93*5a923131SAndroid Build Coastguard Worker       const std::string& metadata_filename,
94*5a923131SAndroid Build Coastguard Worker       const std::vector<std::string>& key_value_pair_headers,
95*5a923131SAndroid Build Coastguard Worker       Error* error) override;
96*5a923131SAndroid Build Coastguard Worker   void CleanupSuccessfulUpdate(
97*5a923131SAndroid Build Coastguard Worker       std::unique_ptr<CleanupSuccessfulUpdateCallbackInterface> callback,
98*5a923131SAndroid Build Coastguard Worker       Error* error) override;
99*5a923131SAndroid Build Coastguard Worker   bool setShouldSwitchSlotOnReboot(const std::string& metadata_filename,
100*5a923131SAndroid Build Coastguard Worker                                    Error* error) override;
101*5a923131SAndroid Build Coastguard Worker   bool resetShouldSwitchSlotOnReboot(Error* error) override;
102*5a923131SAndroid Build Coastguard Worker   bool TriggerPostinstall(const std::string& partition, Error* error) override;
103*5a923131SAndroid Build Coastguard Worker 
104*5a923131SAndroid Build Coastguard Worker   // ActionProcessorDelegate methods:
105*5a923131SAndroid Build Coastguard Worker   void ProcessingDone(const ActionProcessor* processor,
106*5a923131SAndroid Build Coastguard Worker                       ErrorCode code) override;
107*5a923131SAndroid Build Coastguard Worker   void ProcessingStopped(const ActionProcessor* processor) override;
108*5a923131SAndroid Build Coastguard Worker   void ActionCompleted(ActionProcessor* processor,
109*5a923131SAndroid Build Coastguard Worker                        AbstractAction* action,
110*5a923131SAndroid Build Coastguard Worker                        ErrorCode code) override;
111*5a923131SAndroid Build Coastguard Worker 
112*5a923131SAndroid Build Coastguard Worker   // DownloadActionDelegate overrides.
113*5a923131SAndroid Build Coastguard Worker   void BytesReceived(uint64_t bytes_progressed,
114*5a923131SAndroid Build Coastguard Worker                      uint64_t bytes_received,
115*5a923131SAndroid Build Coastguard Worker                      uint64_t total) override;
116*5a923131SAndroid Build Coastguard Worker   bool ShouldCancel(ErrorCode* cancel_reason) override;
117*5a923131SAndroid Build Coastguard Worker   void DownloadComplete() override;
118*5a923131SAndroid Build Coastguard Worker 
119*5a923131SAndroid Build Coastguard Worker   // FilesystemVerifyDelegate overrides
120*5a923131SAndroid Build Coastguard Worker   void OnVerifyProgressUpdate(double progress) override;
121*5a923131SAndroid Build Coastguard Worker 
122*5a923131SAndroid Build Coastguard Worker   // PostinstallRunnerAction::DelegateInterface
123*5a923131SAndroid Build Coastguard Worker   void ProgressUpdate(double progress) override;
124*5a923131SAndroid Build Coastguard Worker 
125*5a923131SAndroid Build Coastguard Worker   // CleanupPreviousUpdateActionDelegateInterface
126*5a923131SAndroid Build Coastguard Worker   void OnCleanupProgressUpdate(double progress) override;
127*5a923131SAndroid Build Coastguard Worker 
128*5a923131SAndroid Build Coastguard Worker   // Check the result of an OTA update. Intended to be called after reboot, this
129*5a923131SAndroid Build Coastguard Worker   // will use prefs on disk to determine if OTA was installed, or rolledback.
130*5a923131SAndroid Build Coastguard Worker   [[nodiscard]] OTAResult GetOTAUpdateResult() const;
131*5a923131SAndroid Build Coastguard Worker   // Intended to be called:
132*5a923131SAndroid Build Coastguard Worker   // 1. When system rebooted and slot switch is attempted
133*5a923131SAndroid Build Coastguard Worker   // 2. When a new update is started
134*5a923131SAndroid Build Coastguard Worker   // 3. When user called |ResetStatus()|
135*5a923131SAndroid Build Coastguard Worker   bool ClearUpdateCompletedMarker();
136*5a923131SAndroid Build Coastguard Worker 
set_update_certificates_path(const std::string & update_certificates_path)137*5a923131SAndroid Build Coastguard Worker   void set_update_certificates_path(
138*5a923131SAndroid Build Coastguard Worker       const std::string& update_certificates_path) {
139*5a923131SAndroid Build Coastguard Worker     update_certificates_path_ = update_certificates_path;
140*5a923131SAndroid Build Coastguard Worker   }
141*5a923131SAndroid Build Coastguard Worker 
142*5a923131SAndroid Build Coastguard Worker  private:
143*5a923131SAndroid Build Coastguard Worker   friend class UpdateAttempterAndroidTest;
144*5a923131SAndroid Build Coastguard Worker 
145*5a923131SAndroid Build Coastguard Worker   // Return |true| only if slot switched successfully after an OTA reboot.
146*5a923131SAndroid Build Coastguard Worker   // This will return |false| if an downgrade OTA is applied. Because after a
147*5a923131SAndroid Build Coastguard Worker   // downgrade OTA, we wipe /data, and there's no way for update_engine to
148*5a923131SAndroid Build Coastguard Worker   // "remember" that a downgrade OTA took place.
149*5a923131SAndroid Build Coastguard Worker   [[nodiscard]] bool OTARebootSucceeded() const;
150*5a923131SAndroid Build Coastguard Worker 
151*5a923131SAndroid Build Coastguard Worker   // Schedules an event loop callback to start the action processor. This is
152*5a923131SAndroid Build Coastguard Worker   // scheduled asynchronously to unblock the event loop.
153*5a923131SAndroid Build Coastguard Worker   void ScheduleProcessingStart();
154*5a923131SAndroid Build Coastguard Worker 
155*5a923131SAndroid Build Coastguard Worker   // Notifies an update request completed with the given error |code| to all
156*5a923131SAndroid Build Coastguard Worker   // observers.
157*5a923131SAndroid Build Coastguard Worker   void TerminateUpdateAndNotify(ErrorCode error_code);
158*5a923131SAndroid Build Coastguard Worker 
159*5a923131SAndroid Build Coastguard Worker   // Sets the status to the given |status| and notifies a status update to
160*5a923131SAndroid Build Coastguard Worker   // all observers.
161*5a923131SAndroid Build Coastguard Worker   void SetStatusAndNotify(UpdateStatus status);
162*5a923131SAndroid Build Coastguard Worker 
163*5a923131SAndroid Build Coastguard Worker   // Helper method to construct the sequence of actions to be performed for
164*5a923131SAndroid Build Coastguard Worker   // applying an update using a given HttpFetcher. The ownership of |fetcher| is
165*5a923131SAndroid Build Coastguard Worker   // passed to this function.
166*5a923131SAndroid Build Coastguard Worker   void BuildUpdateActions(HttpFetcher* fetcher);
167*5a923131SAndroid Build Coastguard Worker 
168*5a923131SAndroid Build Coastguard Worker   // Writes to the processing completed marker. Does nothing if
169*5a923131SAndroid Build Coastguard Worker   // |update_completed_marker_| is empty.
170*5a923131SAndroid Build Coastguard Worker   [[nodiscard]] bool WriteUpdateCompletedMarker();
171*5a923131SAndroid Build Coastguard Worker 
172*5a923131SAndroid Build Coastguard Worker   // Returns whether a slot switch was attempted in the current boot.
173*5a923131SAndroid Build Coastguard Worker   [[nodiscard]] bool UpdateCompletedOnThisBoot() const;
174*5a923131SAndroid Build Coastguard Worker 
175*5a923131SAndroid Build Coastguard Worker   // Prefs to use for metrics report
176*5a923131SAndroid Build Coastguard Worker   // |kPrefsPayloadAttemptNumber|: number of update attempts for the current
177*5a923131SAndroid Build Coastguard Worker   // payload_id.
178*5a923131SAndroid Build Coastguard Worker   // |KprefsNumReboots|: number of reboots when applying the current update.
179*5a923131SAndroid Build Coastguard Worker   // |kPrefsSystemUpdatedMarker|: end timestamp of the last successful update.
180*5a923131SAndroid Build Coastguard Worker   // |kPrefsUpdateTimestampStart|: start timestamp in monotonic time of the
181*5a923131SAndroid Build Coastguard Worker   // current update.
182*5a923131SAndroid Build Coastguard Worker   // |kPrefsUpdateBootTimestampStart|: start timestamp in boot time of
183*5a923131SAndroid Build Coastguard Worker   // the current update.
184*5a923131SAndroid Build Coastguard Worker   // |kPrefsCurrentBytesDownloaded|: number of bytes downloaded for the current
185*5a923131SAndroid Build Coastguard Worker   // payload_id.
186*5a923131SAndroid Build Coastguard Worker   // |kPrefsTotalBytesDownloaded|: number of bytes downloaded in total since
187*5a923131SAndroid Build Coastguard Worker   // the last successful update.
188*5a923131SAndroid Build Coastguard Worker 
189*5a923131SAndroid Build Coastguard Worker   // Metrics report function to call:
190*5a923131SAndroid Build Coastguard Worker   //   |ReportUpdateAttemptMetrics|
191*5a923131SAndroid Build Coastguard Worker   //   |ReportSuccessfulUpdateMetrics|
192*5a923131SAndroid Build Coastguard Worker   // Prefs to update:
193*5a923131SAndroid Build Coastguard Worker   //   |kPrefsSystemUpdatedMarker|
194*5a923131SAndroid Build Coastguard Worker   void CollectAndReportUpdateMetricsOnUpdateFinished(ErrorCode error_code);
195*5a923131SAndroid Build Coastguard Worker 
196*5a923131SAndroid Build Coastguard Worker   // This function is called after update_engine is started after device
197*5a923131SAndroid Build Coastguard Worker   // reboots. If update_engine is restarted w/o device reboot, this function
198*5a923131SAndroid Build Coastguard Worker   // would not be called.
199*5a923131SAndroid Build Coastguard Worker 
200*5a923131SAndroid Build Coastguard Worker   // Metrics report function to call:
201*5a923131SAndroid Build Coastguard Worker   //   |ReportAbnormallyTerminatedUpdateAttemptMetrics|
202*5a923131SAndroid Build Coastguard Worker   //   |ReportTimeToRebootMetrics|
203*5a923131SAndroid Build Coastguard Worker   // Prefs to update:
204*5a923131SAndroid Build Coastguard Worker   //   |kPrefsBootId|, |kPrefsPreviousVersion|
205*5a923131SAndroid Build Coastguard Worker   void UpdateStateAfterReboot(OTAResult result);
206*5a923131SAndroid Build Coastguard Worker 
207*5a923131SAndroid Build Coastguard Worker   // Prefs to update:
208*5a923131SAndroid Build Coastguard Worker   //   |kPrefsPayloadAttemptNumber|, |kPrefsUpdateTimestampStart|,
209*5a923131SAndroid Build Coastguard Worker   //   |kPrefsUpdateBootTimestampStart|
210*5a923131SAndroid Build Coastguard Worker   void UpdatePrefsOnUpdateStart(bool is_resume);
211*5a923131SAndroid Build Coastguard Worker 
212*5a923131SAndroid Build Coastguard Worker   // Prefs to delete:
213*5a923131SAndroid Build Coastguard Worker   //   |kPrefsNumReboots|, |kPrefsCurrentBytesDownloaded|
214*5a923131SAndroid Build Coastguard Worker   //   |kPrefsSystemUpdatedMarker|, |kPrefsUpdateTimestampStart|,
215*5a923131SAndroid Build Coastguard Worker   //   |kPrefsUpdateBootTimestampStart|
216*5a923131SAndroid Build Coastguard Worker   void ClearMetricsPrefs();
217*5a923131SAndroid Build Coastguard Worker 
218*5a923131SAndroid Build Coastguard Worker   // Return source and target slots for update.
219*5a923131SAndroid Build Coastguard Worker   BootControlInterface::Slot GetCurrentSlot() const;
220*5a923131SAndroid Build Coastguard Worker   BootControlInterface::Slot GetTargetSlot() const;
221*5a923131SAndroid Build Coastguard Worker 
222*5a923131SAndroid Build Coastguard Worker   // Helper of public VerifyPayloadApplicable. Return the parsed manifest in
223*5a923131SAndroid Build Coastguard Worker   // |manifest|.
224*5a923131SAndroid Build Coastguard Worker   static bool VerifyPayloadParseManifest(const std::string& metadata_filename,
225*5a923131SAndroid Build Coastguard Worker                                          std::string_view metadata_hash,
226*5a923131SAndroid Build Coastguard Worker                                          DeltaArchiveManifest* manifest,
227*5a923131SAndroid Build Coastguard Worker                                          Error* error);
VerifyPayloadParseManifest(const std::string & metadata_filename,DeltaArchiveManifest * manifest,Error * error)228*5a923131SAndroid Build Coastguard Worker   static bool VerifyPayloadParseManifest(const std::string& metadata_filename,
229*5a923131SAndroid Build Coastguard Worker                                          DeltaArchiveManifest* manifest,
230*5a923131SAndroid Build Coastguard Worker                                          Error* error) {
231*5a923131SAndroid Build Coastguard Worker     return VerifyPayloadParseManifest(metadata_filename, "", manifest, error);
232*5a923131SAndroid Build Coastguard Worker   }
233*5a923131SAndroid Build Coastguard Worker 
234*5a923131SAndroid Build Coastguard Worker   // Enqueue and run a CleanupPreviousUpdateAction.
235*5a923131SAndroid Build Coastguard Worker   void ScheduleCleanupPreviousUpdate();
236*5a923131SAndroid Build Coastguard Worker 
237*5a923131SAndroid Build Coastguard Worker   // Notify and clear |cleanup_previous_update_callbacks_|.
238*5a923131SAndroid Build Coastguard Worker   void NotifyCleanupPreviousUpdateCallbacksAndClear();
239*5a923131SAndroid Build Coastguard Worker 
240*5a923131SAndroid Build Coastguard Worker   // Remove |callback| from |cleanup_previous_update_callbacks_|.
241*5a923131SAndroid Build Coastguard Worker   void RemoveCleanupPreviousUpdateCallback(
242*5a923131SAndroid Build Coastguard Worker       CleanupSuccessfulUpdateCallbackInterface* callback);
243*5a923131SAndroid Build Coastguard Worker 
244*5a923131SAndroid Build Coastguard Worker   bool IsProductionBuild();
245*5a923131SAndroid Build Coastguard Worker 
246*5a923131SAndroid Build Coastguard Worker   DaemonStateInterface* daemon_state_;
247*5a923131SAndroid Build Coastguard Worker 
248*5a923131SAndroid Build Coastguard Worker   // DaemonStateAndroid pointers.
249*5a923131SAndroid Build Coastguard Worker   PrefsInterface* prefs_;
250*5a923131SAndroid Build Coastguard Worker   BootControlInterface* boot_control_;
251*5a923131SAndroid Build Coastguard Worker   HardwareInterface* hardware_;
252*5a923131SAndroid Build Coastguard Worker 
253*5a923131SAndroid Build Coastguard Worker   std::unique_ptr<ApexHandlerInterface> apex_handler_android_;
254*5a923131SAndroid Build Coastguard Worker 
255*5a923131SAndroid Build Coastguard Worker   // Last status notification timestamp used for throttling. Use monotonic
256*5a923131SAndroid Build Coastguard Worker   // TimeTicks to ensure that notifications are sent even if the system clock is
257*5a923131SAndroid Build Coastguard Worker   // set back in the middle of an update.
258*5a923131SAndroid Build Coastguard Worker   base::TimeTicks last_notify_time_;
259*5a923131SAndroid Build Coastguard Worker 
260*5a923131SAndroid Build Coastguard Worker   // The processor for running Actions.
261*5a923131SAndroid Build Coastguard Worker   std::unique_ptr<ActionProcessor> processor_;
262*5a923131SAndroid Build Coastguard Worker 
263*5a923131SAndroid Build Coastguard Worker   // The InstallPlan used during the ongoing update.
264*5a923131SAndroid Build Coastguard Worker   InstallPlan install_plan_;
265*5a923131SAndroid Build Coastguard Worker 
266*5a923131SAndroid Build Coastguard Worker   // For status:
267*5a923131SAndroid Build Coastguard Worker   UpdateStatus status_{UpdateStatus::IDLE};
268*5a923131SAndroid Build Coastguard Worker   double download_progress_{0.0};
269*5a923131SAndroid Build Coastguard Worker 
270*5a923131SAndroid Build Coastguard Worker   // The offset in the payload file where the CrAU part starts.
271*5a923131SAndroid Build Coastguard Worker   int64_t base_offset_{0};
272*5a923131SAndroid Build Coastguard Worker 
273*5a923131SAndroid Build Coastguard Worker   // Helper class to select the network to use during the update.
274*5a923131SAndroid Build Coastguard Worker   std::unique_ptr<NetworkSelectorInterface> network_selector_;
275*5a923131SAndroid Build Coastguard Worker 
276*5a923131SAndroid Build Coastguard Worker   std::unique_ptr<ClockInterface> clock_;
277*5a923131SAndroid Build Coastguard Worker 
278*5a923131SAndroid Build Coastguard Worker   std::unique_ptr<MetricsReporterInterface> metrics_reporter_;
279*5a923131SAndroid Build Coastguard Worker 
280*5a923131SAndroid Build Coastguard Worker   ::android::base::unique_fd payload_fd_;
281*5a923131SAndroid Build Coastguard Worker 
282*5a923131SAndroid Build Coastguard Worker   std::vector<std::unique_ptr<CleanupSuccessfulUpdateCallbackInterface>>
283*5a923131SAndroid Build Coastguard Worker       cleanup_previous_update_callbacks_;
284*5a923131SAndroid Build Coastguard Worker   // Result of previous CleanupPreviousUpdateAction. Nullopt If
285*5a923131SAndroid Build Coastguard Worker   // CleanupPreviousUpdateAction has not been executed.
286*5a923131SAndroid Build Coastguard Worker   std::optional<ErrorCode> cleanup_previous_update_code_{std::nullopt};
287*5a923131SAndroid Build Coastguard Worker 
288*5a923131SAndroid Build Coastguard Worker   // The path to the zip file with X509 certificates.
289*5a923131SAndroid Build Coastguard Worker   std::string update_certificates_path_{constants::kUpdateCertificatesPath};
290*5a923131SAndroid Build Coastguard Worker 
291*5a923131SAndroid Build Coastguard Worker   metrics_utils::PersistedValue<int64_t> metric_bytes_downloaded_;
292*5a923131SAndroid Build Coastguard Worker   metrics_utils::PersistedValue<int64_t> metric_total_bytes_downloaded_;
293*5a923131SAndroid Build Coastguard Worker 
294*5a923131SAndroid Build Coastguard Worker   DISALLOW_COPY_AND_ASSIGN(UpdateAttempterAndroid);
295*5a923131SAndroid Build Coastguard Worker };
296*5a923131SAndroid Build Coastguard Worker 
297*5a923131SAndroid Build Coastguard Worker }  // namespace chromeos_update_engine
298*5a923131SAndroid Build Coastguard Worker 
299*5a923131SAndroid Build Coastguard Worker #endif  // UPDATE_ENGINE_AOSP_UPDATE_ATTEMPTER_ANDROID_H_
300