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 | d14640a | 2018-02-27 18:35:39 -0800 | [diff] [blame] | 19 | #ifdef LIBVINTF_TARGET |
Yifan Hong | 10d8622 | 2018-04-06 15:41:05 -0700 | [diff] [blame] | 20 | #include <android-base/logging.h> |
Yifan Hong | d14640a | 2018-02-27 18:35:39 -0800 | [diff] [blame] | 21 | #include <android-base/properties.h> |
| 22 | #endif |
| 23 | |
Michael Schwartz | 97dc0f9 | 2017-05-08 14:07:14 -0700 | [diff] [blame] | 24 | namespace android { |
| 25 | namespace vintf { |
| 26 | namespace details { |
| 27 | |
Yifan Hong | 8640cd1 | 2017-05-17 12:02:28 -0700 | [diff] [blame] | 28 | static PartitionMounter partitionMounter; |
| 29 | PartitionMounter* gPartitionMounter = &partitionMounter; |
Yifan Hong | 29bb2d4 | 2017-09-27 13:28:00 -0700 | [diff] [blame] | 30 | |
| 31 | static ObjectFactory<RuntimeInfo> runtimeInfoFactory; |
| 32 | ObjectFactory<RuntimeInfo>* gRuntimeInfoFactory = &runtimeInfoFactory; |
| 33 | |
Yifan Hong | d14640a | 2018-02-27 18:35:39 -0800 | [diff] [blame] | 34 | #ifdef LIBVINTF_TARGET |
| 35 | class DevicePropertyFetcher : public PropertyFetcher { |
| 36 | public: |
| 37 | std::string getProperty(const std::string& key, |
| 38 | const std::string& defaultValue) const override { |
| 39 | return android::base::GetProperty(key, defaultValue); |
| 40 | } |
| 41 | uint64_t getUintProperty(const std::string& key, uint64_t defaultValue, |
| 42 | uint64_t max) const override { |
| 43 | return android::base::GetUintProperty(key, defaultValue, max); |
| 44 | } |
| 45 | bool getBoolProperty(const std::string& key, bool defaultValue) const override { |
| 46 | return android::base::GetBoolProperty(key, defaultValue); |
| 47 | } |
| 48 | }; |
| 49 | const PropertyFetcher& getPropertyFetcher() { |
| 50 | static DevicePropertyFetcher fetcher; |
| 51 | return fetcher; |
| 52 | } |
| 53 | #else |
| 54 | const PropertyFetcher& getPropertyFetcher() { |
| 55 | static PropertyFetcher fetcher; |
| 56 | return fetcher; |
| 57 | } |
| 58 | #endif |
| 59 | |
Michael Schwartz | 97dc0f9 | 2017-05-08 14:07:14 -0700 | [diff] [blame] | 60 | } // namespace details |
| 61 | } // namespace vintf |
| 62 | } // namespace android |