blob: de84d7834c63abf64e420b85f90b2e56a1bea09a [file] [log] [blame]
Alex Deymo40d86b22015-09-03 22:27:10 -07001//
2// Copyright (C) 2013 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
Amin Hassaniec7bc112020-10-29 16:47:58 -070017#ifndef UPDATE_ENGINE_CROS_HARDWARE_CHROMEOS_H_
18#define UPDATE_ENGINE_CROS_HARDWARE_CHROMEOS_H_
Alex Deymo40d86b22015-09-03 22:27:10 -070019
Zentaro Kavanaghbaacb982018-02-20 17:48:39 -080020#include <memory>
Alex Deymo40d86b22015-09-03 22:27:10 -070021#include <string>
22#include <vector>
23
24#include <base/macros.h>
25#include <base/time/time.h>
Sen Jiange67bb5b2016-06-20 15:53:56 -070026#include <debugd/dbus-proxies.h>
Alex Deymo40d86b22015-09-03 22:27:10 -070027
Yifan Hong87029332020-09-01 17:20:08 -070028#include "update_engine/common/error_code.h"
Alex Deymo39910dc2015-11-09 17:04:30 -080029#include "update_engine/common/hardware_interface.h"
Alex Deymo40d86b22015-09-03 22:27:10 -070030
31namespace chromeos_update_engine {
32
33// Implements the real interface with Chrome OS verified boot and recovery
34// process.
35class HardwareChromeOS final : public HardwareInterface {
36 public:
37 HardwareChromeOS() = default;
38 ~HardwareChromeOS() override = default;
39
Alex Deymo46a9aae2016-05-04 20:20:11 -070040 void Init();
41
Alex Deymo40d86b22015-09-03 22:27:10 -070042 // HardwareInterface methods.
43 bool IsOfficialBuild() const override;
44 bool IsNormalBootMode() const override;
Sen Jiange67bb5b2016-06-20 15:53:56 -070045 bool AreDevFeaturesEnabled() const override;
Alex Deymo46a9aae2016-05-04 20:20:11 -070046 bool IsOOBEEnabled() const override;
Alex Deymo40d86b22015-09-03 22:27:10 -070047 bool IsOOBEComplete(base::Time* out_time_of_oobe) const override;
48 std::string GetHardwareClass() const override;
Matt Ziegelbaumaa8e1a42019-05-09 21:41:58 -040049 std::string GetDeviceRequisition() const override;
Zentaro Kavanaghbaacb982018-02-20 17:48:39 -080050 int GetMinKernelKeyVersion() const override;
Marton Hunyady99ced782018-05-08 12:59:50 +020051 int GetMinFirmwareKeyVersion() const override;
Zentaro Kavanagh8f6f2432018-05-16 13:48:12 -070052 int GetMaxFirmwareKeyRollforward() const override;
53 bool SetMaxFirmwareKeyRollforward(int firmware_max_rollforward) override;
Zentaro Kavanagh5d956152018-05-15 09:40:33 -070054 bool SetMaxKernelKeyRollforward(int kernel_max_rollforward) override;
Alex Deymo40d86b22015-09-03 22:27:10 -070055 int GetPowerwashCount() const override;
Zentaro Kavanagh28def4f2019-01-15 17:15:01 -080056 bool SchedulePowerwash(bool save_rollback_data) override;
Alex Deymofb905d92016-06-03 19:26:58 -070057 bool CancelPowerwash() override;
Alex Deymodd132f32015-09-14 19:12:07 -070058 bool GetNonVolatileDirectory(base::FilePath* path) const override;
59 bool GetPowerwashSafeDirectory(base::FilePath* path) const override;
Sen Jiang5011df62017-06-28 17:13:19 -070060 int64_t GetBuildTimestamp() const override;
Tianjie Xu4ad3af62019-10-30 11:59:45 -070061 bool AllowDowngrade() const override { return false; }
Amin Hassani1677e812017-06-21 13:36:36 -070062 bool GetFirstActiveOmahaPingSent() const override;
Amin Hassani80f4d4c2018-05-16 13:34:00 -070063 bool SetFirstActiveOmahaPingSent() override;
Tianjie Xud6aa91f2019-11-14 11:55:10 -080064 void SetWarmReset(bool warm_reset) override;
Kelvin Zhangd7191032020-08-11 10:48:16 -040065 std::string GetVersionForLogging(
66 const std::string& partition_name) const override;
Yifan Hong87029332020-09-01 17:20:08 -070067 ErrorCode IsPartitionUpdateValid(
68 const std::string& partition_name,
69 const std::string& new_version) const override;
Alex Deymo40d86b22015-09-03 22:27:10 -070070
71 private:
Alex Deymo46a9aae2016-05-04 20:20:11 -070072 friend class HardwareChromeOSTest;
73
74 // Load the update manager config flags (is_oobe_enabled flag) from the
75 // appropriate location based on whether we are in a normal mode boot (as
76 // passed in |normal_mode|) prefixing the paths with |root_prefix|.
77 void LoadConfig(const std::string& root_prefix, bool normal_mode);
78
79 bool is_oobe_enabled_;
80
Sen Jiange67bb5b2016-06-20 15:53:56 -070081 std::unique_ptr<org::chromium::debugdProxyInterface> debugd_proxy_;
82
Alex Deymo40d86b22015-09-03 22:27:10 -070083 DISALLOW_COPY_AND_ASSIGN(HardwareChromeOS);
84};
85
86} // namespace chromeos_update_engine
87
Amin Hassaniec7bc112020-10-29 16:47:58 -070088#endif // UPDATE_ENGINE_CROS_HARDWARE_CHROMEOS_H_