• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 NET_CONN_SERVICE_PROXY_H
17 #define NET_CONN_SERVICE_PROXY_H
18 
19 #include "iremote_proxy.h"
20 
21 #include "i_net_conn_service.h"
22 
23 namespace OHOS {
24 namespace NetManagerStandard {
25 class NetConnServiceProxy : public IRemoteProxy<INetConnService> {
26 public:
27     explicit NetConnServiceProxy(const sptr<IRemoteObject> &impl);
28     virtual ~NetConnServiceProxy();
29     int32_t SystemReady() override;
30     int32_t RegisterNetSupplier(NetBearType bearerType, const std::string &ident, const std::set<NetCap> &netCaps,
31         uint32_t &supplierId) override;
32     int32_t UnregisterNetSupplier(uint32_t supplierId) override;
33     int32_t RegisterNetSupplierCallback(uint32_t supplierId, const sptr<INetSupplierCallback> &callback) override;
34     int32_t RegisterNetConnCallback(const sptr<INetConnCallback> &callback) override;
35     int32_t RegisterNetConnCallback(const sptr<NetSpecifier> &netSpecifier,
36         const sptr<INetConnCallback> &callback, const uint32_t &timeoutMS) override;
37     int32_t UnregisterNetConnCallback(const sptr<INetConnCallback> &callback) override;
38     int32_t UpdateNetStateForTest(const sptr<NetSpecifier> &netSpecifier, int32_t netState) override;
39     int32_t UpdateNetSupplierInfo(uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo) override;
40     int32_t UpdateNetLinkInfo(uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo) override;
41     int32_t  GetDefaultNet(int32_t& netId) override;
42     int32_t HasDefaultNet(bool &flag) override;
43     int32_t GetIfaceNames(NetBearType bearerType, std::list<std::string> &ifaceNames) override;
44     int32_t GetIfaceNameByType(NetBearType bearerType, const std::string &ident, std::string &ifaceName) override;
45     int32_t RegisterNetDetectionCallback(int32_t netId, const sptr<INetDetectionCallback> &callback) override;
46     int32_t UnRegisterNetDetectionCallback(int32_t netId, const sptr<INetDetectionCallback> &callback) override;
47     int32_t NetDetection(int32_t netId) override;
48     int32_t GetAddressesByName(const std::string &host, int32_t netId, std::vector<INetAddr> &addrList) override;
49     int32_t GetAddressByName(const std::string &host, int32_t netId, INetAddr &addr) override;
50     int32_t GetSpecificNet(NetBearType bearerType, std::list<int32_t> &netIdList) override;
51     int32_t GetAllNets(std::list<int32_t> &netIdList) override;
52     int32_t GetSpecificUidNet(int32_t uid, int32_t &netId) override;
53     int32_t GetConnectionProperties(int32_t netId, NetLinkInfo &info) override;
54     int32_t GetNetCapabilities(int32_t netId, NetAllCapabilities &netAllCap) override;
55     int32_t BindSocket(int32_t socket_fd, int32_t netId) override;
56     int32_t SetAirplaneMode(bool state) override;
57     int32_t IsDefaultNetMetered(bool &isMetered) override;
58     int32_t SetGlobalHttpProxy(const HttpProxy &httpProxy) override;
59     int32_t GetGlobalHttpProxy(HttpProxy &httpProxy) override;
60     int32_t GetNetIdByIdentifier(const std::string &ident, int32_t &netId) override;
61     int32_t SetAppNet(int32_t netId) override;
62 
63 private:
64     bool WriteInterfaceToken(MessageParcel &data);
65     int32_t GetNetCapData(MessageParcel &reply, NetAllCapabilities &netAllCap);
66 
67 private:
68     static inline BrokerDelegator<NetConnServiceProxy> delegator_;
69 };
70 } // namespace NetManagerStandard
71 } // namespace OHOS
72 #endif // NET_CONN_SERVICE_PROXY_H
73