• 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 OHOS_RIL_SIM_PARCEL_H
17 #define OHOS_RIL_SIM_PARCEL_H
18 
19 #include "hril_base_parcel.h"
20 
21 namespace OHOS {
22 namespace Telephony {
23 /**
24  * @brief Defines the SIM card status information.
25  */
26 struct CardStatusInfo {
27     /** SIM card index. */
28     int32_t index = 0;
29 
30     /**
31      * SIM card type:
32      * 0: unknown.
33      * 1: common SIM card.
34      * 2: USIM, supporting 4G.
35      */
36     int32_t simType = 0;
37 
38     /**
39      * SIM card status:
40      * 1: unknown
41      * 0: SIM card not inserted
42      * 1: SIM card detected normally
43      * 2: PIN required
44      * 3: PUK required
45      * 4: PIN2 required
46      * 5: PUK2 required
47      */
48     int32_t simState = 0;
49 };
50 
51 /**
52  * @brief Defines the SIM data request information in 3GPP TS 27.007 V4.3.0
53  * (2001-12) 8.18, + CRSM.
54  */
55 struct SimIoRequestInfo {
56     /** Command passed on by the ME to the SIM; refer GSM 51.011 [28] */
57     int32_t command = 0;
58 
59     /**
60      * This is the identifier of an elementary datafile on SIM.
61      * Mandatory for every command except STATUS
62      */
63     int32_t fileId = 0;
64 
65     /**
66      * Parameters passed on by the MT to the SIM.
67      * These parameters are mandatory for every command,
68      * except GET RESPONSE and STATUS.
69      * The values are described in 3GPP TS 51.011 [28]
70      */
71     int32_t p1 = 0;
72     int32_t p2 = 0;
73     int32_t p3 = 0;
74 
75     /**
76      * Information which shall be written to the SIM(hexadecimal character
77      * format; refer +CSCS).
78      */
79     std::string data = "";
80 
81     /**
82      * Contains the path of an elementary file on the SIM/UICC in hexadecimal
83      * format as defined in ETSI TS 102 221 [60] (e.g. "7F205F70" in SIM and
84      * UICC case). The <pathid> shall only be used in the mode "select by path
85      * from MF" as defined in  ETSI TS 102 221 [60].
86      */
87     std::string path = "";
88 
89     /** Request serial number. */
90     int32_t serial = 0;
91 
92     /** PIN2 */
93     std::string pin2 = "";
94 
95     /** App ID. */
96     std::string aid = "";
97 };
98 
99 /**
100  * @brief Defines the response to the SIM data request in 3GPP TS 27.007 V4.3.0
101  * (2001-12) 8.18, + CRSM.
102  */
103 struct IccIoResultInfo {
104     /**
105      * Information from the SIM about the execution of the actual command.
106      * These parameters are delivered to the TE in both cases, on successful or
107      * failed execution of the command
108      */
109     int32_t sw1 = 0;
110     int32_t sw2 = 0;
111 
112     /** Response information */
113     std::string response = "";
114 };
115 
116 /**
117  * @brief Defines the SIM card lock information.
118  */
119 struct SimLockInfo {
120     /** Request serial number. */
121     int32_t serial = 0;
122 
123     /**
124      * String type, which specifies the object operated by this command.
125      * "SC": SIM PIN1;
126      * "AO": prohibit all outgoing calls;
127      * "OI": All international outgoing calls are prohibited;
128      * "OX": All international outgoing calls are prohibited, except for the country of origin;
129      * "AI": All incoming calls are prohibited;
130      * "IR": When roaming outside the home area, all incoming calls are prohibited;
131      * "AB": prohibit all services (applicable only when <mode>=0);
132      * "AG": Outgoing call is prohibited (applicable only when <mode>=0);
133      * "AC": Incoming calls are prohibited (applicable only when <mode>=0);
134      * "FD": FDN;
135      * "PN": lock the network;
136      * "PU": lock subnet;
137      * "PP": Lock SP.
138      */
139     std::string fac = "";
140 
141     /**
142      * Mode:
143      * 0: deactivation (When fac is set to PN, PU, or PP, the operation is equivalent to unlocking.)
144      * 1: activation (When fac is set to PN, PU, or PP, activation is not supported.)
145      * 2: query
146      */
147     int32_t mode = 0;
148 
149     /**
150      * SIM card lock status.
151      * It indicates the activation status of the first three layers of locks when fac is set to PN, PU, or PP.
152      * 0: not activated
153      * 1: activated
154      */
155     int32_t status = 0;
156 
157     /** Password text */
158     std::string passwd = "";
159 
160     /**
161      * Service type. The value is the sum of integers that represent the service type. The default value is 255.
162      * 1: telephony service
163      * 2: data service
164      * 4: fax service
165      * 8: SMS service
166      * 16: data circuit sync
167      * 32: data circuit async
168      * 64: dedicated packet access
169      * 128: dedicated portable device (PAD) access
170      */
171     int32_t classx = 0;
172 };
173 
174 /**
175  * @brief Defines the SIM card password information.
176  */
177 struct SimPasswordInfo {
178     /** Request serial number. */
179     int32_t serial = 0;
180 
181     /**
182      * String type, which specifies the object operated by this command.
183      * “SC”:SIM PIN1;
184      * “P2”:SIM PIN2;
185      * "OI": All international outgoing calls are prohibited;
186      * "OX": All international outgoing calls are prohibited, except for the country of origin;
187      * "AI": All incoming calls are prohibited;
188      * "IR": When roaming outside the home area, all incoming calls are prohibited;
189      * "AB": prohibit all services (applicable only when <mode>=0);
190      * "AG": Outgoing call is prohibited (applicable only when <mode>=0);
191      * "AC": Incoming call service is prohibited (applicable only when <mode>=0).
192      */
193     std::string fac = "";
194 
195     /** Old password text */
196     std::string oldPassword = "";
197 
198     /** New password text */
199     std::string newPassword = "";
200 
201     /** Max length of oldPassword or newPassword */
202     int32_t passwordLength = 0;
203 };
204 
205 /**
206  * @brief Defines the maximum number of SIM password attempts.
207  */
208 struct SimPinInputTimes {
209     /** Request serial number. */
210     int32_t serial = 0;
211 
212     /**
213      * Param of string.
214      * SIM PIN2 is mean that SIM PIN2 request. SIM PUK2 is mean that SIM PUK2
215      * request.
216      */
217     std::string code = "";
218 
219     /**
220      * The remaining number of entries, for PIN2, the maximum number of entries is 3 times;
221      * for PUK2, the maximum number of entries is 10 times.
222      */
223     int32_t times = 0;
224 
225     /**
226      * The remaining number of PUK, the maximum number of entries is 10 times.
227      */
228     int32_t pukTimes = 0;
229 
230     /**
231      * The remaining number of PIN, the maximum number of entries is 3 times.
232      */
233     int32_t pinTimes = 0;
234 
235     /**
236      * The remaining number of PUK2, the maximum number of entries is 10
237      * times.
238      */
239     int32_t puk2Times = 0;
240 
241     /**
242      * The remaining number of PIN2, the maximum number of entries is 3 times.
243      */
244     int32_t pin2Times = 0;
245 };
246 
247 /**
248  * @brief Defines the APDU data transmission request information.
249  */
250 struct ApduSimIORequestInfo {
251     /** Request serial number. */
252     int32_t serial = 0;
253 
254     /** Channel ID */
255     int32_t channelId = 0;
256 
257     /** APDU instruction type. For details, see ETSI 102 221 [55]. */
258     int32_t type = 0;
259 
260     /** APDU instruction. For details, see ETSI 102 221 [55]. */
261     int32_t instruction = 0;
262 
263     /**
264      * Command parameter 1 of the SIM data request. For details, see 3GPP
265      * TS 51.011[28].
266      */
267     int32_t p1 = 0;
268 
269     /**
270      * Command parameter 2 of the SIM data request. For details, see 3GPP
271      * TS 51.011[28].
272      */
273     int32_t p2 = 0;
274 
275     /**
276      * Command parameter 3 of the SIM data request. For details, see 3GPP
277      * TS 51.011[28]. If p3 is a negative value, a 4-byte APDU is sent to the
278      * SIM card.
279      */
280     int32_t p3 = 0;
281 
282     /** Data to be transmitted */
283     std::string data = "";
284 };
285 
286 /**
287  * @brief Defines the SIM card authentication request information.
288  */
289 struct SimAuthenticationRequestInfo {
290     /** Request serial number. */
291     int32_t serial = 0;
292 
293     /** App ID */
294     std::string aid = "";
295 
296     /** Authentication data */
297     std::string authData = "";
298 };
299 
300 /**
301  * @brief Defines the response to the request for enabling the logical channel of the APDU.
302  */
303 struct OpenLogicalChannelResponse {
304     /**
305      * Information from the SIM about the execution of the actual command.
306      * These parameters are delivered to the TE in both cases, on successful or
307      * failed execution of the command
308      */
309     int32_t sw1 = 0;
310 
311     /**
312      * Status word 2 of the SIM card, which is returned by the SIM card after
313      * command execution.
314      */
315     int32_t sw2 = 0;
316 
317     /** ID of the opened logical channel */
318     int32_t channelId = 0;
319 
320     /** Response information */
321     std::string response = "";
322 };
323 
324 /**
325  * @brief Defines the response to the request for unlocking the SIM card.
326  */
327 struct LockStatusResp {
328     /** Query result. For details, see {@link RilErrType}. */
329     int32_t result = 0;
330 
331     /** Number of remaining attempts */
332     int32_t remain = 0;
333 };
334 } // namespace Telephony
335 } // namespace OHOS
336 #endif // OHOS_RIL_SIM_PARCEL_H