• 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_TYPES_H
17 #define CELLULAR_DATA_TYPES_H
18 
19 #include <cstdint>
20 #include <parcel.h>
21 
22 namespace OHOS {
23 namespace Telephony {
24 enum class DataConnectionStatus : int32_t {
25     DATA_STATE_DISCONNECTED = 11,
26     DATA_STATE_CONNECTING = 12,
27     DATA_STATE_CONNECTED = 13,
28     DATA_STATE_SUSPENDED = 14
29 };
30 
31 enum class CellDataFlowType : int32_t {
32     DATA_FLOW_TYPE_NONE = 0,
33     DATA_FLOW_TYPE_DOWN = 1,
34     DATA_FLOW_TYPE_UP = 2,
35     DATA_FLOW_TYPE_UP_DOWN = 3,
36     DATA_FLOW_TYPE_DORMANT = 4
37 };
38 
39 enum class DataSwitchCode : int32_t {
40     CELLULAR_DATA_DISABLED = 0,
41     CELLULAR_DATA_ENABLED = 1
42 };
43 
44 enum class DataSimDetectedCode : int32_t {
45     SIM_DETECTED_DISABLED = 0,
46     SIM_DETECTED_ENABLED = 1
47 };
48 
49 enum class IntelligenceSwitchCode : int32_t {
50     INTELLIGENCE_SWITCH_DISABLED = 0,
51     INTELLIGENCE_SWITCH_ENABLED = 1
52 };
53 
54 enum class RoamingSwitchCode : int32_t {
55     CELLULAR_DATA_ROAMING_DISABLED = 0,
56     CELLULAR_DATA_ROAMING_ENABLED = 1
57 };
58 
59 enum class DataRespondCode : int32_t {
60     SET_FAILED = 0,
61     SET_SUCCESS = 1
62 };
63 
64 enum class RequestNetCode : int32_t {
65     REQUEST_FAILED = 0,
66     REQUEST_SUCCESS = 1
67 };
68 
69 enum class DataConnectState : int32_t {
70     /**
71      * Indicates that a cellular data link is unknown.
72      */
73     DATA_STATE_UNKNOWN = -1,
74 
75     /**
76      * Indicates that a cellular data link is disconnected.
77      */
78     DATA_STATE_DISCONNECTED = 0,
79 
80     /**
81      * Indicates that a cellular data link is being connected.
82      */
83     DATA_STATE_CONNECTING = 1,
84 
85     /**
86      * Indicates that a cellular data link is connected.
87      */
88     DATA_STATE_CONNECTED = 2,
89 
90     /**
91      * Indicates that a cellular data link is suspended.
92      */
93     DATA_STATE_SUSPENDED = 3
94 };
95 
96 struct ApnInfo : public Parcelable {
97     std::u16string apnName = u"";
98     std::u16string apn = u"";
99     std::u16string mcc = u"";
100     std::u16string mnc = u"";
101     std::u16string user = u"";
102     std::u16string type = u"";
103     std::u16string proxy = u"";
104     std::u16string mmsproxy = u"";
105 
MarshallingApnInfo106     bool Marshalling(Parcel &parcel) const
107     {
108         if (!parcel.WriteString16(apnName)) {
109             return false;
110         }
111         if (!parcel.WriteString16(apn)) {
112             return false;
113         }
114         if (!parcel.WriteString16(mcc)) {
115             return false;
116         }
117         if (!parcel.WriteString16(mnc)) {
118             return false;
119         }
120         if (!parcel.WriteString16(user)) {
121             return false;
122         }
123         if (!parcel.WriteString16(type)) {
124             return false;
125         }
126         if (!parcel.WriteString16(proxy)) {
127             return false;
128         }
129         if (!parcel.WriteString16(mmsproxy)) {
130             return false;
131         }
132         return true;
133     };
134 
UnmarshallingApnInfo135     static ApnInfo* Unmarshalling(Parcel &parcel)
136     {
137         std::unique_ptr<ApnInfo> param = std::make_unique<ApnInfo>();
138         if (!param->ReadFromParcel(parcel)) {
139             return nullptr;
140         }
141         return param.release();
142     };
143 
ReadFromParcelApnInfo144     bool ReadFromParcel(Parcel &parcel)
145     {
146         if (!parcel.ReadString16(apnName)) {
147             return false;
148         }
149         if (!parcel.ReadString16(apn)) {
150             return false;
151         }
152         if (!parcel.ReadString16(mcc)) {
153             return false;
154         }
155         if (!parcel.ReadString16(mnc)) {
156             return false;
157         }
158         if (!parcel.ReadString16(user)) {
159             return false;
160         }
161         if (!parcel.ReadString16(type)) {
162             return false;
163         }
164         if (!parcel.ReadString16(proxy)) {
165             return false;
166         }
167         if (!parcel.ReadString16(mmsproxy)) {
168             return false;
169         }
170         return true;
171     };
172 };
173 } // namespace Telephony
174 } // namespace OHOS
175 #endif // CELLULAR_DATA_TYPES_H