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_SIM_DATA_TYPE_H 17 #define OHOS_SIM_DATA_TYPE_H 18 19 #include <iostream> 20 #include <string> 21 #include <vector> 22 23 #include "event_handler.h" 24 #include "event_runner.h" 25 #include "sim_constant.h" 26 27 namespace OHOS { 28 namespace Telephony { 29 struct IccControllerHolder { 30 int fileId = 0; 31 int fileNum = 0; 32 int fileSize = 0; 33 int countFiles = 0; 34 bool getAllFile = false; 35 std::string filePath = ""; 36 AppExecFwk::InnerEvent::Pointer fileLoaded = AppExecFwk::InnerEvent::Pointer(nullptr, nullptr); 37 std::vector<std::string> fileResults {}; IccControllerHolderIccControllerHolder38 IccControllerHolder(int efId, int recordNum) : fileId(efId), fileNum(recordNum), getAllFile(false) {} IccControllerHolderIccControllerHolder39 IccControllerHolder(int efId, int recordNum, std::string path) 40 : fileId(efId), fileNum(recordNum), getAllFile(false), filePath(path) 41 {} IccControllerHolderIccControllerHolder42 IccControllerHolder(int efId, std::string path) : fileId(efId), fileNum(1), getAllFile(true), filePath(path) {} IccControllerHolderIccControllerHolder43 explicit IccControllerHolder(int efId) : fileId(efId), fileNum(1), getAllFile(true) {} 44 }; 45 46 struct IccFileData { 47 int32_t sw1 = 0; 48 int32_t sw2 = 0; 49 std::string resultData = ""; 50 std::shared_ptr<void> exception = nullptr; 51 }; 52 53 struct FileToControllerMsg { 54 int arg1 = INVALID_VALUE; 55 int arg2 = INVALID_VALUE; 56 std::shared_ptr<void> iccLoader = nullptr; 57 }; 58 59 struct ControllerToFileMsg : public FileToControllerMsg, IccFileData { ControllerToFileMsgControllerToFileMsg60 ControllerToFileMsg(const FileToControllerMsg *cmd, const IccFileData *fd) 61 { 62 if (cmd != nullptr) { 63 arg1 = cmd->arg1; 64 arg2 = cmd->arg2; 65 iccLoader = cmd->iccLoader; 66 } 67 if (fd != nullptr) { 68 sw1 = fd->sw1; 69 sw2 = fd->sw2; 70 resultData = fd->resultData; 71 exception = fd->exception; 72 } 73 } 74 }; 75 76 struct IccToRilMsg { IccToRilMsgIccToRilMsg77 explicit IccToRilMsg(std::shared_ptr<IccControllerHolder> holder) : controlHolder(holder) {} 78 std::shared_ptr<IccControllerHolder> controlHolder = nullptr; 79 int arg1 = INVALID_VALUE; 80 int arg2 = INVALID_VALUE; 81 }; 82 83 struct IccFromRilMsg : public IccToRilMsg { IccFromRilMsgIccFromRilMsg84 explicit IccFromRilMsg(std::shared_ptr<IccControllerHolder> &holder) : IccToRilMsg(holder) {} 85 IccFileData fileData; 86 }; 87 88 struct EfLinearResult : public FileToControllerMsg { EfLinearResultEfLinearResult89 explicit EfLinearResult(const FileToControllerMsg *cmd) 90 { 91 if (cmd != nullptr) { 92 arg1 = cmd->arg1; 93 arg2 = cmd->arg2; 94 iccLoader = cmd->iccLoader; 95 } 96 } 97 const static int Ef_RESULT_NUM = 3; 98 int valueData[Ef_RESULT_NUM] = {0}; 99 std::shared_ptr<void> exception = nullptr; 100 }; 101 102 struct MultiRecordResult : public FileToControllerMsg { MultiRecordResultMultiRecordResult103 explicit MultiRecordResult(const FileToControllerMsg *cmd) 104 { 105 if (cmd != nullptr) { 106 arg1 = cmd->arg1; 107 arg2 = cmd->arg2; 108 iccLoader = cmd->iccLoader; 109 } 110 } 111 std::vector<std::string> fileResults {}; 112 int resultLength = 0; 113 std::shared_ptr<void> exception = nullptr; 114 }; 115 116 struct PointerWrapper { 117 AppExecFwk::InnerEvent::Pointer caller = AppExecFwk::InnerEvent::Pointer(nullptr, nullptr); 118 }; 119 120 struct DiallingNumbersHandleHolder { 121 int fileID = 0; 122 int index = 0; 123 std::shared_ptr<void> diallingNumber = nullptr; 124 std::shared_ptr<PointerWrapper> callerCache = nullptr; 125 }; 126 127 struct DiallingNumbersHandlerResult : public DiallingNumbersHandleHolder { DiallingNumbersHandlerResultDiallingNumbersHandlerResult128 explicit DiallingNumbersHandlerResult(const DiallingNumbersHandleHolder *cmd) 129 { 130 if (cmd != nullptr) { 131 fileID = cmd->fileID; 132 index = cmd->index; 133 diallingNumber = cmd->diallingNumber; 134 callerCache = cmd->callerCache; 135 } 136 } 137 std::shared_ptr<void> result = nullptr; 138 std::shared_ptr<void> exception = nullptr; 139 }; 140 141 struct ResultObtain { 142 int fileID = 0; 143 }; 144 145 struct ResponseResult : public ResultObtain { ResponseResultResponseResult146 explicit ResponseResult(const ResultObtain *cmd) 147 { 148 if (cmd != nullptr) { 149 fileID = cmd->fileID; 150 } 151 } 152 std::shared_ptr<void> result = nullptr; 153 std::shared_ptr<void> exception = nullptr; 154 }; 155 156 struct TagData { TagDataTagData157 TagData(int parentTag, int efid, int sfi, int indexNum) 158 : tag(parentTag), fileId(efid), shortFileId(sfi), index(indexNum) 159 {} 160 int tag = 0; 161 int fileId = 0; 162 int shortFileId = 0; 163 int index = 0; 164 }; 165 166 struct UsimFetcher { 167 int fileID = 0; 168 std::shared_ptr<PointerWrapper> callerCache = nullptr; 169 }; 170 171 struct UsimResult : public UsimFetcher { UsimResultUsimResult172 explicit UsimResult(const UsimFetcher *cmd) 173 { 174 if (cmd != nullptr) { 175 fileID = cmd->fileID; 176 callerCache = cmd->callerCache; 177 } 178 } 179 std::shared_ptr<void> result = nullptr; 180 std::shared_ptr<void> exception = nullptr; 181 }; 182 } // namespace Telephony 183 } // namespace OHOS 184 #endif // OHOS_SIM_DATA_TYPE_H 185