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 30namespace OHOS { 31namespace NetManagerStandard { 32namespace { 33constexpr const char *AIRPLANE_MODE_URI = 34 "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=airplane_mode"; 35constexpr const char *GLOBAL_PROXY_HOST_URI = 36 "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=global_proxy_host"; 37constexpr const char *GLOBAL_PROXY_PORT_URI = 38 "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=global_proxy_port"; 39constexpr const char *GLOBAL_PROXY_EXCLUSIONS_URI = 40 "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=global_proxy_exclusions"; 41 42constexpr const char *USER_URI_PATTERN = "##USERID##"; 43constexpr const char *USER_PROXY_HOST_URI = 44 "datashare:///com.ohos.settingsdata/entry/settingsdata/" 45 "USER_SETTINGSDATA_##USERID##?Proxy=true&key=global_proxy_host"; 46constexpr const char *USER_PROXY_PORT_URI = 47 "datashare:///com.ohos.settingsdata/entry/settingsdata/" 48 "USER_SETTINGSDATA_##USERID##?Proxy=true&key=global_proxy_port"; 49constexpr const char *USER_PROXY_EXCLUSIONS_URI = 50 "datashare:///com.ohos.settingsdata/entry/settingsdata/" 51 "USER_SETTINGSDATA_##USERID##?Proxy=true&key=global_proxy_exclusions"; 52 53constexpr const char *KEY_AIRPLANE_MODE = "settings.telephony.airplanemode"; 54constexpr const char *KEY_GLOBAL_PROXY_HOST = "settings.netmanager.proxy_host"; 55constexpr const char *KEY_GLOBAL_PROXY_PORT = "settings.netmanager.proxy_port"; 56constexpr const char *KEY_GLOBAL_PROXY_EXCLUSIONS = "settings.netmanager.proxy_exclusions"; 57} // namespace 58 59class NetDataShareHelperUtils final { 60public: 61 NetDataShareHelperUtils(); 62 ~NetDataShareHelperUtils() = default; 63 int32_t Query(Uri &uri, const std::string &key, std::string &value); 64 int32_t Insert(Uri &uri, const std::string &key, const std::string &value); 65 int32_t Update(Uri &uri, const std::string &key, const std::string &value); 66 67private: 68 std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper(); 69}; 70} // namespace NetManagerStandard 71} // namespace OHOS 72#endif // NET_DATASHARE_UTILS_H 73