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_stub.h"
17
18 #include "appexecfwk_errors.h"
19 #include "errors.h"
20 #include "form_mgr_errors.h"
21 #include "fms_log_wrapper.h"
22 #include "ipc_skeleton.h"
23 #include "ipc_types.h"
24 #include "iremote_object.h"
25
26 namespace OHOS {
27 namespace AppExecFwk {
FormPublishInterceptorStub()28 FormPublishInterceptorStub::FormPublishInterceptorStub()
29 {}
30
~FormPublishInterceptorStub()31 FormPublishInterceptorStub::~FormPublishInterceptorStub()
32 {}
33
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)34 int FormPublishInterceptorStub::OnRemoteRequest(uint32_t code,
35 MessageParcel &data, MessageParcel &reply, MessageOption &option)
36 {
37 HILOG_INFO("code:%{public}u, flags:%{public}d", code, option.GetFlags());
38 std::u16string descriptor = FormPublishInterceptorStub::GetDescriptor();
39 std::u16string remoteDescriptor = data.ReadInterfaceToken();
40 if (descriptor != remoteDescriptor) {
41 HILOG_ERROR("localDescriptor not equal to remote");
42 return ERR_APPEXECFWK_FORM_INVALID_PARAM;
43 }
44
45 switch (code) {
46 case static_cast<uint32_t>(IFormPublishInterceptor::Message::FORM_PROCESS_PUBLISH_FORM):
47 return HandleProcessPublishForm(data, reply);
48 default:
49 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
50 }
51 }
52
HandleProcessPublishForm(MessageParcel & data,MessageParcel & reply)53 int FormPublishInterceptorStub::HandleProcessPublishForm(MessageParcel &data, MessageParcel &reply)
54 {
55 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
56 if (want == nullptr) {
57 HILOG_ERROR("ReadParcelable<Want> failed");
58 return ERR_APPEXECFWK_PARCEL_ERROR;
59 }
60 int32_t result = ProcessPublishForm(*want);
61 reply.WriteInt32(result);
62 return result;
63 }
64 } // namespace AppExecFwk
65 } // namespace OHOS