History log of /system/update_engine/real_system_state.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
e5f6f2571d43eb65e0b27dd8d50f2c1f0b3fe30f 20-Apr-2017 Daniel Erat <derat@chromium.org> update_engine: Use org.chromium.NetworkProxyService.

Make update_engine call Chrome's new
org.chromium.NetworkProxyService D-Bus service to resolve
network proxies instead of using
org.chromium.LibCrosService. The new service supports
asynchronous replies instead of responding via D-Bus
signals.

BUG=chromium:446115,chromium:703217
TEST=unit tests pass; also added debug logging and verified
that chrome's proxy settings are used

(cherry picked from commit 941cf235c5e56eddc6e4f2de2f38bee032a4dead)
Cherry-pick updated to resolve conflicts with existing code in AOSP.

Change-Id: I8c0704482e9988fe9ed14d32797b3a5b8da3d46a
Reviewed-on: https://chromium-review.googlesource.com/497491
Commit-Ready: Dan Erat <derat@chromium.org>
Tested-by: Dan Erat <derat@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
/system/update_engine/real_system_state.h
dc066f14d22f7e3843ad3c4bbcfd8718f95d4dcd 27-Mar-2017 Alex Deymo <deymo@google.com> Remove weave support from update_engine.

This codepath is not used anymore.

Bug: None
Test: `make checkbuild`.
Change-Id: I0f7f22d63cb2c3fbfabcda25763160e2470ef2c5
/system/update_engine/real_system_state.h
14c0da88a93aa7b1aa71d5e7e923b537f0d419f3 21-Jul-2016 Alex Deymo <deymo@google.com> Remove libcurl support from update_engine_sideload.

While sideloading an update from recovery we don't need nor want to
download payload from HTTP(S) URLs, only local file:// are supported.
This patch moves libcurl_http_fetcher and certificate_checker files out
of libpayload_consumer dropping the libcurl and libssl dependencies from
it and the update_engine_sideload.

Bug: 27178350
TEST=build UE for Brillo and Android. Unittests still pass and
update_engine_sideload doesn't link to libcurl.

Change-Id: Iffefdb094654f7277dc825c041fe55aac9ee8756
/system/update_engine/real_system_state.h
03a4de7dc77b058987fc0670f4f67ba10ff31bc8 21-Jul-2016 Alex Deymo <deymo@google.com> Build update_engine_sideload.

Add a new "sideload" executable target that applies an update payload
directly using the UpdateAttempterAndroid.

This initial CL buils a dynamically linked program that's targeted to
run in the system image for now, but will later be transformed into a
static binary to run from the recovery environment.

Bug: 27178350
TEST=Applied a payload directly on a device using:
`update_engine_sideload --payload=file://foo/bar ...`

Change-Id: I289a724d013abdc390187d669dccd3edf2fd3434
/system/update_engine/real_system_state.h
c92195c0f6cba4851b7352062bba03c95b7a7e94 14-Jun-2016 Sen Jiang <senj@google.com> Compile libupdate_engine without DBus.

Test: mma with and without BRILLO_USE_DBUS=1
Test: adb shell /data/nativetest/update_engine_unittests/update_engine_unittests
Bug: 28800946

Change-Id: If3b05e7bc7a123d3d9b0dcc4597d915249a2de33
/system/update_engine/real_system_state.h
aeeb2e015ef5ef046c744d3c5daa7f353eb71b4e 10-Jun-2016 Sen Jiang <senj@google.com> Make UpdateAttempter own debugd_proxy.

It's the only class using this proxy.

Test: mma
Bug: 28800946

Change-Id: I1a98b417f213db5d47de451390367ca4975db4b0
/system/update_engine/real_system_state.h
9730679339fbf3e52a706dcab36eaeffbc71e404 09-Jun-2016 Sen Jiang <senj@google.com> Make RealDevicePolicyProvider own session_manager.

It's the only class using this proxy.

Bug: 28800946
Test: mma

Change-Id: I4a7e5469aa0a27d5756a88a0d6af4017737b70fc
/system/update_engine/real_system_state.h
b8c6a8f559a89b2709c946ad580d749d20925926 08-Jun-2016 Sen Jiang <senj@google.com> Add PowerManagerInterface.

Hide all dbus stuff under the new interface, so that we can implement
a real power_manager for android in the future if needed.

Test: mma
Bug: 28800946

Change-Id: I26c883f4d0bc71f0410dfe4422b22bdd9df70575
/system/update_engine/real_system_state.h
f5bebaef8dd12ff71baaf6fb4d4543db3615a6b4 04-Jun-2016 Sen Jiang <senj@google.com> Add ConnectionManagerAndroid.

