• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 "liblp/property_fetcher.h"
18 
19 #include <memory>
20 
21 #include <android-base/properties.h>
22 
23 namespace android {
24 namespace fs_mgr {
25 
GetProperty(const std::string & key,const std::string & default_value)26 std::string PropertyFetcher::GetProperty(const std::string& key, const std::string& default_value) {
27     return android::base::GetProperty(key, default_value);
28 }
29 
GetBoolProperty(const std::string & key,bool default_value)30 bool PropertyFetcher::GetBoolProperty(const std::string& key, bool default_value) {
31     return android::base::GetBoolProperty(key, default_value);
32 }
33 
GetInstanceAllocation()34 static std::unique_ptr<IPropertyFetcher>* GetInstanceAllocation() {
35     static std::unique_ptr<IPropertyFetcher> instance = std::make_unique<PropertyFetcher>();
36     return &instance;
37 }
38 
GetInstance()39 IPropertyFetcher* IPropertyFetcher::GetInstance() {
40     return GetInstanceAllocation()->get();
41 }
42 
OverrideForTesting(std::unique_ptr<IPropertyFetcher> && fetcher)43 void IPropertyFetcher::OverrideForTesting(std::unique_ptr<IPropertyFetcher>&& fetcher) {
44     GetInstanceAllocation()->swap(fetcher);
45     fetcher.reset();
46 }
47 
48 }  // namespace fs_mgr
49 }  // namespace android
50