| Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // | 
 | 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 Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 16 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_COMMON_HARDWARE_INTERFACE_H_ | 
 | 18 | #define UPDATE_ENGINE_COMMON_HARDWARE_INTERFACE_H_ | 
| Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 19 |  | 
 | 20 | #include <string> | 
| Alex Vakulenko | 59e253e | 2014-02-24 10:40:21 -0800 | [diff] [blame] | 21 | #include <vector> | 
| Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 22 |  | 
| Alex Deymo | dd132f3 | 2015-09-14 19:12:07 -0700 | [diff] [blame] | 23 | #include <base/files/file_path.h> | 
| Alex Deymo | bccbc38 | 2014-04-03 13:38:55 -0700 | [diff] [blame] | 24 | #include <base/time/time.h> | 
 | 25 |  | 
| Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 26 | namespace chromeos_update_engine { | 
 | 27 |  | 
| Alex Deymo | 763e7db | 2015-08-27 21:08:08 -0700 | [diff] [blame] | 28 | // The hardware interface allows access to the crossystem exposed properties, | 
 | 29 | // such as the firmware version, hwid, verified boot mode. | 
| Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 30 | // These stateless functions are tied together in this interface to facilitate | 
 | 31 | // unit testing. | 
 | 32 | class HardwareInterface { | 
 | 33 |  public: | 
| Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame] | 34 |   virtual ~HardwareInterface() {} | 
 | 35 |  | 
| Alex Deymo | 1c4e84a | 2015-09-22 16:58:10 -0700 | [diff] [blame] | 36 |   // Returns whether this is an official build. Official build means that the | 
 | 37 |   // server maintains and updates the build, so update_engine should run and | 
 | 38 |   // periodically check for updates. | 
| Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 39 |   virtual bool IsOfficialBuild() const = 0; | 
| J. Richard Barnette | 056b0ab | 2013-10-29 15:24:56 -0700 | [diff] [blame] | 40 |  | 
 | 41 |   // Returns true if the boot mode is normal or if it's unable to | 
 | 42 |   // determine the boot mode. Returns false if the boot mode is | 
| Alex Deymo | 1c4e84a | 2015-09-22 16:58:10 -0700 | [diff] [blame] | 43 |   // developer. A dev-mode boot will allow the user to access developer-only | 
 | 44 |   // features. | 
| Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 45 |   virtual bool IsNormalBootMode() const = 0; | 
| J. Richard Barnette | 522d36f | 2013-10-28 17:22:12 -0700 | [diff] [blame] | 46 |  | 
| Sen Jiang | e67bb5b | 2016-06-20 15:53:56 -0700 | [diff] [blame] | 47 |   // Returns whether the developer features are enabled. | 
 | 48 |   virtual bool AreDevFeaturesEnabled() const = 0; | 
 | 49 |  | 
| Alex Deymo | 46a9aae | 2016-05-04 20:20:11 -0700 | [diff] [blame] | 50 |   // Returns whether the device has an OOBE flow that the user must go through | 
 | 51 |   // before getting non-critical updates. Use IsOOBEComplete() to determine if | 
 | 52 |   // that flow is complete. | 
 | 53 |   virtual bool IsOOBEEnabled() const = 0; | 
 | 54 |  | 
| Alex Deymo | bccbc38 | 2014-04-03 13:38:55 -0700 | [diff] [blame] | 55 |   // Returns true if the OOBE process has been completed and EULA accepted, | 
 | 56 |   // False otherwise. If True is returned, and |out_time_of_oobe| isn't null, | 
 | 57 |   // the time-stamp of when OOBE happened is stored at |out_time_of_oobe|. | 
 | 58 |   virtual bool IsOOBEComplete(base::Time* out_time_of_oobe) const = 0; | 
 | 59 |  | 
| J. Richard Barnette | 522d36f | 2013-10-28 17:22:12 -0700 | [diff] [blame] | 60 |   // Returns the HWID or an empty string on error. | 
| Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 61 |   virtual std::string GetHardwareClass() const = 0; | 
| J. Richard Barnette | 522d36f | 2013-10-28 17:22:12 -0700 | [diff] [blame] | 62 |  | 
 | 63 |   // Returns the firmware version or an empty string if the system is | 
 | 64 |   // not running chrome os firmware. | 
| Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 65 |   virtual std::string GetFirmwareVersion() const = 0; | 
| J. Richard Barnette | 522d36f | 2013-10-28 17:22:12 -0700 | [diff] [blame] | 66 |  | 
 | 67 |   // Returns the ec version or an empty string if the system is not | 
 | 68 |   // running a custom chrome os ec. | 
| Alex Vakulenko | d0fdfb3 | 2014-02-21 15:26:26 -0800 | [diff] [blame] | 69 |   virtual std::string GetECVersion() const = 0; | 
| Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 70 |  | 
| Alex Deymo | ebbe7ef | 2014-10-30 13:02:49 -0700 | [diff] [blame] | 71 |   // Returns the powerwash_count from the stateful. If the file is not found | 
 | 72 |   // or is invalid, returns -1. Brand new machines out of the factory or after | 
 | 73 |   // recovery don't have this value set. | 
 | 74 |   virtual int GetPowerwashCount() const = 0; | 
| Alex Deymo | dd132f3 | 2015-09-14 19:12:07 -0700 | [diff] [blame] | 75 |  | 
| Alex Deymo | fb905d9 | 2016-06-03 19:26:58 -0700 | [diff] [blame] | 76 |   // Signals that a powerwash (stateful partition wipe) should be performed | 
 | 77 |   // after reboot. | 
 | 78 |   virtual bool SchedulePowerwash() = 0; | 
 | 79 |  | 
 | 80 |   // Cancel the powerwash operation scheduled to be performed on next boot. | 
 | 81 |   virtual bool CancelPowerwash() = 0; | 
 | 82 |  | 
| Alex Deymo | dd132f3 | 2015-09-14 19:12:07 -0700 | [diff] [blame] | 83 |   // Store in |path| the path to a non-volatile directory (persisted across | 
 | 84 |   // reboots) available for this daemon. In case of an error, such as no | 
 | 85 |   // directory available, returns false. | 
 | 86 |   virtual bool GetNonVolatileDirectory(base::FilePath* path) const = 0; | 
 | 87 |  | 
 | 88 |   // Store in |path| the path to a non-volatile directory persisted across | 
 | 89 |   // powerwash cycles. In case of an error, such as no directory available, | 
 | 90 |   // returns false. | 
 | 91 |   virtual bool GetPowerwashSafeDirectory(base::FilePath* path) const = 0; | 
| Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 92 | }; | 
 | 93 |  | 
 | 94 | }  // namespace chromeos_update_engine | 
 | 95 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 96 | #endif  // UPDATE_ENGINE_COMMON_HARDWARE_INTERFACE_H_ |