1 /*
2 * Copyright (C) 2021-2023 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 #include "core_service_stub.h"
17
18 #include "string_ex.h"
19 #include "telephony_errors.h"
20 #include "telephony_log_wrapper.h"
21
22 #ifdef HICOLLIE_ENABLE
23 #include "xcollie/xcollie.h"
24 #include "xcollie/xcollie_define.h"
25 #define XCOLLIE_TIMEOUT_SECONDS 30
26 #endif
27
28 namespace OHOS {
29 namespace Telephony {
30 constexpr int32_t INVALID_VALUE = -1;
31
CoreServiceStub()32 CoreServiceStub::CoreServiceStub()
33 {
34 AddHandlerNetWorkToMap();
35 AddHandlerDeviceToMap();
36 AddHandlerImsToMap();
37 AddHandlerSimToMap();
38 AddHandlerSimLockToMap();
39 AddHandlerSimToMapExt();
40 AddHandlerVoiceMailToMap();
41 AddHandlerPdpProfileToMap();
42 AddHandlerOpkeyVersionToMap();
43 #ifdef CORE_SERVICE_SUPPORT_ESIM
44 AddHandlerEsimToMap();
45 #endif
46 }
47
AddHandlerNetWorkToMap()48 void CoreServiceStub::AddHandlerNetWorkToMap()
49 {
50 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_PS_RADIO_TECH)] =
51 [this](MessageParcel &data, MessageParcel &reply) { return OnGetPsRadioTech(data, reply); };
52 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_CS_RADIO_TECH)] =
53 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCsRadioTech(data, reply); };
54 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_OPERATOR_NUMERIC)] =
55 [this](MessageParcel &data, MessageParcel &reply) { return OnGetOperatorNumeric(data, reply); };
56 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_RESIDENT_NETWORK_NUMERIC)] =
57 [this](MessageParcel &data, MessageParcel &reply) { return OnGetResidentNetworkNumeric(data, reply); };
58 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_OPERATOR_NAME)] =
59 [this](MessageParcel &data, MessageParcel &reply) { return OnGetOperatorName(data, reply); };
60 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIGNAL_INFO_LIST)] =
61 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSignalInfoList(data, reply); };
62 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_NETWORK_STATE)] =
63 [this](MessageParcel &data, MessageParcel &reply) { return OnGetNetworkState(data, reply); };
64 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_RADIO_STATE)] =
65 [this](MessageParcel &data, MessageParcel &reply) { return OnSetRadioState(data, reply); };
66 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_RADIO_STATE)] =
67 [this](MessageParcel &data, MessageParcel &reply) { return OnGetRadioState(data, reply); };
68 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_NETWORK_SEARCH_RESULT)] =
69 [this](MessageParcel &data, MessageParcel &reply) { return OnGetNetworkSearchInformation(data, reply); };
70 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_NETWORK_SELECTION_MODE)] =
71 [this](MessageParcel &data, MessageParcel &reply) { return OnGetNetworkSelectionMode(data, reply); };
72 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_NETWORK_SELECTION_MODE)] =
73 [this](MessageParcel &data, MessageParcel &reply) { return OnSetNetworkSelectionMode(data, reply); };
74 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_ISO_COUNTRY_CODE_FOR_NETWORK)] =
75 [this](MessageParcel &data, MessageParcel &reply) { return OnGetIsoCountryCodeForNetwork(data, reply); };
76 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_CELL_INFO_LIST)] =
77 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellInfoList(data, reply); };
78 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_NEIGHBORING_CELL_INFO_LIST)] =
79 [this](MessageParcel &data, MessageParcel &reply) { return OnGetNeighboringCellInfoList(data, reply); };
80 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_CELL_LOCATION)] =
81 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellLocation(data, reply); };
82 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_PREFERRED_NETWORK_MODE)] =
83 [this](MessageParcel &data, MessageParcel &reply) { return OnGetPreferredNetwork(data, reply); };
84 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_PREFERRED_NETWORK_MODE)] =
85 [this](MessageParcel &data, MessageParcel &reply) { return OnSetPreferredNetwork(data, reply); };
86 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_NETWORK_CAPABILITY)] =
87 [this](MessageParcel &data, MessageParcel &reply) { return OnGetNetworkCapability(data, reply); };
88 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_NETWORK_CAPABILITY)] =
89 [this](MessageParcel &data, MessageParcel &reply) { return OnSetNetworkCapability(data, reply); };
90 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_NR_OPTION_MODE)] =
91 [this](MessageParcel &data, MessageParcel &reply) { return OnSetNrOptionMode(data, reply); };
92 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_NR_OPTION_MODE)] =
93 [this](MessageParcel &data, MessageParcel &reply) { return OnGetNrOptionMode(data, reply); };
94 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_NR_SSB_ID_INFO)] =
95 [this](MessageParcel &data, MessageParcel &reply) { return OnGetNrSsbIdInfo(data, reply); };
96 }
97
AddHandlerDeviceToMap()98 void CoreServiceStub::AddHandlerDeviceToMap()
99 {
100 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_IMEI)] =
101 [this](MessageParcel &data, MessageParcel &reply) { return OnGetImei(data, reply); };
102 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_IMEISV)] =
103 [this](MessageParcel &data, MessageParcel &reply) { return OnGetImeiSv(data, reply); };
104 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_MEID)] =
105 [this](MessageParcel &data, MessageParcel &reply) { return OnGetMeid(data, reply); };
106 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_UNIQUE_DEVICE_ID)] =
107 [this](MessageParcel &data, MessageParcel &reply) { return OnGetUniqueDeviceId(data, reply); };
108 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_BASEBAND_VERSION)] =
109 [this](MessageParcel &data, MessageParcel &reply) { return OnGetBasebandVersion(data, reply); };
110 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::FACTORY_RESET)] =
111 [this](MessageParcel &data, MessageParcel &reply) { return OnFactoryReset(data, reply); };
112 }
113
AddHandlerImsToMap()114 void CoreServiceStub::AddHandlerImsToMap()
115 {
116 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_IMS_REG_STATUS)] =
117 [this](MessageParcel &data, MessageParcel &reply) { return OnGetImsRegStatus(data, reply); };
118 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::REG_IMS_CALLBACK)] =
119 [this](MessageParcel &data, MessageParcel &reply) { return OnRegisterImsRegInfoCallback(data, reply); };
120 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::UN_REG_IMS_CALLBACK)] =
121 [this](MessageParcel &data, MessageParcel &reply) { return OnUnregisterImsRegInfoCallback(data, reply); };
122 }
123
AddHandlerSimToMap()124 void CoreServiceStub::AddHandlerSimToMap()
125 {
126 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::HAS_SIM_CARD)] =
127 [this](MessageParcel &data, MessageParcel &reply) { return OnHasSimCard(data, reply); };
128 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIM_STATE)] =
129 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSimState(data, reply); };
130 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_DSDS_MODE)] =
131 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDsdsMode(data, reply); };
132 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SPN)] =
133 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSimSpn(data, reply); };
134 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_ICCID)] =
135 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSimIccId(data, reply); };
136 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIM_OPERATOR_NUMERIC)] =
137 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSimOperatorNumeric(data, reply); };
138 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_IMSI)] =
139 [this](MessageParcel &data, MessageParcel &reply) { return OnGetIMSI(data, reply); };
140 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::IS_CT_SIM_CARD)] =
141 [this](MessageParcel &data, MessageParcel &reply) { return OnIsCTSimCard(data, reply); };
142 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::IS_SIM_ACTIVE)] =
143 [this](MessageParcel &data, MessageParcel &reply) { return OnIsSimActive(data, reply); };
144 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIM_LANGUAGE)] =
145 [this](MessageParcel &data, MessageParcel &reply) { return OnGetLocaleFromDefaultSim(data, reply); };
146 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIM_GID1)] =
147 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSimGid1(data, reply); };
148 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIM_GID2)] =
149 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSimGid2(data, reply); };
150 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIM_EONS)] =
151 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSimEons(data, reply); };
152 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIM_SUB_INFO)] =
153 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSimSubscriptionInfo(data, reply); };
154 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_DEFAULT_VOICE_SLOTID)] =
155 [this](MessageParcel &data, MessageParcel &reply) { return OnSetDefaultVoiceSlotId(data, reply); };
156 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_DEFAULT_VOICE_SLOTID)] =
157 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultVoiceSlotId(data, reply); };
158 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_DEFAULT_VOICE_SIMID)] =
159 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultVoiceSimId(data, reply); };
160 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_PRIMARY_SLOTID)] =
161 [this](MessageParcel &data, MessageParcel &reply) { return OnSetPrimarySlotId(data, reply); };
162 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_PRIMARY_SLOTID)] =
163 [this](MessageParcel &data, MessageParcel &reply) { return OnGetPrimarySlotId(data, reply); };
164 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_SHOW_NUMBER)] =
165 [this](MessageParcel &data, MessageParcel &reply) { return OnSetShowNumber(data, reply); };
166 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SHOW_NUMBER)] =
167 [this](MessageParcel &data, MessageParcel &reply) { return OnGetShowNumber(data, reply); };
168 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_SHOW_NAME)] =
169 [this](MessageParcel &data, MessageParcel &reply) { return OnSetShowName(data, reply); };
170 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SHOW_NAME)] =
171 [this](MessageParcel &data, MessageParcel &reply) { return OnGetShowName(data, reply); };
172 }
173
AddHandlerSimLockToMap()174 void CoreServiceStub::AddHandlerSimLockToMap()
175 {
176 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::UNLOCK_PIN)] =
177 [this](MessageParcel &data, MessageParcel &reply) { return OnUnlockPin(data, reply); };
178 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::UNLOCK_PUK)] =
179 [this](MessageParcel &data, MessageParcel &reply) { return OnUnlockPuk(data, reply); };
180 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::ALTER_PIN)] =
181 [this](MessageParcel &data, MessageParcel &reply) { return OnAlterPin(data, reply); };
182 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::CHECK_LOCK)] =
183 [this](MessageParcel &data, MessageParcel &reply) { return OnGetLockState(data, reply); };
184 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SWITCH_LOCK)] =
185 [this](MessageParcel &data, MessageParcel &reply) { return OnSetLockState(data, reply); };
186 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::UNLOCK_PIN2)] =
187 [this](MessageParcel &data, MessageParcel &reply) { return OnUnlockPin2(data, reply); };
188 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::UNLOCK_PUK2)] =
189 [this](MessageParcel &data, MessageParcel &reply) { return OnUnlockPuk2(data, reply); };
190 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::ALTER_PIN2)] =
191 [this](MessageParcel &data, MessageParcel &reply) { return OnAlterPin2(data, reply); };
192 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::UNLOCK_SIMLOCK)] =
193 [this](MessageParcel &data, MessageParcel &reply) { return OnUnlockSimLock(data, reply); };
194 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::HAS_OPERATOR_PRIVILEGES)] =
195 [this](MessageParcel &data, MessageParcel &reply) { return OnHasOperatorPrivileges(data, reply); };
196 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SIM_AUTHENTICATION)] =
197 [this](MessageParcel &data, MessageParcel &reply) { return OnSimAuthentication(data, reply); };
198 }
199
AddHandlerSimToMapExt()200 void CoreServiceStub::AddHandlerSimToMapExt()
201 {
202 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_ISO_COUNTRY_CODE)] =
203 [this](MessageParcel &data, MessageParcel &reply) { return OnGetISOCountryCodeForSim(data, reply); };
204 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_ACTIVE_ACCOUNT_INFO_LIST)] =
205 [this](MessageParcel &data, MessageParcel &reply) { return OnGetActiveSimAccountInfoList(data, reply); };
206 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_OPERATOR_CONFIG)] =
207 [this](MessageParcel &data, MessageParcel &reply) { return OnGetOperatorConfig(data, reply); };
208 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::REFRESH_SIM_STATE)] =
209 [this](MessageParcel &data, MessageParcel &reply) { return OnRefreshSimState(data, reply); };
210 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_SIM_ACTIVE)] =
211 [this](MessageParcel &data, MessageParcel &reply) { return OnSetActiveSim(data, reply); };
212 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_SIM_ACTIVE_SATELLITE)] =
213 [this](MessageParcel &data, MessageParcel &reply) { return OnSetActiveSimSatellite(data, reply); };
214 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIM_PHONE_NUMBER)] =
215 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSimPhoneNumber(data, reply); };
216 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIM_TELENUMBER_IDENTIFIER)] =
217 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSimTeleNumberIdentifier(data, reply); };
218 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_VOICE_CALL_FORWARDING)] =
219 [this](MessageParcel &data, MessageParcel &reply) { return OnSetVoiceCallForwarding(data, reply); };
220 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::ICC_DIALLING_NUMBERS_GET)] =
221 [this](MessageParcel &data, MessageParcel &reply) { return OnDiallingNumbersGet(data, reply); };
222 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::ICC_DIALLING_NUMBERS_INSERT)] =
223 [this](MessageParcel &data, MessageParcel &reply) { return OnAddIccDiallingNumbers(data, reply); };
224 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::ICC_DIALLING_NUMBERS_UPDATE)] =
225 [this](MessageParcel &data, MessageParcel &reply) { return OnUpdateIccDiallingNumbers(data, reply); };
226 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::ICC_DIALLING_NUMBERS_DELETE)] =
227 [this](MessageParcel &data, MessageParcel &reply) { return OnDelIccDiallingNumbers(data, reply); };
228 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_MAX_SIM_COUNT)] =
229 [this](MessageParcel &data, MessageParcel &reply) { return OnGetMaxSimCount(data, reply); };
230 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::STK_CMD_FROM_APP_ENVELOPE)] =
231 [this](MessageParcel &data, MessageParcel &reply) { return OnSendEnvelopeCmd(data, reply); };
232 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::STK_CMD_FROM_APP_TERMINAL_RESPONSE)] =
233 [this](MessageParcel &data, MessageParcel &reply) { return OnSendTerminalResponseCmd(data, reply); };
234 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::STK_RESULT_FROM_APP_CALL_SETUP_REQUEST)] =
235 [this](MessageParcel &data, MessageParcel &reply) { return OnSendCallSetupRequestResult(data, reply); };
236 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_CARD_TYPE)] =
237 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCardType(data, reply); };
238 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::IS_NR_SUPPORTED)] =
239 [this](MessageParcel &data, MessageParcel &reply) { return OnIsNrSupported(data, reply); };
240 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIM_SLOTID)] =
241 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSlotId(data, reply); };
242 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIM_SIMID)] =
243 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSimId(data, reply); };
244 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_SIM_IO_DONE)] =
245 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSimIO(data, reply); };
246 }
247
AddHandlerVoiceMailToMap()248 void CoreServiceStub::AddHandlerVoiceMailToMap()
249 {
250 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_VOICE_MAIL_TAG)] =
251 [this](MessageParcel &data, MessageParcel &reply) { return OnGetVoiceMailInfor(data, reply); };
252 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_VOICE_MAIL_NUMBER)] =
253 [this](MessageParcel &data, MessageParcel &reply) { return OnGetVoiceMailNumber(data, reply); };
254 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_VOICE_MAIL_COUNT)] =
255 [this](MessageParcel &data, MessageParcel &reply) { return OnGetVoiceMailCount(data, reply); };
256 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_VOICE_MAIL_COUNT)] =
257 [this](MessageParcel &data, MessageParcel &reply) { return OnSetVoiceMailCount(data, reply); };
258 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SET_VOICE_MAIL)] =
259 [this](MessageParcel &data, MessageParcel &reply) { return OnSetVoiceMailInfo(data, reply); };
260 }
261
AddHandlerPdpProfileToMap()262 void CoreServiceStub::AddHandlerPdpProfileToMap()
263 {
264 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::IS_ALLOWED_INSERT_APN)] =
265 [this](MessageParcel &data, MessageParcel &reply) { return OnIsAllowedInsertApn(data, reply); };
266 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_TARGET_OPKEY)] =
267 [this](MessageParcel &data, MessageParcel &reply) { return OnGetTargetOpkey(data, reply); };
268 }
269
AddHandlerOpkeyVersionToMap()270 void CoreServiceStub::AddHandlerOpkeyVersionToMap()
271 {
272 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_OPKEY)] =
273 [this](MessageParcel &data, MessageParcel &reply) { return OnGetOpKey(data, reply); };
274 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_OPNAME)] =
275 [this](MessageParcel &data, MessageParcel &reply) { return OnGetOpName(data, reply); };
276 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_OPKEY_EXT)] =
277 [this](MessageParcel &data, MessageParcel &reply) { return OnGetOpKeyExt(data, reply); };
278 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_OPKEY_VERSION)] =
279 [this](MessageParcel &data, MessageParcel &reply) { return OnGetOpkeyVersion(data, reply); };
280 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::GET_OPNAME_VERSION)] =
281 [this](MessageParcel &data, MessageParcel &reply) { return OnGetOpnameVersion(data, reply); };
282 }
283
284 #ifdef CORE_SERVICE_SUPPORT_ESIM
AddHandlerEsimToMap()285 void CoreServiceStub::AddHandlerEsimToMap()
286 {
287 memberFuncMap_[uint32_t(CoreServiceInterfaceCode::SEND_APDU_DATA)] =
288 [this](MessageParcel &data, MessageParcel &reply) { return OnSendApduData(data, reply); };
289 }
290 #endif
291
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)292 int32_t CoreServiceStub::OnRemoteRequest(
293 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
294 {
295 TELEPHONY_LOGD("CoreServiceStub OnRemoteRequest code %{public}u", code);
296 std::u16string myDescripter = CoreServiceStub::GetDescriptor();
297 std::u16string remoteDescripter = data.ReadInterfaceToken();
298 if (myDescripter != remoteDescripter) {
299 TELEPHONY_LOGE("descriptor checked fail");
300 return TELEPHONY_ERR_DESCRIPTOR_MISMATCH;
301 }
302 auto itFunc = memberFuncMap_.find(code);
303 if (itFunc != memberFuncMap_.end()) {
304 auto memberFunc = itFunc->second;
305 if (memberFunc != nullptr) {
306 int32_t idTimer = SetTimer(code);
307 int32_t result = memberFunc(data, reply);
308 CancelTimer(idTimer);
309 return result;
310 }
311 }
312 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
313 }
314
SetTimer(uint32_t code)315 int32_t CoreServiceStub::SetTimer(uint32_t code)
316 {
317 #ifdef HICOLLIE_ENABLE
318 int32_t idTimer = HiviewDFX::INVALID_ID;
319 std::map<uint32_t, std::string>::iterator itCollieId = collieCodeStringMap_.find(code);
320 if (itCollieId != collieCodeStringMap_.end()) {
321 std::string collieStr = itCollieId->second;
322 std::string collieName = "CoreServiceStub: " + collieStr;
323 unsigned int flag = HiviewDFX::XCOLLIE_FLAG_NOOP;
324 auto TimerCallback = [collieStr](void *) {
325 TELEPHONY_LOGE("OnRemoteRequest timeout func: %{public}s", collieStr.c_str());
326 };
327 idTimer = HiviewDFX::XCollie::GetInstance().SetTimer(
328 collieName, XCOLLIE_TIMEOUT_SECONDS, TimerCallback, nullptr, flag);
329 TELEPHONY_LOGD("SetTimer id: %{public}d, name: %{public}s.", idTimer, collieStr.c_str());
330 }
331 return idTimer;
332 #else
333 TELEPHONY_LOGD("No HICOLLIE_ENABLE");
334 return -1;
335 #endif
336 }
337
CancelTimer(int32_t id)338 void CoreServiceStub::CancelTimer(int32_t id)
339 {
340 #ifdef HICOLLIE_ENABLE
341 if (id == HiviewDFX::INVALID_ID) {
342 return;
343 }
344 TELEPHONY_LOGD("CancelTimer id: %{public}d.", id);
345 HiviewDFX::XCollie::GetInstance().CancelTimer(id);
346 #else
347 return;
348 #endif
349 }
350
OnGetPsRadioTech(MessageParcel & data,MessageParcel & reply)351 int32_t CoreServiceStub::OnGetPsRadioTech(MessageParcel &data, MessageParcel &reply)
352 {
353 auto slotId = data.ReadInt32();
354 int32_t radioTech = 0;
355 int32_t result = GetPsRadioTech(slotId, radioTech);
356 bool ret = reply.WriteInt32(result);
357 if (result == TELEPHONY_ERR_SUCCESS) {
358 ret = (ret && reply.WriteInt32(radioTech));
359 }
360 if (!ret) {
361 TELEPHONY_LOGE("write reply failed.");
362 return TELEPHONY_ERR_WRITE_DATA_FAIL;
363 }
364 return NO_ERROR;
365 }
366
OnGetCsRadioTech(MessageParcel & data,MessageParcel & reply)367 int32_t CoreServiceStub::OnGetCsRadioTech(MessageParcel &data, MessageParcel &reply)
368 {
369 auto slotId = data.ReadInt32();
370 int32_t radioTech = 0;
371 int32_t result = GetCsRadioTech(slotId, radioTech);
372 bool ret = reply.WriteInt32(result);
373 if (result == TELEPHONY_ERR_SUCCESS) {
374 ret = (ret && reply.WriteInt32(radioTech));
375 }
376 if (!ret) {
377 TELEPHONY_LOGE("write reply failed.");
378 return TELEPHONY_ERR_WRITE_DATA_FAIL;
379 }
380 return NO_ERROR;
381 }
382
OnGetOperatorNumeric(MessageParcel & data,MessageParcel & reply)383 int32_t CoreServiceStub::OnGetOperatorNumeric(MessageParcel &data, MessageParcel &reply)
384 {
385 auto slotId = data.ReadInt32();
386 std::u16string result = GetOperatorNumeric(slotId);
387 reply.WriteString16(result);
388 return NO_ERROR;
389 }
390
OnGetResidentNetworkNumeric(MessageParcel & data,MessageParcel & reply)391 int32_t CoreServiceStub::OnGetResidentNetworkNumeric(MessageParcel &data, MessageParcel &reply)
392 {
393 auto slotId = data.ReadInt32();
394 std::string result = GetResidentNetworkNumeric(slotId);
395 reply.WriteString(result);
396 return NO_ERROR;
397 }
398
OnGetOperatorName(MessageParcel & data,MessageParcel & reply)399 int32_t CoreServiceStub::OnGetOperatorName(MessageParcel &data, MessageParcel &reply)
400 {
401 auto slotId = data.ReadInt32();
402 std::u16string operatorName = u"";
403 int32_t result = GetOperatorName(slotId, operatorName);
404 bool ret = reply.WriteInt32(result);
405 if (result == TELEPHONY_ERR_SUCCESS) {
406 ret = (ret && reply.WriteString16(operatorName));
407 }
408 if (!ret) {
409 TELEPHONY_LOGE("write reply failed.");
410 return TELEPHONY_ERR_WRITE_DATA_FAIL;
411 }
412 return NO_ERROR;
413 }
414
OnGetSignalInfoList(MessageParcel & data,MessageParcel & reply)415 int32_t CoreServiceStub::OnGetSignalInfoList(MessageParcel &data, MessageParcel &reply)
416 {
417 auto slotId = data.ReadInt32();
418 std::vector<sptr<SignalInformation>> signals;
419 int32_t result = GetSignalInfoList(slotId, signals);
420 if (!reply.WriteInt32(result)) {
421 TELEPHONY_LOGE("write reply failed.");
422 return TELEPHONY_ERR_WRITE_DATA_FAIL;
423 }
424 if (result == TELEPHONY_ERR_SUCCESS) {
425 reply.WriteInt32(static_cast<int32_t>(signals.size()));
426 for (const auto &v : signals) {
427 v->Marshalling(reply);
428 }
429 }
430 return NO_ERROR;
431 }
432
OnGetNetworkState(MessageParcel & data,MessageParcel & reply)433 int32_t CoreServiceStub::OnGetNetworkState(MessageParcel &data, MessageParcel &reply)
434 {
435 auto slotId = data.ReadInt32();
436 sptr<NetworkState> networkState = nullptr;
437 int32_t result = GetNetworkState(slotId, networkState);
438 if ((networkState == nullptr) && (result != TELEPHONY_ERR_PERMISSION_ERR)) {
439 TELEPHONY_LOGE("networkState is nullptr and permission is not denied.");
440 result = TELEPHONY_ERR_LOCAL_PTR_NULL;
441 }
442 if (!reply.WriteInt32(result)) {
443 TELEPHONY_LOGE("write reply failed.");
444 return TELEPHONY_ERR_WRITE_DATA_FAIL;
445 }
446 if (result == TELEPHONY_ERR_SUCCESS) {
447 networkState->Marshalling(reply);
448 }
449 return NO_ERROR;
450 }
451
OnSetRadioState(MessageParcel & data,MessageParcel & reply)452 int32_t CoreServiceStub::OnSetRadioState(MessageParcel &data, MessageParcel &reply)
453 {
454 int32_t slotId = data.ReadInt32();
455 sptr<INetworkSearchCallback> callback = nullptr;
456 sptr<IRemoteObject> remoteCallback = data.ReadRemoteObject();
457 if (remoteCallback == nullptr) {
458 TELEPHONY_LOGE("CoreServiceStub::OnSetRadioState remoteCallback is nullptr.");
459 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
460 }
461 callback = iface_cast<INetworkSearchCallback>(remoteCallback);
462 if (callback == nullptr) {
463 TELEPHONY_LOGE("CoreServiceStub::OnSetRadioState callback is nullptr.");
464 return TELEPHONY_ERR_LOCAL_PTR_NULL;
465 }
466 bool isOn = data.ReadBool();
467 TELEPHONY_LOGD("CoreServiceStub::OnSetRadioState isOn:%{public}d", isOn);
468 int32_t result = SetRadioState(slotId, isOn, callback);
469 if (!reply.WriteInt32(result)) {
470 TELEPHONY_LOGE("CoreServiceStub::OnSetRadioState write reply failed.");
471 return TELEPHONY_ERR_WRITE_DATA_FAIL;
472 }
473 return NO_ERROR;
474 }
475
OnGetRadioState(MessageParcel & data,MessageParcel & reply)476 int32_t CoreServiceStub::OnGetRadioState(MessageParcel &data, MessageParcel &reply)
477 {
478 int32_t slotId = data.ReadInt32();
479 sptr<INetworkSearchCallback> callback = nullptr;
480 sptr<IRemoteObject> remoteCallback = data.ReadRemoteObject();
481 if (remoteCallback == nullptr) {
482 TELEPHONY_LOGE("CoreServiceStub::OnGetRadioState remoteCallback is nullptr.");
483 return TELEPHONY_ERR_LOCAL_PTR_NULL;
484 }
485 callback = iface_cast<INetworkSearchCallback>(remoteCallback);
486 if (callback == nullptr) {
487 TELEPHONY_LOGE("CoreServiceStub::OnGetRadioState callback is nullptr.");
488 return TELEPHONY_ERR_LOCAL_PTR_NULL;
489 }
490 int32_t result = GetRadioState(slotId, callback);
491 if (!reply.WriteInt32(result)) {
492 TELEPHONY_LOGE("CoreServiceStub::OnGetRadioState write reply failed.");
493 return TELEPHONY_ERR_WRITE_DATA_FAIL;
494 }
495 TELEPHONY_LOGD("CoreServiceStub::OnGetRadioState result:%{public}d", result);
496 return NO_ERROR;
497 }
498
OnGetIsoCountryCodeForNetwork(MessageParcel & data,MessageParcel & reply)499 int32_t CoreServiceStub::OnGetIsoCountryCodeForNetwork(MessageParcel &data, MessageParcel &reply)
500 {
501 int32_t slotId = data.ReadInt32();
502 std::u16string countryCode;
503 int32_t result = GetIsoCountryCodeForNetwork(slotId, countryCode);
504 bool ret = reply.WriteInt32(result);
505 if (result == TELEPHONY_ERR_SUCCESS) {
506 ret = (ret && reply.WriteString16(countryCode));
507 }
508 if (!ret) {
509 TELEPHONY_LOGE("write reply failed.");
510 return TELEPHONY_ERR_WRITE_DATA_FAIL;
511 }
512 return NO_ERROR;
513 }
514
OnGetImei(MessageParcel & data,MessageParcel & reply)515 int32_t CoreServiceStub::OnGetImei(MessageParcel &data, MessageParcel &reply)
516 {
517 int32_t slotId = data.ReadInt32();
518 std::u16string imei = u"";
519 int32_t result = GetImei(slotId, imei);
520 if (!reply.WriteInt32(result)) {
521 TELEPHONY_LOGE("OnRemoteRequest::OnGetImei write reply failed.");
522 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
523 }
524 if (result == TELEPHONY_ERR_SUCCESS) {
525 if (!reply.WriteString16(imei)) {
526 TELEPHONY_LOGE("OnRemoteRequest::OnGetImei write reply failed.");
527 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
528 }
529 }
530 return NO_ERROR;
531 }
532
OnGetImeiSv(MessageParcel & data,MessageParcel & reply)533 int32_t CoreServiceStub::OnGetImeiSv(MessageParcel &data, MessageParcel &reply)
534 {
535 int32_t slotId = data.ReadInt32();
536 std::u16string imeiSv = u"";
537 int32_t result = GetImeiSv(slotId, imeiSv);
538 if (!reply.WriteInt32(result)) {
539 TELEPHONY_LOGE("OnRemoteRequest::OnGetImeiSv write reply failed.");
540 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
541 }
542 if (result == TELEPHONY_ERR_SUCCESS) {
543 if (!reply.WriteString16(imeiSv)) {
544 TELEPHONY_LOGE("OnRemoteRequest::OnGetImeiSv write reply failed.");
545 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
546 }
547 }
548 return NO_ERROR;
549 }
550
OnGetMeid(MessageParcel & data,MessageParcel & reply)551 int32_t CoreServiceStub::OnGetMeid(MessageParcel &data, MessageParcel &reply)
552 {
553 int32_t slotId = data.ReadInt32();
554 std::u16string meid = u"";
555 int32_t result = GetMeid(slotId, meid);
556 if (!reply.WriteInt32(result)) {
557 TELEPHONY_LOGE("OnRemoteRequest::OnGetMeid write reply failed.");
558 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
559 }
560 if (result == TELEPHONY_ERR_SUCCESS) {
561 if (!reply.WriteString16(meid)) {
562 TELEPHONY_LOGE("OnRemoteRequest::OnGetMeid write reply failed.");
563 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
564 }
565 }
566 return NO_ERROR;
567 }
568
OnGetUniqueDeviceId(MessageParcel & data,MessageParcel & reply)569 int32_t CoreServiceStub::OnGetUniqueDeviceId(MessageParcel &data, MessageParcel &reply)
570 {
571 int32_t slotId = data.ReadInt32();
572 std::u16string deviceId = u"";
573 int32_t result = GetUniqueDeviceId(slotId, deviceId);
574 if (!reply.WriteInt32(result)) {
575 TELEPHONY_LOGE("OnRemoteRequest::OnGetUniqueDeviceId write reply failed.");
576 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
577 }
578 if (result == TELEPHONY_ERR_SUCCESS) {
579 if (!reply.WriteString16(deviceId)) {
580 TELEPHONY_LOGE("OnRemoteRequest::OnGetUniqueDeviceId write reply failed.");
581 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
582 }
583 }
584 return NO_ERROR;
585 }
586
OnIsNrSupported(MessageParcel & data,MessageParcel & reply)587 int32_t CoreServiceStub::OnIsNrSupported(MessageParcel &data, MessageParcel &reply)
588 {
589 int32_t slotId = data.ReadInt32();
590 bool result = IsNrSupported(slotId);
591 bool ret = reply.WriteBool(result);
592 if (!ret) {
593 TELEPHONY_LOGE("OnRemoteRequest::IS_NR_SUPPORTED write reply failed.");
594 return ERR_FLATTEN_OBJECT;
595 }
596 return NO_ERROR;
597 }
598
OnSetNrOptionMode(MessageParcel & data,MessageParcel & reply)599 int32_t CoreServiceStub::OnSetNrOptionMode(MessageParcel &data, MessageParcel &reply)
600 {
601 int32_t slotId = data.ReadInt32();
602 int32_t nrMode = data.ReadInt32();
603 sptr<INetworkSearchCallback> callback = nullptr;
604 sptr<IRemoteObject> remoteCallback = data.ReadRemoteObject();
605 if (remoteCallback == nullptr) {
606 TELEPHONY_LOGE("CoreServiceStub::OnSetNrOptionMode remoteCallback is nullptr.");
607 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
608 }
609 callback = iface_cast<INetworkSearchCallback>(remoteCallback);
610 if (callback == nullptr) {
611 TELEPHONY_LOGE("CoreServiceStub::OnSetNrOptionMode callback is null");
612 return TELEPHONY_ERR_LOCAL_PTR_NULL;
613 }
614 int32_t result = SetNrOptionMode(slotId, nrMode, callback);
615 if (!reply.WriteInt32(result)) {
616 TELEPHONY_LOGE("OnRemoteRequest::OnSetNrOptionMode write reply failed.");
617 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
618 }
619 return NO_ERROR;
620 }
621
OnGetNrOptionMode(MessageParcel & data,MessageParcel & reply)622 int32_t CoreServiceStub::OnGetNrOptionMode(MessageParcel &data, MessageParcel &reply)
623 {
624 int32_t slotId = data.ReadInt32();
625 sptr<INetworkSearchCallback> callback = nullptr;
626 sptr<IRemoteObject> remoteCallback = data.ReadRemoteObject();
627 if (remoteCallback == nullptr) {
628 TELEPHONY_LOGE("CoreServiceStub::OnGetNrOptionMode remoteCallback is nullptr.");
629 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
630 }
631 callback = iface_cast<INetworkSearchCallback>(remoteCallback);
632 if (callback == nullptr) {
633 TELEPHONY_LOGE("CoreServiceStub::OnGetNrOptionMode callback is null");
634 return TELEPHONY_ERR_LOCAL_PTR_NULL;
635 }
636 int32_t result = GetNrOptionMode(slotId, callback);
637 if (!reply.WriteInt32(result)) {
638 TELEPHONY_LOGE("OnRemoteRequest::OnGetNrOptionMode write reply failed.");
639 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
640 }
641 return NO_ERROR;
642 }
643
OnHasSimCard(MessageParcel & data,MessageParcel & reply)644 int32_t CoreServiceStub::OnHasSimCard(MessageParcel &data, MessageParcel &reply)
645 {
646 int32_t slotId = data.ReadInt32();
647 bool hasSimCard = false;
648 int32_t result = HasSimCard(slotId, hasSimCard);
649 TELEPHONY_LOGD("result is %{public}s", hasSimCard ? "true" : "false");
650 bool ret = reply.WriteInt32(result);
651 if (result == TELEPHONY_ERR_SUCCESS) {
652 ret = (ret && reply.WriteBool(hasSimCard));
653 }
654 if (!ret) {
655 TELEPHONY_LOGE("write reply failed.");
656 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
657 }
658 return NO_ERROR;
659 }
660
OnGetSimState(MessageParcel & data,MessageParcel & reply)661 int32_t CoreServiceStub::OnGetSimState(MessageParcel &data, MessageParcel &reply)
662 {
663 int32_t slotId = data.ReadInt32();
664 SimState simState = SimState::SIM_STATE_UNKNOWN;
665 int32_t result = GetSimState(slotId, simState);
666 bool ret = reply.WriteInt32(result);
667 if (result == TELEPHONY_ERR_SUCCESS) {
668 ret = (ret && reply.WriteInt32(static_cast<int32_t>(simState)));
669 }
670 if (!ret) {
671 TELEPHONY_LOGE("OnRemoteRequest::GET_SIM_STATE write reply failed.");
672 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
673 }
674 return NO_ERROR;
675 }
676
OnGetDsdsMode(MessageParcel & data,MessageParcel & reply)677 int32_t CoreServiceStub::OnGetDsdsMode(MessageParcel &data, MessageParcel &reply)
678 {
679 int32_t dsdsMode = 0; /*0 means DSDS_MODE_V2*/
680 int32_t result = GetDsdsMode(dsdsMode);
681 bool ret = reply.WriteInt32(result);
682 if (result == TELEPHONY_ERR_SUCCESS) {
683 ret = (ret && reply.WriteInt32(static_cast<int32_t>(dsdsMode)));
684 }
685 if (!ret) {
686 TELEPHONY_LOGE("OnRemoteRequest::GET_DSDS_MODE write reply failed.");
687 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
688 }
689 return NO_ERROR;
690 }
691
OnGetCardType(MessageParcel & data,MessageParcel & reply)692 int32_t CoreServiceStub::OnGetCardType(MessageParcel &data, MessageParcel &reply)
693 {
694 int32_t slotId = data.ReadInt32();
695 CardType cardType = CardType::UNKNOWN_CARD;
696 int32_t result = GetCardType(slotId, cardType);
697 bool ret = reply.WriteInt32(result);
698 if (result == TELEPHONY_ERR_SUCCESS) {
699 ret = (ret && reply.WriteInt32(static_cast<int32_t>(cardType)));
700 }
701 if (!ret) {
702 TELEPHONY_LOGE("OnRemoteRequest::GET_CARD_TYPE write reply failed.");
703 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
704 }
705 return NO_ERROR;
706 }
707
OnGetISOCountryCodeForSim(MessageParcel & data,MessageParcel & reply)708 int32_t CoreServiceStub::OnGetISOCountryCodeForSim(MessageParcel &data, MessageParcel &reply)
709 {
710 int32_t slotId = data.ReadInt32();
711 std::u16string countryCode;
712 int32_t result = GetISOCountryCodeForSim(slotId, countryCode);
713 bool ret = reply.WriteInt32(result);
714 if (result == TELEPHONY_ERR_SUCCESS) {
715 ret = (ret && reply.WriteString16(countryCode));
716 }
717 if (!ret) {
718 TELEPHONY_LOGE("OnRemoteRequest::GET_ISO_COUNTRY_CODE write reply failed.");
719 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
720 }
721 return NO_ERROR;
722 }
723
OnGetSimSpn(MessageParcel & data,MessageParcel & reply)724 int32_t CoreServiceStub::OnGetSimSpn(MessageParcel &data, MessageParcel &reply)
725 {
726 int32_t slotId = data.ReadInt32();
727 std::u16string spn;
728 int32_t result = GetSimSpn(slotId, spn);
729 bool ret = reply.WriteInt32(result);
730 if (result == TELEPHONY_ERR_SUCCESS) {
731 ret = (ret && reply.WriteString16(spn));
732 }
733 if (!ret) {
734 TELEPHONY_LOGE("OnRemoteRequest::GET_SPN write reply failed.");
735 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
736 }
737 return NO_ERROR;
738 }
739
OnGetSimIccId(MessageParcel & data,MessageParcel & reply)740 int32_t CoreServiceStub::OnGetSimIccId(MessageParcel &data, MessageParcel &reply)
741 {
742 int32_t slotId = data.ReadInt32();
743 std::u16string iccId;
744 int32_t result = GetSimIccId(slotId, iccId);
745 bool ret = reply.WriteInt32(result);
746 if (result == TELEPHONY_ERR_SUCCESS) {
747 ret = (ret && reply.WriteString16(iccId));
748 }
749 if (!ret) {
750 TELEPHONY_LOGE("OnRemoteRequest::GET_ICCID write reply failed.");
751 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
752 }
753 return NO_ERROR;
754 }
755
OnGetSimOperatorNumeric(MessageParcel & data,MessageParcel & reply)756 int32_t CoreServiceStub::OnGetSimOperatorNumeric(MessageParcel &data, MessageParcel &reply)
757 {
758 int32_t slotId = data.ReadInt32();
759 std::u16string operatorNumeric;
760 int32_t result = GetSimOperatorNumeric(slotId, operatorNumeric);
761 bool ret = reply.WriteInt32(result);
762 if (result == TELEPHONY_ERR_SUCCESS) {
763 ret = (ret && reply.WriteString16(operatorNumeric));
764 }
765 if (!ret) {
766 TELEPHONY_LOGE("OnRemoteRequest::GET_SIM_OPERATOR_NUMERIC write reply failed.");
767 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
768 }
769 return NO_ERROR;
770 }
771
OnGetIMSI(MessageParcel & data,MessageParcel & reply)772 int32_t CoreServiceStub::OnGetIMSI(MessageParcel &data, MessageParcel &reply)
773 {
774 int32_t slotId = data.ReadInt32();
775 std::u16string imsi;
776 int32_t result = GetIMSI(slotId, imsi);
777 bool ret = reply.WriteInt32(result);
778 if (result == TELEPHONY_ERR_SUCCESS) {
779 ret = (ret && reply.WriteString16(imsi));
780 }
781 if (!ret) {
782 TELEPHONY_LOGE("OnRemoteRequest::GET_IMSI write reply failed.");
783 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
784 }
785 return NO_ERROR;
786 }
787
OnIsCTSimCard(MessageParcel & data,MessageParcel & reply)788 int32_t CoreServiceStub::OnIsCTSimCard(MessageParcel &data, MessageParcel &reply)
789 {
790 int32_t slotId = data.ReadInt32();
791 bool isCTSimCard = false;
792 int32_t result = IsCTSimCard(slotId, isCTSimCard);
793 bool ret = reply.WriteInt32(result);
794 if (result == TELEPHONY_ERR_SUCCESS) {
795 ret = (ret && reply.WriteBool(isCTSimCard));
796 }
797 if (!ret) {
798 TELEPHONY_LOGE("OnRemoteRequest::IS_CT_SIM_CARD write reply failed.");
799 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
800 }
801 return NO_ERROR;
802 }
803
OnIsSimActive(MessageParcel & data,MessageParcel & reply)804 int32_t CoreServiceStub::OnIsSimActive(MessageParcel &data, MessageParcel &reply)
805 {
806 int32_t slotId = data.ReadInt32();
807 bool result = IsSimActive(slotId);
808 TELEPHONY_LOGD("OnRemoteRequest::IsSimActive result is %{public}d", result);
809 bool ret = reply.WriteBool(result);
810 if (!ret) {
811 TELEPHONY_LOGE("OnRemoteRequest::IsSimActive write reply failed.");
812 return ERR_FLATTEN_OBJECT;
813 }
814 return NO_ERROR;
815 }
816
OnGetSlotId(MessageParcel & data,MessageParcel & reply)817 int32_t CoreServiceStub::OnGetSlotId(MessageParcel &data, MessageParcel &reply)
818 {
819 int32_t simId = data.ReadInt32();
820 int32_t result = GetSlotId(simId);
821 TELEPHONY_LOGD("OnRemoteRequest::OnGetSlotId result is %{public}d", result);
822 bool ret = reply.WriteInt32(result);
823 if (!ret) {
824 TELEPHONY_LOGE("OnRemoteRequest::OnGetSlotId write reply failed.");
825 return ERR_FLATTEN_OBJECT;
826 }
827 return NO_ERROR;
828 }
829
OnGetSimId(MessageParcel & data,MessageParcel & reply)830 int32_t CoreServiceStub::OnGetSimId(MessageParcel &data, MessageParcel &reply)
831 {
832 int32_t slotId = data.ReadInt32();
833 int32_t result = GetSimId(slotId);
834 TELEPHONY_LOGD("OnRemoteRequest::OnGetSimId result is %{public}d", result);
835 bool ret = reply.WriteInt32(result);
836 if (!ret) {
837 TELEPHONY_LOGE("OnRemoteRequest::OnGetSimId write reply failed.");
838 return ERR_FLATTEN_OBJECT;
839 }
840 return NO_ERROR;
841 }
842
OnGetNetworkSearchInformation(MessageParcel & data,MessageParcel & reply)843 int32_t CoreServiceStub::OnGetNetworkSearchInformation(MessageParcel &data, MessageParcel &reply)
844 {
845 sptr<INetworkSearchCallback> callback = nullptr;
846 int32_t slotId = data.ReadInt32();
847 sptr<IRemoteObject> remoteCallback = data.ReadRemoteObject();
848 if (remoteCallback != nullptr) {
849 callback = iface_cast<INetworkSearchCallback>(remoteCallback);
850 }
851 if (callback == nullptr) {
852 TELEPHONY_LOGE("CoreServiceStub::OnGetNetworkSearchInformation callback is null");
853 return TELEPHONY_ERR_LOCAL_PTR_NULL;
854 }
855 int32_t result = GetNetworkSearchInformation(slotId, callback);
856 if (!reply.WriteInt32(result)) {
857 TELEPHONY_LOGE("OnRemoteRequest::OnGetNetworkSearchInformation write reply failed.");
858 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
859 }
860 return NO_ERROR;
861 }
862
OnGetNetworkSelectionMode(MessageParcel & data,MessageParcel & reply)863 int32_t CoreServiceStub::OnGetNetworkSelectionMode(MessageParcel &data, MessageParcel &reply)
864 {
865 sptr<INetworkSearchCallback> callback = nullptr;
866 int32_t slotId = data.ReadInt32();
867 sptr<IRemoteObject> remoteCallback = data.ReadRemoteObject();
868 if (remoteCallback != nullptr) {
869 callback = iface_cast<INetworkSearchCallback>(remoteCallback);
870 }
871 if (callback == nullptr) {
872 TELEPHONY_LOGE("CoreServiceStub::OnGetNetworkSelectionMode callback is null");
873 return TELEPHONY_ERR_LOCAL_PTR_NULL;
874 }
875 int32_t result = GetNetworkSelectionMode(slotId, callback);
876 if (!reply.WriteInt32(result)) {
877 TELEPHONY_LOGE("CoreServiceStub::OnGetNetworkSelectionMode write reply failed.");
878 return TELEPHONY_ERR_WRITE_DATA_FAIL;
879 }
880 return NO_ERROR;
881 }
882
OnSetNetworkSelectionMode(MessageParcel & data,MessageParcel & reply)883 int32_t CoreServiceStub::OnSetNetworkSelectionMode(MessageParcel &data, MessageParcel &reply)
884 {
885 sptr<INetworkSearchCallback> callback = nullptr;
886 int32_t slotId = data.ReadInt32();
887 int32_t selectMode = data.ReadInt32();
888 TELEPHONY_LOGD("CoreServiceStub::OnSetNetworkSelectionMode selectMode:%{public}d", selectMode);
889 bool resumeSelection = data.ReadBool();
890 sptr<IRemoteObject> remoteCallback = data.ReadRemoteObject();
891 if (remoteCallback != nullptr) {
892 callback = iface_cast<INetworkSearchCallback>(remoteCallback);
893 } else {
894 TELEPHONY_LOGE("CoreServiceStub::OnSetNetworkSelectionMode remoteCallback is null");
895 }
896 sptr<NetworkInformation> networkState = NetworkInformation::Unmarshalling(data);
897 if (callback == nullptr) {
898 TELEPHONY_LOGE("CoreServiceStub::OnSetNetworkSelectionMode callback is null");
899 return TELEPHONY_ERR_LOCAL_PTR_NULL;
900 }
901 int32_t result = SetNetworkSelectionMode(slotId, selectMode, networkState, resumeSelection, callback);
902 if (!reply.WriteInt32(result)) {
903 TELEPHONY_LOGE("OnRemoteRequest::OnSetNetworkSelectionMode write reply failed.");
904 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
905 }
906 return NO_ERROR;
907 }
908
OnGetLocaleFromDefaultSim(MessageParcel & data,MessageParcel & reply)909 int32_t CoreServiceStub::OnGetLocaleFromDefaultSim(MessageParcel &data, MessageParcel &reply)
910 {
911 std::u16string result = GetLocaleFromDefaultSim();
912 bool ret = reply.WriteString16(result);
913 if (!ret) {
914 TELEPHONY_LOGE("OnRemoteRequest::GetLocaleFromDefaultSim write reply failed.");
915 return ERR_FLATTEN_OBJECT;
916 }
917 return NO_ERROR;
918 }
919
OnGetSimGid1(MessageParcel & data,MessageParcel & reply)920 int32_t CoreServiceStub::OnGetSimGid1(MessageParcel &data, MessageParcel &reply)
921 {
922 int32_t slotId = data.ReadInt32();
923 std::u16string gid1;
924 int32_t result = GetSimGid1(slotId, gid1);
925 bool ret = reply.WriteInt32(result);
926 if (result == TELEPHONY_ERR_SUCCESS) {
927 ret = (ret && reply.WriteString16(gid1));
928 }
929 if (!ret) {
930 TELEPHONY_LOGE("OnRemoteRequest::GetSimGid1 write reply failed.");
931 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
932 }
933 return NO_ERROR;
934 }
935
OnGetSimGid2(MessageParcel & data,MessageParcel & reply)936 int32_t CoreServiceStub::OnGetSimGid2(MessageParcel &data, MessageParcel &reply)
937 {
938 int32_t slotId = data.ReadInt32();
939 std::u16string result = GetSimGid2(slotId);
940 bool ret = reply.WriteString16(result);
941 if (!ret) {
942 TELEPHONY_LOGE("OnRemoteRequest::GetSimGid2 write reply failed.");
943 return ERR_FLATTEN_OBJECT;
944 }
945 return NO_ERROR;
946 }
947
OnGetSimEons(MessageParcel & data,MessageParcel & reply)948 int32_t CoreServiceStub::OnGetSimEons(MessageParcel &data, MessageParcel &reply)
949 {
950 int32_t slotId = data.ReadInt32();
951 const std::string plmn = data.ReadString();
952 int32_t lac = data.ReadInt32();
953 bool longNameRequired = data.ReadBool();
954 std::u16string result = GetSimEons(slotId, plmn, lac, longNameRequired);
955 bool ret = reply.WriteString16(result);
956 if (!ret) {
957 TELEPHONY_LOGE("OnRemoteRequest::GetSimEons write reply failed.");
958 return ERR_FLATTEN_OBJECT;
959 }
960 return NO_ERROR;
961 }
962
OnGetSimSubscriptionInfo(MessageParcel & data,MessageParcel & reply)963 int32_t CoreServiceStub::OnGetSimSubscriptionInfo(MessageParcel &data, MessageParcel &reply)
964 {
965 int32_t slotId = data.ReadInt32();
966 IccAccountInfo iccAccountInfo;
967 int32_t result = GetSimAccountInfo(slotId, iccAccountInfo);
968 bool ret = reply.WriteInt32(result);
969 if (!iccAccountInfo.Marshalling(reply)) {
970 TELEPHONY_LOGE("OnGetSimSubscriptionInfo IccAccountInfo reply Marshalling is false");
971 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
972 }
973 if (!ret) {
974 TELEPHONY_LOGE("OnGetSimSubscriptionInfo write reply failed.");
975 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
976 }
977 return NO_ERROR;
978 }
979
OnSetDefaultVoiceSlotId(MessageParcel & data,MessageParcel & reply)980 int32_t CoreServiceStub::OnSetDefaultVoiceSlotId(MessageParcel &data, MessageParcel &reply)
981 {
982 int32_t slotId = data.ReadInt32();
983 int32_t result = SetDefaultVoiceSlotId(slotId);
984 bool ret = reply.WriteInt32(result);
985 if (!ret) {
986 TELEPHONY_LOGE("OnSetDefaultVoiceSlotId write reply failed.");
987 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
988 }
989 return NO_ERROR;
990 }
991
OnGetDefaultVoiceSlotId(MessageParcel & data,MessageParcel & reply)992 int32_t CoreServiceStub::OnGetDefaultVoiceSlotId(MessageParcel &data, MessageParcel &reply)
993 {
994 int32_t result = GetDefaultVoiceSlotId();
995 bool ret = reply.WriteInt32(result);
996 if (!ret) {
997 TELEPHONY_LOGE("OnGetDefaultVoiceSlotId write reply failed.");
998 return ERR_FLATTEN_OBJECT;
999 }
1000 return NO_ERROR;
1001 }
1002
OnGetDefaultVoiceSimId(MessageParcel & data,MessageParcel & reply)1003 int32_t CoreServiceStub::OnGetDefaultVoiceSimId(MessageParcel &data, MessageParcel &reply)
1004 {
1005 int32_t simId = 0;
1006 int32_t result = GetDefaultVoiceSimId(simId);
1007 if (!reply.WriteInt32(result)) {
1008 TELEPHONY_LOGE("write int32 reply failed.");
1009 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1010 }
1011 if (result == TELEPHONY_ERR_SUCCESS) {
1012 if (!reply.WriteInt32(simId)) {
1013 TELEPHONY_LOGE("write int32 reply failed.");
1014 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1015 }
1016 }
1017 return NO_ERROR;
1018 }
1019
OnSetPrimarySlotId(MessageParcel & data,MessageParcel & reply)1020 int32_t CoreServiceStub::OnSetPrimarySlotId(MessageParcel &data, MessageParcel &reply)
1021 {
1022 int32_t slotId = data.ReadInt32();
1023 int32_t result = SetPrimarySlotId(slotId);
1024 if (!reply.WriteInt32(result)) {
1025 TELEPHONY_LOGE("OnRemoteRequest::OnSetPrimarySlotId write reply failed.");
1026 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1027 }
1028 return NO_ERROR;
1029 }
1030
OnGetPrimarySlotId(MessageParcel & data,MessageParcel & reply)1031 int32_t CoreServiceStub::OnGetPrimarySlotId(MessageParcel &data, MessageParcel &reply)
1032 {
1033 int32_t slotId = INVALID_VALUE;
1034 int32_t result = GetPrimarySlotId(slotId);
1035 bool ret = reply.WriteInt32(result);
1036 if (result == TELEPHONY_ERR_SUCCESS) {
1037 ret = (ret && reply.WriteInt32(slotId));
1038 }
1039 if (!ret) {
1040 TELEPHONY_LOGE("write reply failed.");
1041 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1042 }
1043 return NO_ERROR;
1044 }
1045
OnUnlockPin(MessageParcel & data,MessageParcel & reply)1046 int32_t CoreServiceStub::OnUnlockPin(MessageParcel &data, MessageParcel &reply)
1047 {
1048 LockStatusResponse response = { UNLOCK_FAIL, TELEPHONY_ERROR };
1049 int32_t slotId = data.ReadInt32();
1050 std::u16string pin = data.ReadString16();
1051 int32_t result = UnlockPin(slotId, pin, response);
1052 bool ret = reply.WriteInt32(result);
1053 TELEPHONY_LOGI(
1054 "OnUnlockPin, response.result :%{public}d, response.remain :%{public}d", response.result, response.remain);
1055 if (result == TELEPHONY_ERR_SUCCESS) {
1056 ret = (ret && reply.WriteInt32(response.result));
1057 ret = (ret && reply.WriteInt32(response.remain));
1058 }
1059 if (!ret) {
1060 TELEPHONY_LOGE("CoreServiceStub::OnUnlockPin write reply failed.");
1061 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1062 }
1063 return NO_ERROR;
1064 }
1065
OnUnlockPuk(MessageParcel & data,MessageParcel & reply)1066 int32_t CoreServiceStub::OnUnlockPuk(MessageParcel &data, MessageParcel &reply)
1067 {
1068 LockStatusResponse response = { UNLOCK_FAIL, TELEPHONY_ERROR };
1069 int32_t slotId = data.ReadInt32();
1070 std::u16string newPin = data.ReadString16();
1071 std::u16string puk = data.ReadString16();
1072 int32_t result = UnlockPuk(slotId, newPin, puk, response);
1073 bool ret = reply.WriteInt32(result);
1074 TELEPHONY_LOGI(
1075 "OnUnlockPuk, response.result :%{public}d, response.remain :%{public}d", response.result, response.remain);
1076 if (result == TELEPHONY_ERR_SUCCESS) {
1077 ret = (ret && reply.WriteInt32(response.result));
1078 ret = (ret && reply.WriteInt32(response.remain));
1079 }
1080 if (!ret) {
1081 TELEPHONY_LOGE("CoreServiceStub::OnUnlockPuk write reply failed.");
1082 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1083 }
1084 return NO_ERROR;
1085 }
1086
OnAlterPin(MessageParcel & data,MessageParcel & reply)1087 int32_t CoreServiceStub::OnAlterPin(MessageParcel &data, MessageParcel &reply)
1088 {
1089 LockStatusResponse response = { UNLOCK_FAIL, TELEPHONY_ERROR };
1090 int32_t slotId = data.ReadInt32();
1091 std::u16string newPin = data.ReadString16();
1092 std::u16string oldPin = data.ReadString16();
1093 int32_t result = AlterPin(slotId, newPin, oldPin, response);
1094 bool ret = reply.WriteInt32(result);
1095 TELEPHONY_LOGI(
1096 "OnAlterPin, response.result :%{public}d, response.remain :%{public}d", response.result, response.remain);
1097 if (result == TELEPHONY_ERR_SUCCESS) {
1098 ret = (ret && reply.WriteInt32(response.result));
1099 ret = (ret && reply.WriteInt32(response.remain));
1100 }
1101 if (!ret) {
1102 TELEPHONY_LOGE("CoreServiceStub::OnAlterPin write reply failed.");
1103 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1104 }
1105 return NO_ERROR;
1106 }
1107
OnUnlockPin2(MessageParcel & data,MessageParcel & reply)1108 int32_t CoreServiceStub::OnUnlockPin2(MessageParcel &data, MessageParcel &reply)
1109 {
1110 LockStatusResponse response = { UNLOCK_FAIL, TELEPHONY_ERROR };
1111 int32_t slotId = data.ReadInt32();
1112 std::u16string pin2 = data.ReadString16();
1113 int32_t result = UnlockPin2(slotId, pin2, response);
1114 bool ret = reply.WriteInt32(result);
1115 TELEPHONY_LOGI(
1116 "OnUnlockPin2, response.result :%{public}d, response.remain :%{public}d", response.result, response.remain);
1117 if (result == TELEPHONY_ERR_SUCCESS) {
1118 ret = (ret && reply.WriteInt32(response.result));
1119 ret = (ret && reply.WriteInt32(response.remain));
1120 }
1121 if (!ret) {
1122 TELEPHONY_LOGE("CoreServiceStub::OnUnlockPin2 write reply failed.");
1123 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1124 }
1125 return NO_ERROR;
1126 }
1127
OnUnlockPuk2(MessageParcel & data,MessageParcel & reply)1128 int32_t CoreServiceStub::OnUnlockPuk2(MessageParcel &data, MessageParcel &reply)
1129 {
1130 LockStatusResponse response = { UNLOCK_FAIL, TELEPHONY_ERROR };
1131 int32_t slotId = data.ReadInt32();
1132 std::u16string newPin2 = data.ReadString16();
1133 std::u16string puk2 = data.ReadString16();
1134 int32_t result = UnlockPuk2(slotId, newPin2, puk2, response);
1135 bool ret = reply.WriteInt32(result);
1136 TELEPHONY_LOGI(
1137 "OnUnlockPuk2, response.result :%{public}d, response.remain :%{public}d", response.result, response.remain);
1138 if (result == TELEPHONY_ERR_SUCCESS) {
1139 ret = (ret && reply.WriteInt32(response.result));
1140 ret = (ret && reply.WriteInt32(response.remain));
1141 }
1142 if (!ret) {
1143 TELEPHONY_LOGE("CoreServiceStub::OnUnlockPuk2 write reply failed.");
1144 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1145 }
1146 return NO_ERROR;
1147 }
1148
OnAlterPin2(MessageParcel & data,MessageParcel & reply)1149 int32_t CoreServiceStub::OnAlterPin2(MessageParcel &data, MessageParcel &reply)
1150 {
1151 LockStatusResponse response = { UNLOCK_FAIL, TELEPHONY_ERROR };
1152 int32_t slotId = data.ReadInt32();
1153 std::u16string newPin2 = data.ReadString16();
1154 std::u16string oldPin2 = data.ReadString16();
1155 int32_t result = AlterPin2(slotId, newPin2, oldPin2, response);
1156 bool ret = reply.WriteInt32(result);
1157 TELEPHONY_LOGI(
1158 "OnAlterPin2, response.result :%{public}d, response.remain :%{public}d", response.result, response.remain);
1159 if (result == TELEPHONY_ERR_SUCCESS) {
1160 ret = (ret && reply.WriteInt32(response.result));
1161 ret = (ret && reply.WriteInt32(response.remain));
1162 }
1163 if (!ret) {
1164 TELEPHONY_LOGE("CoreServiceStub::OnAlterPin2 write reply failed.");
1165 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1166 }
1167 return NO_ERROR;
1168 }
1169
OnSetLockState(MessageParcel & data,MessageParcel & reply)1170 int32_t CoreServiceStub::OnSetLockState(MessageParcel &data, MessageParcel &reply)
1171 {
1172 LockInfo options;
1173 int32_t slotId = data.ReadInt32();
1174 options.lockType = static_cast<LockType>(data.ReadInt32());
1175 options.lockState = static_cast<LockState>(data.ReadInt32());
1176 options.password = data.ReadString16();
1177 LockStatusResponse response = { UNLOCK_FAIL, TELEPHONY_ERROR };
1178 TELEPHONY_LOGI("CoreServiceStub::OnSetLockState(), lockType = %{public}d, lockState = %{public}d, "
1179 "slotId = %{public}d",
1180 options.lockType, options.lockState, slotId);
1181 int32_t result = SetLockState(slotId, options, response);
1182 bool ret = reply.WriteInt32(result);
1183 TELEPHONY_LOGI(
1184 "OnSetLockState, response.result :%{public}d, response.remain :%{public}d", response.result, response.remain);
1185 if (result == TELEPHONY_ERR_SUCCESS) {
1186 ret = (ret && reply.WriteInt32(response.result));
1187 ret = (ret && reply.WriteInt32(response.remain));
1188 }
1189 if (!ret) {
1190 TELEPHONY_LOGE("CoreServiceStub::OnSetLockState write reply failed.");
1191 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1192 }
1193 return NO_ERROR;
1194 }
1195
OnGetLockState(MessageParcel & data,MessageParcel & reply)1196 int32_t CoreServiceStub::OnGetLockState(MessageParcel &data, MessageParcel &reply)
1197 {
1198 LockState lockState = LockState::LOCK_ERROR;
1199 LockType lockType;
1200 int32_t slotId = data.ReadInt32();
1201 lockType = static_cast<LockType>(data.ReadInt32());
1202 TELEPHONY_LOGI("CoreServiceStub::OnGetLockState(),lockType = %{public}d, slotId = %{public}d", lockType, slotId);
1203 int32_t result = GetLockState(slotId, lockType, lockState);
1204 bool ret = reply.WriteInt32(result);
1205 if (result == TELEPHONY_ERR_SUCCESS) {
1206 ret = (ret && reply.WriteInt32(static_cast<int32_t>(lockState)));
1207 }
1208 if (!ret) {
1209 TELEPHONY_LOGE("CoreServiceStub::OnGetLockState write reply failed.");
1210 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1211 }
1212 return NO_ERROR;
1213 }
1214
OnRefreshSimState(MessageParcel & data,MessageParcel & reply)1215 int32_t CoreServiceStub::OnRefreshSimState(MessageParcel &data, MessageParcel &reply)
1216 {
1217 int32_t slotId = data.ReadInt32();
1218 TELEPHONY_LOGD("CoreServiceStub::OnRefreshSimState(), slotId = %{public}d", slotId);
1219 int32_t result = RefreshSimState(slotId);
1220 bool ret = reply.WriteInt32(result);
1221 if (!ret) {
1222 TELEPHONY_LOGE("CoreServiceStub::OnRefreshSimState write reply failed.");
1223 return ERR_FLATTEN_OBJECT;
1224 }
1225 return NO_ERROR;
1226 }
1227
OnSetActiveSim(MessageParcel & data,MessageParcel & reply)1228 int32_t CoreServiceStub::OnSetActiveSim(MessageParcel &data, MessageParcel &reply)
1229 {
1230 int32_t slotId = data.ReadInt32();
1231 int32_t enable = data.ReadInt32();
1232 TELEPHONY_LOGD("CoreServiceStub::OnSetActiveSim(), slotId = %{public}d", slotId);
1233 int32_t result = SetActiveSim(slotId, enable);
1234 bool ret = reply.WriteInt32(result);
1235 if (!ret) {
1236 TELEPHONY_LOGE("CoreServiceStub::OnSetActiveSim write reply failed.");
1237 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1238 }
1239 return NO_ERROR;
1240 }
1241
OnSetActiveSimSatellite(MessageParcel & data,MessageParcel & reply)1242 int32_t CoreServiceStub::OnSetActiveSimSatellite(MessageParcel &data, MessageParcel &reply)
1243 {
1244 int32_t slotId = data.ReadInt32();
1245 int32_t enable = data.ReadInt32();
1246 TELEPHONY_LOGD("CoreServiceStub::OnSetActiveSimSatellite(), slotId = %{public}d", slotId);
1247 int32_t result = SetActiveSimSatellite(slotId, enable);
1248 bool ret = reply.WriteInt32(result);
1249 if (!ret) {
1250 TELEPHONY_LOGE("CoreServiceStub::OnSetActiveSimSatellite write reply failed.");
1251 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1252 }
1253 return NO_ERROR;
1254 }
1255
OnGetPreferredNetwork(MessageParcel & data,MessageParcel & reply)1256 int32_t CoreServiceStub::OnGetPreferredNetwork(MessageParcel &data, MessageParcel &reply)
1257 {
1258 sptr<INetworkSearchCallback> callback = nullptr;
1259 int32_t slotId = data.ReadInt32();
1260 sptr<IRemoteObject> remoteCallback = data.ReadRemoteObject();
1261 if (remoteCallback != nullptr) {
1262 TELEPHONY_LOGD("CoreServiceStub::OnGetPreferredNetwork remote callback is not null.");
1263 callback = iface_cast<INetworkSearchCallback>(remoteCallback);
1264 }
1265 if (callback == nullptr) {
1266 TELEPHONY_LOGE("CoreServiceStub::OnGetPreferredNetwork callback is null");
1267 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1268 }
1269 int32_t result = GetPreferredNetwork(slotId, callback);
1270 if (!reply.WriteInt32(result)) {
1271 TELEPHONY_LOGE("OnRemoteRequest::OnGetPreferredNetwork write reply failed.");
1272 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1273 }
1274 return NO_ERROR;
1275 }
1276
OnGetNetworkCapability(MessageParcel & data,MessageParcel & reply)1277 int32_t CoreServiceStub::OnGetNetworkCapability(MessageParcel &data, MessageParcel &reply)
1278 {
1279 int32_t slotId = data.ReadInt32();
1280 int32_t networkCapabilityType = data.ReadInt32();
1281 int32_t networkCapabilityState = 0;
1282 int32_t result = GetNetworkCapability(slotId, networkCapabilityType, networkCapabilityState);
1283 bool ret = reply.WriteInt32(result);
1284 if (result == TELEPHONY_ERR_SUCCESS) {
1285 ret = (ret && reply.WriteInt32(networkCapabilityState));
1286 }
1287 if (!ret) {
1288 TELEPHONY_LOGE("OnRemoteRequest::OnGetNetworkCapability write reply failed.");
1289 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1290 }
1291 return NO_ERROR;
1292 }
1293
OnSetNetworkCapability(MessageParcel & data,MessageParcel & reply)1294 int32_t CoreServiceStub::OnSetNetworkCapability(MessageParcel &data, MessageParcel &reply)
1295 {
1296 int32_t slotId = data.ReadInt32();
1297 int32_t networkCapabilityType = data.ReadInt32();
1298 int32_t networkCapabilityState = data.ReadInt32();
1299 int32_t result = SetNetworkCapability(slotId, networkCapabilityType, networkCapabilityState);
1300 if (!reply.WriteInt32(result)) {
1301 TELEPHONY_LOGE("OnRemoteRequest::OnSetNetworkCapability write reply failed.");
1302 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1303 }
1304 return NO_ERROR;
1305 }
1306
OnSetShowNumber(MessageParcel & data,MessageParcel & reply)1307 int32_t CoreServiceStub::OnSetShowNumber(MessageParcel &data, MessageParcel &reply)
1308 {
1309 int32_t slotId = data.ReadInt32();
1310 std::u16string number = data.ReadString16();
1311 int32_t result = SetShowNumber(slotId, number);
1312 bool ret = reply.WriteInt32(result);
1313 if (!ret) {
1314 TELEPHONY_LOGE("OnSetShowNumber write reply failed.");
1315 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1316 }
1317 return result;
1318 }
1319
OnGetShowNumber(OHOS::MessageParcel & data,OHOS::MessageParcel & reply)1320 int32_t CoreServiceStub::OnGetShowNumber(OHOS::MessageParcel &data, OHOS::MessageParcel &reply)
1321 {
1322 int32_t slotId = data.ReadInt32();
1323 std::u16string showNumber;
1324 int32_t result = GetShowNumber(slotId, showNumber);
1325 bool ret = reply.WriteInt32(result);
1326 if (result == TELEPHONY_ERR_SUCCESS) {
1327 ret = (ret && reply.WriteString16(showNumber));
1328 }
1329 if (!ret) {
1330 TELEPHONY_LOGE("OnGetShowNumber write reply failed.");
1331 return ERR_FLATTEN_OBJECT;
1332 }
1333 return NO_ERROR;
1334 }
1335
OnSetShowName(MessageParcel & data,MessageParcel & reply)1336 int32_t CoreServiceStub::OnSetShowName(MessageParcel &data, MessageParcel &reply)
1337 {
1338 int32_t slotId = data.ReadInt32();
1339 std::u16string name = data.ReadString16();
1340 int32_t result = SetShowName(slotId, name);
1341 bool ret = reply.WriteInt32(result);
1342 if (!ret) {
1343 TELEPHONY_LOGE("OnSetShowName write reply failed.");
1344 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1345 }
1346 return NO_ERROR;
1347 }
1348
OnSetPreferredNetwork(MessageParcel & data,MessageParcel & reply)1349 int32_t CoreServiceStub::OnSetPreferredNetwork(MessageParcel &data, MessageParcel &reply)
1350 {
1351 sptr<INetworkSearchCallback> callback = nullptr;
1352 int32_t slotId = data.ReadInt32();
1353 int32_t networkMode = data.ReadInt32();
1354 TELEPHONY_LOGI("CoreServiceStub::OnSetPreferredNetwork selectMode:%{public}d", networkMode);
1355 sptr<IRemoteObject> remoteCallback = data.ReadRemoteObject();
1356 if (remoteCallback != nullptr) {
1357 callback = iface_cast<INetworkSearchCallback>(remoteCallback);
1358 } else {
1359 TELEPHONY_LOGE("CoreServiceStub::OnSetPreferredNetwork remoteCallback is null");
1360 }
1361 if (callback == nullptr) {
1362 TELEPHONY_LOGE("CoreServiceStub::OnSetPreferredNetwork callback is null");
1363 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1364 }
1365 int32_t result = SetPreferredNetwork(slotId, networkMode, callback);
1366 if (!reply.WriteInt32(result)) {
1367 TELEPHONY_LOGE("OnRemoteRequest::OnSetPreferredNetwork write reply failed.");
1368 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1369 }
1370 return NO_ERROR;
1371 }
1372
OnGetShowName(OHOS::MessageParcel & data,OHOS::MessageParcel & reply)1373 int32_t CoreServiceStub::OnGetShowName(OHOS::MessageParcel &data, OHOS::MessageParcel &reply)
1374 {
1375 int32_t slotId = data.ReadInt32();
1376 std::u16string showName;
1377 int32_t result = GetShowName(slotId, showName);
1378 bool ret = reply.WriteInt32(result);
1379 if (result == TELEPHONY_ERR_SUCCESS) {
1380 ret = (ret && reply.WriteString16(showName));
1381 }
1382 if (!ret) {
1383 TELEPHONY_LOGE("OnGetShowName write reply failed.");
1384 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1385 }
1386 return NO_ERROR;
1387 }
1388
OnGetActiveSimAccountInfoList(MessageParcel & data,MessageParcel & reply)1389 int32_t CoreServiceStub::OnGetActiveSimAccountInfoList(MessageParcel &data, MessageParcel &reply)
1390 {
1391 std::vector<IccAccountInfo> iccAccountInfoList;
1392 int32_t result = GetActiveSimAccountInfoList(iccAccountInfoList);
1393 int32_t size = static_cast<int32_t>(iccAccountInfoList.size());
1394 bool ret = reply.WriteInt32(result);
1395 ret = (ret && reply.WriteInt32(size));
1396 if (!ret) {
1397 TELEPHONY_LOGE("OnGetActiveSimAccountInfoList write reply failed.");
1398 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1399 }
1400 std::vector<IccAccountInfo>::iterator it = iccAccountInfoList.begin();
1401 while (it != iccAccountInfoList.end()) {
1402 TELEPHONY_LOGI("OnGetActiveSimAccountInfoList slotIndex = %{public}d", (*it).slotIndex);
1403 if (!(*it).Marshalling(reply)) {
1404 TELEPHONY_LOGE("OnGetActiveSimAccountInfoList IccAccountInfo reply Marshalling is false");
1405 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1406 }
1407 ++it;
1408 }
1409 return NO_ERROR;
1410 }
1411
OnGetOperatorConfig(MessageParcel & data,MessageParcel & reply)1412 int32_t CoreServiceStub::OnGetOperatorConfig(MessageParcel &data, MessageParcel &reply)
1413 {
1414 int32_t slotId = data.ReadInt32();
1415 OperatorConfig operatorConfig;
1416 int32_t result = GetOperatorConfigs(slotId, operatorConfig);
1417 bool ret = reply.WriteInt32(result);
1418 if (!ret) {
1419 TELEPHONY_LOGE("OnGetOperatorConfig write reply failed.");
1420 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1421 }
1422 if (result == TELEPHONY_ERR_SUCCESS) {
1423 if (!operatorConfig.Marshalling(reply)) {
1424 TELEPHONY_LOGE("OnGetOperatorConfig operatorConfig reply Marshalling is false");
1425 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1426 }
1427 }
1428 return NO_ERROR;
1429 }
1430
OnGetSimPhoneNumber(MessageParcel & data,MessageParcel & reply)1431 int32_t CoreServiceStub::OnGetSimPhoneNumber(MessageParcel &data, MessageParcel &reply)
1432 {
1433 int32_t slotId = data.ReadInt32();
1434 std::u16string telephoneNumber;
1435 int32_t result = GetSimTelephoneNumber(slotId, telephoneNumber);
1436 bool ret = reply.WriteInt32(result);
1437 if (result == TELEPHONY_ERR_SUCCESS) {
1438 ret = (ret && reply.WriteString16(telephoneNumber));
1439 }
1440 if (!ret) {
1441 TELEPHONY_LOGE("OnRemoteRequest::OnGetSimPhoneNumber write reply failed.");
1442 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1443 }
1444 return NO_ERROR;
1445 }
1446
OnGetSimTeleNumberIdentifier(MessageParcel & data,MessageParcel & reply)1447 int32_t CoreServiceStub::OnGetSimTeleNumberIdentifier(MessageParcel &data, MessageParcel &reply)
1448 {
1449 const int32_t slotId = data.ReadInt32();
1450 std::u16string result = GetSimTeleNumberIdentifier(slotId);
1451 bool ret = reply.WriteString16(result);
1452 if (!ret) {
1453 TELEPHONY_LOGE("OnRemoteRequest::OnGetSimPhoneNumber write reply failed.");
1454 return ERR_FLATTEN_OBJECT;
1455 }
1456 return NO_ERROR;
1457 }
1458
OnGetVoiceMailInfor(MessageParcel & data,MessageParcel & reply)1459 int32_t CoreServiceStub::OnGetVoiceMailInfor(MessageParcel &data, MessageParcel &reply)
1460 {
1461 int32_t slotId = data.ReadInt32();
1462 std::u16string voiceMailIdentifier;
1463 int32_t result = GetVoiceMailIdentifier(slotId, voiceMailIdentifier);
1464 bool ret = reply.WriteInt32(result);
1465 if (result == TELEPHONY_ERR_SUCCESS) {
1466 ret = (ret && reply.WriteString16(voiceMailIdentifier));
1467 }
1468 if (!ret) {
1469 TELEPHONY_LOGE("OnRemoteRequest::OnGetVoiceMailInfor write reply failed.");
1470 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1471 }
1472 return NO_ERROR;
1473 }
1474
OnGetVoiceMailNumber(MessageParcel & data,MessageParcel & reply)1475 int32_t CoreServiceStub::OnGetVoiceMailNumber(MessageParcel &data, MessageParcel &reply)
1476 {
1477 int32_t slotId = data.ReadInt32();
1478 std::u16string voiceMailNumber;
1479 int32_t result = GetVoiceMailNumber(slotId, voiceMailNumber);
1480 bool ret = reply.WriteInt32(result);
1481 if (result == TELEPHONY_ERR_SUCCESS) {
1482 ret = (ret && reply.WriteString16(voiceMailNumber));
1483 }
1484 if (!ret) {
1485 TELEPHONY_LOGE("OnRemoteRequest::OnGetVoiceMailNumber write reply failed.");
1486 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1487 }
1488 return NO_ERROR;
1489 }
1490
OnGetVoiceMailCount(MessageParcel & data,MessageParcel & reply)1491 int32_t CoreServiceStub::OnGetVoiceMailCount(MessageParcel &data, MessageParcel &reply)
1492 {
1493 int32_t slotId = data.ReadInt32();
1494 int32_t voiceMailCount;
1495 int32_t result = GetVoiceMailCount(slotId, voiceMailCount);
1496 bool ret = reply.WriteInt32(result);
1497 if (result == TELEPHONY_ERR_SUCCESS) {
1498 ret = (ret && reply.WriteInt32(voiceMailCount));
1499 }
1500 if (!ret) {
1501 TELEPHONY_LOGE("OnRemoteRequest::OnGetVoiceMailCount write reply failed.");
1502 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1503 }
1504 return NO_ERROR;
1505 }
1506
OnSetVoiceMailCount(MessageParcel & data,MessageParcel & reply)1507 int32_t CoreServiceStub::OnSetVoiceMailCount(MessageParcel &data, MessageParcel &reply)
1508 {
1509 int32_t slotId = data.ReadInt32();
1510 int32_t voiceMailCount = data.ReadInt32();
1511 int32_t result = SetVoiceMailCount(slotId, voiceMailCount);
1512 if (!reply.WriteInt32(result)) {
1513 TELEPHONY_LOGE("OnRemoteRequest::OnSetVoiceMailCount write reply failed.");
1514 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1515 }
1516 return NO_ERROR;
1517 }
1518
OnSetVoiceCallForwarding(MessageParcel & data,MessageParcel & reply)1519 int32_t CoreServiceStub::OnSetVoiceCallForwarding(MessageParcel &data, MessageParcel &reply)
1520 {
1521 int32_t slotId = data.ReadInt32();
1522 bool enable = data.ReadBool();
1523 std::string number = data.ReadString();
1524 int32_t result = SetVoiceCallForwarding(slotId, enable, number);
1525 if (!reply.WriteInt32(result)) {
1526 TELEPHONY_LOGE("OnRemoteRequest::OnSetVoiceCallForwarding write reply failed.");
1527 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1528 }
1529 return NO_ERROR;
1530 }
1531
OnDiallingNumbersGet(MessageParcel & data,MessageParcel & reply)1532 int32_t CoreServiceStub::OnDiallingNumbersGet(MessageParcel &data, MessageParcel &reply)
1533 {
1534 int32_t slotId = data.ReadInt32();
1535 int32_t type = data.ReadInt32();
1536 std::vector<std::shared_ptr<DiallingNumbersInfo>> diallingNumbers;
1537 int32_t result = QueryIccDiallingNumbers(slotId, type, diallingNumbers);
1538 bool ret = reply.WriteInt32(result);
1539 if (!ret) {
1540 TELEPHONY_LOGE("OnRemoteRequest::OnDiallingNumbersGet write reply failed.");
1541 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1542 }
1543 if (result == TELEPHONY_ERR_SUCCESS) {
1544 reply.WriteInt32(static_cast<int32_t>(diallingNumbers.size()));
1545 for (const auto &v : diallingNumbers) {
1546 v->Marshalling(reply);
1547 }
1548 }
1549 return NO_ERROR;
1550 }
1551
OnAddIccDiallingNumbers(MessageParcel & data,MessageParcel & reply)1552 int32_t CoreServiceStub::OnAddIccDiallingNumbers(MessageParcel &data, MessageParcel &reply)
1553 {
1554 int32_t slotId = data.ReadInt32();
1555 int32_t type = data.ReadInt32();
1556 std::shared_ptr<DiallingNumbersInfo> diallingNumber = DiallingNumbersInfo::UnMarshalling(data);
1557 if (diallingNumber == nullptr) {
1558 TELEPHONY_LOGE("CoreServiceStub::OnAddIccDiallingNumbers diallingNumber is null");
1559 return TELEPHONY_ERR_READ_DATA_FAIL;
1560 }
1561 int32_t result = AddIccDiallingNumbers(slotId, type, diallingNumber);
1562 bool ret = reply.WriteInt32(result);
1563 if (!ret) {
1564 TELEPHONY_LOGE("OnAddIccDiallingNumbers write reply failed.");
1565 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1566 }
1567 return NO_ERROR;
1568 }
1569
OnUpdateIccDiallingNumbers(MessageParcel & data,MessageParcel & reply)1570 int32_t CoreServiceStub::OnUpdateIccDiallingNumbers(MessageParcel &data, MessageParcel &reply)
1571 {
1572 int32_t slotId = data.ReadInt32();
1573 int32_t type = data.ReadInt32();
1574 std::shared_ptr<DiallingNumbersInfo> diallingNumber = DiallingNumbersInfo::UnMarshalling(data);
1575 if (diallingNumber == nullptr) {
1576 TELEPHONY_LOGE("CoreServiceStub::OnUpdateIccDiallingNumbers diallingNumber is null");
1577 return TELEPHONY_ERR_READ_DATA_FAIL;
1578 }
1579 int32_t result = UpdateIccDiallingNumbers(slotId, type, diallingNumber);
1580 bool ret = reply.WriteInt32(result);
1581 if (!ret) {
1582 TELEPHONY_LOGE("OnUpdateIccDiallingNumbers write reply failed.");
1583 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1584 }
1585 return NO_ERROR;
1586 }
1587
OnDelIccDiallingNumbers(MessageParcel & data,MessageParcel & reply)1588 int32_t CoreServiceStub::OnDelIccDiallingNumbers(MessageParcel &data, MessageParcel &reply)
1589 {
1590 int32_t slotId = data.ReadInt32();
1591 int32_t type = data.ReadInt32();
1592 std::shared_ptr<DiallingNumbersInfo> diallingNumber = DiallingNumbersInfo::UnMarshalling(data);
1593 if (diallingNumber == nullptr) {
1594 TELEPHONY_LOGE("CoreServiceStub::OnDelIccDiallingNumbers diallingNumber is null");
1595 return TELEPHONY_ERR_READ_DATA_FAIL;
1596 }
1597 int32_t result = DelIccDiallingNumbers(slotId, type, diallingNumber);
1598 bool ret = reply.WriteInt32(result);
1599 if (!ret) {
1600 TELEPHONY_LOGE("OnDelIccDiallingNumbers write reply failed.");
1601 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1602 }
1603 return NO_ERROR;
1604 }
1605
OnSetVoiceMailInfo(MessageParcel & data,MessageParcel & reply)1606 int32_t CoreServiceStub::OnSetVoiceMailInfo(MessageParcel &data, MessageParcel &reply)
1607 {
1608 int32_t slotId = data.ReadInt32();
1609 std::u16string name = data.ReadString16();
1610 std::u16string number = data.ReadString16();
1611 int32_t result = SetVoiceMailInfo(slotId, name, number);
1612
1613 bool ret = reply.WriteInt32(result);
1614 if (!ret) {
1615 TELEPHONY_LOGE("OnSetVoiceMailInfo write reply failed.");
1616 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1617 }
1618 return NO_ERROR;
1619 }
1620
OnGetMaxSimCount(MessageParcel & data,MessageParcel & reply)1621 int32_t CoreServiceStub::OnGetMaxSimCount(MessageParcel &data, MessageParcel &reply)
1622 {
1623 int32_t result = GetMaxSimCount();
1624 int32_t ret = reply.WriteInt32(result);
1625 if (!ret) {
1626 TELEPHONY_LOGE("OnGetMaxSimCount write reply failed.");
1627 return ERR_FLATTEN_OBJECT;
1628 }
1629 return NO_ERROR;
1630 }
1631
OnGetOpKey(MessageParcel & data,MessageParcel & reply)1632 int32_t CoreServiceStub::OnGetOpKey(MessageParcel &data, MessageParcel &reply)
1633 {
1634 int32_t slotId = data.ReadInt32();
1635 std::u16string opkey;
1636 int32_t result = GetOpKey(slotId, opkey);
1637 if (!reply.WriteInt32(result)) {
1638 TELEPHONY_LOGE("OnRemoteRequest::OnGetOpKey write reply failed.");
1639 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1640 }
1641 if (result == TELEPHONY_ERR_SUCCESS) {
1642 if (!reply.WriteString16(opkey)) {
1643 TELEPHONY_LOGE("OnRemoteRequest::OnGetOpKey write reply failed.");
1644 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1645 }
1646 }
1647 return NO_ERROR;
1648 }
1649
OnGetOpKeyExt(MessageParcel & data,MessageParcel & reply)1650 int32_t CoreServiceStub::OnGetOpKeyExt(MessageParcel &data, MessageParcel &reply)
1651 {
1652 int32_t slotId = data.ReadInt32();
1653 std::u16string opkeyExt;
1654 int32_t result = GetOpKeyExt(slotId, opkeyExt);
1655 if (!reply.WriteInt32(result)) {
1656 TELEPHONY_LOGE("OnRemoteRequest::OnGetOpKeyExt write reply failed.");
1657 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1658 }
1659 if (result == TELEPHONY_ERR_SUCCESS) {
1660 if (!reply.WriteString16(opkeyExt)) {
1661 TELEPHONY_LOGE("OnRemoteRequest::OnGetOpKeyExt write reply failed.");
1662 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1663 }
1664 }
1665 return NO_ERROR;
1666 }
1667
OnGetOpName(MessageParcel & data,MessageParcel & reply)1668 int32_t CoreServiceStub::OnGetOpName(MessageParcel &data, MessageParcel &reply)
1669 {
1670 int32_t slotId = data.ReadInt32();
1671 std::u16string opname;
1672 int32_t result = GetOpName(slotId, opname);
1673 if (!reply.WriteInt32(result)) {
1674 TELEPHONY_LOGE("OnRemoteRequest::OnGetOpName write reply failed.");
1675 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1676 }
1677 if (result == TELEPHONY_ERR_SUCCESS) {
1678 if (!reply.WriteString16(opname)) {
1679 TELEPHONY_LOGE("OnRemoteRequest::OnGetOpName write reply failed.");
1680 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1681 }
1682 }
1683 return NO_ERROR;
1684 }
1685
OnSendEnvelopeCmd(MessageParcel & data,MessageParcel & reply)1686 int32_t CoreServiceStub::OnSendEnvelopeCmd(MessageParcel &data, MessageParcel &reply)
1687 {
1688 int32_t slotId = data.ReadInt32();
1689 std::string cmd = data.ReadString();
1690 int32_t result = SendEnvelopeCmd(slotId, cmd);
1691 TELEPHONY_LOGI("OnRemoteRequest::OnSendEnvelopeCmd result is %{public}s", result ? "true" : "false");
1692 bool ret = reply.WriteInt32(result);
1693 if (!ret) {
1694 TELEPHONY_LOGE("OnRemoteRequest::OnSendEnvelopeCmd write reply failed.");
1695 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1696 }
1697 return NO_ERROR;
1698 }
1699
OnSendTerminalResponseCmd(MessageParcel & data,MessageParcel & reply)1700 int32_t CoreServiceStub::OnSendTerminalResponseCmd(MessageParcel &data, MessageParcel &reply)
1701 {
1702 int32_t slotId = data.ReadInt32();
1703 std::string cmd = data.ReadString();
1704 int32_t result = SendTerminalResponseCmd(slotId, cmd);
1705 TELEPHONY_LOGD("OnRemoteRequest::OnSendTerminalResponseCmd result is %{public}s", result ? "true" : "false");
1706 bool ret = reply.WriteInt32(result);
1707 if (!ret) {
1708 TELEPHONY_LOGE("OnRemoteRequest::OnSendTerminalResponseCmd write reply failed.");
1709 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1710 }
1711 return NO_ERROR;
1712 }
1713
OnSendCallSetupRequestResult(MessageParcel & data,MessageParcel & reply)1714 int32_t CoreServiceStub::OnSendCallSetupRequestResult(MessageParcel &data, MessageParcel &reply)
1715 {
1716 int32_t slotId = data.ReadInt32();
1717 bool accept = data.ReadInt32();
1718 int32_t result = SendCallSetupRequestResult(slotId, accept);
1719 TELEPHONY_LOGD("OnRemoteRequest::OnSendCallSetupRequestResult result is %{public}d", result);
1720 bool ret = reply.WriteInt32(result);
1721 if (!ret) {
1722 TELEPHONY_LOGE("OnRemoteRequest::OnSendCallSetupRequestResult write reply failed.");
1723 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1724 }
1725 return NO_ERROR;
1726 }
1727
OnUnlockSimLock(MessageParcel & data,MessageParcel & reply)1728 int32_t CoreServiceStub::OnUnlockSimLock(MessageParcel &data, MessageParcel &reply)
1729 {
1730 PersoLockInfo lockInfo;
1731 int32_t slotId = data.ReadInt32();
1732 lockInfo.lockType = static_cast<PersoLockType>(data.ReadInt32());
1733 lockInfo.password = data.ReadString16();
1734 LockStatusResponse response = { UNLOCK_FAIL, TELEPHONY_ERROR };
1735
1736 TELEPHONY_LOGI("CoreServiceStub::OnUnlockSimLock(), lockType = %{public}d", lockInfo.lockType);
1737 int32_t result = UnlockSimLock(slotId, lockInfo, response);
1738 bool ret = reply.WriteInt32(result);
1739 if (result == TELEPHONY_ERR_SUCCESS) {
1740 ret = (ret && reply.WriteInt32(response.result));
1741 ret = (ret && reply.WriteInt32(response.remain));
1742 }
1743 if (!ret) {
1744 TELEPHONY_LOGE("CoreServiceStub::OnUnlockSimLock write reply failed.");
1745 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1746 }
1747 return NO_ERROR;
1748 }
1749
OnGetImsRegStatus(MessageParcel & data,MessageParcel & reply)1750 int32_t CoreServiceStub::OnGetImsRegStatus(MessageParcel &data, MessageParcel &reply)
1751 {
1752 int32_t slotId = data.ReadInt32();
1753 ImsServiceType imsSrvType = static_cast<ImsServiceType>(data.ReadInt32());
1754 ImsRegInfo info;
1755 int32_t result = GetImsRegStatus(slotId, imsSrvType, info);
1756 bool ret = reply.WriteInt32(result);
1757 ret = (ret && reply.WriteInt32(info.imsRegState));
1758 ret = (ret && reply.WriteInt32(info.imsRegTech));
1759 if (!ret) {
1760 TELEPHONY_LOGE("write reply failed.");
1761 return ERR_FLATTEN_OBJECT;
1762 }
1763 return NO_ERROR;
1764 }
1765
OnGetCellInfoList(MessageParcel & data,MessageParcel & reply)1766 int32_t CoreServiceStub::OnGetCellInfoList(MessageParcel &data, MessageParcel &reply)
1767 {
1768 auto slotId = data.ReadInt32();
1769 std::vector<sptr<CellInformation>> cellInfo;
1770 int32_t result = GetCellInfoList(slotId, cellInfo);
1771 if (!reply.WriteInt32(result)) {
1772 TELEPHONY_LOGE("OnRemoteRequest::OnGetCellInfoList write reply failed.");
1773 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1774 }
1775 if (result == TELEPHONY_ERR_SUCCESS) {
1776 reply.WriteInt32(static_cast<int32_t>(cellInfo.size()));
1777 for (const auto &v : cellInfo) {
1778 v->Marshalling(reply);
1779 }
1780 }
1781 return NO_ERROR;
1782 }
1783
OnGetNeighboringCellInfoList(MessageParcel & data,MessageParcel & reply)1784 int32_t CoreServiceStub::OnGetNeighboringCellInfoList(MessageParcel &data, MessageParcel &reply)
1785 {
1786 auto slotId = data.ReadInt32();
1787 std::vector<sptr<CellInformation>> cellInfo;
1788 int32_t result = GetNeighboringCellInfoList(slotId, cellInfo);
1789 if (!reply.WriteInt32(result)) {
1790 TELEPHONY_LOGE("OnRemoteRequest::OnGetCellInfoList write reply failed.");
1791 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1792 }
1793 if (result == TELEPHONY_ERR_SUCCESS) {
1794 reply.WriteInt32(static_cast<int32_t>(cellInfo.size()));
1795 for (const auto &v : cellInfo) {
1796 v->Marshalling(reply);
1797 }
1798 }
1799 return NO_ERROR;
1800 }
1801
OnGetCellLocation(MessageParcel & data,MessageParcel & reply)1802 int32_t CoreServiceStub::OnGetCellLocation(MessageParcel &data, MessageParcel &reply)
1803 {
1804 int32_t slotId = data.ReadInt32();
1805 int32_t result = SendUpdateCellLocationRequest(slotId);
1806 if (!reply.WriteInt32(result)) {
1807 TELEPHONY_LOGE("OnRemoteRequest::OnGetCellLocation write reply failed.");
1808 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1809 }
1810 return NO_ERROR;
1811 }
1812
OnHasOperatorPrivileges(MessageParcel & data,MessageParcel & reply)1813 int32_t CoreServiceStub::OnHasOperatorPrivileges(MessageParcel &data, MessageParcel &reply)
1814 {
1815 int32_t slotId = data.ReadInt32();
1816 bool hasOperatorPrivileges = false;
1817 int32_t result = HasOperatorPrivileges(slotId, hasOperatorPrivileges);
1818 bool ret = reply.WriteInt32(result);
1819 if (result == TELEPHONY_ERR_SUCCESS) {
1820 ret = (ret && reply.WriteBool(hasOperatorPrivileges));
1821 }
1822 if (!ret) {
1823 TELEPHONY_LOGE("OnHasOperatorPrivileges write reply failed.");
1824 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1825 }
1826 return NO_ERROR;
1827 }
1828
OnSimAuthentication(MessageParcel & data,MessageParcel & reply)1829 int32_t CoreServiceStub::OnSimAuthentication(MessageParcel &data, MessageParcel &reply)
1830 {
1831 int32_t slotId = data.ReadInt32();
1832 AuthType authType = static_cast<AuthType>(data.ReadInt32());
1833 std::string authData = data.ReadString();
1834 SimAuthenticationResponse response = { 0 };
1835 int32_t result = SimAuthentication(slotId, authType, authData, response);
1836 reply.WriteInt32(result);
1837 reply.WriteInt32(response.sw1);
1838 reply.WriteInt32(response.sw2);
1839 reply.WriteString(response.response);
1840
1841 return NO_ERROR;
1842 }
1843
OnRegisterImsRegInfoCallback(MessageParcel & data,MessageParcel & reply)1844 int32_t CoreServiceStub::OnRegisterImsRegInfoCallback(MessageParcel &data, MessageParcel &reply)
1845 {
1846 int32_t slotId = data.ReadInt32();
1847 ImsServiceType imsSrvType = static_cast<ImsServiceType>(data.ReadInt32());
1848 sptr<ImsRegInfoCallback> callback = iface_cast<ImsRegInfoCallback>(data.ReadRemoteObject());
1849 int32_t result;
1850 if (callback == nullptr) {
1851 TELEPHONY_LOGE("callback is nullptr!");
1852 result = TELEPHONY_ERR_ARGUMENT_NULL;
1853 } else {
1854 result = RegisterImsRegInfoCallback(slotId, imsSrvType, callback);
1855 }
1856 bool ret = reply.WriteInt32(result);
1857 if (!ret) {
1858 TELEPHONY_LOGE("write reply failed.");
1859 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1860 }
1861 return NO_ERROR;
1862 }
1863
OnUnregisterImsRegInfoCallback(MessageParcel & data,MessageParcel & reply)1864 int32_t CoreServiceStub::OnUnregisterImsRegInfoCallback(MessageParcel &data, MessageParcel &reply)
1865 {
1866 int32_t slotId = data.ReadInt32();
1867 ImsServiceType imsSrvType = static_cast<ImsServiceType>(data.ReadInt32());
1868 int32_t result = UnregisterImsRegInfoCallback(slotId, imsSrvType);
1869 bool ret = reply.WriteInt32(result);
1870 if (!ret) {
1871 TELEPHONY_LOGE("write reply failed.");
1872 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1873 }
1874 return NO_ERROR;
1875 }
1876
OnGetBasebandVersion(MessageParcel & data,MessageParcel & reply)1877 int32_t CoreServiceStub::OnGetBasebandVersion(MessageParcel &data, MessageParcel &reply)
1878 {
1879 int32_t slotId = data.ReadInt32();
1880 std::string version = "";
1881 int32_t result = GetBasebandVersion(slotId, version);
1882 if (!reply.WriteInt32(result)) {
1883 TELEPHONY_LOGE("OnRemoteRequest::OnGetBasebandVersion write reply failed.");
1884 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1885 }
1886 if (result == TELEPHONY_ERR_SUCCESS) {
1887 if (!reply.WriteString(version)) {
1888 TELEPHONY_LOGE("OnRemoteRequest::OnGetBasebandVersion write reply failed.");
1889 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1890 }
1891 }
1892 return NO_ERROR;
1893 }
1894
OnGetNrSsbIdInfo(MessageParcel & data,MessageParcel & reply)1895 int32_t CoreServiceStub::OnGetNrSsbIdInfo(MessageParcel &data, MessageParcel &reply)
1896 {
1897 int32_t slotId = data.ReadInt32();
1898 std::shared_ptr<NrSsbInformation> nrSsbInformation = std::make_shared<NrSsbInformation>();
1899 if (nrSsbInformation == nullptr) {
1900 TELEPHONY_LOGE("nrSsbInformation is null.");
1901 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1902 }
1903 int32_t result = GetNrSsbIdInfo(slotId, nrSsbInformation);
1904 if (!reply.WriteInt32(result)) {
1905 TELEPHONY_LOGE("Write reply failed.");
1906 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1907 }
1908 if (result == TELEPHONY_ERR_SUCCESS) {
1909 if (!nrSsbInformation->Marshalling(reply)) {
1910 TELEPHONY_LOGE("Marshalling is failed.");
1911 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1912 }
1913 }
1914 return NO_ERROR;
1915 }
1916
OnFactoryReset(MessageParcel & data,MessageParcel & reply)1917 int32_t CoreServiceStub::OnFactoryReset(MessageParcel &data, MessageParcel &reply)
1918 {
1919 int32_t slotId = data.ReadInt32();
1920 int32_t result = FactoryReset(slotId);
1921 if (!reply.WriteInt32(result)) {
1922 TELEPHONY_LOGE("Write reply failed.");
1923 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1924 }
1925 return NO_ERROR;
1926 }
1927
OnIsAllowedInsertApn(MessageParcel & data,MessageParcel & reply)1928 int32_t CoreServiceStub::OnIsAllowedInsertApn(MessageParcel &data, MessageParcel &reply)
1929 {
1930 std::string value = data.ReadString();
1931 bool result = IsAllowedInsertApn(value);
1932 if (!reply.WriteBool(result)) {
1933 TELEPHONY_LOGE("Write reply failed.");
1934 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1935 }
1936 return NO_ERROR;
1937 }
1938
OnGetTargetOpkey(MessageParcel & data,MessageParcel & reply)1939 int32_t CoreServiceStub::OnGetTargetOpkey(MessageParcel &data, MessageParcel &reply)
1940 {
1941 int32_t slotId = data.ReadInt32();
1942 std::u16string opkey;
1943 int32_t result = GetTargetOpkey(slotId, opkey);
1944 if (!reply.WriteString16(opkey)) {
1945 TELEPHONY_LOGE("Write reply opkey failed.");
1946 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1947 }
1948 if (!reply.WriteInt32(result)) {
1949 TELEPHONY_LOGE("Write reply result failed.");
1950 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1951 }
1952 return NO_ERROR;
1953 }
1954
OnGetOpkeyVersion(MessageParcel & data,MessageParcel & reply)1955 int32_t CoreServiceStub::OnGetOpkeyVersion(MessageParcel &data, MessageParcel &reply)
1956 {
1957 std::string versionInfo;
1958 int32_t result = GetOpkeyVersion(versionInfo);
1959 if (!reply.WriteString(versionInfo)) {
1960 TELEPHONY_LOGE("Write versionInfo result failed.");
1961 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1962 }
1963 if (!reply.WriteInt32(result)) {
1964 TELEPHONY_LOGE("Write reply result failed.");
1965 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1966 }
1967 return NO_ERROR;
1968 }
1969
OnGetOpnameVersion(MessageParcel & data,MessageParcel & reply)1970 int32_t CoreServiceStub::OnGetOpnameVersion(MessageParcel &data, MessageParcel &reply)
1971 {
1972 std::string versionInfo;
1973 int32_t result = GetOpnameVersion(versionInfo);
1974 if (!reply.WriteString(versionInfo)) {
1975 TELEPHONY_LOGE("Write versionInfo result failed.");
1976 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1977 }
1978 if (!reply.WriteInt32(result)) {
1979 TELEPHONY_LOGE("Write reply result failed.");
1980 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1981 }
1982 return NO_ERROR;
1983 }
1984
OnGetSimIO(MessageParcel & data,MessageParcel & reply)1985 int32_t CoreServiceStub::OnGetSimIO(MessageParcel &data, MessageParcel &reply)
1986 {
1987 int32_t slotId = data.ReadInt32();
1988 int32_t command = data.ReadInt32();
1989 int32_t fileId = data.ReadInt32();
1990 std::string dataStr = data.ReadString();
1991 std::string path = data.ReadString();
1992 SimAuthenticationResponse response = { 0 };
1993 int32_t result = GetSimIO(slotId, command, fileId, dataStr, path, response);
1994 if (!reply.WriteInt32(result)) {
1995 TELEPHONY_LOGE("Write reply result failed.");
1996 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1997 }
1998 reply.WriteInt32(result);
1999 reply.WriteInt32(response.sw1);
2000 reply.WriteInt32(response.sw2);
2001 reply.WriteString(response.response);
2002
2003 return NO_ERROR;
2004 }
2005
2006 #ifdef CORE_SERVICE_SUPPORT_ESIM
OnSendApduData(MessageParcel & data,MessageParcel & reply)2007 int32_t CoreServiceStub::OnSendApduData(MessageParcel &data, MessageParcel &reply)
2008 {
2009 EsimApduData apduData;
2010 int32_t slotId = data.ReadInt32();
2011 std::u16string aid = data.ReadString16();
2012 apduData.closeChannelFlag_ = data.ReadBool();
2013 apduData.unusedDefaultReqHeadFlag_ = data.ReadBool();
2014 apduData.data_ = data.ReadString16();
2015 apduData.instructionType_ = data.ReadInt32();
2016 apduData.instruction_ = data.ReadInt32();
2017 apduData.p1_ = data.ReadInt32();
2018 apduData.p2_ = data.ReadInt32();
2019 apduData.p3_ = data.ReadInt32();
2020 ResponseEsimResult responseResult;
2021 int32_t result = SendApduData(slotId, aid, apduData, responseResult);
2022 bool ret = reply.WriteInt32(result);
2023 if (result == TELEPHONY_ERR_SUCCESS) {
2024 ret = (ret && reply.WriteInt32(static_cast<int32_t>(responseResult.resultCode_)));
2025 ret = (ret && reply.WriteString16(responseResult.response_));
2026 ret = (ret && reply.WriteInt32(responseResult.sw1_));
2027 ret = (ret && reply.WriteInt32(responseResult.sw2_));
2028 }
2029 if (!ret) {
2030 TELEPHONY_LOGE("write reply failed.");
2031 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
2032 }
2033 return NO_ERROR;
2034 }
2035 #endif
2036 } // namespace Telephony
2037 } // namespace OHOS
2038