Merge remote-tracking branch 'goog/upstream-master'.
The following commits were reverted:
840703a Fix update over cellular network on guest account
eaad5d0 Do not merge to AOSP: Fixes the link to brillo-clang-format in CrOS
740efad Reboot even if a system update is not available.
Fixed a few sign compare warnings.
Had to ifdef out 2 SquashfsFilesystemTest because it depends on unsquashfs -m.
Test: update_engine_unittests
Change-Id: I6f4ca5003e78c76064ec60d0797505d8c18d00bf
Merged-In: I6f4ca5003e78c76064ec60d0797505d8c18d00bf
diff --git a/common/fake_hardware.h b/common/fake_hardware.h
index a384597..f2b2c9d 100644
--- a/common/fake_hardware.h
+++ b/common/fake_hardware.h
@@ -83,6 +83,14 @@
int64_t GetBuildTimestamp() const override { return build_timestamp_; }
+ bool GetFirstActiveOmahaPingSent() const override {
+ return first_active_omaha_ping_sent_;
+ }
+
+ void SetFirstActiveOmahaPingSent() override {
+ first_active_omaha_ping_sent_ = true;
+ }
+
// Setters
void SetIsOfficialBuild(bool is_official_build) {
is_official_build_ = is_official_build;
@@ -144,6 +152,7 @@
int powerwash_count_{kPowerwashCountNotSet};
bool powerwash_scheduled_{false};
int64_t build_timestamp_{0};
+ bool first_active_omaha_ping_sent_{false};
DISALLOW_COPY_AND_ASSIGN(FakeHardware);
};
diff --git a/common/hardware_interface.h b/common/hardware_interface.h
index c9e2f85..94442d1 100644
--- a/common/hardware_interface.h
+++ b/common/hardware_interface.h
@@ -94,6 +94,15 @@
// Returns the timestamp of the current OS build.
virtual int64_t GetBuildTimestamp() const = 0;
+
+ // Returns whether the first active ping was sent to Omaha at some point, and
+ // that the value is persisted across recovery (and powerwash) once set with
+ // |SetFirstActiveOmahaPingSent()|.
+ virtual bool GetFirstActiveOmahaPingSent() const = 0;
+
+ // Persist the fact that first active ping was sent to omaha. It bails out if
+ // it fails.
+ virtual void SetFirstActiveOmahaPingSent() = 0;
};
} // namespace chromeos_update_engine
diff --git a/common/http_fetcher_unittest.cc b/common/http_fetcher_unittest.cc
index eb85f68..867216e 100644
--- a/common/http_fetcher_unittest.cc
+++ b/common/http_fetcher_unittest.cc
@@ -633,7 +633,7 @@
fetcher->Unpause();
fetcher->Pause();
// Proxy resolver comes back after we paused the fetcher.
- ASSERT_TRUE(proxy_callback);
+ ASSERT_FALSE(proxy_callback.is_null());
proxy_callback.Run({1, kNoProxy});
}
diff --git a/common/mock_hardware.h b/common/mock_hardware.h
index 1c4253a..42fa7ba 100644
--- a/common/mock_hardware.h
+++ b/common/mock_hardware.h
@@ -63,6 +63,12 @@
ON_CALL(*this, GetPowerwashSafeDirectory(testing::_))
.WillByDefault(testing::Invoke(&fake_,
&FakeHardware::GetPowerwashSafeDirectory));
+ ON_CALL(*this, GetFirstActiveOmahaPingSent())
+ .WillByDefault(testing::Invoke(&fake_,
+ &FakeHardware::GetFirstActiveOmahaPingSent()));
+ ON_CALL(*this, SetFirstActiveOmahaPingSent())
+ .WillByDefault(testing::Invoke(&fake_,
+ &FakeHardware::SetFirstActiveOmahaPingSent()));
}
~MockHardware() override = default;
@@ -78,6 +84,7 @@
MOCK_CONST_METHOD0(GetPowerwashCount, int());
MOCK_CONST_METHOD1(GetNonVolatileDirectory, bool(base::FilePath*));
MOCK_CONST_METHOD1(GetPowerwashSafeDirectory, bool(base::FilePath*));
+ MOCK_CONST_METHOD0(GetFirstActiveOmahaPingSent, bool());
// Returns a reference to the underlying FakeHardware.
FakeHardware& fake() {
diff --git a/common/utils.h b/common/utils.h
index 2117836..e4ffcf8 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -88,8 +88,8 @@
bool PReadAll(int fd, void* buf, size_t count, off_t offset,
ssize_t* out_bytes_read);
-bool PReadAll(const FileDescriptorPtr& fd, void* buf, size_t count, off_t offset,
- ssize_t* out_bytes_read);
+bool PReadAll(const FileDescriptorPtr& fd, void* buf, size_t count,
+ off_t offset, ssize_t* out_bytes_read);
// Opens |path| for reading and appends its entire content to the container
// pointed to by |out_p|. Returns true upon successfully reading all of the
@@ -256,6 +256,16 @@
}
}
+// Return the total number of blocks in the passed |extents| collection.
+template <class T>
+uint64_t BlocksInExtents(const T& extents) {
+ uint64_t sum = 0;
+ for (const auto& ext : extents) {
+ sum += ext.num_blocks();
+ }
+ return sum;
+}
+
// Converts seconds into human readable notation including days, hours, minutes
// and seconds. For example, 185 will yield 3m5s, 4300 will yield 1h11m40s, and
// 360000 will yield 4d4h0m0s. Zero padding not applied. Seconds are always