Home | History | Annotate | Download | only in common
      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 //
     16 
     17 #ifndef UPDATE_ENGINE_COMMON_HARDWARE_INTERFACE_H_
     18 #define UPDATE_ENGINE_COMMON_HARDWARE_INTERFACE_H_
     19 
     20 #include <string>
     21 #include <vector>
     22 
     23 #include <base/files/file_path.h>
     24 #include <base/time/time.h>
     25 
     26 namespace chromeos_update_engine {
     27 
     28 // The hardware interface allows access to the crossystem exposed properties,
     29 // such as the firmware version, hwid, verified boot mode.
     30 // These stateless functions are tied together in this interface to facilitate
     31 // unit testing.
     32 class HardwareInterface {
     33  public:
     34   virtual ~HardwareInterface() {}
     35 
     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.
     39   virtual bool IsOfficialBuild() const = 0;
     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
     43   // developer. A dev-mode boot will allow the user to access developer-only
     44   // features.
     45   virtual bool IsNormalBootMode() const = 0;
     46 
     47   // Returns true if the OOBE process has been completed and EULA accepted,
     48   // False otherwise. If True is returned, and |out_time_of_oobe| isn't null,
     49   // the time-stamp of when OOBE happened is stored at |out_time_of_oobe|.
     50   virtual bool IsOOBEComplete(base::Time* out_time_of_oobe) const = 0;
     51 
     52   // Returns the HWID or an empty string on error.
     53   virtual std::string GetHardwareClass() const = 0;
     54 
     55   // Returns the firmware version or an empty string if the system is
     56   // not running chrome os firmware.
     57   virtual std::string GetFirmwareVersion() const = 0;
     58 
     59   // Returns the ec version or an empty string if the system is not
     60   // running a custom chrome os ec.
     61   virtual std::string GetECVersion() const = 0;
     62 
     63   // Returns the powerwash_count from the stateful. If the file is not found
     64   // or is invalid, returns -1. Brand new machines out of the factory or after
     65   // recovery don't have this value set.
     66   virtual int GetPowerwashCount() const = 0;
     67 
     68   // Store in |path| the path to a non-volatile directory (persisted across
     69   // reboots) available for this daemon. In case of an error, such as no
     70   // directory available, returns false.
     71   virtual bool GetNonVolatileDirectory(base::FilePath* path) const = 0;
     72 
     73   // Store in |path| the path to a non-volatile directory persisted across
     74   // powerwash cycles. In case of an error, such as no directory available,
     75   // returns false.
     76   virtual bool GetPowerwashSafeDirectory(base::FilePath* path) const = 0;
     77 };
     78 
     79 }  // namespace chromeos_update_engine
     80 
     81 #endif  // UPDATE_ENGINE_COMMON_HARDWARE_INTERFACE_H_
     82