Just a stub implementation that always allow update right now.

Test: mma
Bug: 28800946

Change-Id: I4ff6164d459d142567d49a351f70128f5fc74b9f
/system/update_engine/real_system_state.h
299128ee0f9009f79a62d5f57d75270f62353c9d 04-Jun-2016 Sen Jiang <senj@google.com> Make DBus a singleton.

All the proxies need dbus to initialize, so we are passing dbus around,
to make it easier to compile dbus conditionally, this patch makes it a
singleton so that the proxies can get dbus on their own.

Test: mma
Bug: 28800946

Change-Id: Idf062c843aa34a431c2201bae5b895dc1d0ea787
/system/update_engine/real_system_state.h
fa78f14d818e8e0b8ed5d05ebc389bf833342e7a 27-Jan-2016 Alex Deymo <deymo@google.com> Refactor daemon state and service async notification.

There are three supported IPC mechanism in this code: DBus, binder and
weave (over binder); which are mostly supported by all three platforms
Chrome OS, Brillo and Android. The exceptions are that Brillo and
Chrome OS still *require* DBus and support the others, while the new
Android daemon requires and supports only Binder.

This CL introduces two new interfaces: the ServiceObserverInterface and
the DaemonStateInterface.

The first one abstracts a service (or IPC service) into an interfcae
from the point of view of the daemon initialization and async
notifications of status changes. The second interface encapsulates the
state and main functionality of the update_engine daemon while leaving
the shared initialization in the main.cc and daemon.cc classes.

Bug: 25631949
TEST=`mmma system/update_engine` on edison-eng and aosp_arm-eng
TEST=FEATURES=test emerge-link update_engine

Change-Id: Ic15621031a153e14bdc4df8fcedbca1032e82c21
/system/update_engine/real_system_state.h
e97b39c4140af015f5a2939808cf8ee39bde43a2 20-Jan-2016 Alex Deymo <deymo@google.com> Implement Android UE daemon using brillo::Daemon.

The setup logic for Brillo and Android devices is very similar despite
the differences in the daemon logic and exposed service interface.
This patch reuses the brillo::Daemon derived class and the main()
function from Brillo to implement the daemon and service setup in
Android as well.

In addition, the Chromium OS build now defines the __CHROMEOS__ macro
to make the code behave the same way as in the Brillo case.

Bug: 25631949
TEST=`mmma system/update_engine` on edison-eng and aosp_arm-eng

Change-Id: I0f9690264e0822ef7e71318c73c2f16eda99e07c
/system/update_engine/real_system_state.h
bdd765e3157a2b04265dcdab0d7a55e747924555 23-Jan-2016 Alex Vakulenko <avakulenko@google.com> Revert "Implement Android UE daemon using brillo::Daemon."

This reverts commit c180400937eac75e8b7119f68d44593713dd4557.

This breaks both AOSP and Chrome OS

Change-Id: Ie9686a4d03a8fd53a614ed1706e3268918c414fb
/system/update_engine/real_system_state.h
c180400937eac75e8b7119f68d44593713dd4557 20-Jan-2016 Alex Deymo <deymo@google.com> Implement Android UE daemon using brillo::Daemon.

The setup logic for Brillo and Android devices is very similar despite
the differences in the daemon logic and exposed service interface.
This patch reuses the brillo::Daemon derived class and the main()
function from Brillo to implement the daemon and service setup in
Android as well.

Bug: 25631949
TEST=`mmma system/update_engine` on edison-eng and aosp_arm-eng

Change-Id: I15b2c2990a8055619dd407b2996ea92216c602a2
/system/update_engine/real_system_state.h
8c21b354da6dddb11dda6f5c0631a88710331da2 21-Jan-2016 Alex Deymo <deymo@google.com> Move current daemon destruction logic to RealSystemState.

The UpdateAttempter requires to release the dbus_adaptor pointer
before detruction to avoid sending messages over a dead DBus connection.
This patch moves this logic out of the UpdateEngineDaemon class.

Bug: None
TEST=mm; Tested on Brillo.

Change-Id: I8939c5a2940f435e2e8f574910e0fa2674dc725f
/system/update_engine/real_system_state.h
e119e6ab7edb7226508d49a43b196b44f0c54111 07-Jan-2016 Alex Vakulenko <avakulenko@google.com> update_engine: Switch to use Binder interface to weaved

Now that weaved provides a binder interface for its IPC, switch
to using it instead.

