Export definition of ObjectFactory and PropertyFetcher
They are dependencies of VintfObject and thus should
be public.
Test: builds
Bug: 118634720
Change-Id: I36912f7e3b05f2dc58a9f57845fc3bda6c5d6359
diff --git a/VintfObject.cpp b/VintfObject.cpp
index a1d4a6c..6a5685a 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -83,12 +83,11 @@
}
VintfObject::VintfObject(std::unique_ptr<FileSystem>&& fileSystem,
- std::unique_ptr<details::ObjectFactory<RuntimeInfo>>&& runtimeInfoFactory,
- std::unique_ptr<details::PropertyFetcher>&& propertyFetcher)
+ std::unique_ptr<ObjectFactory<RuntimeInfo>>&& runtimeInfoFactory,
+ std::unique_ptr<PropertyFetcher>&& propertyFetcher)
: mFileSystem(fileSystem ? std::move(fileSystem) : createDefaultFileSystem()),
- mRuntimeInfoFactory(runtimeInfoFactory
- ? std::move(runtimeInfoFactory)
- : std::make_unique<details::ObjectFactory<RuntimeInfo>>()),
+ mRuntimeInfoFactory(runtimeInfoFactory ? std::move(runtimeInfoFactory)
+ : std::make_unique<ObjectFactory<RuntimeInfo>>()),
mPropertyFetcher(propertyFetcher ? std::move(propertyFetcher)
: createDefaultPropertyFetcher()) {}
@@ -740,7 +739,7 @@
return mPropertyFetcher;
}
-const std::unique_ptr<details::ObjectFactory<RuntimeInfo>>& VintfObject::getRuntimeInfoFactory() {
+const std::unique_ptr<ObjectFactory<RuntimeInfo>>& VintfObject::getRuntimeInfoFactory() {
return mRuntimeInfoFactory;
}
diff --git a/VintfObjectAfterUpdate.h b/VintfObjectAfterUpdate.h
index 964b2bb..fbe5291 100644
--- a/VintfObjectAfterUpdate.h
+++ b/VintfObjectAfterUpdate.h
@@ -62,11 +62,11 @@
return mDependency->getFileSystem();
}
- const std::unique_ptr<details::PropertyFetcher>& getPropertyFetcher() override {
+ const std::unique_ptr<PropertyFetcher>& getPropertyFetcher() override {
return mDependency->getPropertyFetcher();
}
- const std::unique_ptr<details::ObjectFactory<RuntimeInfo>>& getRuntimeInfoFactory() override {
+ const std::unique_ptr<ObjectFactory<RuntimeInfo>>& getRuntimeInfoFactory() override {
return mDependency->getRuntimeInfoFactory();
}
diff --git a/include/vintf/ObjectFactory.h b/include/vintf/ObjectFactory.h
new file mode 100644
index 0000000..f71088b
--- /dev/null
+++ b/include/vintf/ObjectFactory.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#pragma once
+
+namespace android {
+namespace vintf {
+
+template <typename T>
+class ObjectFactory {
+ public:
+ virtual ~ObjectFactory() = default;
+ virtual std::shared_ptr<T> make_shared() const { return std::make_shared<T>(); }
+};
+
+} // namespace vintf
+} // namespace android
diff --git a/include/vintf/PropertyFetcher.h b/include/vintf/PropertyFetcher.h
new file mode 100644
index 0000000..1082a81
--- /dev/null
+++ b/include/vintf/PropertyFetcher.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#pragma once
+
+namespace android {
+namespace vintf {
+
+class PropertyFetcher {
+ public:
+ virtual ~PropertyFetcher() = default;
+ virtual std::string getProperty(const std::string& key,
+ const std::string& defaultValue = "") const = 0;
+ virtual uint64_t getUintProperty(const std::string& key, uint64_t defaultValue,
+ uint64_t max = UINT64_MAX) const = 0;
+ virtual bool getBoolProperty(const std::string& key, bool defaultValue) const = 0;
+};
+
+} // namespace vintf
+} // namespace android
diff --git a/include/vintf/VintfObject.h b/include/vintf/VintfObject.h
index cebf7f7..226f18b 100644
--- a/include/vintf/VintfObject.h
+++ b/include/vintf/VintfObject.h
@@ -24,15 +24,14 @@
#include "FileSystem.h"
#include "HalManifest.h"
#include "Named.h"
+#include "ObjectFactory.h"
+#include "PropertyFetcher.h"
#include "RuntimeInfo.h"
namespace android {
namespace vintf {
namespace details {
-template <typename T>
-class ObjectFactory;
-class PropertyFetcher;
class VintfObjectAfterUpdate;
template <typename T>
@@ -88,8 +87,8 @@
* - PropertyFetcher fetches properties for target and nothing for host
*/
VintfObject(std::unique_ptr<FileSystem>&& = nullptr,
- std::unique_ptr<details::ObjectFactory<RuntimeInfo>>&& = nullptr,
- std::unique_ptr<details::PropertyFetcher>&& = nullptr);
+ std::unique_ptr<ObjectFactory<RuntimeInfo>>&& = nullptr,
+ std::unique_ptr<PropertyFetcher>&& = nullptr);
virtual ~VintfObject() = default;
/*
@@ -190,8 +189,8 @@
private:
const std::unique_ptr<FileSystem> mFileSystem;
- const std::unique_ptr<details::ObjectFactory<RuntimeInfo>> mRuntimeInfoFactory;
- const std::unique_ptr<details::PropertyFetcher> mPropertyFetcher;
+ const std::unique_ptr<ObjectFactory<RuntimeInfo>> mRuntimeInfoFactory;
+ const std::unique_ptr<PropertyFetcher> mPropertyFetcher;
details::LockedSharedPtr<HalManifest> mDeviceManifest;
details::LockedSharedPtr<HalManifest> mFrameworkManifest;
@@ -216,8 +215,8 @@
protected:
virtual const std::unique_ptr<FileSystem>& getFileSystem();
- virtual const std::unique_ptr<details::PropertyFetcher>& getPropertyFetcher();
- virtual const std::unique_ptr<details::ObjectFactory<RuntimeInfo>>& getRuntimeInfoFactory();
+ virtual const std::unique_ptr<PropertyFetcher>& getPropertyFetcher();
+ virtual const std::unique_ptr<ObjectFactory<RuntimeInfo>>& getRuntimeInfoFactory();
public:
/*
diff --git a/test/utils-fake.h b/test/utils-fake.h
index 7af84cf..71d8eca 100644
--- a/test/utils-fake.h
+++ b/test/utils-fake.h
@@ -16,6 +16,8 @@
#include <gmock/gmock.h>
+#include <vintf/ObjectFactory.h>
+#include <vintf/PropertyFetcher.h>
#include "utils.h"
using ::testing::_;
diff --git a/utils.h b/utils.h
index f8cc9cd..dccc811 100644
--- a/utils.h
+++ b/utils.h
@@ -22,6 +22,7 @@
#include <utils/Errors.h>
#include <vintf/FileSystem.h>
+#include <vintf/PropertyFetcher.h>
#include <vintf/RuntimeInfo.h>
#include <vintf/parse_xml.h>
@@ -49,13 +50,6 @@
return OK;
}
-template <typename T>
-class ObjectFactory {
- public:
- virtual ~ObjectFactory() = default;
- virtual std::shared_ptr<T> make_shared() const { return std::make_shared<T>(); }
-};
-
// TODO(b/70628538): Do not infer from Shipping API level.
inline Level convertFromApiLevel(size_t apiLevel) {
if (apiLevel < 26) {
@@ -69,16 +63,6 @@
}
}
-class PropertyFetcher {
- public:
- virtual ~PropertyFetcher() = default;
- virtual std::string getProperty(const std::string& key,
- const std::string& defaultValue = "") const = 0;
- virtual uint64_t getUintProperty(const std::string& key, uint64_t defaultValue,
- uint64_t max = UINT64_MAX) const = 0;
- virtual bool getBoolProperty(const std::string& key, bool defaultValue) const = 0;
-};
-
class PropertyFetcherImpl : public PropertyFetcher {
public:
virtual std::string getProperty(const std::string& key,