blob: 5b2bb7dcf8585bae39751c702ec9f7bbef6f6718 [file] [log] [blame]
Michael Schwartz97dc0f92017-05-08 14:07:14 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "utils.h"
18
Yifan Hong52032b82018-02-27 18:35:39 -080019#ifdef LIBVINTF_TARGET
20#include <android-base/properties.h>
21#endif
22
Michael Schwartz97dc0f92017-05-08 14:07:14 -070023namespace android {
24namespace vintf {
25namespace details {
26
Yifan Hong8640cd12017-05-17 12:02:28 -070027static FileFetcher fetcher;
Michael Schwartz97dc0f92017-05-08 14:07:14 -070028FileFetcher* gFetcher = &fetcher;
29
Yifan Hong8640cd12017-05-17 12:02:28 -070030static PartitionMounter partitionMounter;
31PartitionMounter* gPartitionMounter = &partitionMounter;
Yifan Hong29bb2d42017-09-27 13:28:00 -070032
33static ObjectFactory<RuntimeInfo> runtimeInfoFactory;
34ObjectFactory<RuntimeInfo>* gRuntimeInfoFactory = &runtimeInfoFactory;
35
Yifan Hong52032b82018-02-27 18:35:39 -080036#ifdef LIBVINTF_TARGET
37class DevicePropertyFetcher : public PropertyFetcher {
38 public:
39 std::string getProperty(const std::string& key,
40 const std::string& defaultValue) const override {
41 return android::base::GetProperty(key, defaultValue);
42 }
43 uint64_t getUintProperty(const std::string& key, uint64_t defaultValue,
44 uint64_t max) const override {
45 return android::base::GetUintProperty(key, defaultValue, max);
46 }
47 bool getBoolProperty(const std::string& key, bool defaultValue) const override {
48 return android::base::GetBoolProperty(key, defaultValue);
49 }
50};
51const PropertyFetcher& getPropertyFetcher() {
52 static DevicePropertyFetcher fetcher;
53 return fetcher;
54}
55#else
56const PropertyFetcher& getPropertyFetcher() {
57 static PropertyFetcher fetcher;
58 return fetcher;
59}
60#endif
61
Michael Schwartz97dc0f92017-05-08 14:07:14 -070062} // namespace details
63} // namespace vintf
64} // namespace android