Initialize channel information on Init().
The channel information returned by dbus_service relies on the
OmahaRequestParams object being initialized, which didn't happen until
the first update check. This patch also fixes the store of the newly
selected channel.
Bug: chromium:551605,chromium:548486
TEST=deployed update_engine to a link device. Changed channels right after reboot.
Change-Id: I5070b3f8f09fc2ac5a74e2d40df9a2bea92df019
diff --git a/image_properties_chromeos.cc b/image_properties_chromeos.cc
index 8999d6a..ab689f5 100644
--- a/image_properties_chromeos.cc
+++ b/image_properties_chromeos.cc
@@ -140,8 +140,8 @@
lsb_release.SetBoolean(kLsbReleaseIsPowerwashAllowedKey,
properties.is_powerwash_allowed);
- base::FilePath path(std::string(root_prefix) + kStatefulPartition +
- kLsbRelease);
+ std::string root_prefix_str = root_prefix ? root_prefix : "";
+ base::FilePath path(root_prefix_str + kStatefulPartition + kLsbRelease);
if (!base::DirectoryExists(path.DirName()))
base::CreateDirectory(path.DirName());
return lsb_release.Save(path);
diff --git a/real_system_state.cc b/real_system_state.cc
index cf904c2..8efb903 100644
--- a/real_system_state.cc
+++ b/real_system_state.cc
@@ -102,6 +102,15 @@
system_rebooted_ = true;
}
+ // Initialize the OmahaRequestParams with the default settings. These settings
+ // will be re-initialized before every request using the actual request
+ // options. This initialization here pre-loads current channel and version, so
+ // the DBus service can access it.
+ if (!request_params_.Init("", "", false)) {
+ LOG(WARNING) << "Ignoring OmahaRequestParams initialization error. Some "
+ "features might not work properly.";
+ }
+
// Initialize the Update Manager using the default state factory.
chromeos_update_manager::State* um_state =
chromeos_update_manager::DefaultStateFactory(