Bug: 23782171
Change-Id: I0b981b366a7dc42aabc9b61c4e9f90e26a2d74b4
/system/update_engine/real_system_state.h
f7ead8100211e7a285b48b52f4a235647274ab6e 24-Oct-2015 Alex Deymo <deymo@google.com> Implement update_engine weave commands

The new WeaveServiceInterface abstracs the registration and interaction
with weave whenever present. The compilation and usage of weave is
based on the BRILLO_USE_WEAVE flag.

When enabled, update_engine registers the "_updater" component with
methods to force-check for an update and change channels.

Bug: 24386758
Bug: 24386768
Test: Deployed on edison, weave commands and state available online.

Change-Id: Ic49111772e123b8a2b1971da92fe65785f186ccd
/system/update_engine/real_system_state.h
33e91e78bfe98c063b0c3b6d590976e275685686 01-Dec-2015 Alex Deymo <deymo@google.com> Fix certificate checker callback lifetime.

OpenSSL's SSL_CTX_set_verify() function allows us to set a callback
called after certificate validation but doesn't provide a way to pass
private data to this callback. CL:183832 was passing the pointer to the
CertificateChecker instance using a global pointer, nevertheless the
lifetime of this pointer was wrong since libcurl can trigger this
callback asynchronously when the SSL certificates are downloaded.

This patch converts the CertificateChecker into a singleton class and
uses the same trick previously used to pass the ServerToCheck value
using different callbacks.

Bug: 25818567
Test: Run an update on edison-userdebug; FEATURES=test emerge-link update_engine

Change-Id: I84cdb2f8c5ac86d1463634e73e867f213f7a2f5a
/system/update_engine/real_system_state.h
39910dcd1d68987ccee7c3031dc269233a8490bb 10-Nov-2015 Alex Deymo <deymo@google.com> Split payload application code into a subdirectory.

This patch splits from the main libupdate_engine code the part that
is strictly used to download and apply a payload into a new static
library, moving the code to subdirectories. The new library is divided
in two subdirectories: common/ and payload_consumer/, and should not
depend on other update_engine files outside those two subdirectories.
The main difference between those two is that the common/ tools are more
generic and not tied to the payload consumer process, but otherwise they
are both compiled together.

There are still dependencies from the new libpayload_consumer library
into the main directory files and DBus generated files. Those will be
addressed in follow up CLs.

Bug: 25197634
Test: FEATURES=test emerge-link update_engine; `mm` on Brillo.

Change-Id: Id8d0204ea573627e6e26ca9ea17b9592ca95bc23
/system/update_engine/real_system_state.h
dd132f39cced9028c01e98895a4f6c5fb9553de1 15-Sep-2015 Alex Deymo <deymo@google.com> Make non-volatile directory platform-specific.

update_engine daemon needs to persist files (such as the progress of
the update) in a non-volatile storage and also used to store a
marker file on a volatile storage to detect when update_engine is
restarted, likelly due to a crash.

This patch moves the non-volatile directory configuration to the
Hardware interface, making it platform-specific. It also replaces the
system rebooted detection using the boot_id provided by the kernel
instead of storing a file under /tmp. This implementation works both
on Chrome OS and Android.

Bug: 24074252
Test: FEATURES=test emerge-link update_engine; `mma`; deployed and tested manually on brillo.

Change-Id: I921d767982adebfd04eb12e08d8a157d9102d1e3
/system/update_engine/real_system_state.h
40d86b22363fd9461e67ad288e0273bed509937b 04-Sep-2015 Alex Deymo <deymo@google.com> Make Hardware class platform specific.

The Hardware class abstracts the interaction with the actual hardware
which is inherently platform-specific. This patch implementes a stub
version for Android and moves the Chromium OS implementation, handling
both with the same public factory method.

Bug: 23084776
TEST=emerge-link update_engine; `mma -i` builds the stubs.

Change-Id: I19c791a2e3fa22f0ac38bbe68a9c47838bcf019a
/system/update_engine/real_system_state.h
d6deb1d0357f47d5525bfaeffa6c201b19abd3e7 29-Aug-2015 Alex Deymo <deymo@google.com> Use installed DBus libraries instead of generating them.

login_manager, power_manager, debugd and shill now expose a client
library with the generated dbus-proxies.h file and the system_api's
installed dbus-constants.h. This patch changes update_engine from
generating these DBus headers to use the installed client libraries.

The client libraries already include the service path string, so we
don't need to include system_api dbus-constants.h in most cases, unless
we actually use some parameter constants defined there.

BUG=b:23084776,b:23560718
TEST=./build_packages --board=link

Change-Id: Idb4501e784ebb5928c92902d114462be57d5826a
/system/update_engine/real_system_state.h
763e7dbaac735da0ae802933a1015b6b7874bce2 28-Aug-2015 Alex Deymo <deymo@google.com> update_engine: New BootControlInterface class.

