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 "form_publish_interceptor_proxy.h"
17
18 #include "appexecfwk_errors.h"
19 #include "string_ex.h"
20
21 namespace OHOS {
22 namespace AppExecFwk {
ProcessPublishForm(const AAFwk::Want & want)23 int32_t FormPublishInterceptorProxy::ProcessPublishForm(const AAFwk::Want &want)
24 {
25 MessageParcel data;
26 MessageParcel reply;
27 MessageOption option;
28
29 if (!data.WriteInterfaceToken(FormPublishInterceptorProxy::GetDescriptor())) {
30 HILOG_ERROR("write interface token failed");
31 return ERR_FLATTEN_OBJECT;
32 }
33
34 if (!data.WriteParcelable(&want)) {
35 HILOG_ERROR("write want failed");
36 return ERR_FLATTEN_OBJECT;
37 }
38
39 sptr<IRemoteObject> remote = Remote();
40 if (remote == nullptr) {
41 HILOG_ERROR("null remote");
42 return ERR_NULL_OBJECT;
43 }
44
45 int32_t error = remote->SendRequest(
46 static_cast<uint32_t>(IFormPublishInterceptor::Message::FORM_PROCESS_PUBLISH_FORM),
47 data,
48 reply,
49 option);
50 if (error != ERR_OK) {
51 HILOG_ERROR("SendRequest:%{public}d failed", error);
52 return error;
53 }
54 int32_t result = reply.ReadInt32();
55 HILOG_DEBUG("get result from server data = %{public}d", result);
56 return result;
57 }
58 } // namespace AppExecFwk
59 } // namespace OHOS
60