• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 "ims_reg_state_callback_stub.h"
17 
18 #include "sms_network_policy_manager.h"
19 #include "telephony_errors.h"
20 #include "telephony_log_wrapper.h"
21 
22 namespace OHOS {
23 namespace Telephony {
ImsRegStateCallbackStub(const std::shared_ptr<AppExecFwk::EventHandler> handle)24 ImsRegStateCallbackStub::ImsRegStateCallbackStub(const std::shared_ptr<AppExecFwk::EventHandler> handle)
25     : handle_(handle)
26 {}
27 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)28 int32_t ImsRegStateCallbackStub::OnRemoteRequest(
29     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
30 {
31     if (data.ReadInterfaceToken() != GetDescriptor()) {
32         TELEPHONY_LOGE("descriptor checked fail");
33         return TELEPHONY_ERR_DESCRIPTOR_MISMATCH;
34     }
35     TELEPHONY_LOGI("Code is %{public}d", code);
36     int32_t slotId = data.ReadInt32();
37     int32_t imsRegState = data.ReadInt32();
38     int32_t imsRegTech = data.ReadInt32();
39     const ImsRegInfo info = { static_cast<ImsRegState>(imsRegState), static_cast<ImsRegTech>(imsRegTech) };
40     return OnImsRegInfoChanged(slotId, static_cast<ImsServiceType>(code), info);
41 }
42 
OnImsRegInfoChanged(int32_t slotId,ImsServiceType imsSrvType,const ImsRegInfo & info)43 int32_t ImsRegStateCallbackStub::OnImsRegInfoChanged(int32_t slotId, ImsServiceType imsSrvType, const ImsRegInfo &info)
44 {
45     TELEPHONY_LOGI("slotId is %{public}d, imsServiceType is %{public}d, imsRegisterState is %{public}d,"
46                    "imsRegisterTech is %{public}d",
47         slotId, imsSrvType, info.imsRegState, info.imsRegTech);
48     if (handle_ != nullptr) {
49         uint32_t item = NotificationType::NOTIFICATION_TYPE_IMS;
50         handle_->SendEvent(item);
51     }
52     return TELEPHONY_SUCCESS;
53 }
54 } // namespace Telephony
55 } // namespace OHOS