Michael Schwartz | 97dc0f9 | 2017-05-08 14:07:14 -0700 | [diff] [blame] | 1 | /* |
| 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 Hong | 52032b8 | 2018-02-27 18:35:39 -0800 | [diff] [blame] | 19 | #ifdef LIBVINTF_TARGET |
| 20 | #include <android-base/properties.h> |
| 21 | #endif |
| 22 | |
Michael Schwartz | 97dc0f9 | 2017-05-08 14:07:14 -0700 | [diff] [blame] | 23 | namespace android { |
| 24 | namespace vintf { |
| 25 | namespace details { |
| 26 | |
Yifan Hong | 8640cd1 | 2017-05-17 12:02:28 -0700 | [diff] [blame] | 27 | static FileFetcher fetcher; |
Michael Schwartz | 97dc0f9 | 2017-05-08 14:07:14 -0700 | [diff] [blame] | 28 | FileFetcher* gFetcher = &fetcher; |
| 29 | |
Yifan Hong | 8640cd1 | 2017-05-17 12:02:28 -0700 | [diff] [blame] | 30 | static PartitionMounter partitionMounter; |
| 31 | PartitionMounter* gPartitionMounter = &partitionMounter; |
Yifan Hong | 29bb2d4 | 2017-09-27 13:28:00 -0700 | [diff] [blame] | 32 | |
| 33 | static ObjectFactory<RuntimeInfo> runtimeInfoFactory; |
| 34 | ObjectFactory<RuntimeInfo>* gRuntimeInfoFactory = &runtimeInfoFactory; |
| 35 | |
Yifan Hong | 52032b8 | 2018-02-27 18:35:39 -0800 | [diff] [blame] | 36 | #ifdef LIBVINTF_TARGET |
| 37 | class 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 | }; |
| 51 | const PropertyFetcher& getPropertyFetcher() { |
| 52 | static DevicePropertyFetcher fetcher; |
| 53 | return fetcher; |
| 54 | } |
| 55 | #else |
| 56 | const PropertyFetcher& getPropertyFetcher() { |
| 57 | static PropertyFetcher fetcher; |
| 58 | return fetcher; |
| 59 | } |
| 60 | #endif |
| 61 | |
Michael Schwartz | 97dc0f9 | 2017-05-08 14:07:14 -0700 | [diff] [blame] | 62 | } // namespace details |
| 63 | } // namespace vintf |
| 64 | } // namespace android |