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