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 19 #ifdef LIBVINTF_TARGET 20 #include <android-base/properties.h> 21 #endif 22 23 namespace android { 24 namespace vintf { 25 namespace details { 26 27 static FileFetcher fetcher; 28 FileFetcher* gFetcher = &fetcher; 29 30 static PartitionMounter partitionMounter; 31 PartitionMounter* gPartitionMounter = &partitionMounter; 32 33 static ObjectFactory<RuntimeInfo> runtimeInfoFactory; 34 ObjectFactory<RuntimeInfo>* gRuntimeInfoFactory = &runtimeInfoFactory; 35 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 62 } // namespace details 63 } // namespace vintf 64 } // namespace android 65