History log of /system/update_engine/update_attempter.cc
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
72ea95ab7705448b044cafc6b8cf2a2f4d929bd9 31-Mar-2016 Alex Deymo <deymo@google.com> Parse postinstall program progress updates.

In Android postinstall is expected to take a long time in common cases.
This patch allows the postinstall program to report back to the updater
a progress indication, which will then be forwarded to all the clients
listening. These progress updates are part of the FINALIZING status.

Bug: 27880754
TEST=Added unittests. Deployed an update to an edison-eng and post-install reported progress back with the postinstall_example.

(cherry picked from commit 0d29854cf5bb05a22cf161b50052539aa420a36e)

Change-Id: I003e996bd5a9acccfc83012345351174d269107c
/system/update_engine/update_attempter.cc
f25eb491ff60f21659a7e2b230ee1c83957034c7 26-Feb-2016 Alex Deymo <deymo@google.com> Fix resuming canceled updates.

Resuming an interrupted update was broken in several ways. First,
DeltaPerformer::CanResumeUpdate was checking for the number of
resume-failures to be more than the limit, not less. Then, the
resume logic didn't work for payload v2 when there was a
metadata signature included in the payload. Finally, resuming an
update after reading the payload signature (in payload v2) was not
updating the checkpoint, but storing the signature causing it to
attempt to parse it again and fail.

Bug: 27047026
Bug: chromium:590410
TEST=Manual procedure:
1. Start an update: update_engine_client --update ...
2. Cancel the update: update_engine_client --cancel
3. Re-start the same update: update_engine_client --update ...
-> The update should resume from the previous point.

Change-Id: I60134de155aa073a7ba91174cceea7297e5f8d17
/system/update_engine/update_attempter.cc
0cd976de289c9f17d2c10814720fbd6d62d7432d 12-Feb-2016 Alex Deymo <deymo@google.com> Disable ChromeBrowserProxyResolver behind a flag.

In Brillo and Android targets, there isn't a Chrome instance running
to resolve the proxies for a given URL. While this is not a fatal error
it logs abundant error messages on each request, confusing developers.

This patch compiles the ChromeBrowserProxyResolver only when the
USE_LIBCROS flag is set. This is now disabled by default in Brillo and
Android, but enabled in Chrome OS.

Bug: 24277309
TEST=`mma` on edison-eng. Applied an update, no more proxy error logs.

Change-Id: I27779572bf2fc810cb7846d63e123643d0386b0a
/system/update_engine/update_attempter.cc
1b3556cbe66b3f5be35f6117d4013ddc199b064c 03-Feb-2016 Alex Deymo <deymo@google.com> Allow null SystemState in the DownloadAction.

The SystemState is only defined in the libupdate_engine library, so
it may not be defined for other users of libpayload_consumer. This
patch allows to pass a nullptr for the SystemState while explicitly
passing the other classes defined in libpayload_consumer upon
construction.

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

Change-Id: I535d0184a85e0a167ac65875f6e7c07832efbf40
/system/update_engine/update_attempter.cc
ab0d976fa47844870d55c87ab530072cea0c8c53 02-Feb-2016 Alex Deymo <deymo@google.com> CPULimiter: Refactor class to manage the CPU limitation.

This new class replaces the functionality embedded in UpdateAttempter
that limits the max CPU usage allowed by update_engine. This refactor
helps reusing this class outside of the brillo UpdateAttempter.

Bug: None
TEST=FEATURES=test emerge-link update_engine

Change-Id: Ib5487d314846b497a44bb78a3b94609571e0fe38
/system/update_engine/update_attempter.cc
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/update_attempter.cc
40892497a9b1ea124058baf09f5f2873a15cb696 26-Jan-2016 Casey Dahlin <sadmac@google.com> Make client use binder interface on brillo

TEST=Verified status and update commands
Bug: 25908638

Change-Id: I7994de41001b4e116bffa539f23f1344ab1deae9
/system/update_engine/update_attempter.cc
0103c36caa2e38e034e0d22185736b9ccfb35c58 20-Jan-2016 Alex Vakulenko <avakulenko@google.com> update_engine: Update libchrome APIs to r369476

The new libchrome has been ported from Chromium and some APIs have
changed. Make necessary changes at call sites.

Change-Id: I42e65bda7f1dbdf6f6e0ebf356d2cfea6b729193
/system/update_engine/update_attempter.cc
40e84df4331135d190ac96a0d968f36131337824 14-Jan-2016 Alex Deymo <deymo@google.com> Update the weave state after changing the tracking channel.

The tracking channel is reported to weave as part of the state, so we
need to force an update of the weave state when the tracking channel
is changed.

Bug: 24386758
TEST=deployed on edison.

Change-Id: I11705603f893a046bda3907459701d31db83a3c5
/system/update_engine/update_attempter.cc
c7cc45e4ac9ca1f4693dfc93e4ff203992d446a1 07-Jan-2016 Alex Vakulenko <avakulenko@google.com> update_engine: Use helper Command::AbortWithCustomError() method

weaved now provides new variants of Command::Abort() that allow
to specify the error information as brillo::Error or binder::Status.

Command::AbortWithCustomError(brillo::Error*) also makes sure the error
code is prepended with "_", so no need to add that in OnTrackChannel().

BUG: 25875613
Change-Id: Ic9b2cb6f6ef092b85883ebb5bf5e4c936aa770f0
/system/update_engine/update_attempter.cc
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/update_attempter.cc
9bc7aaebc6390d10bb76a2c92521167da14ecbfa 10-Dec-2015 Alex Deymo <deymo@google.com> Initialize the ChromeBrowserProxyResolver only once.

The ChromeBrowserProxyResolver instance was being initialized on every
update check, making it register a listener for the proxy resolved
signal on each update, calling the callback multiple times.

Only the first time the callback is called will actually do something,
and the rest of the calls will only log an error message and return.

This patch removes the error message by registering the callback only once.

Bug: None
TEST=emerge-link update_engine; deployed on a link and ran several update checks.

Change-Id: I8a64fdf168966a895080760b8a95f9d8bf27976c
/system/update_engine/update_attempter.cc
542c19bf271011913a9f352f58e140224c936736 03-Dec-2015 Alex Deymo <deymo@google.com> Remove SystemState references from DeltaPerformer.

DeltaPerformer is used as part of the DownloadAction and had
references to the global SystemState. The common references to
BootControlInterface (to query the partitions based on the names
from the payload) and the HardwareInterface (for dev-mode bits) are
now referenced directly from the DeltaPerformer. The calls to
UpdateAttempter and PayloadState were moved to the
DownloadActionDelegate since these calls are received by classes
outside the payload_consumer.

Bug: 25773375
TEST=FEATURES=test emerge-link update_engine

Change-Id: Id2e81d5ccf835cad22f03b069c681dcce104c456
/system/update_engine/update_attempter.cc
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/update_attempter.cc
2b4268c8f89d115b0895b3f0172f42c11d9b1d7c 04-Dec-2015 Alex Deymo <deymo@google.com> Fix crash on shutdown when update in progress.

The ActionProcessor destructor normally calls the ProcessingStop method
on the delegate. For the UpdateAttempter this call re-schedules a new
update attempt on a half-destroyed update_attempter instance, crashing
update_engine on SIGTERM when the ActionProcessor was running.

This patch inhibits the ActionProcessor from notifying the delegate of
the processor stopping when destroying the update_attempter instance.
It also fixes the declaration order of the dbus_adaptor_ and disables
its usage during daemon shutdown.

Bug: 24989397
TEST=start update-engine; (update_engine_client --update &); sleep 6; stop update-engine; tail /var/log/update_engine.log
TEST=FEATURES=test emerge-link update_engine

Change-Id: I0a40067f63e89759ff80c79cecb6f89b10dba0c2
/system/update_engine/update_attempter.cc
b15a0b8eaf18c9e9341706df9f4ab59ce595a67c 26-Nov-2015 Alex Deymo <deymo@google.com> Remove SystemState from post-install step.

The post-install action only requires to mark the new slot as ready,
for which it was including a reference to the whole SystemState. This
patch removes said dependency replacing it for just the
BootControlInterface.

Bug: 25773375
TEST=FEATURES=test emerge-link update_engine; mma

Change-Id: I814d47c138c7565e9a80f316f25e124adb0d9c4e
/system/update_engine/update_attempter.cc
706a5abae125b8f5ba58a9b7e1e51570bbaa2089 23-Nov-2015 Alex Deymo <deymo@google.com> Remove SystemState dependency from HttpFetcher and InstallPlan.

The SystemState class is an aggregation of all the update_engine
singletons, making it easy to handle cross-dependencies between these
singletons. Nevertheless, since we split the code into a smaller
libpayload_consumer library we need to remove the global dependencies
on the SystemState class from this library and specialize those
dependencies to the actual required class.

Bug: 25773375
TEST=FEATURES=test emerge-link update_engine; mma

Change-Id: I8800157c969db6a8d168f33ac2c6aad4f34fa236
/system/update_engine/update_attempter.cc
c1c17b4ed6a3896b6343e737fd89682fa0c8436b 23-Nov-2015 Alex Deymo <deymo@google.com> Report Enum metrics from CertificateChecker.

The certificate checker was reporting a "user action" whenever an
update check HTTPS connection or HTTPS payload download had an invalid
HTTPS certificate or a valid one that was changed since the last
connection to the same server.

This patch sends an Enum metric for every HTTPS connection to check for
and update or download the payload with one of the three options: an
invalid certificate, a valid one already seen or a valid but different
certificate.

This patch also moves these metrics to the metrics.{h,cc} module, where
all the other metrics are reported, using an observer pattern in the
CertificateChecker, needed to remove the dependency on the metrics
library from the libpayload_consumer.

Bug: 25818567
TEST=FEATURES=test emerge-link update_engine; mma;

Change-Id: Ia1b6eb799e13b439b520ba14549d8973e18bcbfa
/system/update_engine/update_attempter.cc
22ad86121ba56c576bfcaa23e085dab881bd4ff5 20-Nov-2015 Alex Deymo <deymo@google.com> Delete DownloadActionDelegate::SetDownloadStatus() method.

This method is only used by the caller to detect a programming error in
the DownloadAction (calling BytesReceived when not downloading) and log
a message. This patch removes the method from the delegate interface
and makes sure it doesn't issue a call to BytesReceived when not
activelly downloading.

Bug: 25773375
TEST=FEATURES=test emerge-link update_engine

Change-Id: I8ff5c53f1fd40c0777b3f6523703a8bee71c019d
/system/update_engine/update_attempter.cc
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/update_attempter.cc
d942f9d3c8529f896329b19261df6eba044de1b2 07-Nov-2015 Alex Deymo <deymo@google.com> Return the error reason to the caller of SetTargetChannel.

This patch sends back to the caller an error message indicating why the
channel change didn't work.

Bug: 25595865
Test: Deployed on a device and attempted to change to "foo" channel. Error message lists available channels.
Test: FEATURES=test emerge-link update_engine

Change-Id: Idcc67d5c7878ce7af60652d7bf5bf81135325f97
/system/update_engine/update_attempter.cc
87c08866cfc596234a1484147d3943d109418e7e 31-Oct-2015 Alex Deymo <deymo@google.com> Send "success reboot" only after an update.

The <event> message sent to omaha after we reboot into a new version
was originally sent only on the first updatecheck after rebooting into
the new installed version, and included the old version number. A bug
introduced in 2013 removed the check for the empty previous version
making the update_engine send this message on *every* updatecheck. This
patch inserts back the check for the empty previous version to send the
"success reboot" event only after.

While there are still discussions about what's the right event message
to send on that case, this fixes the regression.

Bug: 24867646
Test: FEATURES=test emerge-link update_engine; second <updatecheck> didn't include the <event>

Change-Id: Icd00364aae15c8bf420f1f89ae7b526999b3a124
/system/update_engine/update_attempter.cc
906191f88cb2448691e54f7a6a3b464854053154 12-Oct-2015 Alex Deymo <deymo@google.com> Base the update complete marker on persisted data.

The update complete marker was stored in /var/run, a fixed volatile
location. The marker would signal that an update was already applied
even after an update_engine crash and subsequent restart.

This location, while quite standard on the Unix FHS, is not
available in Android. This patch achieves the same goal by storing the
boot_id in the persisted prefs directory.

Bug: 24868648
Test: Unittests. Restarted update_engine after an update, keeps saying NEED_REBOOT.

Change-Id: I4dc2cbaeaeb0fd3197fa89168deaa042cb776d61
/system/update_engine/update_attempter.cc
3f39d5cc753905874d8d93bef94f857b8808f19e 13-Oct-2015 Alex Vakulenko <avakulenko@google.com> update_engine: Rename "chromeos" -> "brillo" in include paths and namespaces

libchromeos is transitioning to libbrillo and chromeos namespaces
and include directory is changing to brillo.

Bug: 24872993
Change-Id: I770659a95be380a50fe3b2ba9f91d65818f40945
/system/update_engine/update_attempter.cc
e5e5fe926e9ea45b1a381af1bee91a86643ffd72 05-Oct-2015 Alex Deymo <deymo@google.com> Move InstallPlan partitions to a list of partitions.

This patch changes the InstallPlan instance from having hard-coded
rootfs and kernel paritions to have a list of partitions with a
name, source and target information.

The FilesystemVerifierAction, DeltaPerformer and PostInstallAction were
adapter to use the list of partitions instead.

In delta payloads (only supported in the current major version 1) the
list of operations is still fixed: the rootfs first and the kernel.
This list is now populated by the FilesystemVerifierAction including
the size of these partitions, until the whole source partition hash
checking is deprecated (b/23182225).

The PostIntallAction now relies on the DeltaPerformer to populate the
post-install information from the payload. This means that in rollback
we won't run any device-specific post-install operation, and will
simply flip the slots in the bootloader.

Bug: 24667689
Test: Updated unittests. Tested on a dragonboard and a link.

Change-Id: I8277e3190ac74e57832a58dc0730e3713f48af8a
/system/update_engine/update_attempter.cc
cc8ce0e3b11ac76412c26c687d11140cbe18ad91 02-Oct-2015 Christopher Wiley <wiley@google.com> Move UpdateStatus and helpers to dedicated files

This allows us to easily share it between the update_engine proper
and a forthcoming client library.

Bug: 24547247
Test: mmm system/update_engine; emerge-panther update_engine

Change-Id: I8c0db7a0f95dd6368bfc886f1b0d1a9d2efb461f
/system/update_engine/update_attempter.cc
af9a863cd7aa4aa4ef12227908a10bc07440a0f0 24-Sep-2015 Alex Deymo <deymo@google.com> Remove obsolete Installer.* metrics.

These metrics were replaced by the UpdateEngine.* metrics.

Bug: chromium:355745
Test: FEATURES=test emerge-link update_engine

Change-Id: I80d0db44681c428898500dd9099918e98ae40b28
/system/update_engine/update_attempter.cc
9870c0e0a35669674198f596be71056ba0c78d62 23-Sep-2015 Alex Deymo <deymo@google.com> ResetStatus() reverts the boot flags changes.

ResetStatus() is a developer only command used to drop the currently
applied update and go back the idle status. This allows fast testing of
payload application without reboots.

Bug: chromium:224707
Test: update_engine_client --reset_status; `reboot` boots to the same slot.

Change-Id: I7e2bc46247ee5c48aa634c4bdf6f3c577a199647
/system/update_engine/update_attempter.cc
31d95ac85d294b2b1bfa293835013e66c010fbcf 17-Sep-2015 Alex Deymo <deymo@google.com> Mark the active slot from update_engine instead of /postinstall.

In Chrome OS, we were reliying on the /postinst script to generate the
verity hashes and mark the new kernel as bootable. This means that we
also need to run /postinst from the other (not verified) slot when
doing a user-initiated rollback. The update_engine already interacts
with the bootloader via the BootControlInterface to mark the other slot
as unbootable and check if there are other slots available for
rollback.

This patch moves the responsibility of marking the new slot as bootable
from the /postinst script to the update_engine, introducing a new
SetActiveBootSlot() method in the BootControlInterface. Chrome OS
builds will continue to mark the new slot as active from /postinstall
in order to be compatible with old builds, resulting in the new slot
marked as active twice during a successful normal update.

Bug: 23523562
Test: cros flash and image to the new daemon; rolled it back

Change-Id: I02502d7b8e85523a6eb9a7721053739e8381d266
/system/update_engine/update_attempter.cc
aa26f6240865d43f8cecc97bde7828f9b82bc17d 17-Sep-2015 Alex Deymo <deymo@google.com> Move MarkBootSuccessful to BootControlInterface.

