1 /*
2 * Copyright (C) 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 "satellite_core_callback.h"
17
18 #include "radio_event.h"
19 #include "telephony_errors.h"
20 #include "telephony_log_wrapper.h"
21
22 namespace OHOS {
23 namespace Telephony {
SatelliteCoreCallback(const std::shared_ptr<TelEventHandler> & handler)24 SatelliteCoreCallback::SatelliteCoreCallback(const std::shared_ptr<TelEventHandler> &handler) : handler_(handler) {}
25
~SatelliteCoreCallback()26 SatelliteCoreCallback::~SatelliteCoreCallback() {}
27
SetRadioStateResponse(InnerEvent::Pointer & event)28 int32_t SatelliteCoreCallback::SetRadioStateResponse(InnerEvent::Pointer &event)
29 {
30 if (handler_ == nullptr) {
31 TELEPHONY_LOGE("SetRadioStateResponse handler is null!");
32 return TELEPHONY_ERROR;
33 }
34 handler_->SendEvent(event, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE);
35 return TELEPHONY_SUCCESS;
36 }
37
RadioStateChanged(InnerEvent::Pointer & event)38 int32_t SatelliteCoreCallback::RadioStateChanged(InnerEvent::Pointer &event)
39 {
40 if (handler_ == nullptr) {
41 TELEPHONY_LOGE("RadioStateChanged handler is null!");
42 return TELEPHONY_ERROR;
43 }
44 handler_->SendEvent(event, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE);
45 return TELEPHONY_SUCCESS;
46 }
47
SatelliteStatusChanged(InnerEvent::Pointer & event)48 int32_t SatelliteCoreCallback::SatelliteStatusChanged(InnerEvent::Pointer &event)
49 {
50 if (handler_ == nullptr) {
51 TELEPHONY_LOGE("SatelliteStatusChanged handler is null!");
52 return TELEPHONY_ERROR;
53 }
54 handler_->SendEvent(event, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE);
55 return TELEPHONY_SUCCESS;
56 }
57
SimStateChanged(InnerEvent::Pointer & event)58 int32_t SatelliteCoreCallback::SimStateChanged(InnerEvent::Pointer &event)
59 {
60 if (handler_ == nullptr) {
61 TELEPHONY_LOGE("SimStateChanged handler is null!");
62 return TELEPHONY_ERROR;
63 }
64 handler_->SendEvent(event, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE);
65 return TELEPHONY_SUCCESS;
66 }
67 } // namespace Telephony
68 } // namespace OHOS
69