• 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 IntelligenceSwitchCode : int32_t {
45     INTELLIGENCE_SWITCH_DISABLED = 0,
46     INTELLIGENCE_SWITCH_ENABLED = 1
47 };
48 
49 enum class RoamingSwitchCode : int32_t {
50     CELLULAR_DATA_ROAMING_DISABLED = 0,
51     CELLULAR_DATA_ROAMING_ENABLED = 1
52 };
53 
54 enum class DataRespondCode : int32_t {
55     SET_FAILED = 0,
56     SET_SUCCESS = 1
57 };
58 
59 enum class RequestNetCode : int32_t {
60     REQUEST_FAILED = 0,
61     REQUEST_SUCCESS = 1
62 };
63 
64 enum class DataConnectState : int32_t {
65     /**
66      * Indicates that a cellular data link is unknown.
67      */
68     DATA_STATE_UNKNOWN = -1,
69 
70     /**
71      * Indicates that a cellular data link is disconnected.
72      */
73     DATA_STATE_DISCONNECTED = 0,
74 
75     /**
76      * Indicates that a cellular data link is being connected.
77      */
78     DATA_STATE_CONNECTING = 1,
79 
80     /**
81      * Indicates that a cellular data link is connected.
82      */
83     DATA_STATE_CONNECTED = 2,
84 
85     /**
86      * Indicates that a cellular data link is suspended.
87      */
88     DATA_STATE_SUSPENDED = 3
89 };
90 
91 struct ApnInfo : public Parcelable {
92     std::u16string apnName = u"";
93     std::u16string apn = u"";
94     std::u16string mcc = u"";
95     std::u16string mnc = u"";
96     std::u16string user = u"";
97     std::u16string type = u"";
98     std::u16string proxy = u"";
99     std::u16string mmsproxy = u"";
100 
MarshallingApnInfo101     bool Marshalling(Parcel &parcel) const
102     {
103         if (!parcel.WriteString16(apnName)) {
104             return false;
105         }
106         if (!parcel.WriteString16(apn)) {
107             return false;
108         }
109         if (!parcel.WriteString16(mcc)) {
110             return false;
111         }
112         if (!parcel.WriteString16(mnc)) {
113             return false;
114         }
115         if (!parcel.WriteString16(user)) {
116             return false;
117         }
118         if (!parcel.WriteString16(type)) {
119             return false;
120         }
121         if (!parcel.WriteString16(proxy)) {
122             return false;
123         }
124         if (!parcel.WriteString16(mmsproxy)) {
125             return false;
126         }
127         return true;
128     };
129 
UnMarshallingApnInfo130     std::shared_ptr<ApnInfo> UnMarshalling(Parcel &parcel)
131     {
132         std::shared_ptr<ApnInfo> param = std::make_shared<ApnInfo>();
133         if (param == nullptr || !param->ReadFromParcel(parcel)) {
134             param = nullptr;
135         }
136         return param;
137     };
138 
ReadFromParcelApnInfo139     bool ReadFromParcel(Parcel &parcel)
140     {
141         parcel.ReadString16(apnName);
142         parcel.ReadString16(apn);
143         parcel.ReadString16(mcc);
144         parcel.ReadString16(mnc);
145         parcel.ReadString16(user);
146         parcel.ReadString16(type);
147         parcel.ReadString16(proxy);
148         parcel.ReadString16(mmsproxy);
149         return true;
150     };
151 };
152 } // namespace Telephony
153 } // namespace OHOS
154 #endif // CELLULAR_DATA_TYPES_H