• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 #ifndef OHOS_LOCATION_CONFIG_MANAGER_H
17 #define OHOS_LOCATION_CONFIG_MANAGER_H
18 
19 #include <atomic>
20 #include <mutex>
21 #include <string>
22 
23 #include "constant_definition.h"
24 
25 namespace OHOS {
26 namespace Location {
27 class LocationConfigManager {
28 public:
29     ~LocationConfigManager();
30     static LocationConfigManager &GetInstance();
31 
32     /*
33      * @Description Init the LocationConfigManager object
34      *
35      * @return int - init result, when 0 means success, other means some fails happened
36      */
37     int Init();
38 
39     /*
40      * @Description Get current location switch state
41      *
42      * @return int - the location switch state, open/close
43      */
44     int GetLocationSwitchState();
45 
46     /*
47      * @Description set location switch state
48      *
49      * @param state - the location switch state
50      * @return int - 0 success
51      */
52     int SetLocationSwitchState(int state);
53 
54     bool IsExistFile(const std::string& filename);
55     bool CreateFile(const std::string& filename, const std::string& filedata);
56 
57     std::string GetPrivacyTypeConfigPath(const int type);
58     LocationErrCode GetPrivacyTypeState(const int type, bool& isConfirmed);
59     LocationErrCode SetPrivacyTypeState(const int type, bool isConfirmed);
60 
61     /*
62      * @Description get nlp service name
63      *
64      * @param path - config file path
65      * @param name - service name
66      * @return bool - true success
67      */
68     bool GetNlpServiceName(const std::string& path, std::string& name);
69 
70 private:
71     LocationConfigManager();
72     std::string GetLocationSwitchConfigPath();
73 
74 private:
75     std::atomic<int> mPrivacyTypeState[3];
76     std::atomic<int> mLocationSwitchState;         /* location switch state */
77     std::mutex mMutex;
78 };
79 }  // namespace Location
80 }  // namespace OHOS
81 #endif