• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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_ESIM_STATE_TYPE_H
17 #define OHOS_ESIM_STATE_TYPE_H
18 
19 #include <map>
20 #include <parcel.h>
21 #include <string>
22 #include <vector>
23 
24 namespace OHOS {
25 namespace Telephony {
26 /**
27  * @brief Esim Result code.
28  */
29 enum class EsimResultCode {
30     RESULT_SOLVABLE_ERRORS = -2,
31     RESULT_MUST_DISABLE_PROFILE = -1,
32     RESULT_OK = 0,
33     RESULT_GET_EID_FAILED = 201,
34     RESULT_ACTIVATION_CODE_CHANGED = 203,
35     RESULT_ACTIVATION_CODE_INVALID = 204,
36     RESULT_SMDP_ADDRESS_INVALID = 205,
37     RESULT_EUICC_INFO_INVALID = 206,
38     RESULT_TLS_HANDSHAKE_FAILED = 207,
39     RESULT_CERTIFICATE_IO_ERROR = 208,
40     RESULT_CERTIFICATE_RESPONSE_TIMEOUT = 209,
41     RESULT_AUTHENTICATION_FAILED = 210,
42     RESULT_RESPONSE_HTTP_FAILED = 211,
43     RESULT_CONFIRMATION_CODE_INCORRECT = 212,
44     RESULT_EXCEEDED_CONFIRMATION_CODE_TRY_LIMIT = 213,
45     RESULT_NO_PROFILE_ON_SERVER = 214,
46     RESULT_TRANSACTION_ID_INVALID = 215,
47     RESULT_SERVER_ADDRESS_INVALID = 216,
48     RESULT_GET_BOUND_PROFILE_PACKAGE_FAILED = 217,
49     RESULT_USER_CANCEL_DOWNLOAD = 218,
50     RESULT_SERVER_UNAVAILABLE = 220,
51     RESULT_PROFILE_NON_DELETE = 223,
52     RESULT_SMDP_ADDRESS_INCORRECT = 226,
53     RESULT_ANALYZE_AUTHENTICATION_SERVER_RESPONSE_FAILED = 228,
54     RESULT_ANALYZE_AUTHENTICATION_CLIENT_RESPONSE_FAILED = 229,
55     RESULT_ANALYZE_AUTHENTICATION_CLIENT_MATCHING_ID_REFUSED = 231,
56     RESULT_PROFILE_TYPE_ERROR_AUTHENTICATION_STOPPED = 233,
57     RESULT_CARRIER_SERVER_REFUSED_ERRORS = 249,
58     RESULT_CERTIFICATE_INVALID = 251,
59     RESULT_OUT_OF_MEMORY = 263,
60     RESULT_PPR_FORBIDDEN = 268,
61     RESULT_NOTHING_TO_DELETE = 270,
62     RESULT_PPR_NOT_MATCH = 276,
63     RESULT_CAT_BUSY = 283,
64     RESULT_PROFILE_EID_INVALID = 284,
65     RESULT_INVALID_BPP = 285,
66     RESULT_DOWNLOAD_TIMEOUT = 287,
67     RESULT_SECURE_ESIM_CN_SCAN_OVERSEA_PROFILE = 301,
68     RESULT_SECURE_ESIM_OVERSEA_SCAN_CN_PROFILE = 302,
69     RESULT_SGP_22_OTHER = 400,
70 };
71 
72 /**
73  * @brief Inner result code.
74  */
75 enum class ResultInnerCode {
76     RESULT_EUICC_CARD_OK = 0,
77     RESULT_EUICC_CARD_DEFALUT_ERROR = 10000,
78     RESULT_EUICC_CARD_CHANNEL_IN_USE = 10001,
79     RESULT_EUICC_CARD_CHANNEL_OPEN_FAILED = 10002,
80     RESULT_EUICC_CARD_CHANNEL_OTHER_AID = 10003,
81     RESULT_EUICC_CARD_CHANNEL_CLOSE_FAILED = 10004,
82     RESULT_EUICC_CARD_CHANNEL_AID_EMPTY = 10005,
83     RESULT_EUICC_CARD_DATA_PROCESS_ERROR = 10006,
84     RESULT_EUICC_CARD_WAIT_TIMEOUT = 10007,
85 };
86 
87 /**
88  * @brief Euicc OTA update status.
89  */
90 enum class OsuStatus {
91     EUICC_UPGRADE_IN_PROGRESS = 1,
92     EUICC_UPGRADE_FAILED = 2,
93     EUICC_UPGRADE_SUCCESSFUL = 3,
94     EUICC_UPGRADE_ALREADY_LATEST = 4,
95     EUICC_UPGRADE_SERVICE_UNAVAILABLE = 5,
96 };
97 
98 /**
99  * @brief Reason for canceling a profile download session.
100  */
101 enum class CancelReason {
102     CANCEL_REASON_END_USER_REJECTION = 0,
103     CANCEL_REASON_POSTPONED = 1,
104     CANCEL_REASON_TIMEOUT = 2,
105     CANCEL_REASON_PPR_NOT_ALLOWED = 3,
106     CANCEL_REASON_METADATA_MISMATCH = 4,
107     CANCEL_REASON_LOAD_BPP_EXECUTION_ERROR = 5,
108     CANCEL_REASON_UNDEFINED_REASON = 127,
109 };
110 
111 /**
112  * @brief Options for resetting eUICC memory.
113  */
114 enum class ResetOption {
115     DELETE_OPERATIONAL_PROFILES = 1,
116     DELETE_FIELD_LOADED_TEST_PROFILES = 1 << 1,
117     RESET_DEFAULT_SMDP_ADDRESS = 1 << 2,
118 };
119 
120 /**
121  * @brief The profile state.
122  */
123 enum class ProfileState {
124     PROFILE_STATE_UNSPECIFIED = -1,
125     PROFILE_STATE_DISABLED = 0,
126     PROFILE_STATE_ENABLED = 1,
127 };
128 
129 /**
130  * @brief Profile class for the profile.
131  */
132 enum class ProfileClass {
133     PROFILE_CLASS_UNSPECIFIED = -1,
134     PROFILE_CLASS_TEST = 0,
135     PROFILE_CLASS_PROVISIONING = 1,
136     PROFILE_CLASS_OPERATIONAL = 2,
137 };
138 
139 /**
140  * @brief The policy rules of the profile.
141  */
142 enum class PolicyRules {
143     POLICY_RULE_UNSPECIFIED = -1,
144     POLICY_RULE_DISABLE_NOT_ALLOWED = 1,
145     POLICY_RULE_DELETE_NOT_ALLOWED = 1 << 1,
146     POLICY_RULE_DISABLE_AND_DELETE = 1 << 2,
147 };
148 
149 /**
150  * @brief The bit map of resolvable errors.
151  */
152 enum class SolvableErrors {
153     SOLVABLE_ERROR_NEED_CONFIRMATION_CODE = 1 << 0,
154     SOLVABLE_ERROR_NEED_POLICY_RULE = 1 << 1,
155 };
156 
157 /**
158  * @brief Describes the UICC access rule according to the GlobalPlatform Secure Element Access Control specification.
159  */
160 struct AccessRule {
161     std::u16string certificateHashHexStr_ = u"";
162     std::u16string packageName_ = u"";
163     int32_t accessType_ = 0;
164 };
165 
166 /**
167  * @brief Information about the eUICC chip/device.
168  */
169 struct OperatorId {
170     std::u16string mcc_ = u"";
171     std::u16string mnc_ = u"";
172     std::u16string gid1_ = u"";
173     std::u16string gid2_ = u"";
174 };
175 
176 /**
177  * @brief Information about an embedded profile (subscription) on an eUICC.
178  */
179 struct EuiccProfile {
180     std::u16string iccId_ = u"";
181     std::u16string nickName_ = u"";
182     std::u16string serviceProviderName_ = u"";
183     std::u16string profileName_ = u"";
184     ProfileState state_ = ProfileState::PROFILE_STATE_UNSPECIFIED;
185     ProfileClass profileClass_ = ProfileClass::PROFILE_CLASS_UNSPECIFIED;
186     OperatorId carrierId_;
187     PolicyRules policyRules_ = PolicyRules::POLICY_RULE_UNSPECIFIED;
188     std::vector<AccessRule> accessRules_{};
189 };
190 
191 /**
192  * @brief Information about the eUICC chip/device.
193  */
194 struct CarrierIdentifier {
195     std::u16string mcc_ = u"";
196     std::u16string mnc_ = u"";
197     std::u16string spn_ = u"";
198     std::u16string imsi_ = u"";
199     std::u16string gid1_ = u"";
200     std::u16string gid2_ = u"";
201     int32_t carrierId_ = 0;
202     int32_t specificCarrierId_ = 0;
203 };
204 
205 /**
206  * @brief the rules authorisation table stored on eUICC.
207  */
208 struct EuiccRulesAuthTable {
209     std::vector<int32_t> policyRules_;
210     std::vector<CarrierIdentifier> carrierIds_{};
211     std::vector<int32_t> policyRuleFlags_;
212     int32_t position_ = 0;
213 };
214 
215 /**
216  * @brief ConfigInfo about prepareDownload.
217  */
218 struct DownLoadConfigInfo {
219     int32_t portIndex_ = 0;
220     std::u16string hashCc_ = u"";
221     std::u16string smdpSigned2_ = u"";
222     std::u16string smdpSignature2_ = u"";
223     std::u16string smdpCertificate_ = u"";
224 };
225 
226 /**
227  * @brief Config information about Authenticate.
228  */
229 struct AuthenticateConfigInfo {
230     int32_t portIndex_ = 0;
231     std::u16string matchingId_ = u"";
232     std::u16string serverSigned1_ = u"";
233     std::u16string serverSignature1_ = u"";
234     std::u16string euiccCiPkIdToBeUsed_ = u"";
235     std::u16string serverCertificate_ = u"";
236 };
237 
238 /**
239  * @brief Result of a operation.
240  * @brief Result of a bpp operation.
241  */
242 struct ResponseEsimBppResult {
243     int32_t resultCode_ = 0;
244     std::u16string response_ = u"";
245     int32_t seqNumber_ = 0;
246     int32_t profileManagementOperation_ = 0;
247     std::u16string notificationAddress_ = u"";
248     std::u16string iccId_ = u"";
249 };
250 
251 /**
252  * @brief  A profile installation result or a notification generated for profile operations.
253  */
254 enum class EsimEvent {
255     EVENT_DONOTHING = 0,
256     EVENT_INSTALL = 1,
257     EVENT_ENABLE = 1 << 1,
258     EVENT_DISABLE = 1 << 2,
259     EVENT_DELETE = 1 << 3,
260     EVENT_ALL = 15,
261 };
262 
263 /**
264  * @brief A signed notification which is defined in SGP.22.
265  */
266 struct EuiccNotification {
267     int32_t seq_ = 0;
268     std::u16string targetAddr_ = u"";
269     int32_t event_ = 0;
270     std::u16string data_ = u"";
271 };
272 
273 /**
274  * @brief List of notifications.
275  */
276 struct EuiccNotificationList {
277     std::vector<EuiccNotification> euiccNotification_{};
278 };
279 
280 /**
281  * @brief The Data which is sent by the service of LPA
282  */
283 struct EsimApduData {
284     /** The flag of user actively closes the channel */
285     bool closeChannelFlag_ = false;
286 
287     /** Do not use the default request header flag */
288     bool unusedDefaultReqHeadFlag_ = false;
289 
290     /** The data needs to be send */
291     std::u16string data_ = u"";
292 
293     /** APDU instruction type. For details, see ETSI 102 221 [55]. */
294     int32_t instructionType_ = 0;
295 
296     /** APDU instruction. For details, see ETSI 102 221 [55]. */
297     int32_t instruction_ = 0;
298 
299     /**
300      * Command parameter 1 of the SIM data request. For details, see 3GPP
301      * TS 51.011[28].
302      */
303     int32_t p1_ = 0;
304 
305     /**
306      * Command parameter 2 of the SIM data request. For details, see 3GPP
307      * TS 51.011[28].
308      */
309     int32_t p2_ = 0;
310 
311     /**
312      * Command parameter 3 of the SIM data request. For details, see 3GPP
313      * TS 51.011[28]. If p3 is a negative value, a 4-byte APDU is sent to the
314      * SIM card.
315      */
316     int32_t p3_ = 0;
317 };
318 
319 /**
320  * @brief Euicc Information.
321  */
322 struct EuiccInfo2 {
323     std::string raw_ = "";
324     uint32_t rawLen_ = 0;
325     std::string svn_ = "";
326     std::string profileVersion_ = "";
327     std::string firmwareVer_ = "";
328     std::string extCardResource_ = "";
329     std::string uiccCapability_ = "";
330     std::string ts102241Version_ = "";
331     std::string globalPlatformVersion_ = "";
332     std::string rspCapability_ = "";
333     std::string euiccCiPKIdListForVerification_ = "";
334     std::string euiccCiPKIdListForSigning_ = "";
335     int32_t euiccCategory_ = 0;
336     std::string forbiddenProfilePolicyRules_ = "";
337     std::string ppVersion_ = "";
338     std::string sasAccreditationNumber_ = "";
339     std::string response_ = "";
340     int32_t resultCode_ = 0;
341 };
342 
343 /**
344  * @brief Map meta data.
345  */
346 struct MapMetaData {
347     std::u16string nonce = u"";
348     std::u16string imei = u"";
349     std::u16string imei2 = u"";
350     std::u16string timestamp = u"";
351 };
352 
353 /**
354  * @brief Get contract info request.
355  */
356 struct GetContractInfoRequest {
357     std::u16string euiccCiPkidToBeUsed = u"";
358     MapMetaData mapMetaData;
359     std::u16string ePkPosHpke = u"";
360 };
361 
362 } // namespace Telephony
363 } // namespace OHOS
364 #endif // OHOS_ESIM_STATE_TYPE_H
365