1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "cellular_data_controller.h"
17 
18 #include "cellular_data_constant.h"
19 #include "common_event_manager.h"
20 #include "common_event_support.h"
21 #include "core_manager_inner.h"
22 #include "network_search_callback.h"
23 #include "radio_event.h"
24 #include "telephony_log_wrapper.h"
25 #include "uri.h"
26 
27 namespace OHOS {
28 namespace Telephony {
29 using namespace NetManagerStandard;
30 using namespace OHOS::EventFwk;
31 
CellularDataController(int32_t slotId)32 CellularDataController::CellularDataController(int32_t slotId)
33     : TelEventHandler("CellularDataController"), slotId_(slotId)
34 {}
35 
~CellularDataController()36 CellularDataController::~CellularDataController()
37 {
38     UnRegisterEvents();
39     if (systemAbilityListener_ != nullptr) {
40         auto samgrProxy = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
41         if (samgrProxy != nullptr) {
42             samgrProxy->UnSubscribeSystemAbility(COMM_NET_CONN_MANAGER_SYS_ABILITY_ID, systemAbilityListener_);
43             samgrProxy->UnSubscribeSystemAbility(COMM_NET_POLICY_MANAGER_SYS_ABILITY_ID, systemAbilityListener_);
44             samgrProxy->UnSubscribeSystemAbility(COMMON_EVENT_SERVICE_ID, systemAbilityListener_);
45             samgrProxy->UnSubscribeSystemAbility(DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID, systemAbilityListener_);
46             systemAbilityListener_ = nullptr;
47         }
48     }
49 }
50 
Init()51 void CellularDataController::Init()
52 {
53     EventFwk::MatchingSkills matchingSkills;
54     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED);
55     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SIM_CARD_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
56     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);
57     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_ON);
58     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_OFF);
59     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_DATA_SHARE_READY);
60     EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
61     subscriberInfo.SetThreadMode(EventFwk::CommonEventSubscribeInfo::COMMON);
62     cellularDataHandler_ = std::make_shared<CellularDataHandler>(subscriberInfo, slotId_);
63     if (cellularDataHandler_ == nullptr) {
64         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler_ is null", slotId_);
65         return;
66     }
67     cellularDataHandler_->Init();
68     auto samgrProxy = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
69     if (samgrProxy == nullptr) {
70         TELEPHONY_LOGE("samgrProxy is nullptr");
71         return;
72     }
73     systemAbilityListener_ = new (std::nothrow) SystemAbilityStatusChangeListener(slotId_, cellularDataHandler_);
74     if (systemAbilityListener_ == nullptr) {
75         TELEPHONY_LOGE("systemAbilityListener_ is nullptr");
76         return;
77     }
78     samgrProxy->SubscribeSystemAbility(COMM_NET_CONN_MANAGER_SYS_ABILITY_ID, systemAbilityListener_);
79     samgrProxy->SubscribeSystemAbility(COMM_NET_POLICY_MANAGER_SYS_ABILITY_ID, systemAbilityListener_);
80     samgrProxy->SubscribeSystemAbility(COMMON_EVENT_SERVICE_ID, systemAbilityListener_);
81     samgrProxy->SubscribeSystemAbility(DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID, systemAbilityListener_);
82 }
83 
SetCellularDataEnable(bool userDataEnabled)84 int32_t CellularDataController::SetCellularDataEnable(bool userDataEnabled)
85 {
86     if (cellularDataHandler_ == nullptr) {
87         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler_ is null", slotId_);
88         return TELEPHONY_ERR_LOCAL_PTR_NULL;
89     }
90     return cellularDataHandler_->SetCellularDataEnable(userDataEnabled);
91 }
92 
GetIntelligenceSwitchState(bool & switchState)93 int32_t CellularDataController::GetIntelligenceSwitchState(bool &switchState)
94 {
95     if (cellularDataHandler_ == nullptr) {
96         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler_ is null", slotId_);
97         return TELEPHONY_ERR_LOCAL_PTR_NULL;
98     }
99     return cellularDataHandler_->GetIntelligenceSwitchState(switchState);
100 }
101 
SetIntelligenceSwitchEnable(bool userDataEnabled)102 int32_t CellularDataController::SetIntelligenceSwitchEnable(bool userDataEnabled)
103 {
104     if (cellularDataHandler_ == nullptr) {
105         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler_ is null", slotId_);
106         return TELEPHONY_ERR_LOCAL_PTR_NULL;
107     }
108     return cellularDataHandler_->SetIntelligenceSwitchEnable(userDataEnabled);
109 }
110 
IsCellularDataEnabled(bool & dataEnabled) const111 int32_t CellularDataController::IsCellularDataEnabled(bool &dataEnabled) const
112 {
113     if (cellularDataHandler_ == nullptr) {
114         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler_ is null", slotId_);
115         return TELEPHONY_ERR_LOCAL_PTR_NULL;
116     }
117     return cellularDataHandler_->IsCellularDataEnabled(dataEnabled);
118 }
119 
GetCellularDataState() const120 ApnProfileState CellularDataController::GetCellularDataState() const
121 {
122     if (cellularDataHandler_ == nullptr) {
123         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler_ is null", slotId_);
124         return ApnProfileState::PROFILE_STATE_FAILED;
125     }
126     return cellularDataHandler_->GetCellularDataState();
127 }
128 
GetCellularDataState(const std::string & apnType) const129 ApnProfileState CellularDataController::GetCellularDataState(const std::string &apnType) const
130 {
131     if (cellularDataHandler_ == nullptr) {
132         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler_ is null", slotId_);
133         return ApnProfileState::PROFILE_STATE_FAILED;
134     }
135     return cellularDataHandler_->GetCellularDataState(apnType);
136 }
137 
IsCellularDataRoamingEnabled(bool & dataRoamingEnabled) const138 int32_t CellularDataController::IsCellularDataRoamingEnabled(bool &dataRoamingEnabled) const
139 {
140     if (cellularDataHandler_ == nullptr) {
141         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler_ is null", slotId_);
142         return TELEPHONY_ERR_LOCAL_PTR_NULL;
143     }
144     return cellularDataHandler_->IsCellularDataRoamingEnabled(dataRoamingEnabled);
145 }
146 
SetCellularDataRoamingEnabled(bool dataRoamingEnabled)147 int32_t CellularDataController::SetCellularDataRoamingEnabled(bool dataRoamingEnabled)
148 {
149     if (cellularDataHandler_ == nullptr) {
150         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler is null", slotId_);
151         return TELEPHONY_ERR_LOCAL_PTR_NULL;
152     }
153     return cellularDataHandler_->SetCellularDataRoamingEnabled(dataRoamingEnabled);
154 }
155 
ReleaseNet(const NetRequest & request)156 bool CellularDataController::ReleaseNet(const NetRequest &request)
157 {
158     if (cellularDataHandler_ == nullptr) {
159         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler_ is null", slotId_);
160         return false;
161     }
162     return cellularDataHandler_->ReleaseNet(request);
163 }
164 
RequestNet(const NetRequest & request)165 bool CellularDataController::RequestNet(const NetRequest &request)
166 {
167     if (cellularDataHandler_ == nullptr) {
168         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler_ is null", slotId_);
169         return false;
170     }
171     return cellularDataHandler_->RequestNet(request);
172 }
173 
AsynchronousRegister()174 void CellularDataController::AsynchronousRegister()
175 {
176     if (CoreManagerInner::GetInstance().IsInitFinished()) {
177         TELEPHONY_LOGI("Slot%{public}d: core inited", slotId_);
178         Init();
179         RegisterEvents();
180         return;
181     }
182     SendEvent(CellularDataEventCode::MSG_ASYNCHRONOUS_REGISTER_EVENT_ID, CORE_INIT_DELAY_TIME, Priority::HIGH);
183 }
184 
ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)185 void CellularDataController::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
186 {
187     if (event == nullptr) {
188         TELEPHONY_LOGE("Slot%{public}d: event is null.", slotId_);
189         return;
190     }
191     size_t eventId = event->GetInnerEventId();
192     switch (eventId) {
193         case CellularDataEventCode::MSG_ASYNCHRONOUS_REGISTER_EVENT_ID:
194             AsynchronousRegister();
195             break;
196         default:
197             TELEPHONY_LOGE("Slot%{public}d: nothing to do", slotId_);
198             break;
199     }
200 }
201 
RegisterEvents()202 void CellularDataController::RegisterEvents()
203 {
204     if (cellularDataHandler_ == nullptr) {
205         TELEPHONY_LOGE("Slot%{public}d: core is null or cellularDataHandler is null", slotId_);
206         return;
207     }
208     TELEPHONY_LOGI("Slot%{public}d: start", slotId_);
209     CoreManagerInner &coreInner = CoreManagerInner::GetInstance();
210     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_SIM_STATE_CHANGE, nullptr);
211     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_SIM_RECORDS_LOADED, nullptr);
212     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_SIM_ACCOUNT_LOADED, nullptr);
213     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_PS_CONNECTION_ATTACHED, nullptr);
214     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_PS_CONNECTION_DETACHED, nullptr);
215     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_PS_ROAMING_OPEN, nullptr);
216     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_PS_ROAMING_CLOSE, nullptr);
217     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_STATE_CHANGED, nullptr);
218     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_DSDS_MODE_CHANGED, nullptr);
219     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_PS_RAT_CHANGED, nullptr);
220     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_CALL_STATUS_INFO, nullptr);
221     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_EMERGENCY_STATE_OPEN, nullptr);
222     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_EMERGENCY_STATE_CLOSE, nullptr);
223     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_NR_STATE_CHANGED, nullptr);
224     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_NR_FREQUENCY_CHANGED, nullptr);
225     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_RIL_ADAPTER_HOST_DIED, nullptr);
226     coreInner.RegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_FACTORY_RESET, nullptr);
227     if (slotId_ == 0) {
228         sptr<NetworkSearchCallback> networkSearchCallback = std::make_unique<NetworkSearchCallback>().release();
229         if (networkSearchCallback != nullptr) {
230             coreInner.RegisterCellularDataObject(networkSearchCallback);
231         } else {
232             TELEPHONY_LOGE("Slot%{public}d: networkSearchCallback is null", slotId_);
233         }
234     }
235     coreInner.CleanAllConnections(slotId_, RadioEvent::RADIO_CLEAN_ALL_DATA_CONNECTIONS, cellularDataHandler_);
236 }
237 
UnRegisterEvents()238 void CellularDataController::UnRegisterEvents()
239 {
240     if (cellularDataHandler_ == nullptr) {
241         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler_ is null", slotId_);
242         return;
243     }
244     TELEPHONY_LOGI("Slot%{public}d: start", slotId_);
245     CoreManagerInner &coreInner = CoreManagerInner::GetInstance();
246     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_SIM_STATE_CHANGE);
247     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_SIM_RECORDS_LOADED);
248     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_SIM_ACCOUNT_LOADED);
249     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_PS_CONNECTION_ATTACHED);
250     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_PS_CONNECTION_DETACHED);
251     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_PS_ROAMING_OPEN);
252     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_PS_ROAMING_CLOSE);
253     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_STATE_CHANGED);
254     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_DSDS_MODE_CHANGED);
255     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_PS_RAT_CHANGED);
256     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_CALL_STATUS_INFO);
257     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_EMERGENCY_STATE_OPEN);
258     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_EMERGENCY_STATE_CLOSE);
259     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_NR_STATE_CHANGED);
260     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_NR_FREQUENCY_CHANGED);
261     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_RIL_ADAPTER_HOST_DIED);
262     coreInner.UnRegisterCoreNotify(slotId_, cellularDataHandler_, RadioEvent::RADIO_FACTORY_RESET);
263     TELEPHONY_LOGI("Slot%{public}d: end", slotId_);
264 }
265 
HandleApnChanged()266 bool CellularDataController::HandleApnChanged()
267 {
268     if (cellularDataHandler_ == nullptr) {
269         TELEPHONY_LOGE("Slot%{public}d: ApnChanged cellularDataHandler_ is null", slotId_);
270         return static_cast<int32_t>(DataRespondCode::SET_FAILED);
271     }
272     return cellularDataHandler_->HandleApnChanged();
273 }
274 
GetCellularDataFlowType()275 int32_t CellularDataController::GetCellularDataFlowType()
276 {
277     if (cellularDataHandler_ == nullptr) {
278         TELEPHONY_LOGE("Slot%{public}d: cellular data handler is null", slotId_);
279         return static_cast<int32_t>(CellDataFlowType::DATA_FLOW_TYPE_NONE);
280     }
281     return cellularDataHandler_->GetCellularDataFlowType();
282 }
283 
SetPolicyDataOn(bool enable)284 int32_t CellularDataController::SetPolicyDataOn(bool enable)
285 {
286     if (cellularDataHandler_ != nullptr) {
287         cellularDataHandler_->SetPolicyDataOn(enable);
288     }
289     return static_cast<int32_t>(DataRespondCode::SET_SUCCESS);
290 }
291 
IsRestrictedMode() const292 bool CellularDataController::IsRestrictedMode() const
293 {
294     if (cellularDataHandler_ != nullptr) {
295         return cellularDataHandler_->IsRestrictedMode();
296     }
297     return false;
298 }
299 
GetDisConnectionReason()300 DisConnectionReason CellularDataController::GetDisConnectionReason()
301 {
302     if (cellularDataHandler_ != nullptr) {
303         return cellularDataHandler_->GetDisConnectionReason();
304     }
305     return DisConnectionReason::REASON_NORMAL;
306 }
307 
HasInternetCapability(const int32_t cid) const308 bool CellularDataController::HasInternetCapability(const int32_t cid) const
309 {
310     if (cellularDataHandler_ == nullptr) {
311         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler_ is null", slotId_);
312         return false;
313     }
314     return cellularDataHandler_->HasInternetCapability(cid);
315 }
316 
ChangeConnectionForDsds(bool enable) const317 bool CellularDataController::ChangeConnectionForDsds(bool enable) const
318 {
319     if (cellularDataHandler_ == nullptr) {
320         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler is null", slotId_);
321         return false;
322     }
323     cellularDataHandler_->ChangeConnectionForDsds(enable);
324     return true;
325 }
326 
ClearAllConnections(DisConnectionReason reason) const327 bool CellularDataController::ClearAllConnections(DisConnectionReason reason) const
328 {
329     if (cellularDataHandler_ == nullptr) {
330         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler is null", slotId_);
331         return false;
332     }
333     cellularDataHandler_->ClearAllConnections(reason);
334     return true;
335 }
336 
SystemAbilityStatusChangeListener(int32_t slotId,std::shared_ptr<CellularDataHandler> handler)337 CellularDataController::SystemAbilityStatusChangeListener::SystemAbilityStatusChangeListener(
338     int32_t slotId, std::shared_ptr<CellularDataHandler> handler)
339     : slotId_(slotId), handler_(handler)
340 {}
341 
OnAddSystemAbility(int32_t systemAbilityId,const std::string & deviceId)342 void CellularDataController::SystemAbilityStatusChangeListener::OnAddSystemAbility(
343     int32_t systemAbilityId, const std::string &deviceId)
344 {
345     switch (systemAbilityId) {
346         case COMM_NET_CONN_MANAGER_SYS_ABILITY_ID:
347             TELEPHONY_LOGI("COMM_NET_CONN_MANAGER_SYS_ABILITY_ID running");
348             if (handler_ != nullptr) {
349                 handler_->ClearAllConnections(DisConnectionReason::REASON_RETRY_CONNECTION);
350                 CellularDataNetAgent::GetInstance().RegisterNetSupplier(slotId_);
351             }
352             break;
353         case COMM_NET_POLICY_MANAGER_SYS_ABILITY_ID:
354             TELEPHONY_LOGI("COMM_NET_POLICY_MANAGER_SYS_ABILITY_ID running");
355             if (slotId_ == 0) {
356                 CellularDataNetAgent::GetInstance().UnregisterPolicyCallback();
357                 CellularDataNetAgent::GetInstance().RegisterPolicyCallback();
358             }
359             break;
360         case COMMON_EVENT_SERVICE_ID:
361             TELEPHONY_LOGI("COMMON_EVENT_SERVICE_ID running");
362             if (handler_ != nullptr) {
363                 bool subscribeResult = EventFwk::CommonEventManager::SubscribeCommonEvent(handler_);
364                 TELEPHONY_LOGI("subscribeResult = %{public}d", subscribeResult);
365             }
366             break;
367         case DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID:
368             TELEPHONY_LOGI("DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID running");
369             if (handler_ != nullptr) {
370                 handler_->RegisterDataSettingObserver();
371                 handler_->SendEvent(CellularDataEventCode::MSG_DB_SETTING_ENABLE_CHANGED, 0, 0);
372             }
373             break;
374         default:
375             TELEPHONY_LOGE("systemAbilityId is invalid");
376             break;
377     }
378 }
379 
OnRemoveSystemAbility(int32_t systemAbilityId,const std::string & deviceId)380 void CellularDataController::SystemAbilityStatusChangeListener::OnRemoveSystemAbility(
381     int32_t systemAbilityId, const std::string &deviceId)
382 {
383     switch (systemAbilityId) {
384         case COMM_NET_CONN_MANAGER_SYS_ABILITY_ID:
385             TELEPHONY_LOGE("COMM_NET_CONN_MANAGER_SYS_ABILITY_ID stopped");
386             break;
387         case COMM_NET_POLICY_MANAGER_SYS_ABILITY_ID:
388             TELEPHONY_LOGE("COMM_NET_POLICY_MANAGER_SYS_ABILITY_ID stopped");
389             break;
390         case COMMON_EVENT_SERVICE_ID:
391             TELEPHONY_LOGE("COMMON_EVENT_SERVICE_ID stopped");
392             if (handler_ != nullptr) {
393                 bool unSubscribeResult = EventFwk::CommonEventManager::UnSubscribeCommonEvent(handler_);
394                 TELEPHONY_LOGI("unSubscribeResult = %{public}d", unSubscribeResult);
395             }
396             break;
397         case DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID:
398             TELEPHONY_LOGE("DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID stopped");
399             break;
400         default:
401             TELEPHONY_LOGE("systemAbilityId is invalid");
402             break;
403     }
404 }
405 
GetDataConnApnAttr(ApnItem::Attribute & apnAttr) const406 void CellularDataController::GetDataConnApnAttr(ApnItem::Attribute &apnAttr) const
407 {
408     if (cellularDataHandler_ == nullptr) {
409         TELEPHONY_LOGE("Slot%{public}d: GetDataConnApnAttr cellularDataHandler_ is null", slotId_);
410         return;
411     }
412     cellularDataHandler_->GetDataConnApnAttr(apnAttr);
413 }
414 
GetDataConnIpType() const415 std::string CellularDataController::GetDataConnIpType() const
416 {
417     if (cellularDataHandler_ == nullptr) {
418         TELEPHONY_LOGE("Slot%{public}d: GetDataConnIpType cellularDataHandler_ is null", slotId_);
419         return "";
420     }
421     return cellularDataHandler_->GetDataConnIpType();
422 }
423 
GetDataRecoveryState()424 int32_t CellularDataController::GetDataRecoveryState()
425 {
426     if (cellularDataHandler_ == nullptr) {
427         TELEPHONY_LOGE("Slot%{public}d: cellularDataHandler is null", slotId_);
428         return false;
429     }
430     return cellularDataHandler_->GetDataRecoveryState();
431 }
432 
IsNeedDoRecovery(bool needDoRecovery) const433 void CellularDataController::IsNeedDoRecovery(bool needDoRecovery) const
434 {
435     if (cellularDataHandler_ == nullptr) {
436         TELEPHONY_LOGE("Slot%{public}d: IsNeedDoRecovery cellularDataHandler_ is null", slotId_);
437         return;
438     }
439     cellularDataHandler_->IsNeedDoRecovery(needDoRecovery);
440 }
441 } // namespace Telephony
442 } // namespace OHOS
443