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 "state_notification.h"
17
18 #include "core_manager_inner.h"
19 #include "telephony_log_wrapper.h"
20 #include "telephony_state_registry_client.h"
21
22 namespace OHOS {
23 namespace Telephony {
24 StateNotification StateNotification::stateNotification_;
GetInstance()25 StateNotification &StateNotification::GetInstance()
26 {
27 return stateNotification_;
28 }
29
UpdateCellularDataConnectState(int32_t slotId,ApnProfileState dataState,int32_t networkType)30 void StateNotification::UpdateCellularDataConnectState(int32_t slotId, ApnProfileState dataState, int32_t networkType)
31 {
32 int32_t state = CellularDataStateAdapter(dataState);
33 int32_t wrapState = WrapCellularDataState(state);
34 TELEPHONY_LOGI(
35 "slotId = %{public}d, wrapState = %{public}d, networkType = %{public}d", slotId, wrapState, networkType);
36 TelephonyStateRegistryClient::GetInstance().UpdateCellularDataConnectState(slotId, wrapState, networkType);
37 }
38
OnUpDataFlowtype(int32_t slotId,CellDataFlowType flowType)39 void StateNotification::OnUpDataFlowtype(int32_t slotId, CellDataFlowType flowType)
40 {
41 TELEPHONY_LOGI("slotId = %{public}d, flowType = %{public}d", slotId, flowType);
42 int32_t defaultSlotId = CoreManagerInner::GetInstance().GetDefaultCellularDataSlotId();
43 if (flowType != CellDataFlowType::DATA_FLOW_TYPE_NONE && slotId != defaultSlotId) {
44 TELEPHONY_LOGI("defaultSlotId= %{public}d", defaultSlotId);
45 return;
46 }
47 TelephonyStateRegistryClient::GetInstance().UpdateCellularDataFlow(slotId, static_cast<int32_t>(flowType));
48 }
49 } // namespace Telephony
50 } // namespace OHOS