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