The new BootControlInterface class is a platform-independent
abstraction to control the bootloader. It provides methods for setting
what partition slots are available for booting and getting the
bootloader status about the available slots.

The Chrome OS specific implementation of the bootloader was moved to
the BootControlChromeOS which now depends on the vboot_host
implementation used in Chrome OS. Follow up CL will implement the
equivalent class for Brillo.

BUG=b:23010637
TEST=unittests; cros flash from the new image and rolled back from it.

Change-Id: I0a03aeeb8c21d8c99e1866b625e6e8c96628215b
/system/update_engine/real_system_state.h
b8803bbfe96abce0ae792a93bc975d478d98d16a 20-Aug-2015 Alex Deymo <deymo@google.com> Split DBus client proxies into separated headers.

Each daemon we talk to should expose its own DBus library. This patch
splits the DBus proxies we generate from other daemon's .xml files into
separated header files so we can then replace them with libraries.

BUG=b:23084776
TEST=FEATURES=test emerge-link update_engine

Change-Id: Idbf1671eb7fc4259d493dbe2c8bcc8dad5b8784f
/system/update_engine/real_system_state.h
aea4c1cea20dda7ae7e85fc8924a2d784f70d806 20-Aug-2015 Alex Deymo <deymo@google.com> Re-license update_engine to Apache2

This patch automatically replaced the license on all text files from
Chromium OS (BSD style) to AOSP (Apache2), keeping the original year as
a reference.

The license header was added to .gyp and .gypi files, the NOTICE was
replaced with a copy of the Apache2 license and MODULE_LICENSE_* file
was updated.

BUG=b/23084294
TEST=grep 'Chromium OS Authors' doesn't find anything.

Change-Id: Ie5083750755f5180a8a785b24fe67dbf9195cd10
/system/update_engine/real_system_state.h
305345001d85ca2282112c2a30fe75c7a4773491 21-Jul-2015 Alex Deymo <deymo@chromium.org> update_engine: Switch to chrome-dbus for client requests in update_engine

update_engine daemon acts as DBus client to send DBus calls to shill,
power_manager and chrome, and to listen for signals from shill, chrome
and login_manager. This patch migrates these calls and signals to use
chrome-dbus framework instead of dbus-glib.

All references to dbus-glib code are removed.

BUG=chromium:419827
TEST=Updated unittest. Deployed on a link device and tested interactions with shill and chromium.

Change-Id: I31b389e0d1690cccb115ff3b6539c876ba81bd0e
Reviewed-on: https://chromium-review.googlesource.com/290990
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Trybot-Ready: Alex Deymo <deymo@chromium.org>
/system/update_engine/real_system_state.h
f6ee0163504eaf1a7cc136ba2c075d77ae2b4dd5 31-Jul-2015 Alex Deymo <deymo@chromium.org> update_engine: Move ConnectionManager to an abstract Interface.

MockConnectionManager required to use one of ConnectionManager
constructors passing pointers that won't be use by the mock. This
patch moves the interface to its own ConnectionManagerInterface class.

BUG=None
TEST=unittests still pass.

Change-Id: I9ed09daf8e4256304be7dab30cfbe751901dc24b
Reviewed-on: https://chromium-review.googlesource.com/290120
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Trybot-Ready: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
/system/update_engine/real_system_state.h
02f7c1dee242f490143791dbb73fa23fa3007cfa 19-Oct-2014 Ben Chan <benchan@chromium.org> update_engine: Replace scoped_ptr with std::unique_ptr.

BUG=None
TEST=`FEATURES=test emerge-$BOARD update_engine`
TEST=`USE='clang asan' FEATURES=test emerge-$BOARD update_engine`

Change-Id: I55a2f7f53675faaac20ba25f72ed52cf938d7744
Reviewed-on: https://chromium-review.googlesource.com/224189
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
/system/update_engine/real_system_state.h
157fe307f162d13f53e7f98f6e2da7c60c0ff001 12-Aug-2014 Alex Vakulenko <avakulenko@chromium.org> platform2: sweep the lint errors identified by the updated linter

cpplint.py has been updated and identified new issues in existing
code. Stuff like overridden functions that specify 'override' should
not be marked as 'virtual', and constructors with no parameters
should not be marked as 'explicit'.

BUG=None
TEST=cpplint.py `find ./platform2 -name *.cc -or -name *.h`

