• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <initializer_list>
17 #include <list>
18 #include <map>
19 #include <string>
20 #include <utility>
21 
22 #include "cj_lambda.h"
23 #include "state_registry_errors.h"
24 #include "telephony_errors.h"
25 #include "telephony_napi_common_error.h"
26 #include "telephony_observer_impl.h"
27 
28 namespace OHOS {
29 namespace Telephony {
30 namespace {
31 const std::map<std::string_view, TelephonyUpdateEventType> eventMap {
32     { "networkStateChange", TelephonyUpdateEventType::EVENT_NETWORK_STATE_UPDATE },
33     { "callStateChange", TelephonyUpdateEventType::EVENT_CALL_STATE_UPDATE },
34     { "signalInfoChange", TelephonyUpdateEventType::EVENT_SIGNAL_STRENGTHS_UPDATE },
35     { "simStateChange", TelephonyUpdateEventType::EVENT_SIM_STATE_UPDATE },
36     { "cellInfoChange", TelephonyUpdateEventType::EVENT_CELL_INFO_UPDATE },
37     { "cellularDataConnectionStateChange", TelephonyUpdateEventType::EVENT_DATA_CONNECTION_UPDATE },
38     { "cellularDataFlowChange", TelephonyUpdateEventType::EVENT_CELLULAR_DATA_FLOW_UPDATE },
39     { "cfuIndicatorChange", TelephonyUpdateEventType::EVENT_CFU_INDICATOR_UPDATE },
40     { "voiceMailMsgIndicatorChange", TelephonyUpdateEventType::EVENT_VOICE_MAIL_MSG_INDICATOR_UPDATE },
41     { "iccAccountInfoChange", TelephonyUpdateEventType::EVENT_ICC_ACCOUNT_CHANGE },
42 };
43 
GetEventType(std::string_view event)44 TelephonyUpdateEventType GetEventType(std::string_view event)
45 {
46     auto serched = eventMap.find(event);
47     return (serched != eventMap.end() ? serched->second : TelephonyUpdateEventType::NONE_EVENT_TYPE);
48 }
49 } // namespace
50 
ConvertCJErrCode(int32_t errCode)51 static int32_t ConvertCJErrCode(int32_t errCode)
52 {
53     switch (errCode) {
54         case TELEPHONY_ERR_ARGUMENT_MISMATCH:
55         case TELEPHONY_ERR_ARGUMENT_INVALID:
56         case TELEPHONY_ERR_ARGUMENT_NULL:
57         case TELEPHONY_ERR_SLOTID_INVALID:
58         case ERROR_SLOT_ID_INVALID:
59             // 83000001
60             return CJ_ERROR_TELEPHONY_ARGUMENT_ERROR;
61         case TELEPHONY_ERR_DESCRIPTOR_MISMATCH:
62         case TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL:
63         case TELEPHONY_ERR_WRITE_DATA_FAIL:
64         case TELEPHONY_ERR_READ_DATA_FAIL:
65         case TELEPHONY_ERR_WRITE_REPLY_FAIL:
66         case TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL:
67         case TELEPHONY_ERR_REGISTER_CALLBACK_FAIL:
68         case TELEPHONY_ERR_CALLBACK_ALREADY_REGISTERED:
69         case TELEPHONY_ERR_UNINIT:
70         case TELEPHONY_ERR_UNREGISTER_CALLBACK_FAIL:
71             // 83000002
72             return CJ_ERROR_TELEPHONY_SERVICE_ERROR;
73         case TELEPHONY_ERR_VCARD_FILE_INVALID:
74         case TELEPHONY_ERR_FAIL:
75         case TELEPHONY_ERR_MEMCPY_FAIL:
76         case TELEPHONY_ERR_MEMSET_FAIL:
77         case TELEPHONY_ERR_STRCPY_FAIL:
78         case TELEPHONY_ERR_LOCAL_PTR_NULL:
79         case TELEPHONY_ERR_SUBSCRIBE_BROADCAST_FAIL:
80         case TELEPHONY_ERR_PUBLISH_BROADCAST_FAIL:
81         case TELEPHONY_ERR_STRTOINT_FAIL:
82         case TELEPHONY_ERR_ADD_DEATH_RECIPIENT_FAIL:
83         case TELEPHONY_ERR_RIL_CMD_FAIL:
84         case TELEPHONY_ERR_DATABASE_WRITE_FAIL:
85         case TELEPHONY_ERR_DATABASE_READ_FAIL:
86         case TELEPHONY_ERR_UNKNOWN_NETWORK_TYPE:
87             // 83000003
88             return CJ_ERROR_TELEPHONY_SYSTEM_ERROR;
89         case TELEPHONY_ERR_NO_SIM_CARD:
90             // 83000004
91             return CJ_ERROR_TELEPHONY_NO_SIM_CARD;
92         case TELEPHONY_ERR_AIRPLANE_MODE_ON:
93             // 83000005
94             return CJ_ERROR_TELEPHONY_AIRPLANE_MODE_ON;
95         case TELEPHONY_ERR_NETWORK_NOT_IN_SERVICE:
96             // 83000006
97             return CJ_ERROR_TELEPHONY_NETWORK_NOT_IN_SERVICE;
98         case TELEPHONY_ERR_PERMISSION_ERR:
99             // 201
100             return CJ_ERROR_TELEPHONY_PERMISSION_DENIED;
101         case TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API:
102             // 202
103             return CJ_ERROR_TELEPHONY_PERMISSION_DENIED;
104         default:
105             return errCode;
106     }
107 }
108 
IsValidSlotIdEx(TelephonyUpdateEventType eventType,int32_t slotId)109 static bool IsValidSlotIdEx(TelephonyUpdateEventType eventType, int32_t slotId)
110 {
111     int32_t defaultSlotId = DEFAULT_SIM_SLOT_ID;
112     if (eventType == TelephonyUpdateEventType::EVENT_CALL_STATE_UPDATE) {
113         defaultSlotId = -1;
114     }
115     // One more slot for VSim.
116     return ((slotId >= defaultSlotId) && (slotId < SIM_SLOT_COUNT + 1));
117 }
118 
RegisterEventListener(EventListener & eventListener)119 static int32_t RegisterEventListener(EventListener &eventListener)
120 {
121     auto handler = DelayedSingleton<ObserverEventHandler>::GetInstance();
122     if (handler == nullptr) {
123         TELEPHONY_LOGE("Get event handler failed");
124         return TELEPHONY_ERR_LOCAL_PTR_NULL;
125     }
126     return handler->RegisterEventListener(eventListener);
127 }
128 
UnregisterEventListener(const TelephonyUpdateEventType eventType,int64_t funcId)129 static int32_t UnregisterEventListener(const TelephonyUpdateEventType eventType, int64_t funcId)
130 {
131     auto handler = DelayedSingleton<ObserverEventHandler>::GetInstance();
132     if (handler == nullptr) {
133         TELEPHONY_LOGE("Get event handler failed");
134         return TELEPHONY_ERR_LOCAL_PTR_NULL;
135     }
136     return handler->UnregisterEventListener(eventType, funcId);
137 }
138 
NativeOn(EventListener listener,int32_t & errCode)139 static void NativeOn(EventListener listener, int32_t &errCode)
140 {
141     errCode = TELEPHONY_SUCCESS;
142     if (SIM_SLOT_COUNT == 0) {
143         TELEPHONY_LOGE("The device is not support sim card.");
144         return;
145     }
146 
147     if (!IsValidSlotIdEx(listener.eventType, listener.slotId)) {
148         TELEPHONY_LOGE("NativeOn slotId is invalid");
149         errCode = ERROR_SLOT_ID_INVALID;
150         return;
151     }
152 
153     errCode = RegisterEventListener(listener);
154 }
155 
On(std::string_view event,ObserverOptions options,int64_t funcId)156 static int32_t On(std::string_view event, ObserverOptions options, int64_t funcId)
157 {
158     int32_t errCode = TELEPHONY_SUCCESS;
159     std::shared_ptr<bool> isDeleting = std::make_shared<bool>(false);
160     auto func = reinterpret_cast<void(*)(void*)>(funcId);
161     auto callbackRef = CJLambda::Create(func);
162     if (callbackRef == nullptr) {
163         errCode = TELEPHONY_ERR_ARGUMENT_NULL;
164         TELEPHONY_LOGE("TelephonyObserverImpl on register callback is nullptr.");
165         return errCode;
166     }
167 
168     EventListener listener {
169         GetEventType(event),
170         options.slotId,
171         funcId,
172         callbackRef,
173         isDeleting
174     };
175     if (listener.eventType != TelephonyUpdateEventType::NONE_EVENT_TYPE) {
176         NativeOn(listener, errCode);
177     } else {
178         TELEPHONY_LOGE("TelephonyObserverImpl on register eventType is unkonw.");
179         errCode = TELEPHONY_ERR_ARGUMENT_INVALID;
180     }
181 
182     if (errCode == TELEPHONY_STATE_REGISTRY_PERMISSION_DENIED) {
183         errCode = TELEPHONY_ERR_PERMISSION_ERR;
184     }
185     return errCode;
186 }
187 
Off(std::string_view event,int64_t funcId=-1)188 static int32_t Off(std::string_view event, int64_t funcId = -1)
189 {
190     int32_t errCode = TELEPHONY_SUCCESS;
191     TelephonyUpdateEventType eventType = GetEventType(event);
192     if (eventType != TelephonyUpdateEventType::NONE_EVENT_TYPE) {
193         UnregisterEventListener(eventType, funcId);
194     } else {
195         errCode = TELEPHONY_ERR_ARGUMENT_INVALID;
196     }
197     if (errCode == TELEPHONY_STATE_REGISTRY_PERMISSION_DENIED) {
198         errCode = TELEPHONY_ERR_PERMISSION_ERR;
199     }
200     return errCode;
201 }
202 
OnNetworkStateChange(ObserverOptions options,int64_t funcId)203 int32_t TelephonyObserverImpl::OnNetworkStateChange(ObserverOptions options, int64_t funcId)
204 {
205     std::string_view event("networkStateChange");
206     int32_t errCode = On(event, options, funcId);
207     return ConvertCJErrCode(errCode);
208 }
209 
OffNetworkStateChange(int64_t funcId)210 int32_t TelephonyObserverImpl::OffNetworkStateChange(int64_t funcId)
211 {
212     std::string_view event("networkStateChange");
213     int32_t errCode = Off(event, funcId);
214     return ConvertCJErrCode(errCode);
215 }
216 
OffAllNetworkStateChange()217 int32_t TelephonyObserverImpl::OffAllNetworkStateChange()
218 {
219     std::string_view event("networkStateChange");
220     int32_t errCode = Off(event);
221     return ConvertCJErrCode(errCode);
222 }
223 
OnSignalInfoChange(ObserverOptions options,int64_t funcId)224 int32_t TelephonyObserverImpl::OnSignalInfoChange(ObserverOptions options, int64_t funcId)
225 {
226     std::string_view event("signalInfoChange");
227     int32_t errCode = On(event, options, funcId);
228     return ConvertCJErrCode(errCode);
229 }
230 
OffSignalInfoChange(int64_t funcId)231 int32_t TelephonyObserverImpl::OffSignalInfoChange(int64_t funcId)
232 {
233     std::string_view event("signalInfoChange");
234     int32_t errCode = Off(event, funcId);
235     return ConvertCJErrCode(errCode);
236 }
237 
OffAllSignalInfoChange()238 int32_t TelephonyObserverImpl::OffAllSignalInfoChange()
239 {
240     std::string_view event("signalInfoChange");
241     int32_t errCode = Off(event);
242     return ConvertCJErrCode(errCode);
243 }
244 
OnCallStateChange(ObserverOptions options,int64_t funcId)245 int32_t TelephonyObserverImpl::OnCallStateChange(ObserverOptions options, int64_t funcId)
246 {
247     std::string_view event("callStateChange");
248     int32_t errCode = On(event, options, funcId);
249     return ConvertCJErrCode(errCode);
250 }
251 
OffCallStateChange(int64_t funcId)252 int32_t TelephonyObserverImpl::OffCallStateChange(int64_t funcId)
253 {
254     std::string_view event("callStateChange");
255     int32_t errCode = Off(event, funcId);
256     return ConvertCJErrCode(errCode);
257 }
258 
OffAllCallStateChange()259 int32_t TelephonyObserverImpl::OffAllCallStateChange()
260 {
261     std::string_view event("callStateChange");
262     int32_t errCode = Off(event);
263     return ConvertCJErrCode(errCode);
264 }
265 
OnCellularDataConnectionStateChange(ObserverOptions options,int64_t funcId)266 int32_t TelephonyObserverImpl::OnCellularDataConnectionStateChange(ObserverOptions options, int64_t funcId)
267 {
268     std::string_view event("cellularDataConnectionStateChange");
269     int32_t errCode = On(event, options, funcId);
270     return ConvertCJErrCode(errCode);
271 }
272 
OffCellularDataConnectionStateChange(int64_t funcId)273 int32_t TelephonyObserverImpl::OffCellularDataConnectionStateChange(int64_t funcId)
274 {
275     std::string_view event("cellularDataConnectionStateChange");
276     int32_t errCode = Off(event, funcId);
277     return ConvertCJErrCode(errCode);
278 }
279 
OffAllCellularDataConnectionStateChange()280 int32_t TelephonyObserverImpl::OffAllCellularDataConnectionStateChange()
281 {
282     std::string_view event("cellularDataConnectionStateChange");
283     int32_t errCode = Off(event);
284     return ConvertCJErrCode(errCode);
285 }
286 
OnCellularDataFlowChange(ObserverOptions options,int64_t funcId)287 int32_t TelephonyObserverImpl::OnCellularDataFlowChange(ObserverOptions options, int64_t funcId)
288 {
289     std::string_view event("cellularDataFlowChange");
290     int32_t errCode = On(event, options, funcId);
291     return ConvertCJErrCode(errCode);
292 }
293 
OffCellularDataFlowChange(int64_t funcId)294 int32_t TelephonyObserverImpl::OffCellularDataFlowChange(int64_t funcId)
295 {
296     std::string_view event("cellularDataFlowChange");
297     int32_t errCode = Off(event, funcId);
298     return ConvertCJErrCode(errCode);
299 }
300 
OffAllCellularDataFlowChange()301 int32_t TelephonyObserverImpl::OffAllCellularDataFlowChange()
302 {
303     std::string_view event("cellularDataFlowChange");
304     int32_t errCode = Off(event);
305     return ConvertCJErrCode(errCode);
306 }
307 
OnSimStateChange(ObserverOptions options,int64_t funcId)308 int32_t TelephonyObserverImpl::OnSimStateChange(ObserverOptions options, int64_t funcId)
309 {
310     std::string_view event("simStateChange");
311     int32_t errCode = On(event, options, funcId);
312     return ConvertCJErrCode(errCode);
313 }
314 
OffSimStateChange(int64_t funcId)315 int32_t TelephonyObserverImpl::OffSimStateChange(int64_t funcId)
316 {
317     std::string_view event("simStateChange");
318     int32_t errCode = Off(event, funcId);
319     return ConvertCJErrCode(errCode);
320 }
321 
OffAllSimStateChange()322 int32_t TelephonyObserverImpl::OffAllSimStateChange()
323 {
324     std::string_view event("simStateChange");
325     int32_t errCode = Off(event);
326     return ConvertCJErrCode(errCode);
327 }
328 
OnIccAccountInfoChange(ObserverOptions options,int64_t funcId)329 int32_t TelephonyObserverImpl::OnIccAccountInfoChange(ObserverOptions options, int64_t funcId)
330 {
331     std::string_view event("iccAccountInfoChange");
332     int32_t errCode = On(event, options, funcId);
333     return ConvertCJErrCode(errCode);
334 }
335 
OffIccAccountInfoChange(int64_t funcId)336 int32_t TelephonyObserverImpl::OffIccAccountInfoChange(int64_t funcId)
337 {
338     std::string_view event("iccAccountInfoChange");
339     int32_t errCode = Off(event, funcId);
340     return ConvertCJErrCode(errCode);
341 }
342 
OffAllIccAccountInfoChange()343 int32_t TelephonyObserverImpl::OffAllIccAccountInfoChange()
344 {
345     std::string_view event("iccAccountInfoChange");
346     int32_t errCode = Off(event);
347     return ConvertCJErrCode(errCode);
348 }
349 
350 // FfiTelephonyObserver
OnCallStateUpdated(int32_t slotId,int32_t callState,const std::u16string & phoneNumber)351 void FfiTelephonyObserver::OnCallStateUpdated(int32_t slotId, int32_t callState, const std::u16string &phoneNumber)
352 {
353     TELEPHONY_LOGI("OnCallStateUpdated slotId = %{public}d, callState = %{public}d", slotId, callState);
354     std::unique_ptr<CallStateUpdateInfo> callStateInfo =
355         std::make_unique<CallStateUpdateInfo>(slotId, callState, phoneNumber);
356     if (callStateInfo == nullptr) {
357         TELEPHONY_LOGE("callStateInfo is nullptr!");
358         return;
359     }
360     TelephonyObserverImpl::SendEvent(
361         static_cast<uint32_t>(TelephonyCallbackEventId::EVENT_ON_CALL_STATE_UPDATE),
362         callStateInfo);
363 }
364 
OnSignalInfoUpdated(int32_t slotId,const std::vector<sptr<SignalInformation>> & signalInfoList)365 void FfiTelephonyObserver::OnSignalInfoUpdated(
366     int32_t slotId, const std::vector<sptr<SignalInformation>> &signalInfoList)
367 {
368     TELEPHONY_LOGI("OnSignalInfoUpdated slotId = %{public}d, signalInfoList.size = %{public}zu", slotId,
369         signalInfoList.size());
370     std::unique_ptr<SignalUpdateInfo> infoList = std::make_unique<SignalUpdateInfo>(slotId, signalInfoList);
371     if (infoList == nullptr) {
372         TELEPHONY_LOGE("SignalUpdateInfo is nullptr!");
373         return;
374     }
375     TelephonyObserverImpl::SendEvent(
376         static_cast<uint32_t>(TelephonyCallbackEventId::EVENT_ON_SIGNAL_INFO_UPDATE),
377         infoList);
378 }
379 
OnNetworkStateUpdated(int32_t slotId,const sptr<NetworkState> & networkState)380 void FfiTelephonyObserver::OnNetworkStateUpdated(int32_t slotId, const sptr<NetworkState> &networkState)
381 {
382     TELEPHONY_LOGI(
383         "OnNetworkStateUpdated slotId = %{public}d, networkState = %{public}d", slotId, networkState == nullptr);
384     std::unique_ptr<NetworkStateUpdateInfo> networkStateUpdateInfo =
385         std::make_unique<NetworkStateUpdateInfo>(slotId, networkState);
386     if (networkStateUpdateInfo == nullptr) {
387         TELEPHONY_LOGE("NetworkStateUpdateInfo is nullptr!");
388         return;
389     }
390     TelephonyObserverImpl::SendEvent(
391         static_cast<uint32_t>(TelephonyCallbackEventId::EVENT_ON_NETWORK_STATE_UPDATE),
392         networkStateUpdateInfo);
393 }
394 
OnSimStateUpdated(int32_t slotId,CardType type,SimState state,LockReason reason)395 void FfiTelephonyObserver::OnSimStateUpdated(
396     int32_t slotId, CardType type, SimState state, LockReason reason)
397 {
398     TELEPHONY_LOGI("OnSimStateUpdated slotId = %{public}d, simState =  %{public}d", slotId, state);
399     std::unique_ptr<SimStateUpdateInfo> simStateUpdateInfo =
400         std::make_unique<SimStateUpdateInfo>(slotId, type, state, reason);
401     if (simStateUpdateInfo == nullptr) {
402         TELEPHONY_LOGE("SimStateUpdateInfo is nullptr!");
403         return;
404     }
405     TelephonyObserverImpl::SendEvent(
406         static_cast<uint32_t>(TelephonyCallbackEventId::EVENT_ON_SIM_STATE_UPDATE),
407         simStateUpdateInfo);
408 }
409 
OnCellInfoUpdated(int32_t slotId,const std::vector<sptr<CellInformation>> & vec)410 void FfiTelephonyObserver::OnCellInfoUpdated(int32_t slotId, const std::vector<sptr<CellInformation>> &vec)
411 {
412     TELEPHONY_LOGI("OnCellInfoUpdated slotId = %{public}d, cell info size =  %{public}zu", slotId, vec.size());
413     std::unique_ptr<CellInfomationUpdate> cellInfo = std::make_unique<CellInfomationUpdate>(slotId, vec);
414     if (cellInfo == nullptr) {
415         TELEPHONY_LOGE("CellInfomationUpdate is nullptr!");
416         return;
417     }
418     TelephonyObserverImpl::SendEvent(
419         static_cast<uint32_t>(TelephonyCallbackEventId::EVENT_ON_CELL_INFOMATION_UPDATE),
420         cellInfo);
421 }
422 
OnCellularDataConnectStateUpdated(int32_t slotId,int32_t dataState,int32_t networkType)423 void FfiTelephonyObserver::OnCellularDataConnectStateUpdated(
424     int32_t slotId, int32_t dataState, int32_t networkType)
425 {
426     TELEPHONY_LOGD("OnCellularDataConnectStateUpdated slotId=%{public}d, dataState=%{public}d, networkType="
427         "%{public}d",
428         slotId, dataState, networkType);
429     std::unique_ptr<CellularDataConnectState> cellularDataConnectState =
430         std::make_unique<CellularDataConnectState>(slotId, dataState, networkType);
431     if (cellularDataConnectState == nullptr) {
432         TELEPHONY_LOGE("OnCellularDataConnectStateUpdated cellularDataConnectState is nullptr!");
433         return;
434     }
435     TelephonyObserverImpl::SendEvent(
436         static_cast<uint32_t>(TelephonyCallbackEventId::EVENT_ON_CELLULAR_DATA_CONNECTION_UPDATE),
437         cellularDataConnectState);
438 }
439 
OnCellularDataFlowUpdated(int32_t slotId,int32_t dataFlowType)440 void FfiTelephonyObserver::OnCellularDataFlowUpdated(int32_t slotId, int32_t dataFlowType)
441 {
442     TELEPHONY_LOGI(
443         "OnCellularDataFlowUpdated slotId = %{public}d, dataFlowType =  %{public}d", slotId, dataFlowType);
444     std::unique_ptr<CellularDataFlowUpdate> cellularDataFlowUpdateInfo =
445         std::make_unique<CellularDataFlowUpdate>(slotId, dataFlowType);
446     if (cellularDataFlowUpdateInfo == nullptr) {
447         TELEPHONY_LOGE("CellularDataFlowUpdate is nullptr!");
448         return;
449     }
450     TelephonyObserverImpl::SendEvent(
451         static_cast<uint32_t>(TelephonyCallbackEventId::EVENT_ON_CELLULAR_DATA_FLOW_UPDATE),
452         cellularDataFlowUpdateInfo);
453 }
454 
OnCfuIndicatorUpdated(int32_t slotId,bool cfuResult)455 void FfiTelephonyObserver::OnCfuIndicatorUpdated(int32_t slotId, bool cfuResult)
456 {
457     TELEPHONY_LOGI("OnCfuIndicatorUpdated slotId = %{public}d, cfuResult = %{public}d", slotId, cfuResult);
458     std::unique_ptr<CfuIndicatorUpdate> cfuIndicatorUpdateInfo =
459         std::make_unique<CfuIndicatorUpdate>(slotId, cfuResult);
460     if (cfuIndicatorUpdateInfo == nullptr) {
461         TELEPHONY_LOGE("CfuIndicatorUpdate is nullptr!");
462         return;
463     }
464     TelephonyObserverImpl::SendEvent(
465         static_cast<uint32_t>(TelephonyCallbackEventId::EVENT_ON_CFU_INDICATOR_UPDATE),
466         cfuIndicatorUpdateInfo);
467 }
468 
OnIccAccountUpdated()469 void FfiTelephonyObserver::OnIccAccountUpdated()
470 {
471     TELEPHONY_LOGI("OnIccAccountUpdated begin");
472     TelephonyObserverImpl::SendEvent(static_cast<uint32_t>(TelephonyCallbackEventId::EVENT_ON_ICC_ACCOUNT_UPDATE));
473 }
474 
OnVoiceMailMsgIndicatorUpdated(int32_t slotId,bool voiceMailMsgResult)475 void FfiTelephonyObserver::OnVoiceMailMsgIndicatorUpdated(int32_t slotId, bool voiceMailMsgResult)
476 {
477     TELEPHONY_LOGI("OnVoiceMailMsgIndicatorUpdated slotId = %{public}d, voiceMailMsgResult =  %{public}d", slotId,
478         voiceMailMsgResult);
479     std::unique_ptr<VoiceMailMsgIndicatorUpdate> voiceMailMsgIndicatorUpdateInfo =
480         std::make_unique<VoiceMailMsgIndicatorUpdate>(slotId, voiceMailMsgResult);
481     if (voiceMailMsgIndicatorUpdateInfo == nullptr) {
482         TELEPHONY_LOGE("VoiceMailMsgIndicatorUpdate is nullptr!");
483         return;
484     }
485     TelephonyObserverImpl::SendEvent(
486         static_cast<uint32_t>(TelephonyCallbackEventId::EVENT_ON_VOICE_MAIL_MSG_INDICATOR_UPDATE),
487         voiceMailMsgIndicatorUpdateInfo);
488 }
489 }
490 }