History log of /system/update_engine/common/utils.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
2703ef4466066d64d8021904e233b120f38c0272 16-Mar-2017 Sen Jiang <senj@google.com> Store raw payload hash blob in install plan.

We were using a custom sha256 pair in Omaha response, now that Omaha
has a standard hash_sha256 field in package, we should use that instead.

The difference is that hash_sha256 is encoded in hex instead of base64,
but the android payload property is still using base64, to be backward
compatible, we have to keep accepting base64 there, to avoid decoding
and then re-encoding to another encoding, we store the decoded raw hash.

Also removed the hash() related functions in HashCalculator, since it's
rarely used and the caller should encode it in whatever encoding they
want.
Also make use of RawHashOfBytes to simply code in a few places.

Bug: 36252799
Test: update_engine_unittests
Change-Id: Iaa02611b4c9cda3ead5de51e777e8caba6d99d93
(cherry picked from commit f14d51b6823522f6b2eb834f9e14d72c8363a3ad)
/system/update_engine/common/utils.h
f411650403c1d69c15ec0f2ee09b24c6c0ec67b5 23-Mar-2017 Alex Deymo <deymo@google.com> Unmount old postinstall mountpoint from previous runs.

When update_engine crashes, is killed or a developer runs
"stop update_engine" while we are waiting for postinstall to finish
the other partition will continue to be mounted (read-only) on the
/postinsall path. This will prevent to mount the new postinstall
step on top of it due to different SELinux labels when mounted and
unmounted. After failing to run postinstall due to the failed mount
operation we would cleanup the mountpoint, so this situation fixes
itself after one failed update attempt, which can then be resumed
from the very end.

This patch attempts to unmount /postinstall if a filesystem is mounted
there at the time we need to use the mountpoint.

Bug: 36391471
Test: Added unittests.
Change-Id: Idffd7a9319715bfb4ab6a9994c6757d27028d40a
/system/update_engine/common/utils.h
335516c673c0b5db986e3e13bb230618860832ac 28-Nov-2016 Alex Deymo <deymo@google.com> Remove FileWriter from common/utils.h

The FileWriter abstraction is used to write the payload to the
DeltaPerformer. This patch removes its usage from the utils.h and
replaces it with the WriteAll() function already existing in utils.h

Bug: None
Test: Added unittests.

Change-Id: I2d9251565c8978af41ee55f7eae2cede56a72ac2
/system/update_engine/common/utils.h
3295102ed64107f966d4cf8bfe733bb936646630 11-Aug-2016 Alex Deymo <deymo@google.com> Setup a temporary directory for update_engine_sideload.

When running update_engine_sideload from recovery, the default temp
directory (/data/misc/update_engine/tmp) is not available. This
directory is currently used to store a blob when applying a bspatch
from a child process. This patch uses /tmp/update_engine_sideload as
a temporary directory when running update_engine_sideload from recovery.

Bug: 27178350
TEST=`adb sideload` an incremental update.

Change-Id: Iec9f4ec8314e8dae4f6b1e78402dd39ca49c4fa4
/system/update_engine/common/utils.h
5c6bb1d8f89b87e782e26fe74789b6f510704394 27-Jul-2016 Chih-Hung Hsieh <chh@google.com> Fix clang-tidy performance warnings in update_engine.

* Use const reference type for parameters, local variables,
and for-loop index variables to avoid unnecessary copy.
* Convert some for-loops to for-rang loops.

Bug: 30407689
Bug: 30413223
Bug: 30413862
Change-Id: I78996b3f799639fc57ced45e110807625be7dcce
Test: build with WITH_TIDY=1
/system/update_engine/common/utils.h
fb905d9b8d49f8fe41297c7aba2dd0942f1be311 04-Jun-2016 Alex Deymo <deymo@google.com> Implement powerwash on Android.

Powerwash, the name for the equivalent of a factory reset or /data wipe,
can be triggered in Android by writing the desired command to the
recovery command file and rebooting into recovery.

This patch moves the powerwash scheduling/canceling logic to the
HardwareInterface and implements it on Android.

Bug: 28700985
TEST=Called update_engine_client passing POWERWASH=1, BCB is stored up
to offset 832.

Change-Id: If737fd4b9b3e2ed9bce709b3b59f22e9f0a3dc9a
/system/update_engine/common/utils.h
371615b025bdd8106faf65c1ba7439a1236f21bc 14-Apr-2016 Sen Jiang <senj@google.com> Remove utils::MakeTempDirectory().

In favor of base::ScopedTempDir, except for PostinstallRunnerAction,
where the temp directory needs to be removed for every partition.

ScopedDirRemover is also removed because it's no longer used.

Test: ./update_engine_unittests
Test: cros_workon_make update_engine --test
Bug: 26955860

Change-Id: I954e6e892aff0cf9f8434a77408dc3c9eb64c1b5
/system/update_engine/common/utils.h
5fb356cac8a87c62fa83005d99370aa2f8416064 26-Mar-2016 Alex Deymo <deymo@google.com> Mark block device as read-only before mounting.

Mounting a block device as read-only still allows the filesystem to
write to the block device, while keeping the user-facing filesystem
interface "read-only". This behavior will make dm-verity to fail after
reboot if any block is modified during postinstall.

This patch marks the block device as read-only before mounting it, and
marks them read-only or read-write before using them during the update.

Bug: 27859604
TEST=Added logging and deployed an update to brillo, devices are marked RO/RW as needed during a delta update.

