• 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 INTERFACES_INNER_API_NETWORK_MANAGER_INCLUDE_NETWORK_MANAGER_PROXY_H
17 #define INTERFACES_INNER_API_NETWORK_MANAGER_INCLUDE_NETWORK_MANAGER_PROXY_H
18 
19 #include "enterprise_device_mgr_proxy.h"
20 #ifdef NETMANAGER_BASE_EDM_ENABLE
21 #include "http_proxy.h"
22 #endif
23 #include "domain_filter_rule.h"
24 #include "firewall_rule.h"
25 #include "iptables_utils.h"
26 #include "apn_password.h"
27 
28 namespace OHOS {
29 namespace EDM {
30 class NetworkManagerProxy {
31 public:
32     NetworkManagerProxy();
33     ~NetworkManagerProxy();
34     static std::shared_ptr<NetworkManagerProxy> GetNetworkManagerProxy();
35     int32_t GetAllNetworkInterfaces(const AppExecFwk::ElementName &admin, std::vector<std::string> &networkInterface,
36         bool isSync = false);
37     int32_t GetAllNetworkInterfaces(MessageParcel &data, std::vector<std::string> &networkInterface);
38     int32_t GetIpOrMacAddress(const AppExecFwk::ElementName &admin, const std::string &networkInterface, int policyCode,
39         std::string &info, bool isSync = false);
40     int32_t GetIpOrMacAddress(MessageParcel &data, int policyCode, std::string &info);
41     int32_t SetNetworkInterfaceDisabled(const AppExecFwk::ElementName &admin, const std::string &networkInterface,
42         bool isDisabled, bool isSync = false);
43     int32_t SetNetworkInterfaceDisabled(MessageParcel &data);
44     int32_t IsNetworkInterfaceDisabled(const AppExecFwk::ElementName &admin, const std::string &networkInterface,
45         bool &status, bool isSync = false);
46     int32_t IsNetworkInterfaceDisabled(MessageParcel &data, bool &status);
47     int32_t AddIptablesFilterRule(MessageParcel &data);
48     int32_t RemoveIptablesFilterRule(MessageParcel &data);
49     int32_t ListIptablesFilterRules(MessageParcel &data, std::string &result);
50     int32_t AddFirewallRule(MessageParcel &data);
51     int32_t RemoveFirewallRule(const AppExecFwk::ElementName &admin, const IPTABLES::FirewallRule &rule);
52     int32_t GetFirewallRules(MessageParcel &data, std::vector<IPTABLES::FirewallRule> &result);
53     int32_t AddDomainFilterRule(MessageParcel &data);
54     int32_t RemoveDomainFilterRule(const AppExecFwk::ElementName &admin, const IPTABLES::DomainFilterRule &rule);
55     int32_t GetDomainFilterRules(MessageParcel &data, std::vector<IPTABLES::DomainFilterRule> &rule);
56     int32_t TurnOnMobileData(MessageParcel &data);
57     int32_t TurnOffMobileData(MessageParcel &data);
58     int32_t ForceTurnOnMobileData(const AppExecFwk::ElementName &admin);
59     int32_t AddApn(const AppExecFwk::ElementName &admin, const std::map<std::string, std::string> &apnInfoMap,
60         ApnPassword &apnPassword);
61     int32_t DeleteApn(MessageParcel &data);
62     int32_t UpdateApn(const AppExecFwk::ElementName &admin,
63         const std::map<std::string, std::string> &apnInfoMap, const std::string &apnId, ApnPassword &apnPassword);
64     int32_t SetPreferApn(const AppExecFwk::ElementName &admin, const std::string &apnId);
65     int32_t QueryApn(const AppExecFwk::ElementName &admin, const std::string &apnId,
66         std::map<std::string, std::string> &apnInfoMap);
67     int32_t QueryApnIds(const AppExecFwk::ElementName &admin,
68         const std::map<std::string, std::string> &apnInfoMap, std::vector<std::string> &apnIds);
69 #ifdef NETMANAGER_BASE_EDM_ENABLE
70     int32_t SetGlobalHttpProxy(MessageParcel &data);
71     int32_t GetGlobalHttpProxy(const AppExecFwk::ElementName *admin, NetManagerStandard::HttpProxy &httpProxy,
72         int32_t accountId = -1);
73 #endif
74 private:
75     static std::shared_ptr<NetworkManagerProxy> instance_;
76     static std::once_flag flag_;
77 };
78 } // namespace EDM
79 } // namespace OHOS
80 
81 #endif // INTERFACES_INNER_API_NETWORK_MANAGER_INCLUDE_NETWORK_MANAGER_PROXY_H
82