Updating the boot flags to mark the current boot as successful is
platform-specific and part of the BootControlInterface's job. This
patch moves this to a new async method in this interface.

Bug: 24077637
Test: FEATURES=test emerge-link update_engine; cros flash in Chrome OS; tested on a dragonboard.

Change-Id: I23c3ed915dd8d2588a90d84b212bb04977957975
/system/update_engine/update_attempter.cc
ac41a82e4be1be43913292d13d58b5eb2c572f53 16-Sep-2015 Alex Deymo <deymo@google.com> Set default updater URL and version per platform.

Chrome OS and Brillo devices require different production update URL
and updater string ID sent to Omaha. This patch moves these constants
to a platform-dependent file with the definition of the constants.

Bug: brillo:587,brillo:588
Test: FEATURES=test emerge-link update_engine; `mma`; deployed on a dragonboard.

Change-Id: Ibe3b30c32c2fb2caf3ed10a4198272dc13a44d12
/system/update_engine/update_attempter.cc
cbea78f22e1420f3cd2167b963acbf599941eb84 16-Sep-2015 Alex Deymo <deymo@google.com> Remove obsolete GetKernelDevices() method.

update_engine daemon exposed a DBus method GetKernelDevices() returning
the list of available kernel block devices and whether they were
bootable or not. This method was a developer-only method, since it
can't be called from chrome, and no other daemon uses it, besides the
update_engine_client.

The update_engine daemon moved from managing root and kernel partitions
explicitly, to manage slots. So the notion of which block device is the
"kernel" device is now unknown. The information about the available
slots and their status, can be managed with the external tool bootctl
instead. Therefore, this patch removes the GetKernelDevices() method.

Bug: None
Test: emerge-link update_engine; `mma` on AOSP.

Change-Id: I715bdbb73ebbbca3dfb381b16043224a170a3832
/system/update_engine/update_attempter.cc
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/update_attempter.cc
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/update_attempter.cc
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/update_attempter.cc
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/update_attempter.cc
0b3db6b6040f53eb9859e614f7fe4c681213d33a 11-Aug-2015 Alex Deymo <deymo@chromium.org> update_engine: Remove all references to glib.

The message loop in production code switched from
chromeos::GlibMessageLoop to chromeos::BaseMessageLoop used in
chromeos::Dameon. This patch moves all the unittests also to use
chromeos::BaseMessageLoop or chromeos::FakeMessageLoop when I/O is not
required.

This patch removes all (now unused) references to glib.

BUG=chromium:499886
TEST=`grep glib[^c] . -R` return no results. Also, unittests work.

Change-Id: Iddfb17def501829d932ed1f70faad3e00268898e
Reviewed-on: https://chromium-review.googlesource.com/292157
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/update_attempter.cc
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/update_attempter.cc
b7ca096f98a43ebbf412f1b2d3d15bb184f871f8 02-Oct-2014 Alex Deymo <deymo@chromium.org> update_engine: Migrate UE DBus service to chrome DBus bindings.

chromeos-dbus-bindings now generates the adaptor interface that
update_engine exposes over DBus. This interface is implemented in
dbus_service.{h,cc}, which now has a UpdateEngineService class
encapsulating all the service methods implementation.

This allows to write unit test for those methods, which are included
in this CL for all the non-trivial methods.

This CL now uses chrome's DBus bindings for the update_engine serive,
but the proxy interaction is still done using dbus-glib. The main loop
in the main.cc file is now replaced with the chromeos::Dameon, which
uses a chromeos::BaseMessageLoop instead of a GlibMessageLoop. This
causes the asynchronous interactions in the proxy side to not work,
which will be fixed in the next CL.

CQ-DEPEND=CL:290990,CL:291092,CL:293334
BUG=chromium:419827
TEST=Added unittest for all dbus_service methods. deployed and tested manually that update_engine dbus interface works.

Change-Id: I6a6d142b2ac1a61a4c3abcb927665b26114abe5c
Reviewed-on: https://chromium-review.googlesource.com/225324
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@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/update_attempter.cc
461b259af8815d782200782c5ba3599d8de4a66c 25-Jul-2015 Alex Deymo <deymo@chromium.org> update_engine: Use libchromeos to launch subprocesses.

The Subprocess class handles the execution of suprocesses in the
update_engine such as the post-install script and bspatch operations.

This patch migrates this class from using glib functions to use
libchromeos classes with equivalent functionality.

Callsites and unittests were updated to match the new interface.

BUG=chromium:499886
TEST=Unittest still pass. Deployed on link and cros flash another image
using a delta payload.

Change-Id: Ia64d39734e220675113f393a6049e9a9b0fe8409
Reviewed-on: https://chromium-review.googlesource.com/288837
Trybot-Ready: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
/system/update_engine/update_attempter.cc
60ca1a7bca7cc804ec80b510483081ef894de4cd 19-Jun-2015 Alex Deymo <deymo@chromium.org> update_engine: Migrate time-based glib main loop calls to MessageLoop.

This patch replaces most calls to g_idle_add* and g_timeout_add* with
the equivalent MessageLoop::Post*Task(). To maintain compatibility with
unittests running the main loop and doing I/O we instantiate a
GlibMessageLoop for those tests.

BUG=chromium:499886
TEST=unittests still pass.

Change-Id: Ic87ba69bc47391ac3c36d1bfc3ca28d069666af1
Reviewed-on: https://chromium-review.googlesource.com/281197
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Trybot-Ready: Alex Deymo <deymo@chromium.org>
/system/update_engine/update_attempter.cc
eb9e6d8d8813b2d5a81a14e0184f7b4798573606 17-Apr-2015 Allie Wood <alliewood@chromium.org> update_engine: Remove copy from source to destination partition.

Removes the copy of the old rootfs and kernel to the new rootfs and
kernel. This was initially done in FilesystemCopierAction, which is now
called FilesystemVerifierAction.

When FilesystemVerifierAction is given a source rootfs or kernel, it
calculates the hashes. When asked to verify the new rootfs or kernel, it
computes the hashes and compares them against the values in the manifest.

BUG=chromium:463562
TEST=Updates using `cros flash --src-image-to-delta` and unit tests.
CQ-DEPEND=CL:267360

Change-Id: I3c9ba60fa4af0c5381ba8a10883bd47dc40adb8c
Reviewed-on: https://chromium-review.googlesource.com/267554
Reviewed-by: Allie Wood <alliewood@chromium.org>
Commit-Queue: Allie Wood <alliewood@chromium.org>
Trybot-Ready: Allie Wood <alliewood@chromium.org>
Tested-by: Allie Wood <alliewood@chromium.org>
/system/update_engine/update_attempter.cc
fdf005161523d9873a281f2a96d51dd4a3261f4f 02-Mar-2015 Allie Wood <alliewood@chromium.org> update_engine: Add fds for the source partitions.

Add new fds for the source partition, one for the rootfs and another for
the kernel. These are opened if we have a delta update with minor
version 2.

This change also adds support for changing the minor versions in tests.
There is a new private member, supported_minor_version_, which defaults
to kSupportedMinorPayloadVersion. It is set in the unit tests with calls
to SetSupportedVersion.

BUG=chromium:463573
TEST=`FEATURES=test emerge-link update_engine`

Change-Id: Ib988c91eb450b2499c615ae65b271691dfd9c651
Reviewed-on: https://chromium-review.googlesource.com/260950
Trybot-Ready: Allie Wood <alliewood@chromium.org>
Tested-by: Allie Wood <alliewood@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Allie Wood <alliewood@chromium.org>
/system/update_engine/update_attempter.cc
907b4fa4009e5221f7b5f13cc03d9382e693c0c2 27-Jan-2015 David Pursell <dpursell@chromium.org> update_engine: Don't require hashes for non-official builds.

CL 228293 changed hash check logic such that hashes are always required
for official update URLs, on the assumption that they will always be
available.

This turns out to cause problems for situations like the referenced bug,
where the devserver counts as an official URL but isn't providing
hashes. This CL waives the hash check requirement for non-official
(dev/test) builds.

BUG=chromium:452139
TEST=cros_run_unit_tests --board=panther --packages=update_engine

Change-Id: I0a48bfe216a8afdff27e06baa24b3d37e7517b25
Reviewed-on: https://chromium-review.googlesource.com/243730
Trybot-Ready: David Pursell <dpursell@chromium.org>
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Commit-Queue: David Pursell <dpursell@chromium.org>
Tested-by: David Pursell <dpursell@chromium.org>
/system/update_engine/update_attempter.cc
02c1864e204997175302b1aebe3e0be9c6699ea5 06-Nov-2014 David Pursell <dpursell@chromium.org> update_engine: Allow `cros flash` on base images.

A goal of the upcoming debugd dev tools (crbug.com/403170), is to
enable a path to modify a base image such that a developer could run
`cros flash` on it.

Currently update_engine disallows custom omaha URLs and forces a hash
check for base builds, which breaks `cros flash`. This CL relaxes the
restriction slightly to allow use on a base build as long as the system
is in dev mode and the debugd dev tools are also enabled (dev tools are
currently enabled only in dev mode when there is no owner).

The check is done in update_attempter.cc, which only allows an unofficial
Omaha URL if these conditions hold true (unofficial meaning not the main
AU server or the AU test server). The other main change is
AreHashChecksMandatory() in omaha_response_handler_action.cc, which now
allows skipping hash checks for unofficial Omaha URLs.

BUG=chromium:428053
TEST=Ran unit tests, `cros flash` on base images in various states.
CQ-DEPEND=CL:227431

Change-Id: I8583ce6aa70feac8fe74b7a3992e8a4e761833c3
Reviewed-on: https://chromium-review.googlesource.com/228293
Reviewed-by: Alex Deymo <deymo@chromium.org>
Trybot-Ready: David Pursell <dpursell@chromium.org>
Commit-Queue: David Pursell <dpursell@chromium.org>
Tested-by: David Pursell <dpursell@chromium.org>
/system/update_engine/update_attempter.cc
965d708dea9479a307ef176079f3b5e0a4cf34af 15-Nov-2014 Alex Deymo <deymo@chromium.org> update_engine: Remove unused methods from UpdateAttempter.

These methods were never used nor implemented.

BUG=None
TEST=FEATURES=test emerge-link update_engine

Change-Id: I1e869c259855df50c6fe04f1b2ab2c5fdfc79b80
Reviewed-on: https://chromium-review.googlesource.com/229978
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
/system/update_engine/update_attempter.cc
020600db42428e7e96bb0d2e05da225e68650955 06-Nov-2014 Alex Deymo <deymo@chromium.org> update_engine: Use C++11 range-based for loop when possible.

This cleanup just simplifies the notation of several for loops using
the new range-based syntax.

BUG=None
TEST=`FEATURES=test USE="lang clang" emerge-link update_engine`

Change-Id: I2120a1b1c3fd00e9a02a62abfa8427932080d0f9
Reviewed-on: https://chromium-review.googlesource.com/227897
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
/system/update_engine/update_attempter.cc
74b5f55e6ff608857664fe151f54d78bfe0b75bb 07-Oct-2014 Gilad Arnold <garnold@chromium.org> update_engine: Relocate inference and storage of P2P related properties.

This change moves the inference of P2P related properties from
OmahaRequestAction to OmahaResponseHandlerAction, and their storage from
OmahaRequestParams to PayloadState. This is needed in order for the
UpdateCanStart policy to be able to decide P2P properties, which only
happens after the Omaha response is received and processed, and prior to
applying the update. Further, P2P properties do not affect the Omaha
request, and so there's no reason for them to reside in
OmahaRequestParams nor decided as early as OmahaRequestAction.

Additional cleanup includes swapping expected/actual arguments to EXPECT
macros where appropriate, and removing redundant .Times(1) expectation
qualifiers.

BUG=chromium:384087
TEST=Unit tests.

Change-Id: I6d5b4b44745d5dab7e350bdf019dbf804bf196a1
Reviewed-on: https://chromium-review.googlesource.com/223618
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
f329b933db41d26644a97afef928eb1b319d6d99 30-Oct-2014 Alex Deymo <deymo@chromium.org> update_engine: Fix all the "using" declaration usage.

This patch removes unused "using" declarations, that is, declarations
included in a .cc file at a global scope such that "using foo::bar"
that later don't use the identifier "bar" at all.

This also unifies the usage of these identifiers in the .cc files
in favor of using the short name defined by the using declaration.
For example, in several cases the .h refer to a type like
"std::string" because using declarations are forbidden in header
files while the .cc includes "using std::string;" with the purpose
of just writting "string" in the .cc file. Very rarely, the full
identifier is used when a local name ocludes it, for example,
StringVectorToGStrv() and StringVectorToString() in utils.cc named
its argument just "vector" need to refer to std::vector with the
full name. This patch renames those arguments instead.

Finally, it also sorts a few lists of using declarations that weren't
in order.

BUG=None
TEST=FEATURES=test emerge-link update_engine

Change-Id: I30f6b9510ecb7e03640f1951c48d5bb106309840
Reviewed-on: https://chromium-review.googlesource.com/226423
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
/system/update_engine/update_attempter.cc
749ecf1c000ce0243c2eee986282dd568535bafe 22-Oct-2014 Alex Deymo <deymo@chromium.org> update_engine: Re-introduce RefreshDevicePolicy() before computing update params.

The update_manager refreshes the policy for its own usage, but the
code that still remains outside the update_manager and depends on
device policy settings has to reload the policy manually.

This patch re-introduces the call to RefreshDevicePolicy() from
CalculateUpdateParams() that was removed in CL:209101 since some
code still requires it.

BUG=chromium:425827
TEST=delopyed this patch on R39 and tested that the scattering value from the policy is used.
TEST=Changed UpdateAttempterTest.UpdateTest to check this. Verified it fails without the change on update_attempter.cc

Change-Id: I051382987b507752e52a0af87d869a8845f3db6f
Reviewed-on: https://chromium-review.googlesource.com/224808
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
/system/update_engine/update_attempter.cc
519cfc71f0a2f7f01adb51acd19b5cd23d2c93a2 02-Oct-2014 Gilad Arnold <garnold@chromium.org> update_engine: Move scattering wait period store/load to PayloadState.

This is needed for decoupling the inference/use of this value from its
storing/loading, as we shift the former into the Update Manager.

BUG=chromium:384087
TEST=Unit tests.

Change-Id: I4b278dc817b6f148d5638122f934e9d1e280bfae
Reviewed-on: https://chromium-review.googlesource.com/221250
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
afd70ed1393d936579acbd9242c326be47213a69 01-Oct-2014 Gilad Arnold <garnold@chromium.org> update_engine: Remove legacy logic and tests.

This removes logic that was used for tracking whether updates were
disabled by device policy, and unit tests that checked for the presence
of such logic. This logic is now part of the Update Manager's
UpdateCheckAllowed policy request. It is safe to remove the old check
because it'll always conclude that the update request can be sent, given
that the said policy has concluded the same.

BUG=None
TEST=Unit tests.

Change-Id: Ibbb3728f7239f608a6317bc5a8b76cac7f54bc5f
Reviewed-on: https://chromium-review.googlesource.com/220876
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
54fa66dc58f965b276433e08ecebbe268f66de4c 29-Sep-2014 Gilad Arnold <garnold@chromium.org> update_engine: Respond to forced update requests when updates are disabled.

With the new UpdateCheckAllowed policy, we stopped changing the reported
state of the updater when update is permanently disabled, for example
when running from a USB image. This caused a problem whereas client code
(e.g. OOBE) expected the state of the updater to change as an indicator
for the fact that the update request is being processed.

This change fixes that by doing the following:

- Adds a new state (disabled) that is being signaled from the
UpdateAttempter through the system API to DBus clients. This state is
being used when UpdateCheckAllowed indicates that updates are
permanently disabled; the state is immediately set the idle again, so
that subsequent requests can also witness the state change.

- The code that rescheduled checks when the updater state was switched
back to idle was pulled out of that method and placed at the callsites
instead. It is now safe to call SetStatusAndNotify() from the callback
of ScheduleUpdate() without incurring an infinite call chain.

- When an update request is received via DBus, we now make sure to call
ScheduleUpdate() prior to broadcasting the forced update pending
status. This ensures that the policy will be called on each DBus
request, even if updates were formerly disabled.

BUG=chromium:417751
TEST=Unit tests.
TEST=Booting from USB on link, OOBE passes as expected.
TEST=update_engine_client yields the correct sequence of status readings.
CQ-DEPEND=CL:220374

Change-Id: I71eee1674d60956e39f953d44df86b61effd7800
Reviewed-on: https://chromium-review.googlesource.com/220404
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
f9cb98c0cacccca803db48502c7bd461d04cb6b0 22-Sep-2014 Ben Chan <benchan@chromium.org> update_engine: Clean up angle brackets in template types.

