• 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 NET_CONNECT_ADAPTER_H
17 #define NET_CONNECT_ADAPTER_H
18 
19 #include <memory>
20 #include <string>
21 
22 namespace OHOS::NWeb {
23 enum class NetConnectType {
24     CONNECTION_UNKNOWN = 0,
25     CONNECTION_ETHERNET = 1,
26     CONNECTION_WIFI = 2,
27     CONNECTION_2G = 3,
28     CONNECTION_3G = 4,
29     CONNECTION_4G = 5,
30     CONNECTION_NONE = 6,
31     CONNECTION_BLUETOOTH = 7,
32     CONNECTION_5G = 8,
33     CONNECTION_LAST = CONNECTION_5G
34 };
35 
36 enum class NetConnectSubtype {
37     SUBTYPE_UNKNOWN = 0,
38     SUBTYPE_NONE,
39     SUBTYPE_OTHER,
40     SUBTYPE_GSM,
41     SUBTYPE_IDEN,
42     SUBTYPE_CDMA,
43     SUBTYPE_1XRTT,
44     SUBTYPE_GPRS,
45     SUBTYPE_EDGE,
46     SUBTYPE_UMTS,
47     SUBTYPE_EVDO_REV_0,
48     SUBTYPE_EVDO_REV_A,
49     SUBTYPE_HSPA,
50     SUBTYPE_EVDO_REV_B,
51     SUBTYPE_HSDPA,
52     SUBTYPE_HSUPA,
53     SUBTYPE_EHRPD,
54     SUBTYPE_HSPAP,
55     SUBTYPE_LTE,
56     SUBTYPE_LTE_ADVANCED,
57     SUBTYPE_BLUETOOTH_1_2,
58     SUBTYPE_BLUETOOTH_2_1,
59     SUBTYPE_BLUETOOTH_3_0,
60     SUBTYPE_BLUETOOTH_4_0,
61     SUBTYPE_ETHERNET,
62     SUBTYPE_FAST_ETHERNET,
63     SUBTYPE_GIGABIT_ETHERNET,
64     SUBTYPE_10_GIGABIT_ETHERNET,
65     SUBTYPE_WIFI_B,
66     SUBTYPE_WIFI_G,
67     SUBTYPE_WIFI_N,
68     SUBTYPE_WIFI_AC,
69     SUBTYPE_WIFI_AD,
70     SUBTYPE_LAST = SUBTYPE_WIFI_AD
71 };
72 
73 class NetConnCallback {
74 public:
75     virtual int32_t NetAvailable() = 0;
76     virtual int32_t NetCapabilitiesChange(const NetConnectType &netConnectType,
77                                           const NetConnectSubtype &netConnectSubtype) = 0;
78     virtual int32_t NetConnectionPropertiesChange() = 0;
79     virtual int32_t NetUnavailable() = 0;
80 };
81 
82 class NetConnectAdapter {
83 public:
84     NetConnectAdapter() = default;
85 
86     virtual ~NetConnectAdapter() = default;
87 
88     virtual int32_t RegisterNetConnCallback(std::shared_ptr<NetConnCallback> cb) = 0;
89 
90     virtual int32_t UnregisterNetConnCallback(std::shared_ptr<NetConnCallback> cb) = 0;
91 
92     virtual int32_t GetDefaultNetConnect(NetConnectType &type, NetConnectSubtype &netConnectSubtype) = 0;
93 };
94 }  // namespace OHOS::NWeb
95 
96 #endif  // NET_CONNECT_ADAPTER_H