• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "di_config.h"
17 
18 #include "bt_def.h"
19 #include "log.h"
20 
21 namespace OHOS {
22 namespace bluetooth {
GetInstance()23 DIConfig &DIConfig::GetInstance()
24 {
25     static DIConfig instance;
26     return instance;
27 }
28 
DIConfig()29 DIConfig::DIConfig() : config_(AdapterDeviceInfo::GetInstance())
30 {}
31 
~DIConfig()32 DIConfig::~DIConfig()
33 {}
34 
LoadConfigFile() const35 bool DIConfig::LoadConfigFile() const
36 {
37     /// Load Device info Config File.
38     bool ret = config_->Load();
39     if (!ret) {
40         LOG_ERROR("[DIConfig]::%{public}s failed!", __func__);
41     }
42 
43     return ret;
44 }
45 
GetSpecificaitonId() const46 int DIConfig::GetSpecificaitonId() const
47 {
48     int specId = 0;
49     if (!config_->GetValue(SECTION_BREDR, PROPERTY_SPECIFICATION_ID, specId)) {
50         LOG_ERROR("[DIConfig]::%{public}s failed!", __func__);
51     }
52 
53     return specId;
54 }
55 
GetVendorId() const56 int DIConfig::GetVendorId() const
57 {
58     int vendorId = 0;
59     if (!config_->GetValue(SECTION_BREDR, PROPERTY_VENDOR_ID, vendorId)) {
60         LOG_ERROR("[DIConfig]::%{public}s failed!", __func__);
61     }
62 
63     return vendorId;
64 }
65 
GetProductId() const66 int DIConfig::GetProductId() const
67 {
68     int productId = 0;
69     if (!config_->GetValue(SECTION_BREDR, PROPERTY_PRODUCT_ID, productId)) {
70         LOG_ERROR("[DIConfig]::%{public}s failed!", __func__);
71     }
72 
73     return productId;
74 }
75 
GetVersion() const76 int DIConfig::GetVersion() const
77 {
78     int version = 0;
79     if (!config_->GetValue(SECTION_BREDR, PROPERTY_VERSION, version)) {
80         LOG_ERROR("[DIConfig]::%{public}s failed!", __func__);
81     }
82 
83     return version;
84 }
85 
GetPrimaryRecord() const86 bool DIConfig::GetPrimaryRecord() const
87 {
88     bool primaryRecord = false;
89     if (!config_->GetValue(SECTION_BREDR, PROPERTY_PRIMARY_RECORD, primaryRecord)) {
90         LOG_ERROR("[DIConfig]::%{public}s failed!", __func__);
91     }
92 
93     return primaryRecord;
94 }
95 
GetVendorIdSource() const96 int DIConfig::GetVendorIdSource() const
97 {
98     int vendorIdSrc = 0;
99     if (!config_->GetValue(SECTION_BREDR, PROPERTY_VENDOR_ID_SOURCE, vendorIdSrc)) {
100         LOG_ERROR("[DIConfig]::%{public}s failed!", __func__);
101     }
102 
103     return vendorIdSrc;
104 }
105 }  // namespace bluetooth
106 }  // namespace OHOS