Change-Id: I781293cc0b3447dac708470ba6efad4103bf2a58
/system/update_engine/common/utils.h
0d29854cf5bb05a22cf161b50052539aa420a36e 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.

Change-Id: I35f96b92f090219c54cca48d8ab07c54cf8b4ab1
/system/update_engine/common/utils.h
2972608d133dfc8f0422ae143e49b919e6b382c6 10-Mar-2016 Alex Deymo <deymo@google.com> Remove self-crashing logic.

update_engine used to report a crash when something with the omaha
response was really wrong. Nowadays the server side configuration is
automatic and these crashes trigger more on unrelated issues, such as
network problems. These extra crashes generate noise and hide the
volume on other more important crashes.

This patch disables this logic.

Bug: chromium:405375
TEST=m

Change-Id: I17b245c4b2892bf765af63005820e1fc2e7277b0
/system/update_engine/common/utils.h
dcbc0ae6a5c48b40a1bc7d3c2ed62ec2a9fe7748 18-Mar-2016 Sen Jiang <senj@google.com> Remove GetFilesystemSize.

We don't need to get filesystem size now, because the files passed to
delta_generator is already resized properly.

Also moved Is*Filesystem() to delta_diff_utils.

Test: ./update_engine_unittests
Bug: None

Change-Id: I442d69d1820d08c0f3bd63e7f1986fc4b0d6655e
/system/update_engine/common/utils.h
e0d04282910d423ddc950dd38224c001efc41d42 01-Mar-2016 Sen Jiang <senj@google.com> Check if zlib is compatible.

Add a --zlib_fingerprint flag in delta_generator to check if the zlib of
source image is compatible, and only enable IMGDIFF operation if it is.

Test: Added unittest to check /etc/zlib_fingerprint
Bug: 27156099

Change-Id: Ida346a99430c95cdc8a43e1055d6efa08f07ca25
/system/update_engine/common/utils.h
14dbd333439f34c648b9f783ffa656ef565de0cc 02-Mar-2016 Alex Deymo <deymo@google.com> Mount the new system as 'postinstall_file' in postinstall.

When mounting the new filesystem on /postinstall, we need to override
the file attributes from the new system (unknown to the current selinux
policies) with a consistent label that will be used only in the context
of postinstall. This patch passes an extra option to mount(2) in
Brillo and Android to achieve this.

Bug: 27177071
TEST=Deployed a postinstall script with `ls -laZ`, contents show "postinstall_file".

Change-Id: Ia43b45c92e4c4cd340a884818ac00f24a418f9e7
/system/update_engine/common/utils.h
390efedcb7e17587da765b6d682077cb7fa46ee1 18-Feb-2016 Alex Deymo <deymo@google.com> Parse postinstall parameters from the payload metadata.

Payload v2 includes a description of the post-install command it should
run, while in payload v1 we use the default values. This patch mounts
the partition on the new top-level directory called /postinstall that
should already be created.

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

Change-Id: Iaedf3b01e5e1ad57c68bd316b4b6e79cbab35bb6
/system/update_engine/common/utils.h
e88e9feb5a64c1358baeb1c8547e82aa08e1cd83 04-Feb-2016 Alex Deymo <deymo@google.com> Android: Print the error code string from the client.

The update_engine_client needs to translate the numeric ErrorCode to a
string name that can be printed on the output. This patch moves the
ErrorCodeToString() function to a new error_code_utils.{h,cc} pair of
files so it can be included easily from the client binary and uses it
in the Android update_engine_client.

Bug: 25631767
Bug: 25598547
TEST=`update_engine_client --update` prints the error message in a non-Brillo device.

Change-Id: Ib40813924ec676f3e703412de90d389b2596177e
/system/update_engine/common/utils.h
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/common/utils.h
9138ef59467bafa57baf42fbc15a5d1c3fef0586 22-Nov-2015 Alex Deymo <deymo@google.com> Remove unused includes.

These includes are not used anymore.

Bug: 25773375
TEST=emerge-link update_engine; mma

Change-Id: Ib6ab47d64b526e650208420f3355bb7b88beaec8
/system/update_engine/common/utils.h
a2591795edb1a4f4c751347daab16c70daad1274 17-Nov-2015 Alex Deymo <deymo@google.com> Move metrics time helpers to metrics_utils.

The metrics module reports metrics periodically, for which it needs to
keep track of the duration since some events (for example, the update
finished). These helpers were in the common/utils.h, but they rely on
the global SystemState to access both Prefs and Clock.

Since these helpers are specific to the metric reporting, this CL moves
them to the metrics_utils.h module.

Bug: 25197634
TEST=FEATURES=test emerge-link update_engine; mmma system/update_engine

Change-Id: Ia48091adbdc56c339c69c86c91c5c01aa58c54fb
/system/update_engine/common/utils.h
38429cf76aaac8c499004b6f537229a26b381602 12-Nov-2015 Alex Deymo <deymo@google.com> common: Split out metrics utils from utils.cc.

The utility functions to convert error codes and network settings to
the types defined by the metrics framework are split out the utils.cc
file. These tools are only used by the update_engine daemon to report
back metrics on an update check.

Bug: 25197634
Test: FEATURES=test emerge-link update_engine; mma

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

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

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

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

Change-Id: Id8d0204ea573627e6e26ca9ea17b9592ca95bc23
/system/update_engine/common/utils.h