blob: 4f3c98f739f8542c565cd0f914c326c89c2dbaf1 [file] [log] [blame]
Jay Srinivasan43488792012-06-19 00:25:31 -07001// Copyright (c) 2012 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
5#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_
7
Jay Srinivasanf0572052012-10-23 18:12:56 -07008#include "metrics/metrics_library.h"
Jay Srinivasan43488792012-06-19 00:25:31 -07009#include <policy/device_policy.h>
10#include <policy/libpolicy.h>
11
Gilad Arnoldf3815bb2013-01-14 11:58:24 -080012#include "update_engine/gpio_handler.h"
Jay Srinivasanae4697c2013-03-18 17:08:08 -070013#include "update_engine/omaha_request_params.h"
Gilad Arnoldf3815bb2013-01-14 11:58:24 -080014
Jay Srinivasan43488792012-06-19 00:25:31 -070015namespace chromeos_update_engine {
16
Jay Srinivasan55f50c22013-01-10 19:24:35 -080017// SystemState is the root class within the update engine. So we should avoid
18// any circular references in header file inclusion. Hence forward-declaring
19// the required classes.
David Zeuthenf413fe52013-04-22 14:04:39 -070020class ClockInterface;
Jay Srinivasan55f50c22013-01-10 19:24:35 -080021class ConnectionManager;
22class PrefsInterface;
23class PayloadStateInterface;
24class GpioHandler;
25class UpdateAttempter;
26
Jay Srinivasan43488792012-06-19 00:25:31 -070027// An interface to global system context, including platform resources,
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080028// the current state of the system, high-level objects whose lifetime is same
29// as main, system interfaces, etc.
Jay Srinivasan43488792012-06-19 00:25:31 -070030// Carved out separately so it can be mocked for unit tests.
31// Currently it has only one method, but we should start migrating other
32// methods to use this as and when needed to unit test them.
33// TODO (jaysri): Consider renaming this to something like GlobalContext.
34class SystemState {
35 public:
36 // Destructs this object.
37 virtual ~SystemState() {}
38
39 // Returns true if the OOBE process has been completed and EULA accepted.
40 // False otherwise.
41 virtual bool IsOOBEComplete() = 0;
42
Jay Srinivasan53173b92013-05-17 17:13:01 -070043 // Returns true if we're running an official (i.e, non-dev, non-test) build.
44 // False otherwise.
45 virtual bool IsOfficialBuild() = 0;
46
Jay Srinivasan43488792012-06-19 00:25:31 -070047 // Sets or gets the latest device policy.
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080048 virtual void set_device_policy(const policy::DevicePolicy* device_policy) = 0;
49 virtual const policy::DevicePolicy* device_policy() const = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070050
David Zeuthenf413fe52013-04-22 14:04:39 -070051 // Gets the interface object for the clock.
52 virtual ClockInterface* clock() = 0;
53
Jay Srinivasan43488792012-06-19 00:25:31 -070054 // Gets the connection manager object.
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080055 virtual ConnectionManager* connection_manager() = 0;
Jay Srinivasanf0572052012-10-23 18:12:56 -070056
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080057 // Gets the Metrics Library interface for reporting UMA stats.
Jay Srinivasanf0572052012-10-23 18:12:56 -070058 virtual MetricsLibraryInterface* metrics_lib() = 0;
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080059
60 // Gets the interface object for persisted store.
61 virtual PrefsInterface* prefs() = 0;
62
Jay Srinivasan2b5a0f02012-12-19 17:25:56 -080063 // Gets the interface for the payload state object.
64 virtual PayloadStateInterface* payload_state() = 0;
Gilad Arnoldbf7919b2013-01-08 13:07:37 -080065
66 // Returns a pointer to the GPIO handler.
67 virtual GpioHandler* gpio_handler() const = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070068
Jay Srinivasan55f50c22013-01-10 19:24:35 -080069 // Returns a pointer to the update attempter object.
70 virtual UpdateAttempter* update_attempter() = 0;
Jay Srinivasanae4697c2013-03-18 17:08:08 -070071
72 // Returns a pointer to the object that stores the parameters that are
73 // common to all Omaha requests.
74 virtual OmahaRequestParams* request_params() = 0;
Chris Sosabe45bef2013-04-09 18:25:12 -070075
76 // If true, this is the first instance of the update engine since the system
77 // restarted. Important for tracking whether you are running instance of the
78 // update engine on first boot or due to a crash/restart.
79 virtual bool system_rebooted() = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070080};
81
82} // namespace chromeos_update_engine
83
Jay Srinivasan55f50c22013-01-10 19:24:35 -080084#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_