Remove D-Bus dependency from Config

This is achieved by using a generic ConfigAdaptorInterface to communicate
with the adaptor.

Use FakeConfigAdaptor for testing, which provides the storage for
the property variables.

While there, update the Config APIs to use the generic internal Error type
instead of brillo::Error (which is tailored more towards D-Bus). The D-Bus
adaptor will convert it to brillo::Error when returning from D-Bus method
calls.

Bug: 24194427
TEST=Setup AP on Chrome OS and Brillo device
TEST=Run unittests

Change-Id: I5aa8ffd0805bcbb0125224f4f430245b70f56b6a
diff --git a/service.cc b/service.cc
index cd8a0e1..4b5a026 100644
--- a/service.cc
+++ b/service.cc
@@ -33,6 +33,7 @@
 #include "apmanager/event_dispatcher.h"
 #endif  // __BRILLO__
 
+#include "apmanager/error.h"
 #include "apmanager/manager.h"
 
 using brillo::dbus_utils::AsyncEventSequencer;
@@ -80,11 +81,11 @@
                              ManagerAdaptor::GetObjectPath().value().c_str(),
                              service_identifier)),
       dbus_path_(dbus::ObjectPath(service_path_)),
-      config_(new Config(manager, service_path_)),
+      config_(new Config(manager, service_identifier)),
       dhcp_server_factory_(DHCPServerFactory::GetInstance()),
       file_writer_(FileWriter::GetInstance()),
       process_factory_(ProcessFactory::GetInstance()) {
-  SetConfig(config_->dbus_path());
+  SetConfig(config_->adaptor()->GetRpcObjectIdentifier());
   SetState(kStateIdle);
   // TODO(zqiu): come up with better server address management. This is good
   // enough for now.
@@ -115,9 +116,6 @@
   RegisterWithDBusObject(dbus_object_.get());
   dbus_object_->RegisterAsync(
       sequencer->GetHandler("Service.RegisterAsync() failed.", true));
-
-  // Register Config DBus object.
-  config_->RegisterAsync(object_manager, bus, sequencer);
 }
 
 bool Service::StartInternal(brillo::ErrorPtr* error) {
@@ -133,10 +131,10 @@
 
   // Generate hostapd configuration content.
   string config_str;
-  if (!config_->GenerateConfigFile(error, &config_str)) {
-    brillo::Error::AddTo(
-        error, FROM_HERE, brillo::errors::dbus::kDomain, kServiceError,
-        "Failed to generate config file");
+  Error internal_error;
+  if (!config_->GenerateConfigFile(&internal_error, &config_str)) {
+    // TODO(zqiu): temporary until D-Bus is decoupled from this class.
+    internal_error.ToDBusError(error);
     return false;
   }