Change-Id: Ibb9de43286d874d076ffd5ebb1b13c36ec794f01
Reviewed-on: https://chromium-review.googlesource.com/211950
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
/system/update_engine/real_system_state.h
cf175a098081f3f0e9ca52d997a7ce1585c14c2d 11-Jul-2014 Gilad Arnold <garnold@chromium.org> Fix cpplint errors.

The only non-obvious change here is the switch from dynamic_cast to
static_cast in three cases of down-casting in UpdateAttempter.
dynamic_cast is banned by style, nor does it add any safety in this
particular case (subsequent code dereferences the result right away
without checking whether it's null).

BUG=None
TEST=None

Change-Id: I9d49b46362feaf9c6fa13b2715ebe9fe50308a9a
Reviewed-on: https://chromium-review.googlesource.com/207470
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
/system/update_engine/real_system_state.h
63784a578dd26880454d70797519358a2326291b 28-May-2014 Alex Deymo <deymo@chromium.org> Rename the PolicyManager to UpdateManager.

This change renames the PolicyManager class, directory, tests, etc,
to avoid confusion with libpolicy and its classes.

BUG=chromium:373551
TEST=emerged on link.
CQ-DEPEND=CL:I43081673c7ba409f02273197da7915537bde39c6

Change-Id: Iffa76caa3b95ecbbdba87ab01006d1d8ce35a27f
Reviewed-on: https://chromium-review.googlesource.com/201876
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
/system/update_engine/real_system_state.h
7d623ebf9eee346fdeee71f1ccb32ebaf4bd3318 14-May-2014 Nam T. Nguyen <namnguyen@chromium.org> update_engine: Remove GPIO support.

We have not used GPIO since Jan 2013. This CL removes the GPIO handling code.
As a side effect, it also removes dependency on libudev.

BUG=chromium:221725
CQ-DEPEND=CL:199683
TEST=unittest
TEST=AU end2end test on real device from older version to a version that
has CL applied, then from that to another newer version (need not have
this CL applied).

Change-Id: I4352488ec360b44a44b137c40a3ae4ec35c6fe9d
Reviewed-on: https://chromium-review.googlesource.com/199626
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
/system/update_engine/real_system_state.h
680d022b08b1368ddbea970a75ebff7c642f2621 25-Apr-2014 Alex Deymo <deymo@chromium.org> PolicyManager: Remove unnecessary Init() methods.

The PolicyManager::Init() method always return true as it can't
really fail. This patch removes it and simplifies the interface
on the FakePolicyManager to make it easier to use it on Policy
unit testing exposing the FakeState there.

BUG=chromium:358269
TEST=Build and unittests.

Change-Id: Ib27dd41a483b10f164810e18585a8e4b4cb92f5a
Reviewed-on: https://chromium-review.googlesource.com/196968
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
/system/update_engine/real_system_state.h
c83baf63f764104e9472e74f293baf0982ac0280 03-Apr-2014 Alex Deymo <deymo@chromium.org> PolicyManager: New DevicePolicy provider.

This provider gives access to the members of the DevicePolicy
protobuf using the libpolicy to access it. The libpolicy doesn't
provide a way to get a notification when the policy was updated, but
that could be fixed on the future monitoring the file on disk. This
patch attempts to refresh the device policy every hour and updates
all the variables accordingly.

The variables exposed by this provider are only those used by the
update_engine code currently. If new variables need to be exposed
this can easily extended.

To achieve this, a new generic Variable class is introduce, named
AsyncCopyVariable, that allows you to Set or Unset the current value
of the variable and notify the subscribed observers while doing that.

BUG=chromium:358326
TEST=Unit tests added and pass.

Change-Id: Ieee6c9b33160f7dfe40c033db685a79d8fd57fe7
Reviewed-on: https://chromium-review.googlesource.com/194179
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
/system/update_engine/real_system_state.h
1f84723f499b3b309efac11324ed4e6c937341b6 07-Apr-2014 Gilad Arnold <garnold@chromium.org> Revise the SystemState hierarchy.

* Removed all #includes from SystemState; added includes in .cc files
that use the various objects (MetricsLibrary, DevicePolicy, etc).

* MockSystemState:

- Regulated the set of getters/setters: foo() returns the current Foo
object interface; this object can be overridden by set_foo();
mock_foo() or fake_foo() returns the default (internal) mock/fake
equivalent, and fails if it is different from foo() (safety).

- Make member declaration order consistent with that of API.

- Removed MOCK_METHOD declarations for two methods and replaced them
with fake getter/setter. This means that MockSystemState is now
reduced to a fake, and can be renamed (separate CL). This also means
that a few tests have a slightly different semantics now.

* All virtual overrides are qualified as such. However, removed the
'const' method qualified from all getters: it made little sense,
especially when considering that getters are handing addresses of
internal mock members.

* Made the UpdateAttempter a contained member of both
{Real,Mock}SystemState, resolving initialization dependencies. In
general, the invariant is that all members of the SystemState that
rely on it being fully populated by the time of their initialization,
need to export a separate Init() method, that will be called (by the
SystemState implementation constructor or Init() method) only after
all members are set.

* Made the mock GPIO handler and connection manager contained members of
MockSystemState; the destructor could safely be moved.

* Cleanup in UpdateAttempter (part of resolving dependencies):

- Ordinary member initialization done via default initializers
(constants) or initializer list in the constructor (parameters).

- Init() method only does work that cannot be done during
construction, with appropriate comment documenting the need for it.

- Better reuse via constructor delegation.

BUG=chromium:358278
TEST=Unit tests.

Change-Id: I96ff6fc7e7400b0a9feb6cc8d4ffe97a51000f91
Reviewed-on: https://chromium-review.googlesource.com/193587
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/real_system_state.h
76b2b4822d57360d0c77f070bd8fc25bc08fd93e 01-Apr-2014 Gilad Arnold <garnold@chromium.org> Fix/extend unit test related functionality.

* Adds mock methods to UpdateAttempterMock and turning corresponding
base methods into a virtual (needed for subsequent unit testing).

* Adds a setter to OmahaRequestParams.

* Limited general cleanup.

BUG=chromium:346914
TEST=Unit tests.

Change-Id: I0519ad5c43ddebabc1aff6585cf43a290a2081dc
Reviewed-on: https://chromium-review.googlesource.com/192660
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
/system/update_engine/real_system_state.h
bccbc387ed23ec18adcd0ef8b50d958ef38cd619 03-Apr-2014 Alex Deymo <deymo@chromium.org> Move IsOOBEComplete to HardwareInterface.

This patch moves the mockable IsOOBEComplete to the HardwareInterface
which already has a fake implemented. This is required as a first
step to make it available on the PolicyManager.

This patch also passes a null pointer when the timestamp isn't
required.

BUG=chromium:358269
TEST=Unittests adjusted and passing.

Change-Id: I620e0f4521832b3f2c0170811116251cdfe58f26
Reviewed-on: https://chromium-review.googlesource.com/193101
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
/system/update_engine/real_system_state.h
94c0616c9f81b65154953ac31e488cc87191e17c 22-Mar-2014 Alex Deymo <deymo@chromium.org> Create a PolicyManager instance on the SystemState.

This patch creates the PolicyManager object on the update engine's
SystemState class, which aggregates all the singleton classes.

This patch doesn't add any functionality, other than initialize and
destroy the PolicyManager, State and Providers from the SystemState.

BUG=chromium:354079
TEST=Build.

Change-Id: Ib06d9c3d24926eaca43de2d11770ef6da7d16985
Reviewed-on: https://chromium-review.googlesource.com/191502
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
/system/update_engine/real_system_state.h
1b9d6ae00b3c3badf9785584c2c867710f214a62 03-Mar-2014 Gilad Arnold <garnold@chromium.org> Further cleanup around DBus interface classes.

* Removed the "Glib" part from the various DbusGlib class name and added
"Wrapper" instead: only part of the methods here declared have
anything to do with Glib; in essence, this is an interface containing
wrappers for various DBus functions.

* Changed "Dbus" to "DBus", to comply with the rest of the world.

* Renamed the actual implementation "RealDBusWrapper" (instead of
"Concrete").

* Separated out RealDBusWrapper into its own header file. Client code,
which often only cares about the abstract class, does not need to pull
it unless specifically requiring it.

* Cleaned up the includes in these headers.

Aside from all that, also renamed system_state.cc into
real_system_state.cc, as this is what this file contains.

BUG=None
TEST=Unit tests.

Change-Id: I015c407cbc159aba8b5925eb0e916ba604c829cd
Reviewed-on: https://chromium-review.googlesource.com/189373
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
/system/update_engine/real_system_state.h
639aa36fc7e27ba400402cd7a32b091f555783a6 04-Feb-2014 David Zeuthen <zeuthen@chromium.org> Record installation date and include it in every Omaha request.

Introduce a new state variable, install-date-days, to track the the
point in time that OOBE completed and include this value - if set - in
each Omaha request. This state variable tracks the number of PST8PDT
("Pacific Time") calendar weeks since Jan 1st 2007 0:00 PST, times
seven. It is included as an attribute of the <app> element, like this:

<app appid="{...}" ... delta_okay="true" ... installdate="2590">

If the state variable is not set, the installdate attribute is not
included.

For new installs (e.g. where OOBE is not complete), the
install-date-days variable is set from the "elapsed_days" value in the
Omaha response. In this case - which should be the majority going
forward - we don't rely on the local clock on the device at all.

On the other hand, for existing installs (e.g. where OOBE was
completed in an OS version not including this CL) and also new
installs where the update-check during OOBE failed (e.g. no network
connection), install-date-days is derived from the timestamp of the
/home/chronos/.oobe_completed marker file. This case obviously relies
on the local clock on the device being set correctly.

Also introduce a new metric, Installer.InstallDateProvisioningSource
to track how install-date-days is provisioned. This metric has two
possible values, kProvisionedFromOmahaResponse (0) and
kProvisionedFromOOBEMarker (1).

In addition to new unit tests, I tested this manually by munging the
/home/chronos/.oobe_completed and
/var/lib/update_engine/prefs/install-date-days files. Also, since
devserver does not send the "elapsed_days" value, I had to point
update_engine to the official Omaha server using the -omaha-url option
with the https://tools.google.com/service/update2 value.

BUG=chromium:336838
TEST=New unit tests + unit tests pass + manual testing.

Change-Id: Id901059c4ab0f9184d1f4ddce72273d739e58224
Reviewed-on: https://chromium-review.googlesource.com/184907
Tested-by: David Zeuthen <zeuthen@chromium.org>
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/real_system_state.h
056b0abc1273a6eebfd73060a1d0344ef02b8696 29-Oct-2013 J. Richard Barnette <jrbarnette@chromium.org> Move IsOfficialBuild() and IsNormalBootMode() into HardwareInterface.

This makes the implementation of the two methods part of the
HardwareInterface, so that unit tests won't end up with meaningless
(and unpredictable) calls to the real functions.

BUG=None
TEST=unit tests

Change-Id: Ia23932634124987c1d6ff0683acb15cf4819bc5e
Reviewed-on: https://chromium-review.googlesource.com/175024
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Richard Barnette <jrbarnette@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
/system/update_engine/real_system_state.h
526cb58ddecbbc1ba5d2e3faf068d26d0661d464 06-Aug-2013 David Zeuthen <zeuthen@chromium.org> p2p: Make P2PManager available from the SystemState singleton

BUG=chromium:260426
TEST=Unit tests pass
Change-Id: Iadaa531d631c8d7268f35d512ff33f8d53e1cc5e
Reviewed-on: https://chromium-review.googlesource.com/64828
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/real_system_state.h
4243291a6655972fe89d4747a0089834c9e47c20 13-Jul-2013 Alex Deymo <deymo@chromium.org> Send an UMA metric when failed to boot into the new partition.

When a payload is successfully applied, the /other/ partition
is marked as valid and a reboot is needed, the reboot into this
new partition can fail due to several reasons. If than happens,
the firmware can rollback to the previous partition.

When this happens, this fix sends a new UMA metric with the
attempt number of this failing payload.

In order to test this functionality we need to fake the
utils::BootDevice() to emulate a reboot into the same or
a different partition. To achieve this, this function is
moved to a new "HardwareInterface" that can be faked
using the FakeHardware class that can hold similar hardware
related functions. Implementations and unittest were
refactored as needed.

BUG=chromium:243572
TEST=unittests

Change-Id: I1a4242df0bd61e2718ab881ead603b1d3705b877
Reviewed-on: https://gerrit.chromium.org/gerrit/61815
Commit-Queue: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
/system/update_engine/real_system_state.h
aa18e1641879f2df5993c2b02eb6f50d4443a649 20-Jun-2013 Chris Sosa <sosa@chromium.org> Blacklist versions as part of Rollback along with unittests.

This CL adds version blacklisting as part of AU Rollback. A few additional
things:

1) Since this pref must persist across rollback I have introduced a
powerwash_safe_prefs as part of system_state that will persist across
powerwashes.
2) Fixed bug where we needed to read the device policy (which is read during an
update_check before Rollback would work).
3) Some refactoring to move pref constants to constants.
4) Passing keepimg into our powerwash command so we don't wipe the old
partitions.