C++11 no longer has the angle bracket pitfall in template types.

BUG=None
TEST=`FEATURES=test emerge-$BOARD update_engine`

Change-Id: I0168b9f208ad8e62ae614b8a3b8bcf31c58fa9f2
Reviewed-on: https://chromium-review.googlesource.com/219203
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
/system/update_engine/update_attempter.cc
06c76a49bfd29c8abdb8abd5b646a6583783191a 05-Sep-2014 Ben Chan <benchan@chromium.org> Update code to include base/files/file_util.h

file_util.h was moved from base to base/files
(https://codereview.chromium.org/468253002). This CL updates platform2
code to include base/files/file_util.h instead of base/file_util.h.

BUG=chromium:411001
TEST=Trybot run on paladin, release, and chromiumos-sdk builders.

Change-Id: I488925b54615e131e508a460dc1a27f88168f936
Reviewed-on: https://chromium-review.googlesource.com/216851
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
/system/update_engine/update_attempter.cc
ec7f91625b799abf67ea3119490f2f1de8e4e677 15-Jul-2014 Gilad Arnold <garnold@chromium.org> update_engine: Ditch UpdateCheckScheduler, use UpdateCheckAllowed instead.

This change removes the update_check_scheduler module and replaces it
with async requests to the UpdateCheckAllowed policy, done by the
UpdateAttempter directly.

* A new UpdateAttempter::ScheduleUpdates() is used as a replacement for
UpdateCheckScheduler::Run() and rescheduling of periodic checks inside
UpdateCheckScheduler. The callback
UpdateAttempter::OnUpdateScheduled() handles both periodic and
interactive checks.

* The UpdateAttempter keeps track of whether or not an update check is
being waited for (waiting_for_scheduled_check_) so that we can ensure
liveness. This is a similar check to the one performed inside the
UpdateCheckScheduler.

* Inference of the update target version prefix and channel (via device
policy), as well as update disabled, are now performed by the
UpdateManager policy. Also eliminating reference to the list of
network types allowed by policy, which is not enforced anyway and will
be superceded by another policy request (UpdateDownloadAllowed).

* Since update check scheduling is now performed relative to the last
update check time (as recorded by the UpdateAttempter), we care to
update this time as soon as the request is issued (in addition to when
a response is received). This ensures that we won't be scheduling
back-to-back update requests in the case where a response was not
received. Updating the last check time is delegated to a method call;
we replace raw use of time(2) with the ClockInterface abstraction.

* Handling of forced update checks has been revised: the UpdateAttempter
keeps track of the most recent app_version and omaha_url values that
were received through DBus events; it notifies the UpdateManager not
only of whether or not a forced (formerly, "interactive") update
request is pending, but also whether or not it is indeed interactive
or should be treated as a normal periodic one. The UpdateManager
reflects this back to the updater via the result output of
UpdateCheckAllowed, which tells the UpdateManager whether the custom
app_version and omaha_url should be used (interactive) or not.

BUG=chromium:358269
TEST=Unit tests.

Change-Id: Ifa9857b98e58fdd974f91a0fec674fa4472e3a9d
Reviewed-on: https://chromium-review.googlesource.com/209101
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
88b591f24cb3f94f982d7024c2e8ed25c2cc26a2 29-Aug-2014 Alex Vakulenko <avakulenko@chromium.org> update_engine: Replace NULL with nullptr

Replaced the usage of NULL with nullptr. This also makes it possible to
use standard gtest macros to compare pointers in Update Manager's unit tests.
So, there is no need in custom UMTEST_... macros which are replaced with the
gtest macros (see change in update_engine/update_manager/umtest_utils.h):

UMTEST_ASSERT_NULL(p) => ASSERT_EQ(nullptr, p)
UMTEST_ASSERT_NOT_NULL(p) => ASSERT_NE(nullptr, p)
UMTEST_EXPECT_NULL(p) => EXPECT_EQ(nullptr, p)
UMTEST_EXPECT_NOT_NULL(p) => EXPECT_NE(nullptr, p)

BUG=None
TEST=FEATURES=test emerge-link update_engine
USE="clang asan" FEATURES=test emerge-link update_engine

Change-Id: I77a42a1e9ce992bb2f9f263db5cf75fe6110a4ec
Reviewed-on: https://chromium-review.googlesource.com/215136
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
/system/update_engine/update_attempter.cc
4906c1c6dac2ef7916bfa7193cc9324e99b4d223 21-Aug-2014 Alex Vakulenko <avakulenko@chromium.org> update_engine: Replace googe::protobuf::Closure with base::Closure

In order to clean up libchromeos, remove chromeos/callback.h and
switch update_engine from using
googe::protobuf::Closure/NewPermanentCallback to base::Closure/Bind

BUG=chromium:406060
TEST=FEATURES=test emerge-link update_engine

Change-Id: I02d222c3f6c9a5bf5177d58e3a25a596348619bf
Reviewed-on: https://chromium-review.googlesource.com/213675
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
/system/update_engine/update_attempter.cc
d9aca3b95945f51c3cae2e716a6b4accfd88bf13 21-Aug-2014 David Zeuthen <zeuthen@chromium.org> update_engine: Add helpful messages about lsb-release file.

In some unit tests we either don't have /etc/lsb-release or we don't
have a real clock and the (non-fatal) error messages about this can be
confusing. Rectify this by pointing out that these error messages may
occur in some unit tests.

BUG=chromium:401862
TEST=Unit tests pass.

Change-Id: Ie5298f0c6e8689c43ffc3c89aebf7690937a7518
Reviewed-on: https://chromium-review.googlesource.com/213545
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/update_attempter.cc
3e0b53e2c4aaecebc7c0c60b48f41ce27c7eaa55 13-Aug-2014 Alex Deymo <deymo@chromium.org> update_engine: Fake chromeos-setgoodkernel command for testing.

This patch fakes the chromeos-setgoodkernel command when running
unittests so the command doesn't attempt to run it. It also makes
Subprocess log the error message when there's a failure running
an async process.

BUG=chromium:401866
TEST=cros_workon_make update_engine --test

Change-Id: Ieca3216c57f6f9bc2f71a53e520575ae1fc19c0e
Reviewed-on: https://chromium-review.googlesource.com/212260
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
/system/update_engine/update_attempter.cc
9abb763fa3840d69cc1098c0233162557a7f99ea 07-Aug-2014 Ben Chan <benchan@chromium.org> update_engine: Use integer types from stdint.h

This CL replaces the deprecated int* and uint* types from
'base/basictypes.h' with the int*_t and uint*_t types from 'stdint.h'.

BUG=chromium:401356
TEST=`FEATURES=test emerge-$BOARD update_engine`

Change-Id: I658b34ad9e6feb938e0b569b72947a052ef8f8af
Reviewed-on: https://chromium-review.googlesource.com/211380
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
/system/update_engine/update_attempter.cc
44666f97392f1f0f8be292fe6a4edcf9237540df 23-Jul-2014 Alex Deymo <deymo@chromium.org> update_engine: Remove dependency on libupdate_engine from the client.

The update_engine_client is a very small DBus client that only
depends on a single utils:: function from the update_engine daemon
codebase. Because of this, it was forced to be linked against many
libraries that it didn't use.

This patch factors out this glib helper function to a new
glib_utils.{cc,h} file and includes only that in the
update_engine_client binary.

BUG=chromium:396440
TEST=FEATURES=test emerge-link update_engine

Change-Id: Icf8d8b3c6ebd22cdb39e6674fb3d9071071ec941
Reviewed-on: https://chromium-review.googlesource.com/209472
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
/system/update_engine/update_attempter.cc
44dc3bfd45eaddc1e7b586f8839babe4540418b5 19-Jul-2014 Gilad Arnold <garnold@chromium.org> update_engine: UM: UpdateCheckAllowed now considers interactive update requests.

This is necessary so we can delegate handling of all update checks to
the UpdateManager, allowing us to share logic between the two cases and
eliminate multiple entry point to UpdateAttempter::Update() and handling
of interference between these two processes. Instead, these are all
handled naturally by the UpdateManager.

BUG=chromium:394389
TEST=Unit tests.

Change-Id: I32a1ab917e5aeb5c2da1953d8b0ffa8c9d8d62f9
Reviewed-on: https://chromium-review.googlesource.com/209100
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
a0258a557d36ff78eacdacd39bdc88c5e6c1056e 11-Jul-2014 Gilad Arnold <garnold@chromium.org> UpdateManager: Obey server-dictated poll interval when scheduling checks.

This abides by the current logic, as found in
UpdateCheckScheduler::ComputeNextIntervalAndFuzz(). New unit tests
added to verify this behavior, as well as the addition of a new
UpdaterProvider variable to pull this value from the UpdateAttempter.

BUG=chromium:358269
TEST=Unit tests.

Change-Id: I0ac67dea5a622823a9c4713ec7165a55bc0a5c92
Reviewed-on: https://chromium-review.googlesource.com/207471
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
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/update_attempter.cc
65f1da02c7a366893c9fe5d448ed3c8db73d5b4e 28-Jun-2014 Daniel Erat <derat@chromium.org> update_engine: Use powerd for rebooting.

Make update_engine call powerd's RequestRestart method to
restart the system instead of running "shutdown -r now"
directly. This avoids races where Chrome asks powerd to shut
down the system but then update_engine sees that an update
has been applied and reboots it instead.

BUG=chromium:372074
TEST=applied an update and requested a reboot from the UI;
checked that the request was logged by powerd. held the
power button to shut down while an update was pending
and checked that the system shut down instead of
rebooting. built update_engine with the
power_management USE flag unset and checked that it was
still able to reboot the system.
CQ-DEPEND=I73f67cca9875b00bd944e4ff9779ad24fc4cd738
CQ-DEPEND=I2888fdde50a71460b74f2ef33d63ac00c5938626

Change-Id: Ic5f7c33c3f7fc5fe92ac8a2e1800830678cac235
Reviewed-on: https://chromium-review.googlesource.com/206074
Tested-by: Daniel Erat <derat@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Daniel Erat <derat@chromium.org>
/system/update_engine/update_attempter.cc
d2779df63aaad8b65fc5d4badee7dbc9bed7f2b6 16-Jun-2014 Alex Vakulenko <avakulenko@chromium.org> update_engine: fixed warnings from cpplint

Fixed all the cpplint warnings in update engine.

BUG=None
TEST=Unit tests still pass.

Change-Id: I285ae858eec8abe0b26ff203b99a42a200ceb71c
Reviewed-on: https://chromium-review.googlesource.com/204027
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
/system/update_engine/update_attempter.cc
d1c4d2dd3daed1d507038046c0355fbafb85260c 05-Jun-2014 Gilad Arnold <garnold@chromium.org> Change ErrorCode into an enum class.

This change is needed in order for us to be able to import ErrorCode
symbols from chromeos_update_engine into chromeos_update_manager.
Unfortunately, shifting from plain 'enum' into an 'enum class' means
that the compiler treats the new class as a distinct type from int,
which in turn means that plenty of seamless arithmetic/bitwise
operations we used for manipulating error code values throughout the
code needed to be retrofitted with static_cast operators.

In the future, we should consider imposing a proper abstraction on
update engine error codes that'll prevent mingling with value encoding
directly and prevent such nastiness. It'll also make things more
coherent (types, semantics) and safer.

BUG=chromium:358329
TEST=Unit tests.

Change-Id: Ie55fa566b764cdab6c4785d995fb6daee4cb32d3
Reviewed-on: https://chromium-review.googlesource.com/203209
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
bc91a2743fd3ffabb3ead3181ad8da3060afe1f1 21-May-2014 Alex Deymo <deymo@chromium.org> Replace std::tr1::shared_ptr by std::shared_ptr.

This patch replaces C++ Technical Report 1 additions to C++03 with
the newer C++11 name.

Includes and using statements updated accordingly.

BUG=None
TEST=Build and unittests.

Change-Id: I9bdad6d39684545c786f5c76fb598a15b557d6eb
Reviewed-on: https://chromium-review.googlesource.com/200665
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
/system/update_engine/update_attempter.cc
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/update_attempter.cc
a6dab94046bcd6c560c822e0175c75427368ab20 25-Apr-2014 Gilad Arnold <garnold@chromium.org> PM: UpdaterProvider reports the number of consecutive failed update checks.

This adds a new variable to UpdaterProvider, along with the necessary
bits of implementation in UpdateAttempter, to track and report this
number.

BUG=chromium:367006
TEST=Unit tests.

Change-Id: I819dc5c9d4d351e5bfe1373dba0993e3f622b0e0
Reviewed-on: https://chromium-review.googlesource.com/197092
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
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/update_attempter.cc
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/update_attempter.cc
44b9b7ed0a702e54afccb86228668c59151859be 02-Apr-2014 Chris Sosa <sosa@chromium.org> Fix rollback crash while previous rollback is in progress.

The CHECK in Rollback is wrong. We should not be crashing the update_engine
just because we have a previous rollback in progress. This CL changes the
CHECK to a if/else and cleans up the Rollback() logic to be easier to follow
and removes a redundant check for partitions (since CanRollback already
covers this problem).

This CL also cleans up a couple rollback-related unittests.

BUG=chromium:356975
TEST=unittests + on device

Change-Id: Iee8de65eabcddd1dbe6c6413e33a15bf75302260
Reviewed-on: https://chromium-review.googlesource.com/192909
Tested-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
/system/update_engine/update_attempter.cc
33bae491eded4ef4f1eb4f4ef0f01ef0e5463f3a 26-Feb-2014 David Zeuthen <zeuthen@chromium.org> Add new metrics.

The current metrics (Installer.* namespace) have several shortcomings,
for example it's not immediately clear when and how frequent each
metric is reported. This CL introduces new metrics that addresses this
and other problems. The new metrics are all in the UpdateEngine.*
namespace and fall into five categories

UpdateEngine.Daily.* Reported daily.
UpdateEngine.Check.* On every check.
UpdateEngine.Attempt.* On every attempt.
UpdateEngine.SuccessfulUpdate.* With every successful update.
UpdateEngine.* Miscellaneous

Most of the new metrics mimic existing metrics and also leverage the
existing code, book-keeping and unit tests. The plan is to remove the
Installer.* metrics once we're happy with the new ones.

I've also tested this manually by performing updates and verifying
that chrome://histograms looks correct.

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

Change-Id: I7a3f68d75910384b116c7e4664776e25d3997584
Reviewed-on: https://chromium-review.googlesource.com/191314
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/update_attempter.cc
2bddadd17e31ca1341604f8652432a8619557688 27-Mar-2014 Alex Vakulenko <avakulenko@chromium.org> update_engine: Added more logging and debugging for rollback checking

To help troubleshoot issues similar to http://crbug.com/356975 I added
more logging in DBus methods of update_engine to trace various stages
of determining available boot partitions, etc.

Also added two more DBus methods - to get the suggested rollback
partition name (and switched CanRollback to use this method) and
the list of availavle kernel partitions along with the 'bootable'
flag for each.

Changed update_engine_client to show the name of avaiable rollback
partition with --can_rollback and also added --show_kernels to
output list of available kernel partitions and whether each partition
is bootable or not.

BUG=None
TEST=Unit tests pass

Change-Id: Ib7f92a6460c578953ea1ba9b23bd0669acb0e22f
Reviewed-on: https://chromium-review.googlesource.com/191949
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
/system/update_engine/update_attempter.cc
75039d7397f03dff77bdf4e26398049ff88edc4c 25-Mar-2014 Alex Vakulenko <avakulenko@chromium.org> update_engine: update to libbase 242728

Made update_engine link with libchrome-242728 and fixed compile
issues due to changes in namespaces and include file layout.

Also removed some of suppressed compiler warnings and fixed the
issues masked by them (e.g. mismatched printf-like specifiers).

Added -Wextra compiler option to enable additional useful warnings
to ensure more strict checking... Had to disable "unused-parameter"
though since we have a lot of functions (mainly in fakes) that do
not use all of their parameters.

BUG=chromium:351593
TEST=Unit tests passed.
CQ-DEPEND=CL:191721

Change-Id: I1aa63a48d5f1f4ea75ba6b00aec7aa5f3bad15c4
Reviewed-on: https://chromium-review.googlesource.com/191510
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
/system/update_engine/update_attempter.cc
d38b113179e6d238ad7db16629b1146222c57c85 25-Mar-2014 Chris Sosa <sosa@chromium.org> Remove stable channel check for rollback.

BUG=chromium:356265
TEST=Unittests

Change-Id: Id1b8345fdf5cbd4ea12e3fe297b41260b96ee86c
Reviewed-on: https://chromium-review.googlesource.com/191443
Tested-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
/system/update_engine/update_attempter.cc
dea2eac2c565ed5b587278b865e2c07b805a8333 14-Mar-2014 Alex Vakulenko <avakulenko@chromium.org> update_engine: Added ability to retrieve old version via DBus

Now it is possible to retrieve an old OS version that was in use
before the last reboot, provided that we are now booted into
an updated version. This is to be used by crash reporter in case
the reboot was caused by a crash in kernel while reboot was pending
for an update. In such a scenario, the crash would be attributed
to the current (updated) version, which is wrong.

Also added additional parameter, --old_version, to
update_engine_client to retrieve the old version number, if any,
from the update engine.

BUG=chrome-os-partner:26518
TEST=cros deploy and tested via update_engine_client

Change-Id: I84e2322c5698b44b4c77f25c8f4211cdb367e5dc
Reviewed-on: https://chromium-review.googlesource.com/190149
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
/system/update_engine/update_attempter.cc
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/update_attempter.cc
59e253e555072d11f3646fc1286459cbc6aa5419 24-Feb-2014 Alex Vakulenko <avakulenko@chromium.org> update_engine: added CanRollback dbus method

Added a method to the update engine to check if a rollback
partition is available and can be booted from.
update_engine_client is also updated to call the function
when --can_rollback paramater is specified

BUG=chromium:343301
TEST=Ran "update_engine_client --can_rollback" and unit tests

Change-Id: If3fcb29a0067069a22812f60e9b67c6fdbbd18bd
Reviewed-on: https://chromium-review.googlesource.com/187157
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
/system/update_engine/update_attempter.cc
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/update_attempter.cc
6646b44ac128d07b33435d0bbf7cfd140af15eb9 14-Nov-2013 Don Garrett <dgarrett@google.com> Don't rollback if the other partition isn't valid.

Before we start a rollback to the other OS slot, validate the GPT flags show
it as bootable. This should prevent us from attempting a rollback if an
update has been attempted and failed, or is currently in progress. Such
a rollback would always fail, since the other partition would be left in
a partially modified state.

Piggyback:
Move sanity test in hardware that was added to the wrong method.
Undid some unittest changes that were decided against after the fact.

BUG=chromium:267054
TEST=Unittests
Manual Update Rollbacks (with/without flags on other partition)

Change-Id: Ide6b0673855ba2e4b05a0db93413a1a9f2ece2a9
Reviewed-on: https://chromium-review.googlesource.com/176755
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
/system/update_engine/update_attempter.cc
83692e4fd17b5669eeb3edb24b8c4cd8152c7283 08-Nov-2013 Don Garrett <dgarrett@google.com> Mark the new kernel invalid when starting an update.

Before we overwrite the new kernel, mark it as unbootable by setting the GPT
flags "successful" and "tries" to 0. This is good, but not critical as a
general behavior because it prevents the firmware from even trying a kernel
we think will be bad.

It's more useful, because it gives us a definitive way to know if the other
kernel is expected to be valid for purposes of things like rollback. There
will be a future CL to use it for preventing rollback to a known invalid
installation.

Also adds a MockHardware implementation backed by the FakeHardware
implementation, and switches MockSystemState to use it.

BUG=chromium:280816
TEST=Manual watching of flags, and multiple updates.
CQ-DEPEND=CL:176177

Change-Id: Idb083279cd1438a555c5165c69b25c351207e382
Reviewed-on: https://chromium-review.googlesource.com/176169
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
/system/update_engine/update_attempter.cc
af9085e6b77f3f53a2d824b720414e0b1ab2e8a0 07-Nov-2013 Don Garrett <dgarrett@google.com> Fix UE crash during rollback operations.

When we finalized a rollback operation, we were trying to send
update metrics based on the response_handler_action_. However,
that pointer was NULL because rollback has no Omaha resonse.

BUG=chromium:312849
TEST=Replicated problem, used logs to confirm NULL pointer.
Manually tested fix without crash.

Change-Id: I55eb79501e7e36ef24010c40b1de118fbb14a58a
Reviewed-on: https://chromium-review.googlesource.com/176026
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
/system/update_engine/update_attempter.cc
3c55abd5fa1e3db40974b2e8d94f2ddce65fe40d 14-Oct-2013 David Zeuthen <zeuthen@chromium.org> Add D-Bus method to get the duration since an update completed.

This new API can be used by Chrome to automatically reboot the device
at N hours after updating. This is implemented as a D-Bus method that
returns the number of micro-seconds on the wall-clock since the update
completed. If the device has not updated, the D-Bus method returns an
error.

For robustness, durations are measured using the CLOCK_BOOTTIME clock
instead of the usual CLOCK_REALTIME clock. This avoids interference
with NTP adjustments, the RTC clock being wrong and other things.

BUG=chromium:218192
TEST=New unit test + unit tests pass + manual test on a device using
the gdbus(1) command as the chronos user.

Change-Id: I51d44d69afe2d3024bb0780916c3c4e3f8ebb19e
Reviewed-on: https://chromium-review.googlesource.com/173032
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/update_attempter.cc
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/update_attempter.cc
192449ed75fd9ef81e59b82cc26ad9a5f0e5f8a2 28-Oct-2013 Chris Sosa <sosa@chromium.org> Add --follow to update_engine_client that follows any AU operation to completion.

Before, this ability was nested in with -update, this CL separates the logic
into a --follow flag. To keep existing behavior, I'm forcing --follow to true
when --update is set.

In this CL I also sort the flags variables and clean up some of the logic.
Now all flags should work together except for explicitly mutually exclusive
flags which I noted in the code (this removes early return 0's).

Finally I changed all the LOG(FATAL)'s to LOG(ERROR)'s because the fatals
throw a stack trace which isn't valuable.

BUG=chromium:309051
TEST=Ran
-rollback with and without -follow (found bug with policy that I also fixed.
tested also with update, check_for_update, status, watch_for_status_updates
and app_version.

Change-Id: I1bc1d5bf760af1df117172443112c4ad5864d8a3
Reviewed-on: https://chromium-review.googlesource.com/174905
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
/system/update_engine/update_attempter.cc
308429363870cf92a74a60ae8a645aa60b1a3a64 28-Oct-2013 J. Richard Barnette <jrbarnette@chromium.org> Move KernelDeviceOfBootDevice() to utils.

The function to construct the kernel partition block device from
its corresponding boot device uses only string manipulations, and
doesn't operate on the underlying hardware. This removes the
function from HardwareInterface, in favor of utils.

BUG=None
TEST=unit tests

Change-Id: I94b2c477413c4b484045a696f0ffbc77d9853195
Reviewed-on: https://chromium-review.googlesource.com/174913
Commit-Queue: Richard Barnette <jrbarnette@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
/system/update_engine/update_attempter.cc
c1f07c34c0907a8b281407fbf42d2aa61d65b045 10-Oct-2013 Daniel Erat <derat@chromium.org> update_engine: Use shared constants for update status.

BUG=chromium:221803
TEST=did a build
CQ-DEPEND=I8558357a20a54e6d9df237bba03ebfc2b6a00f08

Change-Id: I391c952c409b1721254d2d4a35f9ebca5d39bc0e
Reviewed-on: https://chromium-review.googlesource.com/172615
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Daniel Erat <derat@chromium.org>
Commit-Queue: Daniel Erat <derat@chromium.org>
/system/update_engine/update_attempter.cc
985b112a749ccbe025ea4aa0245b13f92c28a057 09-Oct-2013 David Zeuthen <zeuthen@chromium.org> Add Installer.OSAgeDays metric

This adds a new metric conveying the age of the running OS instance,
where this is defined as the time-span between the current wall-clock
time and the time-stamp of the /etc/lsb-release file. This metric is
reported daily.

BUG=chromium:304950
TEST=New unit tests for daily metrics + unit tests pass. Manual test
for Installer.OSAgeDays by inspecting chrome://histograms.

Change-Id: I6713bed6730641a95443372a3e3166c4e1dc64ee
Reviewed-on: https://chromium-review.googlesource.com/172162
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/update_attempter.cc
92d9c8bc5cd418e34944d6fc4bae44e3b4370246 11-Sep-2013 David Zeuthen <zeuthen@chromium.org> Also use DevicePolicy::GetAuP2PEnabled() to determine if p2p is enabled

With this change update_engine will use p2p either if the user has
manually enabled it (through the crosh flag) OR if the enterprise has
enabled it in Enterprise Policy.

BUG=chromium:260442
TEST=New unit tests + unit tests pass.

Change-Id: I54cd92c481bd2fd7c90232d7137ce2b37fa2ce61
Reviewed-on: https://chromium-review.googlesource.com/168950
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/update_attempter.cc
052d290ce38bd67629e3f0f5d4e4b7cfa8b7c201 06-Sep-2013 David Zeuthen <zeuthen@chromium.org> p2p: Remove IsP2PAllowedForInteractiveChecks() function and its users

This is no longer needed now that it's possible to just pass
-interactive=false to the update_engine_client program.

BUG=chromium:273251
TEST=Manually tested + unit tests pass.

Change-Id: If8b1d600125d7a3108a81471dbcd2f9ca00a6988
Reviewed-on: https://chromium-review.googlesource.com/168446
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/update_attempter.cc
8f191b22a1a1ab2b803d65ee488729206e648695 06-Aug-2013 David Zeuthen <zeuthen@chromium.org> p2p: Use p2p for updates

This is the main patch for enabling use of p2p for consuming and/or
sharing updates via p2p. Refer to the ddoc and other documentation for
how this works.

BUG=chromium:260426,chromium:273110
TEST=New unit tests + unit tests pass + manual testing
Change-Id: I6bc3bddae1e041ccc176969a651396e8e89cb3f0
Reviewed-on: https://chromium-review.googlesource.com/64829
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/update_attempter.cc
70e476ed0a09f8ca2d0a9e3f0e1cd78ccefd5fbe 31-Jul-2013 Gilad Arnold <garnold@chromium.org> AU/unittest: allow use of a parametric update completed marker

This should allow unit tests to be run in parallel. We introduce
a private constructor available only to specific test classes of
UpdateAttempter, which allows us to set a different marker.

Note that, in all unit tests that do not specifically make use of this
marker, we actually want UpdateAttempter to ignore it entirely. I'm not
entirely positive whether not ignoring would lead to interferences
between concurrently run tests, but I think it's better to err on the
safe side. (The marker is never ignored when used with any code other
than UpdateAttempter unit testing code.)

BUG=chromium:236465
TEST=Unit tests pass incl ignore semantics when not needed

Change-Id: I30fbed2ae2c21368d79127ed44811007e2a66e77
Reviewed-on: https://gerrit.chromium.org/gerrit/63840
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
fb1020e30511825c1c39f3764f07ef237a6f668e 30-Jul-2013 Chris Sosa <sosa@chromium.org> Add version information to install plan and GetStatus.

As per the TODO this information is useful for debugging and testing
changes i.e. I'd like to know what version I'm updating to. GetStatus
already supports getting this version but we never populate the field.

BUG=chromium:264505
TEST=Unittests + ran update_engine_client -update which uses GetStatus
to communicate status.

Change-Id: I5332e2f206d92aedba509cd5469e9610c88bcd03
Reviewed-on: https://gerrit.chromium.org/gerrit/63675
Commit-Queue: Chris Sosa <sosa@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
/system/update_engine/update_attempter.cc
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/update_attempter.cc
d6ab4045f64836f20f4662e3832e38cfa2a61515 18-Jul-2013 Chris Sosa <sosa@chromium.org> ChannelDelegated policy: if value is missing, assume it is false.

We missed another use of the same check. This should fix that call.

BUG=chromium:261400
TEST=unittests.

Change-Id: I88cb4d22905c4c7953c63fdafaa83bd7547dafa1
Reviewed-on: https://gerrit.chromium.org/gerrit/62498
Commit-Queue: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
/system/update_engine/update_attempter.cc
28e479c3b08cb4d1280905f5d3510f8ec4ed719c 12-Jul-2013 Chris Sosa <sosa@chromium.org> Don't allow rollback on the stable-channel.

This change explicitly disallows rollback on the stable-channel.

BUG=chromium:252539
TEST=unittests + on device.

Change-Id: I71caf95daae185790cf9fb0fda790eaf960bbe6b
Reviewed-on: https://gerrit.chromium.org/gerrit/61687
Tested-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
/system/update_engine/update_attempter.cc
76a29aef71c1602d6dcec6fc7062d2162b03c9ec 12-Jul-2013 Chris Sosa <sosa@chromium.org> Don't allow rollback when we are enterprise enrolled.

As stated (and verified) by the device_policy protobuf, we can determine
whether a device is enterprise enrolled by checking if GetOwner is empty.
We use this knowledge to not allow rollback when powerwash is also requested (
the default).

As part of this CL I've figured out how to unittest Rollback and added tests
for both enterprise and non-enterprise rollback.

BUG=chromium:254829
TEST=Tested on both an enrolled and non-enrolled device. Verified only the
latter actually did a powerwash while the other aborted correctly. Also ran
new unittests

Change-Id: Idfe6bfef88819fe1bab7da6b31854faf7642c9ce
Reviewed-on: https://gerrit.chromium.org/gerrit/61645
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
/system/update_engine/update_attempter.cc
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/update_attempter.cc
e4c58bf01b6ccc915c6b261007dbb75241ed69b8 19-Jun-2013 David Zeuthen <zeuthen@chromium.org> Add Installer.TimeToRebootMinutes metric

This patch introduces a new metric for tracking the duration between
when an update has successfully completed (and the user is presented
with the "reboot arrow" in the panel) and when the system has booted
into the new update.

BUG=chromium:248800
TEST=New unit test + Unit tests pass + Manual tested

Change-Id: Ia22cedc3b70f1d9c2598bed9469b34a257546a64
Reviewed-on: https://gerrit.chromium.org/gerrit/59132
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/update_attempter.cc
d317e40be46e1b69f624a8165472c99fe6346a1e 12-Jun-2013 Chris Sosa <sosa@chromium.org> Implement Rollback to previously booted partitions.

This CL implements rollback to whatever partition we ran from before.
We expose this functionality via dbus under AttemptRollback and expose
a new command-line option to update_engine_client that a developer can
use.

BUG=chromium:242665
TEST=Unittests, full update, update + rollback and verified.

Change-Id: Ie59f90b9a0b777dc1329592449090c70892236bf
Reviewed-on: https://gerrit.chromium.org/gerrit/58427
Commit-Queue: Chris Sosa <sosa@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
/system/update_engine/update_attempter.cc
a99981fda75fe0b17e96c700e3ddc93eca1cebe5 29-Apr-2013 David Zeuthen <zeuthen@chromium.org> Rename ActionExitCode to ErrorCode

Nowadays ActionExitCode is used throughout the codebase so use a more
generic name to reflect this.

BUG=chromium:216507
TEST=unit tests pass

Change-Id: I23d1d7e2676443251dbc42ed137fd018aadfa8a3
Reviewed-on: https://gerrit.chromium.org/gerrit/49512
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/update_attempter.cc
674c318a84e4344fce0fdaee039784ed7900d188 18-Apr-2013 David Zeuthen <zeuthen@chromium.org> Use better histogram parameters for duration metrics

In the current code this is capped at 20 minutes which is not helpful
as we're interested in data for devices that take much longer to
update. Instead, use one year for UpdateDuration and one month for
UpdateDurationUptime. Also move the code that sends the metric into
PayloadState to better conform with newly added code.

Also rename the metrics to they have the suffix Minutes. E.g. the new
metric names are

Installer.UpdateDurationMinutes
Installer.UpdateDurationUptimeMinutes

Also add unit test for utils::FormatTimeDelta().

BUG=None
TEST=Unit tests, look at chrome://histogram

Change-Id: I8581ec111f9833bdd72f10888c9626f40779f8b9
Reviewed-on: https://gerrit.chromium.org/gerrit/48558
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
/system/update_engine/update_attempter.cc
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/update_attempter.cc
19409b74019d787100b768306e75ab3e5882898d 13-Apr-2013 Jay Srinivasan <jaysri@chromium.org> Add metrics to report the number of bytes downloaded per protocol.

This CL adds these two basic metrics:
1. The number of megabytes downloaded using each protocol (or source
in general, as we want to consider HTTP downloads from server and possibly
a peer in future as two different sources) for each successful update. The
totals across all protocols will equal the payload size exactly.
2. The total number of megabytes downloaded since the last update attempt.
If there are no errors, this should be same as above. Otherwise, this will
be larger and will help us to compute the update efficiency.

BUG=chromium:225953
TEST=Unit tests pass, new Unit tests added.
TEST=chrome://histograms shows metrics correctly.

Change-Id: Ic02e218f46568427df99a8a9df2011860aee84f3
Reviewed-on: https://gerrit.chromium.org/gerrit/48069
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
9a017f2c5ae41c04a7c7c15b5dbd08faadae7606 12-Apr-2013 David Zeuthen <zeuthen@chromium.org> Measure and send update duration (and corresponding uptime) to UMA

This patch introduces two new metrics, Installer.UpdateDuration and
Installer.UpdateDurationUptime. The former is the timespan from when
the update was first discovered until it has been downloaded and
applied (including the time the device is suspended or powered
off). The latter is similar, but without taking into account time
spent in suspend or powered off.

For example, if the device is suspended (or powered off) for N seconds
while updating, the Installer.UpdateDuration metric will be N seconds
bigger than Installer.UpdateDurationUptime metric:

Histogram: Installer.UpdateDuration recorded 1 samples, average = 313.0
Histogram: Installer.UpdateDurationUptime recorded 1 samples, average = 251.0

Also remove the existing Installer.UpdateTime metric as this didn't
take process restarts into account and is now superseeded by the
Installer.UpdateDuration metric.

This is done by using the CLOCK_MONOTONIC_RAW clock (available in
Linux 2.6.28 and later) since this clock indeed does not advance when
the system is sleeping.

We use the PayloadState class to persist recorded data across
update_engine process restart (including device reboots).

Since clock_gettime(2) and CLOCK_MONOTONIC_RAW requires linking to the
librt library do this and also request the system header files to
expose the required symbols and defines, i.e. define _POSIX_C_SOURCE
>= 199309L.

Also remove _POSIX_C_SOURCE mangling from update_attempter.cc since
it's actually not needed there and generally it's better to make the
environment the same across all translation units (by putting whatever
is needed in e.g. CCFLAGS).

BUG=chromium:226763
TEST=unit tests, force update, examine chrome://histograms

Change-Id: I883668564b5fa78ff3e19156bd77496ff929ca58
Signed-off-by: David Zeuthen <zeuthen@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47928
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
d29695df35b7192faef4009d42a62c37bdd90a8f 09-Apr-2013 Jay Srinivasan <jaysri@chromium.org> Refactoring: Move prefs constants out to the constants.h/cc

Adding/removing the set of keys used by various parts of the Update Engine code
does not affect the implementation of the prefs module, hence separating them.

BUG=chromium:229090
TEST=Unit tests pass.

Change-Id: Id774b726a47b461e563e2e413527054e4da0c012
Reviewed-on: https://gerrit.chromium.org/gerrit/47593
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
Commit-Queue: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
1c0fe79c7ef2b43946d756b54c8505d2bf48b93b 29-Mar-2013 Jay Srinivasan <jaysri@chromium.org> Cancel the current download if user chooses a different channel.

In my earlier CL, to keep the implementation simple, we disallowed changing
a channel until the previous change completed in its entirety. Given that
the UI is not going to be updated for M27, such a restriction turned out
to be very confusing when playing around with channel changing. So, we
decided to implement a simple form of canceling the download if the
user selected a different channel while we're downloading the bits. This
implementation can easily be extended to support a general form of cancel
in the future, if required.

This CL also adds validation of libchromeos API calls when interpreting
the policy values. It also cleans up some bogus error messages that were
logged earlier when we abort a download.

BUG=chromium:222617
TEST=All scenarios pass on ZGB. Unit Tests pass.

Change-Id: I7cd691fe461d9ce47314299f6e2598944650ee33
Reviewed-on: https://gerrit.chromium.org/gerrit/46095
Commit-Queue: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
dc9a8ca2c26dd2d187385609b35ac040367f26de 20-Mar-2013 Jay Srinivasan <jaysri@chromium.org> Fix update_disabled flag to be set to false when there's no policy.

My previous check-in introduced an uninitialized variable which
may cause some random AU failures because of the update_disbled
flag being initialized to true based on the contents of the stack.

This CL fixes it by always setting it to false.

BUG=chromium:222161
TEST=Unit Tests Pass, work as expected on my ZGB.

Change-Id: I80fce1db566f6cea0ea80370c4a90dc538215316
Reviewed-on: https://gerrit.chromium.org/gerrit/45941
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
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/update_attempter.cc
5b3f3b90678204070c927c461c6030d32ae3f269 04-Feb-2013 Julian Pastarmov <pastarmovj@chromium.org> Make policy reloads explicit.

BUG=chromium-os:38541
TEST=unit tests pass
CQ-DEPEND=I20461078ca890c6ec2f81ad5383c06c4d75a64cd

Change-Id: I3f9ca593247816534d4f9f87e8a0c7db593b87b5
Reviewed-on: https://gerrit.chromium.org/gerrit/42540
Reviewed-by: Will Drewry <wad@chromium.org>
Commit-Queue: Julian Pastarmov <pastarmovj@chromium.org>
Tested-by: Julian Pastarmov <pastarmovj@chromium.org>
/system/update_engine/update_attempter.cc
b92f0df60b3b1d8ad0ac95fea74cc4fbbf93d204 11-Jan-2013 Gilad Arnold <garnold@chromium.org> AU: coalesce interactive / user-initiated flags

The latter was introduced recently but turns out it just carries
a duplicate meaning to the former, so we're eliminating it. This also
makes the case of a simulated scheduled update check more accurate, as
all of the effects of a scheduled update are made.

BUG=None
TEST=Unit tests; interactive/scheduled update check behaves as expected.

Change-Id: I8971aefcfc15cb76733059860832507e88795883
Reviewed-on: https://gerrit.chromium.org/gerrit/41082
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
bbdd4909bcd20448ad89aa1e02c936e42aedf548 11-Jan-2013 Gilad Arnold <garnold@chromium.org> AU: add an interactive flag to Omaha requests

Such a flag can be used to distinguish between user-initiated
(interactive) checks and those that are due to background scheduling. In
the former case, we may want to suppress the probabilistic throttling
that's commonly used with latest releases. This CL piggybacks the new
functionality on top of an existing dataflow used for distinguishing
between interactive / scheduled checks, only it pushes it further so it
is evident in the Omaha request as well.

Comes with a unit test for ensuring that the Omaha flag is set as
expected.

BUG=chromium-os:26594
TEST=Dbus initiated checks correctly tainted

Change-Id: Ia2b3ff5ce3a866c64e453557028b8cbd92c1a258
Reviewed-on: https://gerrit.chromium.org/gerrit/41081
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
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/update_attempter.cc
bf7919ba5ecd58a6a03afdca8ff88caebd25581d 08-Jan-2013 Gilad Arnold <garnold@chromium.org> AU: disable GPIOs in production; some structural changes

Since we are not making use of the GPIO funcionality in UE for the
moment, it's been advised that it should be disabled. This CL does just
that, plus a few small changes:

* Adds a "no-op" GPIO implementation, which simply returns a constant
value every time it's being asked whether test-mode was signaled (in
this case, we set it to return false).

* The GPIO handler is embedded in SystemState. This makes sense from
both the conceptual and usability standpoint. The SystemState object
can be parametrized to initialize either a real or a no-op GPIO
handler.

BUG=chromium-os:32263
TEST=passes unit tests; does not engage GPIO protocol on x86-alex

Change-Id: I8121647baa7611041073dcf305beddab57c0e49c
Reviewed-on: https://gerrit.chromium.org/gerrit/40633
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
2b5a0f065187fd19179e3809148dbfc376ada7a0 20-Dec-2012 Jay Srinivasan <jaysri@chromium.org> Classify errors and advance URL index according to the error code.

In CL https://gerrit.chromium.org/gerrit/39638, we always incremented
the URL index irrespective of the error code. That would cause the first
URL to be given up too quickly in favor of the second one even for
transient errors such as when user closes a lid and reopens after some
time.

The right behavior in this case is to just count those failures towards
the URL and only after repeated failures with no progress should we
advance the URL index.

This CL implements this logic and completes the multiple URL-related
work items outlined in the design doc.

BUG=chromium-os:37206
TEST=Tested all uses cases on my ZGB. Added and updated unit tests.

Change-Id: Ida0cfbfeb9bfab732144049d1b27e3b8958bc252
Reviewed-on: https://gerrit.chromium.org/gerrit/39885
Commit-Queue: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
6f6ea00aa8c4cf54b6842be32ca1226854c24f78 14-Dec-2012 Jay Srinivasan <jaysri@chromium.org> Support for processing multiple URLs in update_engine.

Main changes:
1. Added a new PayloadState class which encapsulates all the persisted
state we use for multiple URLs, back-off (TBD), etc.
2. Added support for handling multiple URLs stored in the OmahaResponse in
OmahaRequestAction and OmahaResponseHandlerAction code.
3. Added support for picking the right URL in OmahaResponseHandlerAction
and putting it in the install_plan. This way, the rest of the code that
uses the install_plan is oblivious to the presence of multiple URLs :-)
4. Added support for advancing to next URL when an update fails. The full
error classification is a new work item (chromium-os:37206). Right now,
it's a basic round-robin on every error.
5. Updated the conditions for determining when hash checks are mandatory.
Previously since there was only one URL, if it was HTTPS, the checks were
waived. Now, even if there's one HTTP URL, we make hash checks mandatory
even if other HTTPS URLs are present.

6. Added new unit tests for PayloadState and the new logic added to other
places.

Noisy changes:
1. Instead of passing PrefsInterface to OmahaRequestAction and
OmahaResponseHandlerAction, we're now passing SystemState which will now
contain PrefsInterface and the newly added PayloadState object that these
actions need to do their work.
2. Renamed a bunch of setters/getters to set_x() and x() instead of SetX()
and GetX() methods - this was pending from Gilad's old CR. As I'm
adding new methods in the correct style, I went ahead and fixed it to
avoid the confusing styles.
3. Updated all existing unit tests to reflect these changes.

BUG=chromium-os:36807
TEST=All Single/Multiple URL scenarios work fine on my ZGB as expected.
TEST=Old and new unit tests run fine.

Change-Id: Id31f9ccb220471f3ec3a475f624dc03c16119144
Reviewed-on: https://gerrit.chromium.org/gerrit/39638
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
4f8ee27b3592351cd71897d192065758340932d1 30-Nov-2012 Chris Sosa <sosa@chromium.org> Modify priority tweaking to use CGroups.

This modifies the behavior of setpriority and getpriority
to use CGroups rather than niceness levels.

I've removed the unittest comparing priorities as its not
really valid any more as we are just writing numbers to files.

I've also refactored references to priority to reference cpu
shares etc.

BUG=chromium-os:36229
TEST=Unittest + doing end to end test in bgnd
CQ-DEPEND=I6a0e56073e7281268e0550919c9ec9202b18db26

Change-Id: I48c8270c2065f1e0677e5e53df3557131577b97c
Reviewed-on: https://gerrit.chromium.org/gerrit/39147
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
Commit-Ready: Chris Sosa <sosa@chromium.org>
/system/update_engine/update_attempter.cc
edce28385c15d953bd04f7bc715c45f02dc850f6 25-Oct-2012 Jay Srinivasan <jaysri@chromium.org> Addressing review comments that came after merging previous CL.

Minor updates to naming conventions and comments.

BUG=chromium-os:34299
TEST=Retested on ZGB. Re-ran unit tests.
Change-Id: I7db665d4f69969a972ee801f0e0cea9cf33437a6
Reviewed-on: https://gerrit.chromium.org/gerrit/36531
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
f057205065339c54d3403263f049e2ea69417665 24-Oct-2012 Jay Srinivasan <jaysri@chromium.org> Send UMA Stats for update engine error codes.

With the latest addition of new optional security checks for the update
manifest and operations checked in, we now want to track the number of
failures, if any, over time to help us decide when it is safe to make
the new security checks mandatory. This CL adds the UMA metric for
reporting the new (as well as the old) error codes to UMA for the first
time.

There's no change to the existing errors that are being sent to Omaha.
Due to UMA restrictions, some Omaha codes will be aggregated when being
sent to UMA.

BUG=chromium-os:34299
TEST=Unit tests pass, tested on real ZGB, all stats show up in
chrome://histograms correctly for both dev mode and normal mode.
Change-Id: I3ce4645636311cedbb33f601e775951966c0a545
Reviewed-on: https://gerrit.chromium.org/gerrit/36408
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
51dcf260754837962dd22db3b7babee181471e7d 14-Sep-2012 Jay Srinivasan <jaysri@chromium.org> Verify AU payload manifest signature if present.

In order to support downloads over http for a number of reasons, we need
to secure http downloads. The first step in this process is to
verify the signature of the manifest itself before parsing. This can be
done even for https-based downloads in order to provide defense-in-depth
against a SSL attack. This CL adds the required verification logic in
update_engine, if such a manifest signature is present in the Omaha
response.

Until the delta generator is modified in a subsequent check-in to update
the manifest and payload with the required signature, none of this new
code will have any effect.

The delta generator change to populate non-zero values for these new
fields will follow in subsequent CLs.

BUG=chromium-os:33602
TEST=Tested on ZGB to make sure existing functionality works fine.
Added new unit tests.
Change-Id: I2d8b09c23faf87049893b1dee97a34e1f300aded
Reviewed-on: https://gerrit.chromium.org/gerrit/32844
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
c1ba09a8f4d3eda4654b34bf01d41fd9ad1d9f38 14-Aug-2012 Jay Srinivasan <jaysri@chromium.org> Support in update_engine for script for UI jank investigation.

We need to update image_to_live.sh to run in a loop to help investigate
the kernel behavior during AU. Since update_engine doesn't allow a
new update to be applied unless the device is rebooted after the previous
update, this CL adds an option to reset the state for testing purposes.

This CL does not cause any change in product code, since
update_engine_client will never be invoked with this option in product.

BUG=chromium-os:27954
TEST=Tested on ZGB.
Change-Id: I561e58893818a1b4990fdc131cd3bb64e473155e
Reviewed-on: https://gerrit.chromium.org/gerrit/29907
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
21be0753ca991afed45998ecd4c157c245f1fad0 26-Jul-2012 Jay Srinivasan <jaysri@chromium.org> Make sure waiting period in memory and persisted file are always in sync.

Sometimes the waiting period is 0 and there's no wall-clock-wait-period
prefs file created even though scattering is enabled. It happens because
the existing code doesn't maintain the invariants properly. So when a
user-initiated update check happens, the wall-clock-wait-period prefs
file is deleted but the in-memory variable
omaha_request_params_.waiting_period is not being updated.

This CL fixes these invariants by ensuring all the scattering artifacts
are removed completely when scattering is disabled and they're properly
recomputed when scattering is enabled.

BUG=chromium-os:32924
TEST=Updated unit tests, tested on ZGB.
Change-Id: Iabd2fd744f8c1a5099c00cf4d1f952757ec3e634
Reviewed-on: https://gerrit.chromium.org/gerrit/28348
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
34b5d86d057d450325dd06d35ae182ac6da306e4 23-Jul-2012 Jay Srinivasan <jaysri@chromium.org> Use a local UpdateFirstSeenAt timestamp instead of UpdatePublishedOn

The existing implementation that used the UpdatePublishedOn doesn't work
well with other AU enterprise policies such as stop AU, target version,
etc. This change will help all those scenarios to work and will make
the co-existence of policies more intuitive for the enterprise admin.

Basically, these scenarios bring out a flaw in the assumption I had
made earlier. i.e. we had assumed that if an update was pushed 5 months
ago, we never have to scatter that because most machines would have
been picked up the update by then. With the other AU policies like
stop AU or version pinning, this assumption is not true and scattering
is still relevant in these cases.

This new UpdateFirstSeenAt timestamp is the first time a Chrome device
hears of an update from Omaha that's eligble to be applied to the device
based on all policies except scattering. It'll use this timestamp instead
of the UpdatePublishedOn from the rule (which is no longer needed) and
everything else remains the same. This UpdateFirstSeenAt value will
also be persisted so that the waiting period can be satisfied over reboots
when an update is not ready to be applied yet.

This timestamp will be cleared (only) after an update has been successfully
applied and the device is waiting to be rebooted.

Also contains a minor fix for avoiding the crash mentioned in 32797.

BUG=chromium-os:32280
TEST=Added new unit tests, tested on ZGB.
Change-Id: I1d7845a11f7eb7fc0a019018c8c4b9a3c68ee2cd
Reviewed-on: https://gerrit.chromium.org/gerrit/28100
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
581c2ea71d31a8a1fd4aef49c923bf2b996f35d8 19-Jul-2012 Gilad Arnold <garnold@chromium.org> Modify a FilesystemCopierAction unit test.

* Reverse previous changes, which proved impotent in solving an
intermittent test failure.

* Disabled the failing test.

BUG=chromium-os:31082
TEST=Builds and runs unit tests

Change-Id: Ib7b3552e98ca40b6141688e2dea5a1407db12b2a
Reviewed-on: https://gerrit.chromium.org/gerrit/27910
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
7c04e76f469b30b0086201baba94db1c15a028e5 23-May-2012 Gilad Arnold <garnold@chromium.org> Enable test mode updates.

* Uses the GPIO module to deduce whether a current update session needs
to be treated as a controlled test, which allows a few relaxations.

* LibcurlHttpFetcher is extended to relax some of its security lock down
provisions.

* Fix: a test mode flag remains persistent throughout an update attempt,
so that it can be delegated to the various HttpFetcher instances used
in the same attempt.

BUG=chromium-os:25397
TEST=Builds and unittests; automated test script works w/ servo
connected Alex

Change-Id: I8a29d1a21a0632912c10f01f69a26d9c659472fd
Reviewed-on: https://gerrit.chromium.org/gerrit/25128
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
6dbbd397f5e1fea080a16ddaac41f9d92da159d4 11-Jul-2012 Gilad Arnold <garnold@chromium.org> Diagnose/eliminate FilesystemCopierAction unit test failure.

* Added a retry count for failed write operations: for the particular
failure at hand (an EIO return value on the last write call), we would
attempt to "rewrite" the buffer up to a given number of times. This
will tell us whether the error we're getting is transient or
persistent. This mechanism will try to reposition the output stream to
where it last succeeded, and re-mark buffer as full. The retry count
is zero for all instances of FilesystemCopierAction with the exception
of the instance used in RunAsRootSimpleTest (where it's set to 3).

Note, however, that we will keep failing to operation to ensure that
the unit tests are failing (and logs can be inspected). If this proves
to be a transient error that can be worked around via retry, we'll
probably leave this mechanism in place (but will stop failing the
action).

* Added a debug message that prints the number of bytes we're trying to
write when we attempt to write the residual (i.e. last piece of) data.
This is just to be sure that we're passing the correct number.

* Removed the random selection of data to be copied during
RunAsRootSimpleTest. It is obvious by now that only the sizes that are
not divisible by the (unknown but likely a reasonably large exponent
of two) fragment size are failing.

BUG=chromium-os:31082
TEST=Builds and runs unit tests

Change-Id: I3367eee638333686ab24997297d868cee416ff96
Reviewed-on: https://gerrit.chromium.org/gerrit/27094
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
e73acab3a647460ae98da60e2473d287ddf43675 10-Jul-2012 Jay Srinivasan <jaysri@chromium.org> Support in update_engine for the crosh autest "-scheduled" option.

This is needed to enable manual testing of scattering feature on
MP-signed images.

BUG=chromium-os:32289
TEST=update_engine_client works as expected on zgb when passing
autest and autest-scatter to omaha_url.
Change-Id: Ib3d3e70f2e87632b6a61c7e5cd45791210c12c99
Reviewed-on: https://gerrit.chromium.org/gerrit/27005
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
4348879380222dc8c74b0976e527bf3da66ba08f 19-Jun-2012 Jay Srinivasan <jaysri@chromium.org> UpdateEngine-side changes to allow updates over 3G based on device policy.

Some enterprise chromebooks have only 3G and hence they need the ability
to update over 3G if the enterprise policy allows that. This CL adds
the support in update_engine to enable that.

BUG=chromium-os:31099
TEST=Tested E2E on 3G, added unit tests and did regression testing.
CQ-DEPEND=I1a55a392f3dc0f12d917eb45dcf0456b57735514
Change-Id: I121bda35e54fa6c35e002a76db198d13b72b650e
Reviewed-on: https://gerrit.chromium.org/gerrit/25470
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
08fce04e5341c99f308ee7462b1f351f5232eacd 08-Jun-2012 Jay Srinivasan <jaysri@chromium.org> Don't scatter during OOBE or user-initiated update checks.

We need to add logic to disable scattering of downloads if we are in OOBE
or if we're doing a manual update check.

Scheduled checks are already disabled during OOBE, but this extra check
will ensure that any scattering policy (there's a pending work item to get
policy during OOBE) during OOBE will have no effect on the update.

Similarly manual (i.e user-initiated) update checks through
update_engine_client or through Chrome UI should not honor scattering.
That way, this can serve as a simple user-friendly workaround in case
there's any bug in scattering logic that bricks the system by any chance.

BUG=chromeos-31563: Don't scatter during OOBE or manual update checks.
TEST=Updated unit tests. Tested all code paths manually on ZGB and Kaen.
Change-Id: Ib631e560c1f620ca53db79ee59dc66efb27ea83c
Reviewed-on: https://gerrit.chromium.org/gerrit/24564
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
480ddfa079ebd01ed87e495332dec121d9ae781f 02-Jun-2012 Jay Srinivasan <jaysri@chromium.org> Scatter downloads to reduce bandwidth spikes.

Support in update_engine to honor the enterprise policy to scatter the
downloading of ChromeOS automatic updates so that we reduce bandwidth
spikes caused due to simultaneous downloads of updates by a large number
of enterprise devices.

This has no effect on consumer devices.

BUG=chromeos-29615: Implement scattering of downloads in UpdateEngine
TEST=Manually tested all scenarios, Unit tests added for all new code.
CQ-DEPEND=I1f56b5516970d5988eebb2cf8f93f6905823801d
Change-Id: I4a8f4974467a064d723ab13cbd78b1ca3ceff420
Reviewed-on: https://gerrit.chromium.org/gerrit/21574
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
4d740ebe4fd3cef70d415113f427f64ee5e87f7e 15-May-2012 Gilad Arnold <garnold@chromium.org> Revised GPIO module interface + GPIO discovery logic

* The GpioHandler class is no longer a static singleton, rather an
ordinary object with a dynamic guard against multiple instances. This
makes testing/mocking a lot easier and simplifies implementation.

* It uses a basic, mockable udev interface; the module comes with
complete unit testing of the discovery mechanism.

* Corresponding changes to user classes, including UpdateAttempter and
UpdateCheckScheduler.

Note that the implementation of the test mode signaling protocol is
currently a no-op, always returning false, and hence has no effect on
the update process yet. This mechanism will be implemented in a later
CL.

BUG=chromium-os:25397
TEST=Builds and passes unit tests (including new ones)

Change-Id: I2f6254db6799ff5ef8616314890833f6e3269ff6
Reviewed-on: https://gerrit.chromium.org/gerrit/22869
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
56d5aa471205bf2271219252ec94b5f0c986a68b 26-Mar-2012 Jay Srinivasan <jaysri@chromium.org> Report usage of StopAutoUpdate policy in borgmon charts

Omaha already has an event result for reporting UpdateDeferred (9)
which shows up in the borgman charts. In order to use that we should
perform a normal updatecheck without the updatedisabled set to true and
then discard the response with event type UpdateComplete (3) but with
event result UpdateDeferred (9).

BUG=28645: Report StopAutoUpdate enforcement in Borgmon charts for Omaha
TEST=Tested success, error and deferred cases on my zgb.
Change-Id: I27cb4465ea9876b39edaff3b747ada44a4f875d4
Reviewed-on: https://gerrit.chromium.org/gerrit/19112
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
0a70874c61118a2b276edc731ad890c6826be2be 20-Mar-2012 Jay Srinivasan <jaysri@chromium.org> Implement the update engine portion for new enterprise policies.

Enterprises need the ability to stop the auto updates and pin clients
to a given target version. This CL adds support for these features in
the update_engine.

BUG=27307: Implement StopAutoUpdate based on enterprise policy
TEST=Added new unit tests, manually tested all cases on ZGB.
CQ-DEPEND=I523c3f67e0cb07fd24744dc0a30382ff2fe2128a
Change-Id: Id576401afc6d2c93f0e9ece7c6c0ddcf4b1bc00d
Reviewed-on: https://gerrit.chromium.org/gerrit/17867
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
/system/update_engine/update_attempter.cc
ed74731163f5d6b7586ae302a0b0948302af9753 16-Mar-2012 Gilad Arnold <garnold@chromium.org> Temporary hack to allow evaluation of automated test harness with MP images.

* Enable dutflaga/b GPIO export on Alex.

* (Temporary) Use a corp workstation as mock server address.

BUG=chromium-os:25397
TEST=Normal update behavior not affected; test scenario update on
x86-alex works against specified workstation.

Change-Id: If6741749557942d0f9c89cb6146b4f6e2a2cefbf
Reviewed-on: https://gerrit.chromium.org/gerrit/18302
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
/system/update_engine/update_attempter.cc
1ebd813ad19214d0b59ade04005c3b84ae765e42 05-Mar-2012 Gilad Arnold <garnold@chromium.org> GPIO test signal safe fallback + refactoring.

This addresses the problem of spurious GPIO signals indicating a test
scenario whereas in fact this isn't one, which may lead to hosts unable
to get an update (ZGB, Lumpy). This is also a partial fix to a problem
with Stumpy, where such spurious signals are inherent to the board
implementation.

* Safe fallback: a GPIO-signaled test scenario will be ignored other
than on the first time, in both places it is being checked
(UpdateAttempter::Update() and UpdateCheckScheduler::StaticCheck()).
This will ensure that we do not (a) override EULA/OOBE-complete flag
more than once; and (b) we do not attempt to update against a local
test server more than once. This generally covers against spurious
GPIO, as long as a user cannot trigger an update check on
a non-OOBE-complete system (appears to be a safe assumption).

* The retry timeout after failing an update with the test server is
shortened to 1 minute (compared to the default 45 minute). This
substantially increases the chances for a system exhibiting spurious
GPIO signals to get updates.

* Moved the GPIO functionality into a separate module/class. This makes
more sense now that it is being used by more than one class
(UpdateAttempter and UpdateCheckScheduler). The implementation of
GpioHandler has no instance data members and so behaves like
a singleton, but otherwise looks and feels like a normal class.

* Also changing the private test server URL to use an unregistered TCP
port (further reduces the chances of anything responding on the LAN).

* Some minor fixes.

BUG=chromium-os:27077, chromium-os:27109, chromium-os:25397,
chromium-os:27157

TEST=Unittests passed; GPIO reading + fallback work on x86-alex.

Change-Id: Ide1a60a690f1263efd47872360470347e56eeb45
Reviewed-on: https://gerrit.chromium.org/gerrit/17344
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
f960911404a24cfce594ca452a0256fd44657424 29-Feb-2012 Gilad Arnold <garnold@chromium.org> A file descriptor closer that uses HANDLE_EINTR.

- A new flavor of ScopedFdCloser which wraps close() with HANDLE_EINTR,
which will retry closing the file descriptor if the last close attempt
was interrupted by EINTR. This appears to be a recommended practice
per POSIX documentation.

- Both ScopedFdCloser and ScopedEintrSafeFdCloser ensure a successful
close() prior to resetting the file descriptor.

- Better use of HANDLE_EINTR elsewhere: just realized that this macro
returns the value of the last evaluation of its argument.

BUG=chromium-os:25397
TEST=Image builds properly; GPIO functionality works (x86-alex).

Change-Id: I3425bb580499c7138cd31917011662d33ffab8a6
Reviewed-on: https://gerrit.chromium.org/gerrit/17079
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
28e2f39b85e0a4d0d093123562e70d8906c03bef 09-Feb-2012 Gilad Arnold <garnold@chromium.org> Added GPIO support for update engine automated test.

New functionality in update engine for discovering and reading the
dut_flaga/b GPIOs; we use the dut_flaga value as trigger for using
a different update server URL.

Note: in the future, we will migrate all GPIO functionality outside of
update engine, into its own dedicated package.

CQ-DEPEND=I82cdd28a87f5227e63586810534b92922d43ae52
BUG=chromium-os:25397
TEST=GPIOs were discovered and read on x86-alex, w/ and w/o servo.

Change-Id: Ice3a7ee9669c0916956b492c9524e4b5808d6fb3
Reviewed-on: https://gerrit.chromium.org/gerrit/16554
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
e4ad2508de4d69d7a90d3ce441efe2c82c55bd1d 30-Dec-2011 Gilad Arnold <garnold@chromium.org> AU multi-range fetcher requests properly closed ranges when their length
is known.

* HttpFetcher allows to set the length of data to be fetched.
LibcurlHttpFetcher uses this value in applying the appropriate libcurl
option (CURLOPT_RANGE). MultiHttpFetcher sets the desired payload
length in the underlying fetcher accordingly.

* Improved functionality of test_http_server: (a) correctly parses
closed range intervals; (b) generalized response header generation;
(c) unified and generalized get handling for both stable and flaky
cases.

* Small scale refactoring, improved logging and readability.

BUG=chromium-os:24666
TEST=unit tests

Change-Id: I1727710ca747088c67a68305f355da683b07b6a3
Reviewed-on: https://gerrit.chromium.org/gerrit/13594
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
9bedeb51f80c9547269eef6c2ec09596033bb818 18-Nov-2011 Gilad Arnold <garnold@chromium.org> Fetcher tries all proxies when a secondary chunk download error occurs.

This is a fix to issue 18143:

* New test cases for asserting the desired behavior: if a transfer of
a secondary chunk within a multi-chunk fetch fails, then the fetcher
needs to retry with other available proxies; it will only fail when no
additional proxies are available. The tests ensure both success (one
of the proxies eventually succeeds) and failure (all proxies fail)
cases.

* Small fix to LibcurlHttpFetcher to retry with other proxies upon
failure (error value) of a secondary chunk.

Other changes applied in the course of this fix:

* Massive refactoring of http_fetcher_unittest: substituted template
specialization in typed test setup with proper subclassing, resulting
in a safer and more maintainable infrastructure; extended URLs to
include all (most) parameters pertaining to test workload, such as
download size, flakiness, etc.

* Respective changes to test_http_server: it is now much more
independent of particular kind of tests, and more easily
parametrizable. Also, generalized several internal methods for better
readability and extensibility, such as writing of arbitrary payloads,
parsing headers,

* Migrated common definitions into http_common.{h,cc} (universal
HTTP-related stuff) and http_fetcher_unittest.h (shared definitions
pertaining to unit tests).

* Extended direct proxy resolver to generate a list of (non-) proxies,
so we can unit test proxy failure. Also, better logging to improve
testability.

* Some renaming of classes for better consistency.

BUG=chromium-os:18143
TEST=unit tests

Change-Id: Ib90b53394d7e47184d9953df8fc80348921e8af0
Reviewed-on: https://gerrit.chromium.org/gerrit/12092
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
/system/update_engine/update_attempter.cc
7ed561bfe6019ed4b988142e97505d7c643e119c 04-Oct-2011 Darin Petkov <petkov@chromium.org> AU: Remove support for old-style updates.

This code is basically untested, unused and a security risk. So, remove...

BUG=chromium-os:12542
TEST=unit tests, tested VM update

Change-Id: Ibed0582b09497acef9debdf88658cddc2b5cecce
Reviewed-on: http://gerrit.chromium.org/gerrit/8728
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Commit-Ready: Darin Petkov <petkov@chromium.org>
/system/update_engine/update_attempter.cc
7f9aea2748370b0a26e1d5c36db7d8bbf3ba1245 12-Sep-2011 Bruno Rocha <bpontes@google.com> Add UMA metrics for detecting and reporting update certificate changes.

LibcurlHttpFetcher checks if the update server certificate has changed
since last update, and stores an eventual report in prefs. UpdateCheckScheduler
submits to UMA reports from the previous update.

BUG=chromium-os:19842
TEST=Included unittest for the new class and tested locally on an Alex device,
since we need to verify against the actual server certificates.

Change-Id: I5bee5d648982cd7618db09b67d5bff377eaa1fc1
Reviewed-on: http://gerrit.chromium.org/gerrit/7565
Reviewed-by: Bruno Pontes Soares Rocha <bpontes@chromium.org>
Tested-by: Bruno Pontes Soares Rocha <bpontes@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
/system/update_engine/update_attempter.cc
771e1bd1ed58ef791ccc41a2b9d96e257403abec 30-Aug-2011 Andrew de los Reyes <adlr@chromium.org> Make public key verification check binding.

Until now, we've just warned on failure. This CL makes the update fail
if the check fails.

BUG=chromium-os:19872
TEST=unittests; tested on device

Change-Id: I485b2548849f46d2b802c478736671bb44a85aab
Reviewed-on: http://gerrit.chromium.org/gerrit/6998
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Andrew de los Reyes <adlr@chromium.org>
/system/update_engine/update_attempter.cc
7fbbe8a9e57ec52f7bc597d0cb607036300ac54c 01-Aug-2011 Patrick Dubroy <dubroy@chromium.org> Update engine should use the release channel policy if it exists.

The release channel (aka update track) can be specified by a device
policy. When this is the case, the update engine should use the
value specified by the policy instead of the value specified in
/etc/lsb-release.

BUG=chromium-os:17015
TEST=Added two new tests:
- Added test that OmahaRequestParams uses the release channel passed
in to it when the value is valid, and otherwise uses /etc/lsb-release.
- Added test that the update engine correctly picks up the release
channel that's specified by the policy.

Change-Id: I2fe03712220bb3286476b12cd1f1b330ad006d7c
Reviewed-on: http://gerrit.chromium.org/gerrit/5072
Tested-by: Patrick Dubroy <dubroy@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
/system/update_engine/update_attempter.cc
18c7bce69dc040dc8e9c2a1dc207f7447fb06e84 16-Jun-2011 Darin Petkov <petkov@chromium.org> AU: Set error code bit 30 for error events on resumed updates.

BUG=chromium-os:16006
TEST=unit tests, tested on device

Change-Id: I94938529aa2cf2d85396a632d03624c71528b7f9
Reviewed-on: http://gerrit.chromium.org/gerrit/2786
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
/system/update_engine/update_attempter.cc
fb2f4614a4492f954c2e53a2797ef6be66e99b81 10-Jun-2011 Andrew de los Reyes <adlr@chromium.org> AU: Only retry HTTP connect failures when updating in background.

Interactive updates (those that come from dbus, rather than a timer)
will have the check for updates retry on failed HTTP connections only
once. We will still retry on connect failures for background updates 3
times, which is important for the case where a user has just woken
from sleep.

BUG=chromium-os:16255
TEST=unittests, on device test

Change-Id: I9cb0f854856846850cfdeaa4ffbe921d76eee15b
Reviewed-on: http://gerrit.chromium.org/gerrit/2449
Tested-by: Andrew de los Reyes <adlr@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
/system/update_engine/update_attempter.cc
d88a85764b608141adc54f49fdba824919b7d88c 26-May-2011 Thieu Le <thieule@chromium.org> Change PingOmaha() to run synchronously to avoid race conditions.

BUG=chromium-os:15714
TEST=Unit tests, manually applied and update and wait for Omaha pings

Change-Id: I56e5c68ec57bc18a99232a2356f0f67ee5ac7310
Reviewed-on: http://gerrit.chromium.org/gerrit/1633
Reviewed-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Tested-by: Thieu Le <thieule@chromium.org>
/system/update_engine/update_attempter.cc
61635a95b9e6c62e31ed61fb5738c55bb5c92048 19-May-2011 Darin Petkov <petkov@chromium.org> AU: Announce the update engine status on startup.

This is to ensure that the system is in a consistent state in case update-engine
crashes.

BUG=chromium-os:15069
TEST=press "Check for update" in Chrome, restart update-engine while downloading
an update, see the status go back to 'up to date' (rather than get stuck in
'Downloading')

Change-Id: I1e89502a9fa134ec3a81e50a9036ce20b46eb9b0
Reviewed-on: http://gerrit.chromium.org/gerrit/1144
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
/system/update_engine/update_attempter.cc
58dd1348495a13a59edf630f54b1d236ee869339 06-May-2011 Darin Petkov <petkov@chromium.org> Call chromeos-setgoodkernel asynchronously.

Currently, the script may take about 40 seconds to run and it used to run
synchronously thus blocking the event loop and making update-engine unresponsive
on D-Bus. This CL makes the call asynchronous -- however, the update process
still waits for the call to complete before it starts.

Also, make sure Omaha pings don't try to go in parallel.

Also, fail postinstall action if we fail to spawn the postinstall script.

BUG=chromium-os:14954
TEST=ran AU in different scenarios

Change-Id: I9af84e30ef075838e6625d74f3e6b72577d8c386
Reviewed-on: http://gerrit.chromium.org/gerrit/449
Reviewed-by: Thieu Le <thieule@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Darin Petkov <petkov@chromium.org>
/system/update_engine/update_attempter.cc
c1d5c93ddf56e193fd501e5f8fc3fc45efdc560f 21-Apr-2011 Andrew de los Reyes <adlr@chromium.org> AU: Handle firmware update failure when booted from FW slot B.

The firmware updater will fail if we are booted into FW slot B and we
try to update firmware. We shouldn't treat this like a usual update
failure because trying again won't help until we reboot. Thus, with
this CL, we detect this case and request a reboot from the
user. Technically this request is a lie, b/c we are reusing the reboot
request mechanism which tells the user an update has been applied and
thus must be rebooted. We accept this fib since this situation is very
rare: use would have to have 2 FW update updates in a row w/o any
extra boots between.

Also, fix error code in subprocess.

Also, remove execute permissions on a bunch of source files.

BUG=chromium-os:14343
TEST=unittests, tested updates on machine that success, fail, have FW B failure

Review URL: http://codereview.chromium.org/6880077

Change-Id: I2509c6e1c9c9da3ff1ea27da4861c4850bd4d000
/system/update_engine/update_attempter.cc
116fda3221ff3df037ea1feb271883c87644c839 19-Apr-2011 Thieu Le <thieule@chromium.org> Add support to update_engine to poke Omaha after an update has been applied
successfully and is awaiting reboot to help ensure the number of actives
remains accurate.

BUG=chromium-os:12026
TEST=Manual test, unit tests

Change-Id: Ie3397264b0b34e8d423fb9748970f7d330122180

Review URL: http://codereview.chromium.org/6836025
/system/update_engine/update_attempter.cc
6dbf30a3c752c402f5a308de3b59d4c860de2d58 19-Apr-2011 Andrew de los Reyes <adlr@chromium.org> AU: Always run setgoodkernel, unless we abort within 45 seconds of launch.

This addresses a bug in the updater. Previously, we ran setgoodkernel
within 45 seconds of boot, unless an update was running or completed
successfully (thus requiring us to reboot). This change keeps the
indended behavior of running within 45 seconds of boot, but prevents
updating from interfering.

BUG=chromium-os:14280
TEST=tested on device

Change-Id: Ib6a8978835a68440d671785577abccdc5856ef1d

Review URL: http://codereview.chromium.org/6881037
/system/update_engine/update_attempter.cc
21816e18f2aa38e84206cfff7008748b93b61a13 07-Apr-2011 Andrew de los Reyes <adlr@chromium.org> AU: Detect and report public key verify failures, but continue updating.

Make a new OmahaEvent (Type: 14 (kTypeUpdateDownloadFinished), Result:
0 (kResultError), ErrorCode: 18
(kActionCodeDownloadPayloadPubKeyVerificationError)). This event is
sent if we have a successful download that fails public key
verification. Currently this is a non-fatal failure, but we plan to
make it fatal in future clients.

BUG=chromium-os:13341
TEST=unittests; 3 on device tests: w/o public key on device, w/ pub
key and matching download, w/ pub key and non-matching download

Change-Id: Ib6589c78449c2dfcbffa4c85ab679f7fe844584b

Review URL: http://codereview.chromium.org/6792065
/system/update_engine/update_attempter.cc
e6ef2f8bb08facf8939adc9a9e8c48912ffe0a3e 08-Mar-2011 Darin Petkov <petkov@chromium.org> Start action processing asynchronously in UpdateAttempter.

This is done so that we unblock the event loop on dbus calls.

BUG=chromium-os:12758
TEST=unit tests, tested updating the device

Change-Id: I38d9869afb392264a020fc6c653a20622fd38ada

Review URL: http://codereview.chromium.org/6624082
/system/update_engine/update_attempter.cc
000d895da247697f4e4e0c67a3a847f71fca8eb9 03-Mar-2011 Andrew de los Reyes <adlr@chromium.org> AU: Full proxy support

This CL Introduces a new proxy resolver that queries Chrome browser
for all URLs. This means the updater now works with Proxy
AutoConfiguration (PAC) files and automatic proxy detection.

BUG=chromium-os:9478
TEST=performed update, unittests

Review URL: http://codereview.chromium.org/6594025

Change-Id: I2c169aec06109e3eabc4011e0b536685dfd13f79
/system/update_engine/update_attempter.cc
abc7bc0f5d88f110b463191bb8384f95d3c4230a 23-Feb-2011 Darin Petkov <petkov@chromium.org> If a public key is present, disallow old style full payloads.

This is necessary to ensure that if a public key is present the payload is
signed and the signature passes verification.

BUG=chromium-os:11760
TEST=unit tests, tested on device

Change-Id: I6af61ead0e918c0b971dbcfeabcab3be03e6eb97

Review URL: http://codereview.chromium.org/6574009
/system/update_engine/update_attempter.cc
2008e4c384b3f88f707658f1f1b9d44d35afef35 12-Jan-2011 Andrew de los Reyes <adlr@chromium.org> AU: Reduce instances of signalling the crash reporter.

We recently started notifying the crash reporter whenever we attempted
to report an error code to the update server. We now throttle that
back a little bit: we only notify for official builds when we were
successful in reporting the error to the update server.

TEST=unittest; tested on device
BUG=10805

Review URL: http://codereview.chromium.org/6154003

Change-Id: Iaff1d5a0b600663796e63ad308f408c57d6444da
/system/update_engine/update_attempter.cc
bffc6ba64350289e0c940d8e7d47e1f4069506c7 07-Jan-2011 Andrew de los Reyes <adlr@chromium.org> AU: When reporting error to Omaha, also notify crash reporter

TEST=tested on device: made sure error triggered it, non error didn't
trigger it.
BUG=10739

Review URL: http://codereview.chromium.org/6100006

Change-Id: Ifc742916c15694e23ccb3b0c48b9ecacd44a2fd9
/system/update_engine/update_attempter.cc
95508da905b279a6b91aadfc7c4c72f57a5fa610 05-Jan-2011 Darin Petkov <petkov@chromium.org> AU: Send a previous version event after reboot following an update.

The previous version event is sent along with the first update check. This is
best effort -- if the update check doesn't reach the server, the event is lost.

BUG=9198
TEST=unit tests, tested on device

Change-Id: I5ceb7c8e99ae54eb331f6ac58b8977d2a111461c

Review URL: http://codereview.chromium.org/5993007
/system/update_engine/update_attempter.cc
819fef2e0fa08984cf31e848e704442c500ea4f9 17-Dec-2010 Andrew de los Reyes <adlr@chromium.org> AU: MultiHttpFetcher cleanup/rewrite

This is the first of many CLs to cleanup/refactor/unfork the
HttpFetcher classes.

This CL changes MultiHttpFetcher to MultiRangeHTTPFetcher, makes it
work with a single base fetcher, and un-templatizes it.

Also, fix a (new?) bug in SConstruct w/ setting CCFLAGS.

TEST=unittests, tested an interrupted/resumed update on device.
BUG=10395

Review URL: http://codereview.chromium.org/5835004

Change-Id: I8422358a6d425233987dd799c5ee7c87135d85fd
/system/update_engine/update_attempter.cc
3aefa8634c9e9f31b9fdae5a57444c70c2f03928 07-Dec-2010 Darin Petkov <petkov@chromium.org> AU: Split applied update verification into a separate step.

Use instances of FilesystemCopierAction to do applied update verification. This
speeds it up slightly because asynchronous reads happen in parallel with hash
calculation but, more importantly, makes update_engine be responsive to D-Bus
during that step.

BUG=9140
TEST=unit tests, tested on device

Change-Id: I3ec9445de5e8258a63433a61f1a476aef4434f6c

Review URL: http://codereview.chromium.org/5516009
/system/update_engine/update_attempter.cc
5d0783d4a9dc230aebdf89923d31b51fe1def5f1 30-Nov-2010 Andrew de los Reyes <adlr@chromium.org> AU: Always retry on failed connections, even manual checks.

This is a temporary workaround for a bug discovered w/ httpdate and
the oobe.

BUG=9736
TEST=unittests

Change-Id: Ic7bbc867be0298d01686a9ea56ce9b012def5f7b

Review URL: http://codereview.chromium.org/5395004
/system/update_engine/update_attempter.cc
a092955cdf763260563a774f6a68e1bfb38c5a8b 29-Nov-2010 Darin Petkov <petkov@chromium.org> AU: Retry up to 3 times 30 seconds apart on HTTP response code 0.

This is a temporary way to avoid failing to do an update check on resume by
allowing at least 1.5 minutes for the network to go online.

BUG=9705
TEST=tested on device through suspend/resume; unit tests

Change-Id: I291a1c31ce87c17d5dce0e30488d454d7690ddbc

Review URL: http://codereview.chromium.org/5260004
/system/update_engine/update_attempter.cc
4516810fe41a39c0c55d2095679898787259ae38 22-Nov-2010 Andrew de los Reyes <adlr@chromium.org> AU: Manual proxy support

Utilize the ChromeProxyResolver to resolve proxies in our network
requests. This means the following changes:

- HttpFetcher classes take a ProxyResolver* in their ctor. Also, a few
useful functions in HttpFetcher to allow subclasses to iterate
through the proxies.

- LibcurlHttpFetcher support for using the ProxyResolver. It will
attempt to use each proxy in the order specified. If any data comes
in from any proxy, it won't continue down the list and will continue
to use that proxy for its lifetime.

- UpdateAttempter can choose, for a given update session, whether or
not to use the ChromeProxyResolver or DirectProxyResolver. For now,
the logic is: for automatic checks, 80% of the time use
ChromeProxyResolver, 20% DirectProxyResolver. For manual checks, the
first 19 manual checks in a row use Chrome, then once it uses
Direct, then starts over again. The idea is that the updater doesn't
necessarily trust Chrome, so some requests should skip it. If a
manual check is performed, the user likely wants her proxy settings
honored, so use them, but don't allow frequent manual checks to
starve out usage of the DirectProxyResolver.

- Updates to tests

BUG=3167
TEST=unittests, tested on device

Review URL: http://codereview.chromium.org/5205002

Change-Id: Iee0f589e5b28d4b804afe1f5b6729ba066d48d62
/system/update_engine/update_attempter.cc
6d5dbf6458d55db480ebaa1b6fc3152631f722ad 09-Nov-2010 Darin Petkov <petkov@chromium.org> AU: Remove obsolete postinst --postcommit call.

BUG=6251
TEST=unit test, tested update on device

Change-Id: Ib44b4698cab5fa1f2d0b5afd04dca500c8dbe84c

Review URL: http://codereview.chromium.org/4679003
/system/update_engine/update_attempter.cc
d34a4211059ad2687d605939c4bc42daf6e92940 09-Nov-2010 Darin Petkov <petkov@chromium.org> AU: Remove obsolete SetBootableFlagAction.

BUG=6251
TEST=unit tests, tested on device

Change-Id: If1b28d47287abeb0a507d77aa3790fdf39d6513a

Review URL: http://codereview.chromium.org/4719002
/system/update_engine/update_attempter.cc
b00bccc9b93e268416348b9be16d71105311c111 26-Oct-2010 Darin Petkov <petkov@chromium.org> AU: Send UPDATE_AVAILABLE status.

We'll need a new status value to mean that an update is available but it's not
being applied. libcros/Chrome/OOBE currently assume that UPDATE_AVAILABLE will
transition to DOWNLOADING.

BUG=8155
TEST=unit test; tested on the device -- right after checking for updates the
UI transitions to "System update available..." which is incrementally better.

Change-Id: I59fff4a64a8947d8866b57bc22d3179ecfdb0140

Review URL: http://codereview.chromium.org/4171003
/system/update_engine/update_attempter.cc
f622ef70e9f90367a3b7224b1dbc10fc366f3416 26-Oct-2010 Darin Petkov <petkov@chromium.org> AU: Nice for 2 hours, then normal priority.

The intent is to improve system responsiveness during an update.

BUG=8182
TEST=unit tests; tested on device while watching video and having
two gmail tabs open -- update completed in about 10 minutes.

Change-Id: I2a04a136cedd703260aa53e24d9358bdbbe007fa

Review URL: http://codereview.chromium.org/4191002
/system/update_engine/update_attempter.cc
b21ce5dabf502906e21fef4066ebe141c9ba4b49 22-Oct-2010 Darin Petkov <petkov@chromium.org> AU: Don't request data ranges beyond the end of the payload.

This avoids 416 HTTP response error codes from the server. Note that even
without this change update would eventually succeed due to more than 10 resume
failures (so the safety net actually worked).

BUG=8017
TEST=unit tests; tested on device by first reproducing the issue by
interrupting an update during the finalizing step and then getting 416,
then verified the patch resumes the update. Also, verified updates
interrupted in the middle of the download resume correctly.

Change-Id: Iede50a8f8a9d6c000cfeb03308e9ea4f3db74e1b

Review URL: http://codereview.chromium.org/3962005
/system/update_engine/update_attempter.cc
2dd0109675fac379289a9d092fa4a6f6e05e0038 09-Oct-2010 Darin Petkov <petkov@chromium.org> AU: Verify that the applied delta update matches the server-sent hashes.

Also, don't try to resume any delta update that fails for any reason
other than download transfer errors.

BUG=7348
TEST=unit tests, gmerged on device

Change-Id: Ice464b8d421256717d7909fd5fa46d762bd48952

Review URL: http://codereview.chromium.org/3599025
/system/update_engine/update_attempter.cc
9b23057b7f9ad6c366d92a59fcffcc87375bae08 08-Oct-2010 Darin Petkov <petkov@chromium.org> AU: Resume interrupted update attempts.

BUG=7390,7520
TEST=unit tests

Change-Id: I9baf72aa444dd855409f865f03fb665e91f8d03d

Review URL: http://codereview.chromium.org/3620013
/system/update_engine/update_attempter.cc
73058b421f91e04cc605c2a113e0010009a63594 07-Oct-2010 Darin Petkov <petkov@chromium.org> AU: Start checkpointing update progress.

Checkpoint the manifest metadata size and the update
check response hash in the preference store. Also checkpoint
the next operation and data offset.
Add methods for getting/setting hash context.

BUG=7390,7394
TEST=unit tests

Change-Id: I25291bf598ac9b0f1033e11cfe59df45b1f6eeab

Review URL: http://codereview.chromium.org/3521016
/system/update_engine/update_attempter.cc
362757765e7697dd93e8de05fa0a59f29242eb89 01-Oct-2010 Darin Petkov <petkov@chromium.org> AU: Fall back to full updates after a number of failed delta update attempts.

Count each failed delta update attempt. Keep the count in persistent storage. If
the count exceeds a threshold (3), disable delta updates by setting delta_okay
to false in the update check request.

Once this CL is in, we have to ensure that we have a full update payload
available on the update server for each version otherwise we may orphan clients.

BUG=7221
TEST=unit tests, gmerged on device and tested with a mod'ed dev server

Change-Id: I7f7fa73f652f12f22cc8604dad6a26c802b8582d

Review URL: http://codereview.chromium.org/3617002
/system/update_engine/update_attempter.cc
cd1666f5c1be2745197046a55b2fdde7b6045604 23-Sep-2010 Darin Petkov <petkov@chromium.org> AU: move AU completed marker from /tmp to /var/run since /var/run is root-only.

BUG=6578
TEST=unit tests, gmerged on device, updated, restarted update engine and
checked status

Change-Id: If703b66f1bf6efa13f25225d3c5868bc3dd190b7

Review URL: http://codereview.chromium.org/3404015
/system/update_engine/update_attempter.cc
85ced136af57dbfa442e163b430d3c7a3c0a94f5 01-Sep-2010 Darin Petkov <petkov@chromium.org> AU: Implement server-dictated poll interval.

The server will need to include a PollInterval XML attribute in its
update check response. The requested interval is in seconds.

BUG=5984
TEST=unit tests, gmerged on device and tested with a modified dev server

Change-Id: I89d13f9f85d93bc141b74ae677cca813e3364fb5

Review URL: http://codereview.chromium.org/3275006
/system/update_engine/update_attempter.cc
f42cc1c604fe5b0be29847a24f9bd5acf42ba394 01-Sep-2010 Darin Petkov <petkov@chromium.org> AU: Start an UpdateAttempter unit test suite.

This increases the UpdateAttmpter line coverage to almost 40%. More is needed
but this is a good starting point / checkpoint. Also some UpdateCheckScheduler
unit test cleanup.

BUG=6243
TEST=unit tests, gmerge on device

Change-Id: I39c80de3f18095c4a28cb36ab868bed6d7073824

Review URL: http://codereview.chromium.org/3259011
/system/update_engine/update_attempter.cc
1023a6029771fb8dea867e14193df8e58a59a662 30-Aug-2010 Darin Petkov <petkov@chromium.org> AU: Implement exponential back off for 500 and 503 HTTP response codes.

Also refactors the automatic update checks into a separate
scheduler class and adds unit tests for them.

update_check_scheduler.cc 59 / 59: 100.0%
update_check_scheduler.h 1 / 1: 100.0%

Note: because the unit tests for this CL use the
UpdateAttempter class, the CL brings in several untested
modules into the test report reducing the overall test
coverage to ~82%.

BUG=2394
TEST=unit tests, gmerged on device and inspected logs

Change-Id: I078b1727b5338f6fc34e51f5e04a375518d63cef

Review URL: http://codereview.chromium.org/3215006
/system/update_engine/update_attempter.cc
1cd885fe5569952adb97c23886b8d12b68257ba1 26-Aug-2010 Darin Petkov <petkov@chromium.org> AU: Simplify the automatic update check code a little.

Moves automatic update checks into the UpdateAttempter class.
This is in preparation for resolving 2394.

BUG=2394
TEST=unit tests, gmerged on device

Change-Id: I66ddf860cc7e19334187dc7f1892ead53fc936c6

Review URL: http://codereview.chromium.org/3167039
/system/update_engine/update_attempter.cc
af183050a13b6851d7e385bb697ae290ccdaf880 23-Aug-2010 Darin Petkov <petkov@chromium.org> AU: Throttle notifications based on progress; still notify if slow progress.

This switches time based notifications to monotonic TimeTicks to avoid
system clock jump issues.

BUG=5885
TEST=unit tests, gmerged on device and watched notifications

Change-Id: Ia19a7bd9c4dc206f0d793a83eff64e0562af0803

Review URL: http://codereview.chromium.org/3187012
/system/update_engine/update_attempter.cc
9d911fa4ed05cb51319636a4b6ce94b0260156ae 19-Aug-2010 Darin Petkov <petkov@chromium.org> AU: Update status to DOWNLOADING only after receiving some bytes from server.

This ensures that users don't see an update download notification until
after a download has successfully started.

Also, added some DownloadActionDelegate unit tests.

BUG=5822
TEST=unit tests, gmerged to device, made sure updates happened and
notifications received

Change-Id: I96912dcd98a53e9bd7eecc63dab704f959a06441

Review URL: http://codereview.chromium.org/3131022
/system/update_engine/update_attempter.cc
c6c135c3e555a856b762e4f383d1d2768363589d 11-Aug-2010 Darin Petkov <petkov@chromium.org> Nice automatic updates up to a point, then renice if necessary.

BUG=5488
TEST=unit tests, gmerged on device and completed an update
successfully with two 100% CPU "nice -n -20" processes
running in the background.

Review URL: http://codereview.chromium.org/3053049
/system/update_engine/update_attempter.cc
1cbd78ffe68039a5781c3434816e03e64033dc0b 29-Jul-2010 Darin Petkov <petkov@chromium.org> Don't send machine and user ID to Omaha anymore. Send a/r pings instead.

This avoids sending a unique ID in order to track active user counts.
Note that this CL doesn't remove the machine/user/Omaha ID/file from
the params object -- it just makes them unused/obsolete. Removal will
be done in a subsequent CL in an effort to make this CL smaller.

BUG=1439
TEST=unit tests, x86-generic, arm-generic, gmerged and inspected logs

Review URL: http://codereview.chromium.org/2856070
/system/update_engine/update_attempter.cc
296889c68c92b04d307035c5803681f8d2c8f9d3 24-Jul-2010 Darin Petkov <petkov@chromium.org> AU: Provide a reboot_if_needed D-Bus API.

This will reboot if the current state is UPDATED_REBOOT_NEEDED.
Also add -reboot option to the update_engine_client.

BUG=4250
TEST=unit tests,gmerged on device and tried reboot requests

Review URL: http://codereview.chromium.org/3034026
/system/update_engine/update_attempter.cc
5a7f565a542196f24eb87ddac96508f8a84e3329 23-Jul-2010 Darin Petkov <petkov@chromium.org> Add support to update_engine_client for -app_version and -omaha_url.

These options prevent auto-detection of these parameters.
Note that this CL makes the check_for_update DBus method obsolete from
the client's point of view.

BUG=4593
TEST=unit tests, gmerged on device and tried the client with different options.

Review URL: http://codereview.chromium.org/3048008
/system/update_engine/update_attempter.cc
777dbfae01be95ac66f385cd96dc6e4b421fefe5 21-Jul-2010 Darin Petkov <petkov@chromium.org> Narrow down to one generic error per action.

This way if we miss a spot for returning a more specific error code,
we'll at least know which action failed.

BUG=560
TEST=unit tests, gmerged and confirmed that the PostinstallRunner action
still fails...

Review URL: http://codereview.chromium.org/2819059
/system/update_engine/update_attempter.cc
09f96c384e1e5f4d3a1229babd9a1b204daf4927 20-Jul-2010 Darin Petkov <petkov@chromium.org> AU: A basic framework for sending error events when update attempt fails.

Currently, only a generic kTypeUpdateComplete/kResultError/kActionCodeError
will be sent.

BUG=560
TEST=unit test, gmerged, forced updates, inspected logs.

Review URL: http://codereview.chromium.org/3042007
/system/update_engine/update_attempter.cc
9d65b7b9249124a433b9a018a1952435f7f75c4d 20-Jul-2010 Darin Petkov <petkov@chromium.org> Measure and send update time to UMA.

BUG=4852
TEST=unit tests, gmerged, force update, looked at about:histograms.

Review URL: http://codereview.chromium.org/2868061
/system/update_engine/update_attempter.cc
e17f86bae4299882232d3e6858ada68692e80501 20-Jul-2010 Darin Petkov <petkov@chromium.org> Switch OmahaEvent's error_code to ActionExitCode.

Also, emit the errorcode attribute only for non-success events.
Added explicit unit tests for OmahaEvent.

BUG=560
TEST=unit tests, gmerged on device, forced update, looked at logs.

Review URL: http://codereview.chromium.org/3035007
/system/update_engine/update_attempter.cc
c1a8b426be9542bc880923711ca508ea3f84000e 19-Jul-2010 Darin Petkov <petkov@chromium.org> For actions, switch bool success into an exit code.

This way we can signal specific error conditions and then
send appropriate events to Omaha from the UpdateAttempter.

BUG=560
TEST=unit tests, gmerged and looked at logs

Review URL: http://codereview.chromium.org/3022008
/system/update_engine/update_attempter.cc
8c2980e8b973a21468c9fece0490cd440afc0660 17-Jul-2010 Darin Petkov <petkov@chromium.org> AU: send success events to Omaha at more points in the update process.

BUG=560
TEST=unit tests, gmerged on device and looked at logs, emerge-arm-generic.

Review URL: http://codereview.chromium.org/3044003
/system/update_engine/update_attempter.cc
a4a8a8ccc2d9e0285728ed247b43f09433e63323 16-Jul-2010 Darin Petkov <petkov@chromium.org> Turn OmahaRequestPrepAction into OmahaRequestDeviceParams.

Pass the params to OmahaRequestAction's ctor. This simplifies a bit
executing as well as testing of OmahaRequestAction and testing of
OmahaRequestDeviceParams. It also allows us to initialize the params
once per update attempt and use them for all OmahaRequestActions.

BUG=560
TEST=unit tests, gmerged on device and forced an update through dev server,
inspected logs.

Review URL: http://codereview.chromium.org/2836053
/system/update_engine/update_attempter.cc
0dc8e9a73fc3179a67a72ab72ceb2bc6540949bf 14-Jul-2010 Darin Petkov <petkov@chromium.org> Initial implementation of sending an install success event to Omaha.

BUG=560
TEST=emerged,ran unit tests

Review URL: http://codereview.chromium.org/2981008
/system/update_engine/update_attempter.cc
6a5b3229b44c1f81ee153829e9b501e547f29926 13-Jul-2010 Darin Petkov <petkov@chromium.org> Rename UpdateCheckAction|Params to OmahaRequestAction|Params.

Also, renamed UpdateCheckResponse to OmahaResponse.

BUG=560
TEST=unit tests, gmerge'd on device.

Review URL: http://codereview.chromium.org/2981007
/system/update_engine/update_attempter.cc
6b78e29f80e98c4ad009c830012682220dc9de3b 11-May-2010 Andrew de los Reyes <adlr@chromium.org> Init: Start Update Engine at startup

Also related AU Fixes:

- daemonize() for upstart

- remember success in updating across runs of the process.

- bug fixes: don't try to update if an update is in progress, clear
actions out in Update Attempter when updating is complete.

BUG=None
TEST=on device testing

Review URL: http://codereview.chromium.org/2055008
/system/update_engine/update_attempter.cc
63b96d74b2ffe5999243ab5c33f588030bcb42ce 10-May-2010 Andrew de los Reyes <adlr@chromium.org> AU: DBus support.

A few changes to support dbus in the Update Engine daemon:

- SConstruct: build marshaller for the dbus signal.

- Update Attempter: respond to dbus calls and broadcast status on dbus
signal.

- Update Engine Client: flag to listen for status updates.

- Also, cleanup outdated code in Omaha Response Handler.

BUG=None
TEST=attached unittests/on device tests

Review URL: http://codereview.chromium.org/2037002
/system/update_engine/update_attempter.cc
f98bff879c8e90840582f6a60a93918465f2d8b9 06-May-2010 Andrew de los Reyes <adlr@chromium.org> AU: Minor fixes to get it to do full update on real device

- Link w/ gtest only for unittests.

- filesystem_copier_action: always send install plan on the output pipe
on success, even if no copy was performed.

- omaha_response_handler: properly choose install partition based on
new GPT partition spec.

- More useful logging to match memento_updater (which update URL is
used, dump of the request/response for the update check).

- Fixed a bug where I wasn't bonding the proper actions together in update_attempter.

BUG=None
TEST=attached unittests/did full update on Eee PC

Review URL: http://codereview.chromium.org/2044001
/system/update_engine/update_attempter.cc
f97144334e945a5ec88970b4b28f4e98ce0bbb80 04-May-2010 Andrew de los Reyes <adlr@chromium.org> AU: Many minor cleanup changes

postinstall: Run postinst twice, once for pre-commit (ie, before we
mark the install partition bootable in the partition table), and
post-commit (for after we do). This behavior is needed for specific
types of firmware update.

download action: flush caches, as we found was necessary in
memento_updater.sh

omaha request prep action: update the names of keys we look for in
lsb-release, also get the AU server url from a file, rather than
hard-code it.

set bootable flag action: GPT support.

also, some misc utility functions.

BUG=None
TEST=attached unittests

Review URL: http://codereview.chromium.org/1881001
/system/update_engine/update_attempter.cc
f9185170a9763e493e77ffdc5b1f057c3bd3b11e 03-May-2010 Andrew de los Reyes <adlr@chromium.org> AU: Update Downloader to support our image formats.

The downloader used to be dumb in the sense that it would pipe output
to either a DirectFileWriter or a DirectFileWriter via a
GzipDecompressingFileWriter, depending on if we were downloading an
update that was compressed or not. Sadly, things have gotten more
complex: we need to download to two partitions (kernel + rootfs), and
we may stream data via a DeltaPerformer (a type of FileWriter) to the
disk. Thus, the Downloader streams to either
1. gzip decompress->split_writer->direct to disk OR
2. delta performer

Other misc changes: Change FilesystemCopierAction to support
optionally copying the kernel partition rather than root partition.

InstallPlan struct: add an entry for destiation kernel partition.

Test Utils: a new ScopedTempFile class

Utils: support for getting the booted kernel partition device.

BUG=None
TEST=attached unittests

Review URL: http://codereview.chromium.org/1694025
/system/update_engine/update_attempter.cc
4e9b9f4d57a0c95fb1b9281077f0eef5fdf5e345 27-Apr-2010 Andrew de los Reyes <adlr@chromium.org> AU: Beginnings of dbus support.

The AU will be a daemon that runs as root. Non-root will communicate
via dbus with the updater to do things such as: query status, request
forced or full updates, etc.

New files for dbus:

UpdateEngine.conf - security configuration
dbus_constants.h - common constants
dbus_service.* - The object exposed over dbus
org.chromium.UpdateEngine.service - the dbus service file
udpate_attempter.* - Refactored this out of main.cc
update_engine_client.cc - Simple command line utility to interact with
Update Engine over dbus. Whereas Update Engine runs as root, this tool
runs as non-root user.

Review URL: http://codereview.chromium.org/1733013
/system/update_engine/update_attempter.cc