• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 NET_DATASHARE_UTILS_H
17 #define NET_DATASHARE_UTILS_H
18 
19 #include <memory>
20 #include <utility>
21 
22 #include "datashare_helper.h"
23 #include "datashare_predicates.h"
24 #include "datashare_result_set.h"
25 #include "datashare_values_bucket.h"
26 #include "iservice_registry.h"
27 #include "system_ability_definition.h"
28 #include "uri.h"
29 
30 namespace OHOS {
31 namespace NetManagerStandard {
32 namespace {
33 constexpr const char *AIRPLANE_MODE_URI =
34     "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=airplane_mode";
35 constexpr const char *GLOBAL_PROXY_HOST_URI =
36     "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=global_proxy_host";
37 constexpr const char *GLOBAL_PROXY_PORT_URI =
38     "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=global_proxy_port";
39 constexpr const char *GLOBAL_PROXY_EXCLUSIONS_URI =
40     "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=global_proxy_exclusions";
41 
42 constexpr const char *KEY_AIRPLANE_MODE = "settings.telephony.airplanemode";
43 constexpr const char *KEY_GLOBAL_PROXY_HOST = "settings.netmanager.proxy_host";
44 constexpr const char *KEY_GLOBAL_PROXY_PORT = "settings.netmanager.proxy_port";
45 constexpr const char *KEY_GLOBAL_PROXY_EXCLUSIONS = "settings.netmanager.proxy_exclusions";
46 } // namespace
47 
48 class NetDataShareHelperUtils final {
49 public:
50     NetDataShareHelperUtils();
51     ~NetDataShareHelperUtils() = default;
52     int32_t Query(Uri &uri, const std::string &key, std::string &value);
53     int32_t Insert(Uri &uri, const std::string &key, const std::string &value);
54     int32_t Update(Uri &uri, const std::string &key, const std::string &value);
55 
56 private:
57     std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper();
58 
59 private:
60     std::shared_ptr<DataShare::DataShareHelper> dataShareHelper_ = nullptr;
61 };
62 } // namespace NetManagerStandard
63 } // namespace OHOS
64 #endif // NET_DATASHARE_UTILS_H