update_engine: Merge remote-tracking branch 'cros/upstream' into cros/master
Since libchrome in AOSP is ahead of CrOS I had to guard against BASE_VER in a
few places to satisfy older libchromes.
file_fetcher.cc is now needed in delta_generator.
A few unittests need to be run as root.
BUG=chromium:916593
TEST=unittest
TEST=cros_generate_update_payload
TEST=cros flash
CQ-DEPEND=CL:1399261
Change-Id: If3497549e88e559f8ecc38f414259b9c774f4a44
diff --git a/Android.bp b/Android.bp
index 906731f..dac1acd 100644
--- a/Android.bp
+++ b/Android.bp
@@ -28,6 +28,7 @@
name: "ue_defaults",
cflags: [
+ "-DBASE_VER=576279",
"-DUSE_BINDER=1",
"-DUSE_CHROME_NETWORK_PROXY=0",
"-DUSE_CHROME_KIOSK_APP=0",
diff --git a/common_service.cc b/common_service.cc
index 0f88151..88ead28 100644
--- a/common_service.cc
+++ b/common_service.cc
@@ -50,7 +50,11 @@
namespace {
// Log and set the error on the passed ErrorPtr.
void LogAndSetError(ErrorPtr* error,
+#if BASE_VER < 576279
+ const tracked_objects::Location& location,
+#else
const base::Location& location,
+#endif
const string& reason) {
brillo::Error::AddTo(error,
location,
diff --git a/payload_consumer/download_action.cc b/payload_consumer/download_action.cc
index cfa8846..516a456 100644
--- a/payload_consumer/download_action.cc
+++ b/payload_consumer/download_action.cc
@@ -56,6 +56,9 @@
delegate_(nullptr),
p2p_sharing_fd_(-1),
p2p_visible_(true) {
+#if BASE_VER < 576279
+ base::StatisticsRecorder::Initialize();
+#endif
}
DownloadAction::~DownloadAction() {}
diff --git a/payload_consumer/filesystem_verifier_action_unittest.cc b/payload_consumer/filesystem_verifier_action_unittest.cc
index 7fa61c0..f7789f4 100644
--- a/payload_consumer/filesystem_verifier_action_unittest.cc
+++ b/payload_consumer/filesystem_verifier_action_unittest.cc
@@ -274,7 +274,7 @@
}
#ifdef __ANDROID__
-TEST_F(FilesystemVerifierActionTest, WriteVerityTest) {
+TEST_F(FilesystemVerifierActionTest, RunAsRootWriteVerityTest) {
test_utils::ScopedTempFile part_file("part_file.XXXXXX");
constexpr size_t filesystem_size = 200 * 4096;
constexpr size_t part_size = 256 * 4096;
@@ -336,7 +336,7 @@
}
#endif // __ANDROID__
-TEST_F(FilesystemVerifierActionTest, SkipWriteVerityTest) {
+TEST_F(FilesystemVerifierActionTest, RunAsRootSkipWriteVerityTest) {
test_utils::ScopedTempFile part_file("part_file.XXXXXX");
constexpr size_t filesystem_size = 200 * 4096;
constexpr size_t part_size = 256 * 4096;
diff --git a/update_engine.gyp b/update_engine.gyp
index 2d81bed..754b314 100644
--- a/update_engine.gyp
+++ b/update_engine.gyp
@@ -404,6 +404,7 @@
},
},
'sources': [
+ 'common/file_fetcher.cc',
'payload_generator/ab_generator.cc',
'payload_generator/annotated_operation.cc',
'payload_generator/blob_file_writer.cc',
@@ -466,7 +467,6 @@
],
'sources': [
'common/fake_prefs.cc',
- 'common/file_fetcher.cc', # Only required for tests.
'common/mock_http_fetcher.cc',
'common/test_utils.cc',
'fake_shill_proxy.cc',
diff --git a/update_manager/boxed_value.cc b/update_manager/boxed_value.cc
index ffbd00b..35bfb1f 100644
--- a/update_manager/boxed_value.cc
+++ b/update_manager/boxed_value.cc
@@ -51,26 +51,42 @@
template<>
string BoxedValue::ValuePrinter<int>(const void* value) {
const int* val = reinterpret_cast<const int*>(value);
+#if BASE_VER < 576279
+ return base::IntToString(*val);
+#else
return base::NumberToString(*val);
+#endif
}
template<>
string BoxedValue::ValuePrinter<unsigned int>(const void* value) {
const unsigned int* val = reinterpret_cast<const unsigned int*>(value);
+#if BASE_VER < 576279
+ return base::UintToString(*val);
+#else
return base::NumberToString(*val);
+#endif
}
template<>
string BoxedValue::ValuePrinter<int64_t>(const void* value) {
const int64_t* val = reinterpret_cast<const int64_t*>(value);
+#if BASE_VER < 576279
+ return base::Int64ToString(*val);
+#else
return base::NumberToString(*val);
+#endif
}
template<>
string BoxedValue::ValuePrinter<uint64_t>(const void* value) {
const uint64_t* val =
reinterpret_cast<const uint64_t*>(value);
- return base::NumberToString(static_cast<uint64_t>(*val));
+#if BASE_VER < 576279
+ return base::Uint64ToString(*val);
+#else
+ return base::NumberToString(*val);
+#endif
}
template<>
@@ -82,7 +98,11 @@
template<>
string BoxedValue::ValuePrinter<double>(const void* value) {
const double* val = reinterpret_cast<const double*>(value);
+#if BASE_VER < 576279
+ return base::DoubleToString(*val);
+#else
return base::NumberToString(*val);
+#endif
}
template<>
diff --git a/update_manager/evaluation_context_unittest.cc b/update_manager/evaluation_context_unittest.cc
index 6a8475b..d172885 100644
--- a/update_manager/evaluation_context_unittest.cc
+++ b/update_manager/evaluation_context_unittest.cc
@@ -206,7 +206,13 @@
fake_const_var_.reset(new string("Hello world!"));
EXPECT_EQ(*eval_ctx_->GetValue(&fake_const_var_), "Hello world!");
- EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
+ EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
}
// Test that reevaluation occurs when an async variable it depends on changes.
@@ -276,11 +282,23 @@
EXPECT_TRUE(value);
// Ensure that we cannot reschedule an evaluation.
- EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
+ EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
// Ensure that we can reschedule an evaluation after resetting expiration.
eval_ctx_->ResetExpiration();
- EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
+ EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
}
// Test that we clear the events when destroying the EvaluationContext.
@@ -326,7 +344,13 @@
fake_poll_var_.reset(new string("Polled value"));
eval_ctx_->GetValue(&fake_async_var_);
eval_ctx_->GetValue(&fake_poll_var_);
- EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
+ EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
// TearDown() checks for leaked observers on this async_variable, which means
// that our object is still alive after removing its reference.
}
@@ -419,7 +443,13 @@
// The "false" from IsWallclockTimeGreaterThan means that's not that timestamp
// yet, so this should schedule a callback for when that happens.
- EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
+ EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
}
TEST_F(UmEvaluationContextTest,
@@ -429,7 +459,13 @@
// The "false" from IsMonotonicTimeGreaterThan means that's not that timestamp
// yet, so this should schedule a callback for when that happens.
- EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
+ EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
}
TEST_F(UmEvaluationContextTest,
@@ -442,7 +478,13 @@
fake_clock_.GetWallclockTime() - TimeDelta::FromSeconds(1)));
// Callback should not be scheduled.
- EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
+ EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
}
TEST_F(UmEvaluationContextTest,
@@ -455,7 +497,13 @@
fake_clock_.GetMonotonicTime() - TimeDelta::FromSeconds(1)));
// Callback should not be scheduled.
- EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
+ EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(
+#if BASE_VER < 576279
+ Bind(&base::DoNothing)
+#else
+ base::DoNothing()
+#endif
+ ));
}
TEST_F(UmEvaluationContextTest, DumpContext) {