blob: df8f227f88a5a58dfad93d4ea09f593aa3674f78 [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -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//
Alex Deymo42432912013-07-12 20:21:15 -070016
Gilad Arnoldcf175a02014-07-10 16:48:47 -070017#ifndef UPDATE_ENGINE_HARDWARE_INTERFACE_H_
18#define UPDATE_ENGINE_HARDWARE_INTERFACE_H_
Alex Deymo42432912013-07-12 20:21:15 -070019
20#include <string>
Alex Vakulenko59e253e2014-02-24 10:40:21 -080021#include <vector>
Alex Deymo42432912013-07-12 20:21:15 -070022
Alex Deymodd132f32015-09-14 19:12:07 -070023#include <base/files/file_path.h>
Alex Deymobccbc382014-04-03 13:38:55 -070024#include <base/time/time.h>
25
Alex Deymo42432912013-07-12 20:21:15 -070026namespace chromeos_update_engine {
27
Alex Deymo763e7db2015-08-27 21:08:08 -070028// The hardware interface allows access to the crossystem exposed properties,
29// such as the firmware version, hwid, verified boot mode.
Alex Deymo42432912013-07-12 20:21:15 -070030// These stateless functions are tied together in this interface to facilitate
31// unit testing.
32class HardwareInterface {
33 public:
Alex Deymo610277e2014-11-11 21:18:11 -080034 virtual ~HardwareInterface() {}
35
J. Richard Barnette056b0ab2013-10-29 15:24:56 -070036 // Returns true if this is an official Chrome OS build, false otherwise.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080037 virtual bool IsOfficialBuild() const = 0;
J. Richard Barnette056b0ab2013-10-29 15:24:56 -070038
39 // Returns true if the boot mode is normal or if it's unable to
40 // determine the boot mode. Returns false if the boot mode is
41 // developer.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080042 virtual bool IsNormalBootMode() const = 0;
J. Richard Barnette522d36f2013-10-28 17:22:12 -070043
Alex Deymobccbc382014-04-03 13:38:55 -070044 // Returns true if the OOBE process has been completed and EULA accepted,
45 // False otherwise. If True is returned, and |out_time_of_oobe| isn't null,
46 // the time-stamp of when OOBE happened is stored at |out_time_of_oobe|.
47 virtual bool IsOOBEComplete(base::Time* out_time_of_oobe) const = 0;
48
J. Richard Barnette522d36f2013-10-28 17:22:12 -070049 // Returns the HWID or an empty string on error.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080050 virtual std::string GetHardwareClass() const = 0;
J. Richard Barnette522d36f2013-10-28 17:22:12 -070051
52 // Returns the firmware version or an empty string if the system is
53 // not running chrome os firmware.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080054 virtual std::string GetFirmwareVersion() const = 0;
J. Richard Barnette522d36f2013-10-28 17:22:12 -070055
56 // Returns the ec version or an empty string if the system is not
57 // running a custom chrome os ec.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080058 virtual std::string GetECVersion() const = 0;
Alex Deymo42432912013-07-12 20:21:15 -070059
Alex Deymoebbe7ef2014-10-30 13:02:49 -070060 // Returns the powerwash_count from the stateful. If the file is not found
61 // or is invalid, returns -1. Brand new machines out of the factory or after
62 // recovery don't have this value set.
63 virtual int GetPowerwashCount() const = 0;
Alex Deymodd132f32015-09-14 19:12:07 -070064
65 // Store in |path| the path to a non-volatile directory (persisted across
66 // reboots) available for this daemon. In case of an error, such as no
67 // directory available, returns false.
68 virtual bool GetNonVolatileDirectory(base::FilePath* path) const = 0;
69
70 // Store in |path| the path to a non-volatile directory persisted across
71 // powerwash cycles. In case of an error, such as no directory available,
72 // returns false.
73 virtual bool GetPowerwashSafeDirectory(base::FilePath* path) const = 0;
Alex Deymo42432912013-07-12 20:21:15 -070074};
75
76} // namespace chromeos_update_engine
77
Gilad Arnoldcf175a02014-07-10 16:48:47 -070078#endif // UPDATE_ENGINE_HARDWARE_INTERFACE_H_