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 "network_search_notify.h"
17
18 #include "if_system_ability_manager.h"
19 #include "iservice_registry.h"
20 #include "system_ability_definition.h"
21 #include "telephony_errors.h"
22 #include "telephony_log_wrapper.h"
23
24 namespace OHOS {
25 namespace Telephony {
NetworkSearchNotify()26 NetworkSearchNotify::NetworkSearchNotify() {}
~NetworkSearchNotify()27 NetworkSearchNotify::~NetworkSearchNotify() {}
28
NotifyNetworkStateUpdated(int32_t slotId,const sptr<NetworkState> & networkState)29 void NetworkSearchNotify::NotifyNetworkStateUpdated(int32_t slotId, const sptr<NetworkState> &networkState)
30 {
31 if (networkState == nullptr) {
32 TELEPHONY_LOGE("NotifyNetworkStateUpdated networkState is nullptr");
33 return;
34 }
35 int32_t result =
36 DelayedRefSingleton<TelephonyStateRegistryClient>::GetInstance().UpdateNetworkState(slotId, networkState);
37 TELEPHONY_LOGD("NotifyNetworkStateUpdated ret %{public}s", networkState->ToString().c_str());
38 if (result != TELEPHONY_SUCCESS) {
39 TELEPHONY_LOGE("NotifyNetworkStateUpdated TELEPHONY_STATE_REGISTRY_SYS_ABILITY_ID not found");
40 }
41 }
42
NotifySignalInfoUpdated(int32_t slotId,const std::vector<sptr<SignalInformation>> & signalInfos)43 void NetworkSearchNotify::NotifySignalInfoUpdated(
44 int32_t slotId, const std::vector<sptr<SignalInformation>> &signalInfos)
45 {
46 TELEPHONY_LOGD("NotifySignalInfoUpdated~~~ signalInfos size=%{public}zu", signalInfos.size());
47 int32_t result =
48 DelayedRefSingleton<TelephonyStateRegistryClient>::GetInstance().UpdateSignalInfo(slotId, signalInfos);
49 TELEPHONY_LOGD("NotifySignalInfoUpdated ret %{public}d", result);
50 if (result != TELEPHONY_SUCCESS) {
51 TELEPHONY_LOGE("NotifySignalInfoUpdated TELEPHONY_STATE_REGISTRY_SYS_ABILITY_ID not found");
52 }
53 }
54
NotifyCellInfoUpdated(int32_t slotId,const std::vector<sptr<CellInformation>> & cellInfos)55 void NetworkSearchNotify::NotifyCellInfoUpdated(int32_t slotId, const std::vector<sptr<CellInformation>> &cellInfos)
56 {
57 TELEPHONY_LOGD("NotifyCellInfoUpdated~~~ cell size=%{public}zu", cellInfos.size());
58 int32_t result =
59 DelayedRefSingleton<TelephonyStateRegistryClient>::GetInstance().UpdateCellInfo(slotId, cellInfos);
60 TELEPHONY_LOGD("NotifyCellInfoUpdated ret %{public}d", result);
61 if (result != TELEPHONY_SUCCESS) {
62 TELEPHONY_LOGE("NotifyCellInfoUpdated TELEPHONY_STATE_REGISTRY_SYS_ABILITY_ID not found.");
63 }
64 }
65 } // namespace Telephony
66 } // namespace OHOS
67