BUG=chromium:252589 chromium:254217
TEST=Unittests + test on device + using rollback with and without powerwash
checking preserve state.

Change-Id: I991fad944594944425fd9941e10b30a919f2b83b
Reviewed-on: https://gerrit.chromium.org/gerrit/59518
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
/system/update_engine/real_system_state.h
53173b964f6f43c89dbaba41875fcadd7077b2ea 18-May-2013 Jay Srinivasan <jaysri@chromium.org> Download via HTTP only if enterprise policy allows.

In order to rollout HTTP-downloads for AU to stable channel, we want to
be a bit more conservative to preseve the defense in depth we have now
with HTTPS. So, we're introduced a new enterprise policy which should be
explicitly enabled in order for the payloads to be downloaded via HTTP.

This CL adds the support for honoring such a policy in update engine.

BUG=chromium:235562
TEST=New unit tests added, existing ones updated and they all pass.
TEST=Tested on ZGB with and without policy and it works as expected.
Change-Id: I356efbe237b10031161a57c70cb851c521915a76
Reviewed-on: https://gerrit.chromium.org/gerrit/55805
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
Commit-Queue: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/real_system_state.h
f413fe59759c73d6a5624c2158260b4302d01fe2 22-Apr-2013 David Zeuthen <zeuthen@chromium.org> Add unit tests for duration metrics

