shill: Manager: Merge stored configuration in ConfigureService
In ConfigureService, if there is already stored information available
for a service, merge this stored information into newly created services
instead of overriding them with the defaults. This situation can arise
when configuration is loaded via policy for a service that is not
currently visible. User-specified parameters such as AutoConnect can be
lost in this process otherwise.
BUG=chromium-os:37042
TEST=Modified unit tests + manual: login to ONC-managed account
with WiFi disabled, and ensure configuration is merged (credentials are
available in the service although ONC did not provide them).
Change-Id: I92cbb7d14dc21c4173794ef1eb19b792d97c44ac
Reviewed-on: https://gerrit.chromium.org/gerrit/39398
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/profile.cc b/profile.cc
index f9c568b..e73f784 100644
--- a/profile.cc
+++ b/profile.cc
@@ -165,13 +165,19 @@
return service->Save(storage_.get()) && storage_->Flush();
}
-bool Profile::ConfigureService(const ServiceRefPtr &service) {
+bool Profile::LoadService(const ServiceRefPtr &service) {
if (!ContainsService(service))
return false;
- service->SetProfile(this);
return service->Load(storage_.get());
}
+bool Profile::ConfigureService(const ServiceRefPtr &service) {
+ if (!LoadService(service))
+ return false;
+ service->SetProfile(this);
+ return true;
+}
+
bool Profile::ConfigureDevice(const DeviceRefPtr &device) {
return device->Load(storage_.get());
}