blob: bc7fee3fea55986f651b1bfb57dfc61148e0be22 [file] [log] [blame]
Alex Deymo42432912013-07-12 20:21:15 -07001// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Alex Deymo759c2752014-03-17 21:09:36 -07005#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_HARDWARE_INTERFACE_H_
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_HARDWARE_INTERFACE_H_
Alex Deymo42432912013-07-12 20:21:15 -07007
8#include <string>
Alex Vakulenko59e253e2014-02-24 10:40:21 -08009#include <vector>
Alex Deymo42432912013-07-12 20:21:15 -070010
Alex Deymobccbc382014-04-03 13:38:55 -070011#include <base/time/time.h>
12
Alex Deymo42432912013-07-12 20:21:15 -070013namespace chromeos_update_engine {
14
15// The hardware interface allows access to the following parts of the system,
16// closely related to the hardware:
17// * crossystem exposed properties: firmware, hwid, etc.
18// * Physical disk: partition booted from and partition name conversions.
19// These stateless functions are tied together in this interface to facilitate
20// unit testing.
21class HardwareInterface {
22 public:
Don Garrett83692e42013-11-08 10:11:30 -080023 // Returns the currently booted kernel partition. "/dev/sda2", for example.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080024 virtual std::string BootKernelDevice() const = 0;
Don Garrett83692e42013-11-08 10:11:30 -080025
26 // Returns the currently booted rootfs partition. "/dev/sda3", for example.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080027 virtual std::string BootDevice() const = 0;
Alex Deymo42432912013-07-12 20:21:15 -070028
Alex Vakulenko59e253e2014-02-24 10:40:21 -080029 // Returns a list of all kernel partitions available (whether bootable or not)
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080030 virtual std::vector<std::string> GetKernelDevices() const = 0;
Alex Vakulenko59e253e2014-02-24 10:40:21 -080031
Don Garrett83692e42013-11-08 10:11:30 -080032 // Is the specified kernel partition currently bootable, based on GPT flags?
33 // Returns success.
34 virtual bool IsKernelBootable(const std::string& kernel_device,
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080035 bool* bootable) const = 0;
Don Garrett83692e42013-11-08 10:11:30 -080036
37 // Mark the specified kernel partition unbootable in GPT flags. We mark
38 // the other kernel as bootable inside postinst, not inside the UE.
39 // Returns success.
40 virtual bool MarkKernelUnbootable(const std::string& kernel_device) = 0;
41
J. Richard Barnette056b0ab2013-10-29 15:24:56 -070042 // Returns true if this is an official Chrome OS build, false otherwise.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080043 virtual bool IsOfficialBuild() const = 0;
J. Richard Barnette056b0ab2013-10-29 15:24:56 -070044
45 // Returns true if the boot mode is normal or if it's unable to
46 // determine the boot mode. Returns false if the boot mode is
47 // developer.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080048 virtual bool IsNormalBootMode() const = 0;
J. Richard Barnette522d36f2013-10-28 17:22:12 -070049
Alex Deymobccbc382014-04-03 13:38:55 -070050 // Returns true if the OOBE process has been completed and EULA accepted,
51 // False otherwise. If True is returned, and |out_time_of_oobe| isn't null,
52 // the time-stamp of when OOBE happened is stored at |out_time_of_oobe|.
53 virtual bool IsOOBEComplete(base::Time* out_time_of_oobe) const = 0;
54
J. Richard Barnette522d36f2013-10-28 17:22:12 -070055 // Returns the HWID or an empty string on error.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080056 virtual std::string GetHardwareClass() const = 0;
J. Richard Barnette522d36f2013-10-28 17:22:12 -070057
58 // Returns the firmware version or an empty string if the system is
59 // not running chrome os firmware.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080060 virtual std::string GetFirmwareVersion() const = 0;
J. Richard Barnette522d36f2013-10-28 17:22:12 -070061
62 // Returns the ec version or an empty string if the system is not
63 // running a custom chrome os ec.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080064 virtual std::string GetECVersion() const = 0;
Alex Deymo42432912013-07-12 20:21:15 -070065
66 virtual ~HardwareInterface() {}
67};
68
69} // namespace chromeos_update_engine
70
Alex Deymo759c2752014-03-17 21:09:36 -070071#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_HARDWARE_INTERFACE_H_