As a side-effect, move utils::GetMonotonicTime() into the newly added
ClockInterface type.

BUG=None
TEST=Unit tests pass

Change-Id: I972a7e4ba37b63f96348fbeda901697b8ba2fc05
Reviewed-on: https://gerrit.chromium.org/gerrit/48814
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/real_system_state.h
be45bef9e283188b00e7def8967f81843669a7f1 10-Apr-2013 Chris Sosa <sosa@chromium.org> Add update reboot metric to the update engine.

This change add the Installer.UpdateNumReboots metric.

This records the number of reboots that occurred while an update was being
attempted. It uses a marker file stored in tmp to discover whether or not
it's already recorded the reboot.

BUG=chromium:226766
TEST=Unittests | ran an update on a test machine and rebooted/resumed and
checked about:histograms to confirm numbers. Also restart update-engine to
verify it didn't double count that.

Change-Id: I5d2af9d5b62a9d974c7c6243a89cb3359051b650
Reviewed-on: https://gerrit.chromium.org/gerrit/47710
Tested-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
/system/update_engine/real_system_state.h
ae4697c073b84b260990a141acd53c6806da0708 19-Mar-2013 Jay Srinivasan <jaysri@chromium.org> Enhanced channel changing behavior

This CL adds a new DBUS API to UpdateEngine called SetTargetChannel to
change the current channel of the device with an option to indicate
whether to do eventually or immediately.

