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 "file_access_notify_proxy.h"
17
18 #include "file_access_framework_errno.h"
19 #include "hilog_wrapper.h"
20 #include "message_parcel.h"
21
22 namespace OHOS {
23 namespace FileAccessFwk {
FileAccessNotifyProxy(const sptr<IRemoteObject> & impl)24 FileAccessNotifyProxy::FileAccessNotifyProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IFileAccessNotify>(impl)
25 {
26 }
27
Notify(const NotifyMessage & message)28 int FileAccessNotifyProxy::Notify(const NotifyMessage& message)
29 {
30 MessageParcel data;
31 MessageParcel reply;
32 MessageOption option;
33 if (!data.WriteInterfaceToken(FileAccessNotifyProxy::GetDescriptor())) {
34 HILOG_ERROR("write descriptor failed");
35 return E_IPCS;
36 }
37
38 if (!data.WriteParcelable(&message)) {
39 HILOG_ERROR("write parcel message failed");
40 return E_IPCS;
41 }
42
43 int error = Remote()->SendRequest(CMD_NOTIFY, data, reply, option);
44 if (error != 0) {
45 HILOG_ERROR("SendRequest failed, error %{public}d", error);
46 }
47 return error;
48 }
49 } // namespace FileAccessFwk
50 } // namespace OHOS