Refactor D-Bus adaptor for Device out of the Device class
This removes the RPC specific dependencies out of the Device class.
Device adaptors will now be created through the ControlInterface.
While there, make the D-Bus object registration for Device object to
be synchronous instead of asynchronous. Since the daemon will not
be doing anything anyway besides waiting for the registration to
complete. This avoids unnecessary complexity with the object
registration.
Currently for D-Bus, the property variables are being created/stored
in the generated adaptor code. This means that the property variables
will be stored in the adaptor instead of the Device class itself.
Even though this is not ideal, there is no good way around it. In the
ideal world, the Device would maintain its property variables, and
register them with the RPC specific adaptor.
So for the unittest, we will use FakeDeviceAdaptor, which provides the
storage for the property variables.
Also currently gmock doesn't support mocking of a function that returns
a unique_ptr, since it only supports copyable return value and unique_ptr
is not copyable. To work around this issue, I've created mock functions
that return a raw pointer, and override the proxy/adaptor creation
functions to use the mock function in MockControl.
Bug: 24194427
TEST=Start AP service on both Brillo and Chrome OS
TEST=Run unittests on both Brillo and Chrome OS
Change-Id: I8e9f736bb27fe6736f616dd752a37b9cc1be8dfe
diff --git a/device_adaptor_interface.h b/device_adaptor_interface.h
new file mode 100644
index 0000000..37460a4
--- /dev/null
+++ b/device_adaptor_interface.h
@@ -0,0 +1,38 @@
+//
+// Copyright 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef APMANAGER_DEVICE_ADAPTOR_INTERFACE_H_
+#define APMANAGER_DEVICE_ADAPTOR_INTERFACE_H_
+
+#include <string>
+
+namespace apmanager {
+
+class DeviceAdaptorInterface {
+ public:
+ virtual ~DeviceAdaptorInterface() {}
+
+ virtual void SetDeviceName(const std::string& device_name) = 0;
+ virtual std::string GetDeviceName() = 0;
+ virtual void SetPreferredApInterface(const std::string& interface_name) = 0;
+ virtual std::string GetPreferredApInterface() = 0;
+ virtual void SetInUse(bool in_use) = 0;
+ virtual bool GetInUse() = 0;
+};
+
+} // namespace apmanager
+
+#endif // APMANAGER_DEVICE_ADAPTOR_INTERFACE_H_