The API will be called with the option to do it immediately in a
subsequent CL in Chrome UI. For now the old API (set_track) has been
wired up to call the new API to produce the old behavior (i.e. change
eventually). The old API will be removed after Chrome UI code stops
using it.

It's the UI's responsibility to ask the user for confirmation for the
powerwash that may happen in some cases and call the API with the
appropriate value whether or not the powerwash should happen.

For now, we're restricting the changing of channels to only those
devices that are on canary-channel or running test builds. This
restriction will be lifted off once the UI work is ready to give
warning to the users about the powerwash that may happen when they move
to a more stable channel.

We also enforce ReleaseChannelDelegated and ReleaseChannel policies
correctly now as follows:

* If ReleaseChannelDelegated is false, SetTargetChannel will fail as we
need to honor (only) the ReleaseChannel value in this case.
* If ReleaseChannelDelegated is true, we'll allow the SetTargetChannel
call to specify. In this case, we'll ignore the value of ReleaseChannel,
if any.

BUG=chromium-os:39095
TEST=Tested on ZGB by going from canary to dev-channel with and without
powerwash.
TEST=Existing unit tests have been updated and they pass.
TEST=New unit tests have been added.

Change-Id: Ifbf806a06e1c30d2f318e94d73735d1812049abd
Reviewed-on: https://gerrit.chromium.org/gerrit/44619
Commit-Queue: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/real_system_state.h
55f50c24c2624487b803ba2f93588494cc69e523 11-Jan-2013 Jay Srinivasan <jaysri@chromium.org> Segregate UMA metrics for production scenarios from test scenarios.

Currently we separate the UMA metrics only by one category: whether the
device is in dev mode or not. In addition, we need to exclude the noise
from these two categories:
1. Most of our testing on MP-signed images which are performed
with autest.
2. All our hwlab tests run in non-dev mode but they use dev-signed images
with dev-firmware keys.

So this CL defines additional bit fields to represent these states and
if any of these three flags are set, the UMA metric is sent to a
DevModeErrorCodes bucket. Thus the NormalErrorCodes bucket will have only
the production errors and thus we can monitor more effectively.

BUG=chromium-os:37613
TEST=Updated unit tests, ran on ZGB for all scenarios.
Change-Id: Id9cce33f09d1cc50cb15e67c731f7548940cbc24
Reviewed-on: https://gerrit.chromium.org/gerrit/41103
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/real_system_state.h