1 /*
2 * Copyright (c) 2021-2024 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 #include "zidl/convert_callback_proxy.h"
16 #include "zidl/convert_callback_interface_code.h"
17 #include "app_domain_verify_hilog.h"
18 #include "app_domain_verify_parcel_util.h"
19 #include "app_domain_verify_hisysevent.h"
20
21 namespace OHOS {
22 namespace AppDomainVerify {
ConvertCallbackProxy(const sptr<IRemoteObject> & object)23 ConvertCallbackProxy::ConvertCallbackProxy(const sptr<IRemoteObject>& object) : IRemoteProxy<IConvertCallback>(object)
24 {
25 APP_DOMAIN_VERIFY_HILOGI(APP_DOMAIN_VERIFY_MGR_MODULE_CLIENT, "new instance created.");
26 }
27
~ConvertCallbackProxy()28 ConvertCallbackProxy::~ConvertCallbackProxy()
29 {
30 APP_DOMAIN_VERIFY_HILOGI(APP_DOMAIN_VERIFY_MGR_MODULE_CLIENT, "instance dead.");
31 }
32
OnConvert(int resCode,TargetInfo & targetInfo)33 void ConvertCallbackProxy::OnConvert(int resCode, TargetInfo& targetInfo)
34 {
35 APP_DOMAIN_VERIFY_HILOGI(APP_DOMAIN_VERIFY_MGR_MODULE_CLIENT, "OnConvert result %{public}d", resCode);
36 MessageParcel data;
37 MessageParcel reply;
38 MessageOption option(MessageOption::TF_SYNC);
39
40 WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, GetDescriptor());
41 WRITE_PARCEL_AND_RETURN_IF_FAIL(Int32, data, resCode);
42 WRITE_PARCEL_AND_RETURN_IF_FAIL(Parcelable, data, &targetInfo);
43 sptr<IRemoteObject> remote = Remote();
44 if (remote == nullptr) {
45 APP_DOMAIN_VERIFY_HILOGE(
46 APP_DOMAIN_VERIFY_MGR_MODULE_CLIENT, "fail to call OnConvert, for Remote() is nullptr");
47 return;
48 }
49
50 int32_t ret = remote->SendRequest(
51 static_cast<int32_t>(ConvertCallbackInterfaceCode::ON_CONVERT_CALLBACK), data, reply, option);
52 if (ret != NO_ERROR) {
53 APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MGR_MODULE_CLIENT,
54 "fail to call OnConvert, for transact is failed, error code is: %{public}d", ret);
55 UNIVERSAL_ERROR_EVENT(CALL_BACK_FAULT);
56 }
57 }
58 }
59 }