• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 CELLULAR_DATA_CONSTANT_H
17 #define CELLULAR_DATA_CONSTANT_H
18 
19 #include <array>
20 #include <string>
21 #include <vector>
22 
23 #include "cellular_data_types.h"
24 
25 namespace OHOS {
26 namespace Telephony {
27 enum ApnProfileState {
28     PROFILE_STATE_IDLE,
29     PROFILE_STATE_CONNECTING,
30     PROFILE_STATE_CONNECTED,
31     PROFILE_STATE_DISCONNECTING,
32     PROFILE_STATE_FAILED,
33     PROFILE_STATE_RETRYING
34 };
35 
36 enum class RecoveryState : int32_t {
37     STATE_REQUEST_CONTEXT_LIST,
38     STATE_CLEANUP_CONNECTIONS,
39     STATE_REREGISTER_NETWORK,
40     STATE_RADIO_STATUS_RESTART
41 };
42 
43 struct AddressInfo {
44     std::string ip = "";
45     std::string netMask = "";
46     uint8_t type = 0;
47     uint8_t prefixLen = 0;
48 };
49 
50 struct RouteInfo {
51     std::string ip = "";
52     uint8_t type = 0;
53     std::string destination = "";
54 };
55 
56 struct NetSupplier {
57     uint32_t supplierId = 0;
58     uint64_t capability = 0;
59     int32_t slotId = 0;
60     int32_t simId = 0;
61 };
62 
63 struct NetRequest {
64     uint64_t capability = 0;
65     std::string ident = "";
66 };
67 
68 static const uint32_t DEFAULT_BANDWIDTH = 14;
69 struct LinkBandwidthInfo {
70     uint32_t upBandwidth = DEFAULT_BANDWIDTH;
71     uint32_t downBandwidth = DEFAULT_BANDWIDTH;
72 };
73 
CellularDataStateAdapter(ApnProfileState state)74 constexpr int32_t CellularDataStateAdapter(ApnProfileState state)
75 {
76     switch (state) {
77         case PROFILE_STATE_CONNECTING:
78             return static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTING);
79         case PROFILE_STATE_CONNECTED:
80             [[fallthrough]]; // fall_through
81         case PROFILE_STATE_DISCONNECTING:
82             return static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED);
83         case PROFILE_STATE_FAILED:
84             [[fallthrough]]; // fall_through
85         case PROFILE_STATE_RETRYING:
86             [[fallthrough]]; // fall_through
87         case PROFILE_STATE_IDLE:
88             return static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED);
89         default:
90             return static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED);
91     }
92 }
93 
WrapCellularDataState(const int32_t cellularDataState)94 constexpr int32_t WrapCellularDataState(const int32_t cellularDataState)
95 {
96     switch (cellularDataState) {
97         case static_cast<int32_t>(DataConnectionStatus::DATA_STATE_DISCONNECTED): {
98             return static_cast<int32_t>(DataConnectState::DATA_STATE_DISCONNECTED);
99         }
100         case static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTING): {
101             return static_cast<int32_t>(DataConnectState::DATA_STATE_CONNECTING);
102         }
103         case static_cast<int32_t>(DataConnectionStatus::DATA_STATE_CONNECTED): {
104             return static_cast<int32_t>(DataConnectState::DATA_STATE_CONNECTED);
105         }
106         case static_cast<int32_t>(DataConnectionStatus::DATA_STATE_SUSPENDED): {
107             return static_cast<int32_t>(DataConnectState::DATA_STATE_SUSPENDED);
108         }
109         default: {
110             return static_cast<int32_t>(DataConnectState::DATA_STATE_UNKNOWN);
111         }
112     }
113 }
114 
115 enum DataContextRolesId {
116     DATA_CONTEXT_ROLE_INVALID_ID = -1,
117     DATA_CONTEXT_ROLE_ALL_ID = 0,
118     DATA_CONTEXT_ROLE_DEFAULT_ID = 1,
119     DATA_CONTEXT_ROLE_MMS_ID = 2,
120     DATA_CONTEXT_ROLE_SUPL_ID = 3,
121     DATA_CONTEXT_ROLE_DUN_ID = 4,
122     DATA_CONTEXT_ROLE_IMS_ID = 5,
123     DATA_CONTEXT_ROLE_IA_ID = 6,
124     DATA_CONTEXT_ROLE_EMERGENCY_ID = 7
125 };
126 
127 enum class DataContextPriority : int32_t { PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_HIGH };
128 
129 enum TelCallStatus {
130     CALL_STATUS_UNKNOWN = -1,
131     CALL_STATUS_ACTIVE = 0,
132     CALL_STATUS_HOLDING = 1,
133     CALL_STATUS_DIALING = 2,
134     CALL_STATUS_ALERTING = 3,
135     CALL_STATUS_INCOMING = 4,
136     CALL_STATUS_WAITING = 5,
137     CALL_STATUS_DISCONNECTED = 6,
138     CALL_STATUS_DISCONNECTING = 7,
139     CALL_STATUS_IDLE = 8,
140 };
141 
142 enum class DisConnectionReason : int32_t {
143     REASON_NORMAL,
144     REASON_GSM_AND_CALLING_ONLY,
145     REASON_RETRY_CONNECTION,
146     REASON_CLEAR_CONNECTION,
147     REASON_CHANGE_CONNECTION
148 };
149 
150 static constexpr const char *DATA_CONTEXT_ROLE_ALL = "*";
151 static constexpr const char *DATA_CONTEXT_ROLE_DEFAULT = "default";
152 static constexpr const char *DATA_CONTEXT_ROLE_MMS = "mms";
153 static constexpr const char *DATA_CONTEXT_ROLE_SUPL = "supl";
154 static constexpr const char *DATA_CONTEXT_ROLE_DUN = "dun";
155 static constexpr const char *DATA_CONTEXT_ROLE_IMS = "ims";
156 static constexpr const char *DATA_CONTEXT_ROLE_IA = "ia";
157 static constexpr const char *DATA_CONTEXT_ROLE_EMERGENCY = "emergency";
158 static const int32_t DATA_PROFILE_DEFAULT = 0;
159 static const int32_t DATA_PROFILE_MMS = 1;
160 static const int32_t CMCC_MCC_MNC = 46002;
161 static const int32_t DEFAULT_AUTH_TYPE = 0;
162 static const int32_t DEFAULT_MTU = 1500;
163 static const uint8_t DEFAULT_STRENGTH = 20;
164 static const uint32_t DEFAULT_FREQUENCY = 50;
165 static const int64_t CORE_INIT_DELAY_TIME = 1000;
166 static const int32_t MASK_BYTE_BIT = 8;
167 static const int32_t IPV4_BIT = 32;
168 static const int32_t IPV6_BIT = 128;
169 static const int32_t MIN_IPV6_ITEM = 16;
170 static const int32_t MAX_IPV4_ITEM = 8;
171 static const int32_t MIN_IPV4_ITEM = 4;
172 static constexpr const char *DEFAULT_OPERATOR_NUMERIC = "46001";
173 static constexpr const char *DATA_METERED_CONTEXT_ROLES = "default";
174 static constexpr const char *IS_CELLULAR_DATA_ENABLE = "isCellularDataEnable";
175 static constexpr const char *IS_ROAMING = "isRoaming";
176 static constexpr const char *SETTING_SWITCH = "settingSwitch";
177 static constexpr const char *IDENT_PREFIX = "simId";
178 static constexpr const char *DEFAULT_HOSTNAME = "";
179 static constexpr const char *DEFAULT_MASK = "";
180 static constexpr const char *CELLULAR_DATA_RDB_URI = "datashare:///com.ohos.pdpprofileability";
181 static constexpr const char *CELLULAR_DATA_RDB_SELECTION = "datashare:///com.ohos.pdpprofileability/net/pdp_profile";
182 static constexpr const char *CELLULAR_DATA_RDB_RESET = "datashare:///com.ohos.pdpprofileability/net/pdp_profile/reset";
183 static constexpr const char *CELLULAR_DATA_RDB_PREFER =
184     "datashare:///com.ohos.pdpprofileability/net/pdp_profile/preferapn";
185 static constexpr const char *CELLULAR_DATA_SETTING_URI =
186     "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true";
187 static constexpr const char *CELLULAR_DATA_SETTING_DATA_ENABLE_URI =
188     "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=cellular_data_enable";
189 static constexpr const char *CELLULAR_DATA_SETTING_DATA_ROAMING_URI =
190     "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=cellular_data_roaming_enable";
191 static constexpr const char *CELLULAR_DATA_SETTING_DATA_INCALL_URI =
192     "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=cellular_data_incall_enable";
193 static constexpr const char *CELLULAR_DATA_SETTING_INTELLIGENCE_SWITCH_URI =
194     "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?"
195     "Proxy=true&key=intelligence_card_switch_enable";
196 static const int32_t DEFAULT_NET_STATISTICS_PERIOD = 3 * 1000;
197 static const int32_t DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS_DEFAULT = 1000 * 60 * 10;
198 static const int32_t DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS_DEFAULT = 1000 * 10;
199 static const int32_t ESTABLISH_DATA_CONNECTION_DELAY = 1 * 1000;
200 static const int32_t CONNECTION_DISCONNECTION_TIMEOUT = 120 * 1000;
201 static const int32_t RECOVERY_TRIGGER_PACKET = 10;
202 static const int32_t ERROR_APN_ID = -1;
203 static const int32_t VALID_IP_SIZE = 2;
204 static const int32_t TYPE_REQUEST_NET = 1;
205 static const int32_t TYPE_RELEASE_NET = 0;
206 static const int32_t DEFAULT_READ_APN_TIME = 2;
207 static const int32_t DEFAULT_MCC_SIZE = 3;
208 static const int32_t NULL_POINTER_EXCEPTION = -1;
209 static const int32_t PATH_PARAMETER_SIZE = 128;
210 static constexpr const char *ROUTED_IPV4 = "0.0.0.0";
211 static constexpr const char *ROUTED_IPV6 = "::";
212 static constexpr const char *CONFIG_DOWNLINK_THRESHOLDS = "persist.sys.data.downlink";
213 static constexpr const char *CONFIG_UPLINK_THRESHOLDS = "persist.sys.data.uplink";
214 static constexpr const char *CONFIG_TCP_BUFFER = "persist.sys.data.tcpbuffer";
215 static constexpr const char *CONFIG_PREFERAPN = "persist.sys.data.preferapn";
216 static constexpr const char *CONFIG_MOBILE_MTU = "persist.sys.data.mobilemtu";
217 static constexpr const char *CONFIG_DATA_SERVICE_EXT_PATH = "persist.sys.data.dataextpath";
218 static constexpr const char *CONFIG_MULTIPLE_CONNECTIONS = "persist.sys.data.multiple.connections";
219 static constexpr const char *CAPACITY_THRESHOLDS_FOR_DOWNLINK = "100,500,1000,5000,10000,20000,50000,75000,"
220                                                                 "100000,200000,500000,1000000,1500000,2000000";
221 static constexpr const char *CAPACITY_THRESHOLDS_FOR_UPLINK = "100,500,1000,5000,10000,20000,50000,75000,"
222                                                               "100000,200000,500000";
223 static constexpr const char *DEFAULT_TCP_BUFFER_CONFIG = "UMTS:58254,349525,1048576,58254,349525,1048576;"
224                                                          "HSPA:40778,244668,734003,16777,100663,301990;"
225                                                          "HSUPA:131072,262144,2441216,4096,16384,399360;"
226                                                          "HSDPA:61167,367002,1101005,8738,52429,262114;"
227                                                          "HSPAP:122334,734003,2202010,32040,192239,576717;"
228                                                          "EDGE:4093,26280,70800,4096,16384,70800;"
229                                                          "eHRPD:131072,262144,1048576,4096,16384,524288;"
230                                                          "1xRTT:16384,32768,131072,4096,16384,102400;"
231                                                          "GPRS:4092,8760,48000,4096,8760,48000;"
232                                                          "EVDO:4094,87380,262144,4096,16384,262144;"
233                                                          "LTE:524288,4194304,8388608,262144,524288,1048576;"
234                                                          "NR:2097152,6291456,16777216,512000,2097152,8388608;"
235                                                          "LTE_CA:4096,6291456,12582912,4096,1048576,2097152";
236 constexpr const char *DEFAULT_BANDWIDTH_CONFIG =
237     "GPRS:24,24;EDGE:70,18;UMTS:115,115;CDMA-IS95A:14,14;"
238     "CDMA-IS95B:14,14;1xRTT:30,30;EvDo-rev.0:750,48;EvDo-rev.A:950,550;HSDPA:4300,620;"
239     "HSUPA:4300,1800;HSPA:4300,1800;EvDo-rev.B:1500,550;eHRPD:750,48;HSPAP:13000,3400;"
240     "TD-SCDMA:115,115;LTE:30000,15000;NR_NSA:47000,18000;NR_NSA_MMWAVE:145000,60000;"
241     "NR_SA:145000,60000";
242 static constexpr const char *DEFAULT_PREFER_APN = "1";
243 static constexpr const char *DEFAULT_MOBILE_MTU = "1500";
244 static constexpr const char *DEFAULT_MULTIPLE_CONNECTIONS = "1";
245 static const int MAX_BUFFER_SIZE = 1024;
246 static const int MIN_BUFFER_SIZE = 5;
247 static const int UP_DOWN_LINK_SIZE = 100;
248 static const int32_t VALID_VECTOR_SIZE = 2;
249 static const int32_t DELAY_SET_RIL_BANDWIDTH_MS = 3000;
250 static const int32_t DELAY_SET_RIL_UP_DOWN_BANDWIDTH_MS = 50;
251 static constexpr const char *CELLULAR_DATA_COLUMN_ENABLE = "cellular_data_enable";
252 static constexpr const char *CELLULAR_DATA_COLUMN_ROAMING = "cellular_data_roaming_enable";
253 static constexpr const char *CELLULAR_DATA_COLUMN_INCALL = "cellular_data_incall_enable";
254 static constexpr const char *INTELLIGENCE_SWITCH_COLUMN_ENABLE = "intelligence_card_switch_enable";
255 static constexpr const char *CELLULAR_DATA_COLUMN_KEYWORD = "KEYWORD";
256 static constexpr const char *CELLULAR_DATA_COLUMN_VALUE = "VALUE";
257 static const int32_t INVALID_SIM_ID = 0;
258 static const int32_t INVALID_SLOT_ID = -1;
259 } // namespace Telephony
260 } // namespace OHOS
261 #endif // CELLULAR_DATA_CONSTANT_H
262